From e4156b73214f72e623116b3f53c99d0abab20c08 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 23 Jun 2023 15:35:59 +0300 Subject: [PATCH 1/2] Add manage all custom patterns command --- .../src/manage-reusable-blocks-command.js | 17 +++++++++++++++++ packages/core-commands/src/private-apis.js | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 packages/core-commands/src/manage-reusable-blocks-command.js diff --git a/packages/core-commands/src/manage-reusable-blocks-command.js b/packages/core-commands/src/manage-reusable-blocks-command.js new file mode 100644 index 0000000000000..6add1bf20bc0b --- /dev/null +++ b/packages/core-commands/src/manage-reusable-blocks-command.js @@ -0,0 +1,17 @@ +/** + * WordPress dependencies + */ +import { useCommand } from '@wordpress/commands'; +import { __ } from '@wordpress/i18n'; +import { external } from '@wordpress/icons'; + +export function useManageReusableBlocksCommand() { + useCommand( { + name: 'core/manage-reusable-blocks', + label: __( 'Manage all custom patterns' ), + callback: () => { + document.location.href = 'edit.php?post_type=wp_block'; + }, + icon: external, + } ); +} diff --git a/packages/core-commands/src/private-apis.js b/packages/core-commands/src/private-apis.js index b0e0cd87040f6..d167b74f7f74b 100644 --- a/packages/core-commands/src/private-apis.js +++ b/packages/core-commands/src/private-apis.js @@ -2,11 +2,13 @@ * Internal dependencies */ import { useAddPostTypeCommands } from './add-post-type-commands'; +import { useManageReusableBlocksCommand } from './manage-reusable-blocks-command'; import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands'; import { lock } from './lock-unlock'; function useCommands() { useAddPostTypeCommands(); + useManageReusableBlocksCommand(); useSiteEditorNavigationCommands(); } From b32e67f2646cfc53e476aead72cca6b9131cfb04 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 26 Jun 2023 10:34:10 +0300 Subject: [PATCH 2/2] reorganise with useAdminNavigationCommands --- ...commands.js => admin-navigation-commands.js} | 12 ++++++++++-- .../src/manage-reusable-blocks-command.js | 17 ----------------- packages/core-commands/src/private-apis.js | 6 ++---- 3 files changed, 12 insertions(+), 23 deletions(-) rename packages/core-commands/src/{add-post-type-commands.js => admin-navigation-commands.js} (60%) delete mode 100644 packages/core-commands/src/manage-reusable-blocks-command.js diff --git a/packages/core-commands/src/add-post-type-commands.js b/packages/core-commands/src/admin-navigation-commands.js similarity index 60% rename from packages/core-commands/src/add-post-type-commands.js rename to packages/core-commands/src/admin-navigation-commands.js index 47e6014f56944..577e7258df0b6 100644 --- a/packages/core-commands/src/add-post-type-commands.js +++ b/packages/core-commands/src/admin-navigation-commands.js @@ -3,9 +3,9 @@ */ import { useCommand } from '@wordpress/commands'; import { __ } from '@wordpress/i18n'; -import { plus } from '@wordpress/icons'; +import { external, plus } from '@wordpress/icons'; -export function useAddPostTypeCommands() { +export function useAdminNavigationCommands() { useCommand( { name: 'core/add-new-post', label: __( 'Add new post' ), @@ -22,4 +22,12 @@ export function useAddPostTypeCommands() { document.location.href = 'post-new.php?post_type=page'; }, } ); + useCommand( { + name: 'core/manage-reusable-blocks', + label: __( 'Manage all custom patterns' ), + callback: () => { + document.location.href = 'edit.php?post_type=wp_block'; + }, + icon: external, + } ); } diff --git a/packages/core-commands/src/manage-reusable-blocks-command.js b/packages/core-commands/src/manage-reusable-blocks-command.js deleted file mode 100644 index 6add1bf20bc0b..0000000000000 --- a/packages/core-commands/src/manage-reusable-blocks-command.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * WordPress dependencies - */ -import { useCommand } from '@wordpress/commands'; -import { __ } from '@wordpress/i18n'; -import { external } from '@wordpress/icons'; - -export function useManageReusableBlocksCommand() { - useCommand( { - name: 'core/manage-reusable-blocks', - label: __( 'Manage all custom patterns' ), - callback: () => { - document.location.href = 'edit.php?post_type=wp_block'; - }, - icon: external, - } ); -} diff --git a/packages/core-commands/src/private-apis.js b/packages/core-commands/src/private-apis.js index d167b74f7f74b..de5b0de197600 100644 --- a/packages/core-commands/src/private-apis.js +++ b/packages/core-commands/src/private-apis.js @@ -1,14 +1,12 @@ /** * Internal dependencies */ -import { useAddPostTypeCommands } from './add-post-type-commands'; -import { useManageReusableBlocksCommand } from './manage-reusable-blocks-command'; +import { useAdminNavigationCommands } from './admin-navigation-commands'; import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands'; import { lock } from './lock-unlock'; function useCommands() { - useAddPostTypeCommands(); - useManageReusableBlocksCommand(); + useAdminNavigationCommands(); useSiteEditorNavigationCommands(); }