From 15644c02ae81ac7dfcbae1384beb04ec5ec2f825 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 6 Feb 2024 16:33:50 +1100 Subject: [PATCH] Global styles: update return values from getGlobalStylesChanges() (#58707) * Leave it up to the consuming component as to how to present the changes. This includes adding a period at the end of any sentences. * Period. Co-authored-by: ramonjd Co-authored-by: andrewserong --- .../global-styles/get-global-styles-changes.js | 10 ++-------- .../global-styles/test/get-global-styles-changes.js | 6 +++--- .../screen-revisions/revisions-buttons.js | 2 +- .../entities-saved-states/entity-type-list.js | 2 +- .../site-editor/user-global-styles-revisions.spec.js | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/get-global-styles-changes.js b/packages/block-editor/src/components/global-styles/get-global-styles-changes.js index 942d709e6a268d..9bbd11fb7d7977 100644 --- a/packages/block-editor/src/components/global-styles/get-global-styles-changes.js +++ b/packages/block-editor/src/components/global-styles/get-global-styles-changes.js @@ -50,13 +50,7 @@ function getTranslation( key ) { if ( keyArray?.[ 0 ] === 'blocks' ) { const blockName = getBlockNames()?.[ keyArray[ 1 ] ]; - return blockName - ? sprintf( - // translators: %s: block name. - __( '%s block' ), - blockName - ) - : keyArray[ 1 ]; + return blockName || keyArray[ 1 ]; } if ( keyArray?.[ 0 ] === 'elements' ) { @@ -200,7 +194,7 @@ export default function getGlobalStylesChanges( next, previous, options = {} ) { const deleteCount = changesLength - maxResults; const andMoreText = sprintf( // translators: %d: number of global styles changes that are not displayed in the UI. - _n( '…and %d more change.', '…and %d more changes.', deleteCount ), + _n( '…and %d more change', '…and %d more changes', deleteCount ), deleteCount ); changes.splice( maxResults, deleteCount, andMoreText ); diff --git a/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js b/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js index 0c53336c87e02b..2e7a68dab1f7bb 100644 --- a/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js +++ b/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js @@ -171,7 +171,7 @@ describe( 'getGlobalStylesChanges', () => { expect( resultA ).toEqual( [ 'Colors', 'Typography', - 'Test pumpkin flowers block', + 'Test pumpkin flowers', 'H3 element', 'Caption element', 'H6 element', @@ -191,8 +191,8 @@ describe( 'getGlobalStylesChanges', () => { expect( resultA ).toEqual( [ 'Colors', 'Typography', - 'Test pumpkin flowers block', - '…and 5 more changes.', + 'Test pumpkin flowers', + '…and 5 more changes', ] ); } ); 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 dcdc98fefebb6f..07d479251add93 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 @@ -36,7 +36,7 @@ function ChangesSummary( { revision, previousRevision } ) { data-testid="global-styles-revision-changes" className="edit-site-global-styles-screen-revisions__changes" > - { changes.join( ', ' ) } + { changes.join( ', ' ) }. ); } diff --git a/packages/editor/src/components/entities-saved-states/entity-type-list.js b/packages/editor/src/components/entities-saved-states/entity-type-list.js index d422c2ae9bfdbd..cb050a370c4e34 100644 --- a/packages/editor/src/components/entities-saved-states/entity-type-list.js +++ b/packages/editor/src/components/entities-saved-states/entity-type-list.js @@ -59,7 +59,7 @@ function GlobalStylesDescription( { record } ) {

{ __( 'Changes made to:' ) }

- { globalStylesChanges.join( ', ' ) } + { globalStylesChanges.join( ', ' ) }. ) : null; } diff --git a/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js b/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js index 9cb8ba53461e09..c8a87ecbeb69e8 100644 --- a/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js +++ b/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js @@ -57,7 +57,7 @@ test.describe( 'Style Revisions', () => { // Shows changes made in the revision. await expect( page.getByTestId( 'global-styles-revision-changes' ) - ).toHaveText( 'Colors' ); + ).toHaveText( 'Colors.' ); // There should be 2 revisions not including the reset to theme defaults button. await expect( revisionButtons ).toHaveCount(