Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data View Shortcuts: Manage Templates, Pages, and Patterns #66737

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/core-commands/src/site-editor-navigation-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand All @@ -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 ) {
Expand Down
52 changes: 51 additions & 1 deletion packages/editor/src/components/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
drawerLeft,
drawerRight,
edit,
page,
formatListBullets,
listView,
external,
keyboard,
symbol,
page,
layout,
rotateRight,
rotateLeft,
Expand Down Expand Up @@ -467,6 +467,50 @@ const getManipulateDocumentCommands = () =>
};
};

const getDataViewCommands = () =>
function useDataViewCommands() {
const commands = [];

commands.push( {
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?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';
},
} );

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

export default function useCommands() {
useCommandLoader( {
name: 'core/editor/edit-ui',
Expand All @@ -489,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',
} );
}
Loading