Skip to content

Commit

Permalink
Multi entity save panel - remove dynamic copy. (#29637)
Browse files Browse the repository at this point in the history
* remove dynamic copy

* update static copy

* replace copy again

* update strong heading
  • Loading branch information
Addison-Stavlo authored Mar 10, 2021
1 parent 66d9f80 commit a9622b8
Showing 1 changed file with 7 additions and 50 deletions.
57 changes: 7 additions & 50 deletions packages/editor/src/components/entities-saved-states/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { some, groupBy } from 'lodash';
* WordPress dependencies
*/
import { Button, withFocusReturn } from '@wordpress/components';
import { __, sprintf, _n } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { useState, useCallback } from '@wordpress/element';
import { close as closeIcon } from '@wordpress/icons';
Expand All @@ -17,36 +17,6 @@ import { close as closeIcon } from '@wordpress/icons';
*/
import EntityTypeList from './entity-type-list';

const ENTITY_NAMES = {
wp_template_part: ( number ) =>
_n( 'template part', 'template parts', number ),
wp_template: ( number ) => _n( 'template', 'templates', number ),
post: ( number ) => _n( 'post', 'posts', number ),
page: ( number ) => _n( 'page', 'pages', number ),
site: ( number ) => _n( 'site', 'sites', number ),
};

const PLACEHOLDER_PHRASES = {
// 0 is a back up, but should never be observed.
0: __( 'There are no changes.' ),
/* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */
1: __( 'The following changes have been made to your %s.' ),
/* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */
2: __( 'The following changes have been made to your %1$s and %2$s.' ),
/* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */
3: __(
'The following changes have been made to your %1$s, %2$s, and %3$s.'
),
/* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */
4: __(
'The following changes have been made to your %1$s, %2$s, %3$s, and %4$s.'
),
/* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */
5: __(
'The following changes have been made to your %1$s, %2$s, %3$s, %4$s, and %5$s.'
),
};

function EntitiesSavedStates( { isOpen, close } ) {
const { dirtyEntityRecords } = useSelect( ( select ) => {
return {
Expand All @@ -62,23 +32,6 @@ function EntitiesSavedStates( { isOpen, close } ) {
groupBy( dirtyEntityRecords, 'name' )
);

// Get labels for text-prompt phrase.
const entityNamesForPrompt = [];
partitionedSavables.forEach( ( list ) => {
if ( ENTITY_NAMES[ list[ 0 ].name ] ) {
entityNamesForPrompt.push(
ENTITY_NAMES[ list[ 0 ].name ]( list.length )
);
}
} );
// Get text-prompt phrase based on number of entity types changed.
const placeholderPhrase =
PLACEHOLDER_PHRASES[ entityNamesForPrompt.length ] ||
// Fallback for edge case that should not be observed (more than 5 entity types edited).
__( 'The following changes have been made to multiple entities.' );
// eslint-disable-next-line @wordpress/valid-sprintf
const promptPhrase = sprintf( placeholderPhrase, ...entityNamesForPrompt );

// Unchecked entities to be ignored by save function.
const [ unselectedEntities, _setUnselectedEntities ] = useState( [] );

Expand Down Expand Up @@ -147,8 +100,12 @@ function EntitiesSavedStates( { isOpen, close } ) {
</div>

<div className="entities-saved-states__text-prompt">
<strong>{ __( 'Are you ready to save?' ) }</strong>
<p>{ promptPhrase }</p>
<strong>{ __( 'Select the changes you want to save' ) }</strong>
<p>
{ __(
'Some changes may affect other areas of your site.'
) }
</p>
</div>

{ partitionedSavables.map( ( list ) => {
Expand Down

0 comments on commit a9622b8

Please sign in to comment.