Skip to content

Commit

Permalink
Global styles: update return values from getGlobalStylesChanges() (#5…
Browse files Browse the repository at this point in the history
…8707)

* 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 <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
  • Loading branch information
3 people committed Feb 6, 2024
1 parent d8104f0 commit 15644c0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand Down Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe( 'getGlobalStylesChanges', () => {
expect( resultA ).toEqual( [
'Colors',
'Typography',
'Test pumpkin flowers block',
'Test pumpkin flowers',
'H3 element',
'Caption element',
'H6 element',
Expand All @@ -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',
] );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( ', ' ) }.
</span>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function GlobalStylesDescription( { record } ) {
<h3 className="entities-saved-states__description-heading">
{ __( 'Changes made to:' ) }
</h3>
<PanelRow>{ globalStylesChanges.join( ', ' ) }</PanelRow>
<PanelRow>{ globalStylesChanges.join( ', ' ) }.</PanelRow>
</>
) : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

1 comment on commit 15644c0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 15644c0.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7795200487
📝 Reported issues:

Please sign in to comment.