From 67b5ebed8236fa4100be04d2ef3bbf632f49ae42 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Mon, 26 Jun 2023 11:22:38 +0300 Subject: [PATCH] Add `manage all custom patterns` command (#51845) * Add manage all custom patterns command * reorganise with useAdminNavigationCommands --- ...type-commands.js => admin-navigation-commands.js} | 12 ++++++++++-- packages/core-commands/src/private-apis.js | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) rename packages/core-commands/src/{add-post-type-commands.js => admin-navigation-commands.js} (60%) 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/private-apis.js b/packages/core-commands/src/private-apis.js index b0e0cd87040f6..de5b0de197600 100644 --- a/packages/core-commands/src/private-apis.js +++ b/packages/core-commands/src/private-apis.js @@ -1,12 +1,12 @@ /** * Internal dependencies */ -import { useAddPostTypeCommands } from './add-post-type-commands'; +import { useAdminNavigationCommands } from './admin-navigation-commands'; import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands'; import { lock } from './lock-unlock'; function useCommands() { - useAddPostTypeCommands(); + useAdminNavigationCommands(); useSiteEditorNavigationCommands(); }