Skip to content

Commit

Permalink
Re-order template commands
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Jun 13, 2023
1 parent 8074046 commit b39b7f2
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,6 @@ function useEditModeCommandLoader() {

const commands = [];

if ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {
const label =
template.type === 'wp_template'
? __( 'Delete template' )
: __( 'Delete template part' );
commands.push( {
name: 'core/remove-template',
label,
icon: trash,
context: 'site-editor-edit',
callback: ( { close } ) => {
removeTemplate( template );
// Navigate to the template list
history.push( {
path: '/' + template.type,
} );
close();
},
} );
}

if ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {
const label =
template.type === 'wp_template'
? __( 'Reset template' )
: __( 'Reset template part' );
commands.push( {
name: 'core/reset-template',
label,
icon: backup,
callback: ( { close } ) => {
revertTemplate( template );
close();
},
} );
}

if ( isPage ) {
if ( hasPageContentFocus ) {
commands.push( {
Expand All @@ -100,6 +63,43 @@ function useEditModeCommandLoader() {
}
}

if ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {
const label =
template.type === 'wp_template'
? __( 'Reset template' )
: __( 'Reset template part' );
commands.push( {
name: 'core/reset-template',
label,
icon: backup,
callback: ( { close } ) => {
revertTemplate( template );
close();
},
} );
}

if ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {
const label =
template.type === 'wp_template'
? __( 'Delete template' )
: __( 'Delete template part' );
commands.push( {
name: 'core/remove-template',
label,
icon: trash,
context: 'site-editor-edit',
callback: ( { close } ) => {
removeTemplate( template );
// Navigate to the template list
history.push( {
path: '/' + template.type,
} );
close();
},
} );
}

return {
isLoading: ! isLoaded,
commands,
Expand Down

0 comments on commit b39b7f2

Please sign in to comment.