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

Confirm dialog: use more descriptive text for the confirm button #60364

Merged
merged 7 commits into from
Apr 15, 2024
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 @@ -215,7 +215,7 @@ function ScreenRevisions() {
}
>
{ __(
'Any unsaved changes will be lost when you apply this revision.'
'Are you sure you want to apply this revision? Any unsaved changes will be lost.'
) }
</ConfirmDialog>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
onCancel={ () => setIsDialogOpen( false ) }
>
{ __(
'You’ve tried to select a block that is part of a template, which may be used on other posts and pages.'
'You’ve tried to select a block that is part of a template, which may be used on other posts and pages. Would you like to edit the template?.'
) }
</ConfirmDialog>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ export default function PostSwitchToDraftButton() {
const isDisabled = isSaving || ( ! isPublished && ! isScheduled );

let alertMessage;
let confirmButtonText;
if ( isPublished ) {
alertMessage = __( 'Are you sure you want to unpublish this post?' );
confirmButtonText = __( 'Unpublish' );
} else if ( isScheduled ) {
alertMessage = __( 'Are you sure you want to unschedule this post?' );
confirmButtonText = __( 'Unschedule' );
}

const handleConfirm = () => {
Expand Down Expand Up @@ -63,6 +66,7 @@ export default function PostSwitchToDraftButton() {
isOpen={ showConfirmDialog }
onConfirm={ handleConfirm }
onCancel={ () => setShowConfirmDialog( false ) }
confirmButtonText={ confirmButtonText }
>
{ alertMessage }
</ConfirmDialog>
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-trash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function PostTrash() {
isOpen={ showConfirmDialog }
onConfirm={ handleConfirm }
onCancel={ () => setShowConfirmDialog( false ) }
confirmButtonText={ __( 'Move to trash' ) }
>
{ __(
'Are you sure you want to move this post to the trash?'
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-visibility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default function PostVisibility( { onClose } ) {
isOpen={ showPrivateConfirmDialog }
onConfirm={ confirmPrivate }
onCancel={ handleDialogCancel }
confirmButtonText={ __( 'Publish' ) }
>
{ __( 'Would you like to privately publish this post now?' ) }
</ConfirmDialog>
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/change-detection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ test.describe( 'Change detection', () => {
.click();
await page
.getByRole( 'dialog' )
.getByRole( 'button', { name: 'OK' } )
.getByRole( 'button', { name: 'Move to trash' } )
.click();

await expect(
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/editor/various/post-visibility.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.describe( 'Post visibility', () => {

await page.click( 'role=radio[name="Private"i]' );

await page.click( 'role=button[name="OK"i]' );
await page.click( 'role=button[name="Publish"i]' );

const currentStatus = await page.evaluate( () => {
return window.wp.data
Expand Down Expand Up @@ -99,7 +99,7 @@ test.describe( 'Post visibility', () => {

await page.click( 'role=radio[name="Private"i]' );

await page.click( 'role=button[name="OK"i]' );
await page.click( 'role=button[name="Publish"i]' );

const currentStatus = await page.evaluate( () => {
return window.wp.data
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test.describe( 'Preview', () => {
.getByRole( 'button', { name: 'Switch to draft' } )
.click();
// FIXME: The confirmation dialog is not named yet.
await page.click( 'role=dialog >> role=button[name="OK"i]' );
await page.click( 'role=dialog >> role=button[name="Unpublish"i]' );

// Wait for the status change.
// @see https://github.com/WordPress/gutenberg/pull/43933
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/specs/editor/various/switch-to-draft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ test.describe( 'Clicking "Switch to draft" on a published/scheduled post/page',

await switchToDraftUtils.switchToDraftButton.click();

const confirmButtonText =
postStatus === 'publish' ? 'Unpublish' : 'Unschedule';

await page
.getByRole( 'dialog' )
.getByRole( 'button', { name: 'OK' } )
.getByRole( 'button', { name: confirmButtonText } )
.click();

await expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test.describe( 'Style Revisions', () => {
const confirm = page.getByRole( 'dialog' );
await expect( confirm ).toBeVisible();
await expect( confirm ).toHaveText(
/^Any unsaved changes will be lost when you apply this revision./
/^Are you sure you want to apply this revision\? Any unsaved changes will be lost./
);

// This is to make sure there are no lingering unsaved changes.
Expand Down
Loading