From 2006395d2d6a8428975f6b339671d7dbf71686c0 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 10 Jun 2024 13:49:39 -0400 Subject: [PATCH 1/4] Add link to settings page --- wpgraphql-ide.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wpgraphql-ide.php b/wpgraphql-ide.php index 8effc5e..7180c65 100644 --- a/wpgraphql-ide.php +++ b/wpgraphql-ide.php @@ -588,6 +588,23 @@ function sanitize_custom_graphql_ide_link_behavior( $value ) { return 'drawer'; } +/** + * Add settings link to the plugin actions + * + * @param array $links The existing action links. + * @return array The modified action links. + */ +function add_settings_link( $links ) { + $settings_link = sprintf( + '%s', + esc_url( admin_url( 'admin.php?page=graphql-settings#graphql_ide_settings' ) ), + esc_html__( 'Settings', 'wpgraphql-ide' ) + ); + array_unshift( $links, $settings_link ); + return $links; +} +add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\\add_settings_link' ); + /** * Rename and reorder the submenu items under 'GraphQL'. */ From a663ecbfbbd1cd512cfffab031b0e791c1d80229 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 10 Jun 2024 13:56:08 -0400 Subject: [PATCH 2/4] PHPCS Fixes --- wpgraphql-ide.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wpgraphql-ide.php b/wpgraphql-ide.php index 7180c65..82f2d7d 100644 --- a/wpgraphql-ide.php +++ b/wpgraphql-ide.php @@ -591,17 +591,17 @@ function sanitize_custom_graphql_ide_link_behavior( $value ) { /** * Add settings link to the plugin actions * - * @param array $links The existing action links. - * @return array The modified action links. + * @param array $links The existing action links. + * @return array The modified action links. */ -function add_settings_link( $links ) { - $settings_link = sprintf( - '%s', - esc_url( admin_url( 'admin.php?page=graphql-settings#graphql_ide_settings' ) ), - esc_html__( 'Settings', 'wpgraphql-ide' ) - ); - array_unshift( $links, $settings_link ); - return $links; +function add_settings_link( array $links ): array { + $settings_link = sprintf( + '%s', + esc_url( admin_url( 'admin.php?page=graphql-settings#graphql_ide_settings' ) ), + esc_html__( 'Settings', 'wpgraphql-ide' ) + ); + array_unshift( $links, $settings_link ); + return $links; } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\\add_settings_link' ); From d5ebd5d08735657610554b47b8dc6d1536f651c0 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 10 Jun 2024 14:05:27 -0400 Subject: [PATCH 3/4] Add test coverage for settings link --- tests/e2e/specs/plugin-settings-link.spec.js | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/e2e/specs/plugin-settings-link.spec.js diff --git a/tests/e2e/specs/plugin-settings-link.spec.js b/tests/e2e/specs/plugin-settings-link.spec.js new file mode 100644 index 0000000..3618c5d --- /dev/null +++ b/tests/e2e/specs/plugin-settings-link.spec.js @@ -0,0 +1,28 @@ +import { loginToWordPressAdmin, visitPluginsPage, wpAdminUrl } from '../utils.js'; +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +export const selectors = { + pluginsMenuItem: '#menu-plugins a', + pluginSettingsLink: 'a[href*="graphql-settings#graphql_ide_settings"]', + ideSettingsTab: '#graphql_ide_settings-tab', +}; + +// Login to WordPress before each test +test.beforeEach( async ( { page } ) => { + await loginToWordPressAdmin( page ); +} ); + +test( 'should navigate to plugin settings and display IDE Settings tab', async ( { page } ) => { + // Go to Plugins page + await visitPluginsPage( page ); + + // Click on the plugin settings link + await page.click( selectors.pluginSettingsLink ); + + // Correct the expected URL string + const expectedUrl = `${wpAdminUrl}/admin.php?page=graphql-settings#graphql_ide_settings`; + await expect( page ).toHaveURL( expectedUrl ); + + // Check that the IDE Settings tab is visible + await expect( page.locator( selectors.ideSettingsTab ) ).toBeVisible(); +} ); From 43479e0653cd7c5c961a5d746b1b3519020fd792 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 10 Jun 2024 14:10:07 -0400 Subject: [PATCH 4/4] Add changeset --- .changeset/silver-comics-arrive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silver-comics-arrive.md diff --git a/.changeset/silver-comics-arrive.md b/.changeset/silver-comics-arrive.md new file mode 100644 index 0000000..608250c --- /dev/null +++ b/.changeset/silver-comics-arrive.md @@ -0,0 +1,5 @@ +--- +"wpgraphql-ide": patch +--- + +- Add settings link to the IDE Settings tab from the WordPress settings page.