From 0774936ada6fa027c0f32120ed68c5fa70a51647 Mon Sep 17 00:00:00 2001 From: ramon Date: Mon, 8 May 2023 10:33:14 +1000 Subject: [PATCH] Tweaked the revisions buttons copy, shifting the date and meta around. Updated tests --- .../screen-revisions/revisions-buttons.js | 26 +++++++++++-------- .../global-styles/screen-revisions/style.scss | 2 +- .../user-global-styles-revisions.spec.js | 6 ++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js b/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js index 950aeb1a780f7..c4d624bf1727e 100644 --- a/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js +++ b/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js @@ -17,7 +17,7 @@ import { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date'; * @return {string} Translated label. */ function getRevisionLabel( revision ) { - const authorDisplayName = revision?.author?.name; + const authorDisplayName = revision?.author?.name || __( 'User' ); const isUnsaved = 'unsaved' === revision?.id; if ( isUnsaved ) { @@ -37,7 +37,7 @@ function getRevisionLabel( revision ) { return revision?.isLatest ? sprintf( /* translators: %(name)s author display name, %(date)s: revision creation date */ - __( 'Changes saved on %(date)s by %(name)s (current)' ), + __( 'Changes saved by %(name)s on %(date)s (current)' ), { name: authorDisplayName, date: formattedDate, @@ -45,7 +45,7 @@ function getRevisionLabel( revision ) { ) : sprintf( /* translators: %(name)s author display name, %(date)s: revision creation date */ - __( 'Changes saved on %(date)s by %(name)s ' ), + __( 'Changes saved by %(name)s on %(date)s' ), { name: authorDisplayName, date: formattedDate, @@ -73,6 +73,7 @@ function RevisionsButtons( { userRevisions, currentRevisionId, onChange } ) { > { userRevisions.map( ( revision ) => { const { id, author, isLatest, modified } = revision; + const authorDisplayName = author?.name || __( 'User' ); const authorAvatar = author?.avatar_urls?.[ '48' ]; /* * If the currentId hasn't been selected yet, the first revision is @@ -101,15 +102,18 @@ function RevisionsButtons( { userRevisions, currentRevisionId, onChange } ) { label={ getRevisionLabel( revision ) } > - - { 'unsaved' === id - ? __( 'Unsaved changes' ) - : __( 'Changes saved' ) } - + - + { sprintf( + /* translators: %(name)s author display name */ + __( 'Changes saved by %(name)s' ), + { + name: authorDisplayName, + } + ) } + { { await page.getByRole( 'menuitem', { name: 'Revisions' } ).click(); const revisionButtons = page.getByRole( 'button', { - name: /^Changes saved on /, + name: /^Changes saved by /, } ); await expect( revisionButtons ).toHaveCount( @@ -97,7 +97,7 @@ test.describe( 'Global styles revisions', () => { await page.getByRole( 'button', { name: 'Styles actions' } ).click(); await page.getByRole( 'menuitem', { name: 'Revisions' } ).click(); const revisionButtons = page.getByRole( 'button', { - name: /^Changes saved on /, + name: /^Changes saved by /, } ); await expect( revisionButtons ).toHaveCount( @@ -129,7 +129,7 @@ test.describe( 'Global styles revisions', () => { // await expect( image ).toHaveCSS( 'height', '3px' ); await page - .getByRole( 'button', { name: /^Changes saved on / } ) + .getByRole( 'button', { name: /^Changes saved by / } ) .last() .click();