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

Site Editor: Clarify the "Entity" message of the snackbar #54333

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,25 @@ export default function RenameMenuItem( { item, onClose } ) {
throwOnError: true,
} );

createSuccessNotice( __( 'Entity renamed.' ), {
type: 'snackbar',
} );
createSuccessNotice(
item.type === TEMPLATE_PARTS
? __( 'Template part renamed.' )
: __( 'Pattern renamed.' ),
{
type: 'snackbar',
}
);
} catch ( error ) {
const fallbackErrorMessage =
item.type === TEMPLATE_PARTS
? __(
'An error occurred while reverting the template part.'
)
: __( 'An error occurred while reverting the pattern.' );
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: __( 'An error occurred while renaming the entity.' );
: fallbackErrorMessage;

createErrorNotice( errorMessage, { type: 'snackbar' } );
}
Expand Down
8 changes: 7 additions & 1 deletion packages/edit-site/src/components/template-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ export default function TemplateActions( {
}
);
} catch ( error ) {
const fallbackErrorMessage =
template.type === 'wp_template'
? __( 'An error occurred while reverting the template.' )
: __(
'An error occurred while reverting the template part.'
);
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: __( 'An error occurred while reverting the entity.' );
: fallbackErrorMessage;

createErrorNotice( errorMessage, { type: 'snackbar' } );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,25 @@ export default function RenameMenuItem( { template, onClose } ) {
}
);

createSuccessNotice( __( 'Entity renamed.' ), {
type: 'snackbar',
} );
createSuccessNotice(
template.type === 'wp_template'
? __( 'Template renamed.' )
: __( 'Template part renamed.' ),
{
type: 'snackbar',
}
);
} catch ( error ) {
const fallbackErrorMessage =
template.type === 'wp_template'
? __( 'An error occurred while renaming the template.' )
: __(
'An error occurred while renaming the template part.'
);
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: __( 'An error occurred while renaming the entity.' );
: fallbackErrorMessage;

createErrorNotice( errorMessage, { type: 'snackbar' } );
}
Expand Down