Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19f65b1
initial draft: move navigation commands to core commands
yashjawale Aug 25, 2025
b4c4600
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Aug 26, 2025
44debcf
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Aug 28, 2025
c6bf218
Editor: Update command palette test for custom CSS navigation
yashjawale Aug 28, 2025
a8da2d5
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 3, 2025
a61d7dd
fix: move custom css commands back to edit-site
yashjawale Sep 3, 2025
dc564bd
fix: update custom CSS command label
yashjawale Sep 5, 2025
08d18c6
fix: update go to styles command label
yashjawale Sep 5, 2025
a12b460
fix: update navigation command labels with colon
yashjawale Sep 5, 2025
1b85abf
fix: move commands from separate file to existing ones
yashjawale Sep 5, 2025
652a29f
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 5, 2025
8fcbf58
fix: re-add global styles navigation commands to site editor
yashjawale Sep 5, 2025
24ad592
fix: remove redundant global styles navigation command from site editor
yashjawale Sep 5, 2025
44f7f04
fix: implement pages override command in site editor to resolve Menu …
yashjawale Sep 8, 2025
324876f
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 8, 2025
4612e34
fix: filter Pages command in site editor navigation
yashjawale Sep 8, 2025
ba25952
Revert "fix: filter Pages command in site editor navigation"
yashjawale Sep 9, 2025
8b561d7
revert: remove pages command override
yashjawale Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: move commands from separate file to existing ones
  • Loading branch information
yashjawale committed Sep 5, 2025
commit 1b85abf08415807e1701455ba389eaa60c9ce1d6
41 changes: 40 additions & 1 deletion packages/core-commands/src/admin-navigation-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useCommandLoader } from '@wordpress/commands';
import { __ } from '@wordpress/i18n';
import { plus, dashboard } from '@wordpress/icons';
import { plus, dashboard, external } from '@wordpress/icons';
import { getPath } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -227,6 +227,40 @@ const getAddNewPostCommand = () =>
};
};

const getViewSiteCommand = () =>
function useViewSiteCommand() {
const homeUrl = useSelect( ( select ) => {
// Site index.
return select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
)?.home;
}, [] );

const commands = useMemo( () => {
if ( ! homeUrl ) {
return [];
}

return [
{
name: 'core/view-site',
label: __( 'View site' ),
icon: external,
callback: ( { close } ) => {
close();
window.open( homeUrl, '_blank' );
},
},
];
}, [ homeUrl ] );

return {
isLoading: false,
commands,
};
};

export function useAdminNavigationCommands() {
useCommandLoader( {
name: 'core/add-new-post',
Expand All @@ -247,4 +281,9 @@ export function useAdminNavigationCommands() {
name: 'core/admin-navigation',
hook: getAdminBasicNavigationCommands(),
} );

useCommandLoader( {
name: 'core/view-site',
hook: getViewSiteCommand(),
} );
}
2 changes: 0 additions & 2 deletions packages/core-commands/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CommandMenu } from '@wordpress/commands';
*/
import { useAdminNavigationCommands } from './admin-navigation-commands';
import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';
import { useSiteEditorGlobalStylesCommands } from './site-editor-global-styles-commands';
import { unlock } from './lock-unlock';
export { privateApis } from './private-apis';

Expand All @@ -20,7 +19,6 @@ const { RouterProvider } = unlock( routerPrivateApis );
function CommandPalette() {
useAdminNavigationCommands();
useSiteEditorNavigationCommands();
useSiteEditorGlobalStylesCommands();
return (
<RouterProvider pathArg="p">
<CommandMenu />
Expand Down
120 changes: 0 additions & 120 deletions packages/core-commands/src/site-editor-global-styles-commands.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/specs/site-editor/command-center.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ test.describe( 'Site editor command palette', () => {
.getByRole( 'button', { name: 'Open command palette' } )
.click();
await page.keyboard.type( 'custom CSS' );
await page.getByRole( 'option', { name: 'Go to custom CSS' } ).click();
await page.getByRole( 'option', { name: 'Open custom CSS' } ).click();
await expect( page.getByLabel( 'Additional CSS' ) ).toBeVisible();
} );
} );