From 39191c8406865f6532adf2a9a3866f378a361bc7 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Tue, 5 Nov 2024 12:11:14 +0530 Subject: [PATCH 1/5] Add drafts command to command palette --- packages/editor/src/components/commands/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/editor/src/components/commands/index.js b/packages/editor/src/components/commands/index.js index b4b9c05db256d7..381f07e681baeb 100644 --- a/packages/editor/src/components/commands/index.js +++ b/packages/editor/src/components/commands/index.js @@ -254,6 +254,18 @@ function useEditorCommandLoader() { } ); } + commands.push( { + name: 'core/drafts', + label: __( 'Pages/Drafts' ), + keywords: [ 'drafts' ], + icon: edit, + callback: ( { close } ) => { + close(); + window.location.href = + '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; + }, + } ); + return { commands, isLoading: false, From 66fafc7aa708df3d913a1819c4e424c8876d4587 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Tue, 5 Nov 2024 13:01:02 +0530 Subject: [PATCH 2/5] Adding command to site editor --- .../editor/src/components/commands/index.js | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/editor/src/components/commands/index.js b/packages/editor/src/components/commands/index.js index 381f07e681baeb..7bdb575f2b41af 100644 --- a/packages/editor/src/components/commands/index.js +++ b/packages/editor/src/components/commands/index.js @@ -9,6 +9,7 @@ import { drawerLeft, drawerRight, edit, + page, formatListBullets, listView, external, @@ -254,18 +255,6 @@ function useEditorCommandLoader() { } ); } - commands.push( { - name: 'core/drafts', - label: __( 'Pages/Drafts' ), - keywords: [ 'drafts' ], - icon: edit, - callback: ( { close } ) => { - close(); - window.location.href = - '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; - }, - } ); - return { commands, isLoading: false, @@ -306,6 +295,26 @@ function useEditedEntityContextualCommands() { return { isLoading: false, commands }; } +function useSiteEditorCommandLoader() { + const commands = []; + commands.push( { + name: 'core/drafts', + label: __( 'Pages/Drafts' ), + keywords: [ 'drafts' ], + icon: page, + callback: ( { close } ) => { + close(); + window.location.href = + '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; + }, + } ); + + return { + commands, + isLoading: false, + }; +} + export default function useCommands() { useCommandLoader( { name: 'core/editor/edit-ui', @@ -317,4 +326,10 @@ export default function useCommands() { hook: useEditedEntityContextualCommands, context: 'entity-edit', } ); + + useCommandLoader( { + name: 'core/editor/site-editor', + hook: useSiteEditorCommandLoader, + context: 'site-editor', + } ); } From 41f34a447289432b6e0701b193614b556428b8d7 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Wed, 18 Dec 2024 18:45:41 +0530 Subject: [PATCH 3/5] Linting issues updated --- .../editor/src/components/commands/index.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/editor/src/components/commands/index.js b/packages/editor/src/components/commands/index.js index 896fac65d39e76..6446c473c741f0 100644 --- a/packages/editor/src/components/commands/index.js +++ b/packages/editor/src/components/commands/index.js @@ -15,7 +15,6 @@ import { external, keyboard, symbol, - page, layout, rotateRight, rotateLeft, @@ -468,25 +467,26 @@ const getManipulateDocumentCommands = () => }; }; -function useSiteEditorCommandLoader() { - const commands = []; - commands.push( { - name: 'core/drafts', - label: __( 'Pages/Drafts' ), - keywords: [ 'drafts' ], - icon: page, - callback: ( { close } ) => { - close(); - window.location.href = - '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; - }, - } ); +const getuseSiteEditorCommandLoader = () => + function useSiteEditorCommandLoader() { + const commands = []; + commands.push( { + name: 'core/drafts', + label: __( 'Pages/Drafts' ), + keywords: [ 'drafts' ], + icon: page, + callback: ( { close } ) => { + close(); + window.location.href = + '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; + }, + } ); - return { - commands, - isLoading: false, + return { + commands, + isLoading: false, + }; }; -} export default function useCommands() { useCommandLoader( { @@ -502,11 +502,11 @@ export default function useCommands() { useCommandLoader( { name: 'core/editor/site-editor', - hook: useSiteEditorCommandLoader, + hook: getuseSiteEditorCommandLoader(), context: 'site-editor', } ); - - useCommandLoader( { + + useCommandLoader( { name: 'core/editor/page-content-focus', hook: getPageContentFocusCommands(), context: 'entity-edit', From 805f3155f6acc665ead59060e9a69dd4218b504e Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Thu, 19 Dec 2024 17:13:21 +0530 Subject: [PATCH 4/5] Feedback changes --- .../editor/src/components/commands/index.js | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/packages/editor/src/components/commands/index.js b/packages/editor/src/components/commands/index.js index 6446c473c741f0..815d05b4da6d1a 100644 --- a/packages/editor/src/components/commands/index.js +++ b/packages/editor/src/components/commands/index.js @@ -467,18 +467,41 @@ const getManipulateDocumentCommands = () => }; }; -const getuseSiteEditorCommandLoader = () => - function useSiteEditorCommandLoader() { +const getDataViewCommands = () => + function useDataViewCommands() { const commands = []; + commands.push( { - name: 'core/drafts', - label: __( 'Pages/Drafts' ), - keywords: [ 'drafts' ], - icon: page, + name: 'core/data-view/all-templates', + label: __( 'Manage templates' ), + keywords: [ 'templates', 'all templates' ], + icon: layout, callback: ( { close } ) => { close(); window.location.href = - '/wp-admin/site-editor.php?postType=page&layout=list&activeView=drafts'; + '/wp-admin/site-editor.php?p=%2Ftemplate'; + }, + } ); + + commands.push( { + name: 'core/data-view/all-pages', + label: __( 'Manage pages' ), + keywords: [ 'pages', 'all pages' ], + icon: page, + callback: ( { close } ) => { + close(); + window.location.href = '/wp-admin/site-editor.php?p=%2Fpage'; + }, + } ); + + commands.push( { + name: 'core/data-view/all-pages', + label: __( 'Manage Patterns' ), + keywords: [ 'patterns', 'template parts' ], + icon: page, + callback: ( { close } ) => { + close(); + window.location.href = '/wp-admin/site-editor.php?p=%2Fpattern'; }, } ); @@ -500,12 +523,6 @@ export default function useCommands() { context: 'entity-edit', } ); - useCommandLoader( { - name: 'core/editor/site-editor', - hook: getuseSiteEditorCommandLoader(), - context: 'site-editor', - } ); - useCommandLoader( { name: 'core/editor/page-content-focus', hook: getPageContentFocusCommands(), @@ -516,4 +533,10 @@ export default function useCommands() { name: 'core/edit-site/manipulate-document', hook: getManipulateDocumentCommands(), } ); + + useCommandLoader( { + name: 'core/editor/data-views', + hook: getDataViewCommands(), + context: 'data-views', + } ); } From 131fa2647db3c473704b7c8afa09291bec566b29 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Fri, 20 Dec 2024 11:23:27 +0530 Subject: [PATCH 5/5] Feedback changes updated --- .../core-commands/src/site-editor-navigation-commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-commands/src/site-editor-navigation-commands.js b/packages/core-commands/src/site-editor-navigation-commands.js index c1b12a84d4d61a..eb7887a336a1ce 100644 --- a/packages/core-commands/src/site-editor-navigation-commands.js +++ b/packages/core-commands/src/site-editor-navigation-commands.js @@ -337,7 +337,7 @@ const getSiteEditorBasicNavigationCommands = () => result.push( { name: 'core/edit-site/open-pages', - label: __( 'Pages' ), + label: __( 'Manage Pages' ), icon: page, callback: ( { close } ) => { if ( isSiteEditor ) { @@ -356,7 +356,7 @@ const getSiteEditorBasicNavigationCommands = () => result.push( { name: 'core/edit-site/open-templates', - label: __( 'Templates' ), + label: __( 'Manage Templates' ), icon: layout, callback: ( { close } ) => { if ( isSiteEditor ) { @@ -376,7 +376,7 @@ const getSiteEditorBasicNavigationCommands = () => result.push( { name: 'core/edit-site/open-patterns', - label: __( 'Patterns' ), + label: __( 'Manage Patterns' ), icon: symbol, callback: ( { close } ) => { if ( canCreateTemplate ) {