@wordpress/editor 14.0.2 → 14.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/build/components/editor-interface/index.js +2 -2
  2. package/build/components/editor-interface/index.js.map +1 -1
  3. package/build/components/global-styles-provider/index.js +6 -65
  4. package/build/components/global-styles-provider/index.js.map +1 -1
  5. package/build/components/post-actions/actions.js +61 -12
  6. package/build/components/post-actions/actions.js.map +1 -1
  7. package/build/components/post-actions/index.js +4 -1
  8. package/build/components/post-actions/index.js.map +1 -1
  9. package/build/components/post-excerpt/index.js +2 -1
  10. package/build/components/post-excerpt/index.js.map +1 -1
  11. package/build/components/post-excerpt/panel.js +2 -1
  12. package/build/components/post-excerpt/panel.js.map +1 -1
  13. package/build/hooks/pattern-overrides.js +1 -1
  14. package/build/hooks/pattern-overrides.js.map +1 -1
  15. package/build/store/private-actions.js +9 -5
  16. package/build/store/private-actions.js.map +1 -1
  17. package/build-module/components/editor-interface/index.js +2 -2
  18. package/build-module/components/editor-interface/index.js.map +1 -1
  19. package/build-module/components/global-styles-provider/index.js +7 -66
  20. package/build-module/components/global-styles-provider/index.js.map +1 -1
  21. package/build-module/components/post-actions/actions.js +62 -13
  22. package/build-module/components/post-actions/actions.js.map +1 -1
  23. package/build-module/components/post-actions/index.js +4 -1
  24. package/build-module/components/post-actions/index.js.map +1 -1
  25. package/build-module/components/post-excerpt/index.js +2 -1
  26. package/build-module/components/post-excerpt/index.js.map +1 -1
  27. package/build-module/components/post-excerpt/panel.js +2 -1
  28. package/build-module/components/post-excerpt/panel.js.map +1 -1
  29. package/build-module/hooks/pattern-overrides.js +1 -1
  30. package/build-module/hooks/pattern-overrides.js.map +1 -1
  31. package/build-module/store/private-actions.js +9 -5
  32. package/build-module/store/private-actions.js.map +1 -1
  33. package/build-style/style-rtl.css +7 -1
  34. package/build-style/style.css +7 -1
  35. package/package.json +14 -14
  36. package/src/components/editor-interface/index.js +12 -8
  37. package/src/components/global-styles-provider/index.js +7 -90
  38. package/src/components/post-actions/actions.js +104 -20
  39. package/src/components/post-actions/index.js +1 -1
  40. package/src/components/post-card-panel/style.scss +1 -0
  41. package/src/components/post-excerpt/index.js +4 -1
  42. package/src/components/post-excerpt/panel.js +2 -1
  43. package/src/components/post-publish-panel/style.scss +1 -1
  44. package/src/components/post-url/style.scss +4 -0
  45. package/src/components/visual-editor/style.scss +2 -0
  46. package/src/hooks/pattern-overrides.js +2 -3
  47. package/src/store/private-actions.js +54 -21
@@ -7,17 +7,15 @@ import { isPlainObject } from 'is-plain-object';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { registerBlockStyle, store as blocksStore } from '@wordpress/blocks';
11
10
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
12
11
  import { store as coreStore } from '@wordpress/core-data';
13
12
  import { useSelect, useDispatch } from '@wordpress/data';
14
- import { useEffect, useMemo, useCallback } from '@wordpress/element';
13
+ import { useMemo, useCallback } from '@wordpress/element';
15
14
 
16
15
  /**
17
16
  * Internal dependencies
18
17
  */
19
18
  import { unlock } from '../../lock-unlock';
20
- import setNestedValue from '../../utils/set-nested-value';
21
19
 
22
20
  const { GlobalStylesContext, cleanEmptyObject } = unlock(
23
21
  blockEditorPrivateApis
@@ -32,85 +30,6 @@ export function mergeBaseAndUserConfigs( base, user ) {
32
30
  } );
33
31
  }
34
32
 
35
- /**
36
- * Resolves shared block style variation definitions from the user origin
37
- * under their respective block types and registers the block style if required.
38
- *
39
- * @param {Object} userConfig Current user origin global styles data.
40
- * @return {Object} Updated global styles data.
41
- */
42
- function useResolvedBlockStyleVariationsConfig( userConfig ) {
43
- const { getBlockStyles } = useSelect( blocksStore );
44
- const sharedVariations = userConfig?.styles?.blocks?.variations;
45
-
46
- // Collect block style variation definitions to merge and unregistered
47
- // block styles for automatic registration.
48
- const [ userConfigToMerge, unregisteredStyles ] = useMemo( () => {
49
- if ( ! sharedVariations ) {
50
- return [];
51
- }
52
-
53
- const variationsConfigToMerge = {};
54
- const unregisteredBlockStyles = [];
55
-
56
- Object.entries( sharedVariations ).forEach(
57
- ( [ variationName, variation ] ) => {
58
- if ( ! variation?.blockTypes?.length ) {
59
- return;
60
- }
61
-
62
- variation.blockTypes.forEach( ( blockName ) => {
63
- const blockStyles = getBlockStyles( blockName );
64
- const registeredBlockStyle = blockStyles.find(
65
- ( { name } ) => name === variationName
66
- );
67
-
68
- if ( ! registeredBlockStyle ) {
69
- unregisteredBlockStyles.push( [
70
- blockName,
71
- {
72
- name: variationName,
73
- label: variationName,
74
- },
75
- ] );
76
- }
77
-
78
- const path = [
79
- 'styles',
80
- 'blocks',
81
- blockName,
82
- 'variations',
83
- variationName,
84
- ];
85
- setNestedValue( variationsConfigToMerge, path, variation );
86
- } );
87
- }
88
- );
89
-
90
- return [ variationsConfigToMerge, unregisteredBlockStyles ];
91
- }, [ sharedVariations, getBlockStyles ] );
92
-
93
- // Automatically register missing block styles from variations.
94
- useEffect(
95
- () =>
96
- unregisteredStyles?.forEach( ( unregisteredStyle ) =>
97
- registerBlockStyle( ...unregisteredStyle )
98
- ),
99
- [ unregisteredStyles ]
100
- );
101
-
102
- // Merge shared block style variation definitions into overall user config.
103
- const updatedConfig = useMemo( () => {
104
- if ( ! userConfigToMerge ) {
105
- return userConfig;
106
- }
107
-
108
- return deepmerge( userConfigToMerge, userConfig );
109
- }, [ userConfigToMerge, userConfig ] );
110
-
111
- return updatedConfig;
112
- }
113
-
114
33
  function useGlobalStylesUserConfig() {
115
34
  const { globalStylesId, isReady, settings, styles, _links } = useSelect(
116
35
  ( select ) => {
@@ -199,7 +118,7 @@ function useGlobalStylesUserConfig() {
199
118
  options
200
119
  );
201
120
  },
202
- [ globalStylesId ]
121
+ [ globalStylesId, editEntityRecord, getEditedEntityRecord ]
203
122
  );
204
123
 
205
124
  return [ isReady, config, setConfig ];
@@ -219,28 +138,26 @@ export function useGlobalStylesContext() {
219
138
  const [ isUserConfigReady, userConfig, setUserConfig ] =
220
139
  useGlobalStylesUserConfig();
221
140
  const [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();
222
- const userConfigWithVariations =
223
- useResolvedBlockStyleVariationsConfig( userConfig );
224
141
 
225
142
  const mergedConfig = useMemo( () => {
226
- if ( ! baseConfig || ! userConfigWithVariations ) {
143
+ if ( ! baseConfig || ! userConfig ) {
227
144
  return {};
228
145
  }
229
146
 
230
- return mergeBaseAndUserConfigs( baseConfig, userConfigWithVariations );
231
- }, [ userConfigWithVariations, baseConfig ] );
147
+ return mergeBaseAndUserConfigs( baseConfig, userConfig );
148
+ }, [ userConfig, baseConfig ] );
232
149
 
233
150
  const context = useMemo( () => {
234
151
  return {
235
152
  isReady: isUserConfigReady && isBaseConfigReady,
236
- user: userConfigWithVariations,
153
+ user: userConfig,
237
154
  base: baseConfig,
238
155
  merged: mergedConfig,
239
156
  setUserConfig,
240
157
  };
241
158
  }, [
242
159
  mergedConfig,
243
- userConfigWithVariations,
160
+ userConfig,
244
161
  baseConfig,
245
162
  setUserConfig,
246
163
  isUserConfigReady,
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { external, trash, backup } from '@wordpress/icons';
5
5
  import { addQueryArgs } from '@wordpress/url';
6
- import { useDispatch, useSelect } from '@wordpress/data';
6
+ import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
7
7
  import { decodeEntities } from '@wordpress/html-entities';
8
8
  import { store as coreStore } from '@wordpress/core-data';
9
9
  import { __, _n, sprintf, _x } from '@wordpress/i18n';
@@ -155,6 +155,24 @@ const deletePostAction = {
155
155
  },
156
156
  };
157
157
 
158
+ function useCanUserEligibilityCheckPostType( capability, resource, action ) {
159
+ const registry = useRegistry();
160
+ return useMemo(
161
+ () => ( {
162
+ ...action,
163
+ isEligible( item ) {
164
+ return (
165
+ action.isEligible( item ) &&
166
+ registry
167
+ .select( coreStore )
168
+ .canUser( capability, resource, item.id )
169
+ );
170
+ },
171
+ } ),
172
+ [ action, registry, capability, resource ]
173
+ );
174
+ }
175
+
158
176
  const trashPostAction = {
159
177
  id: 'move-to-trash',
160
178
  label: __( 'Move to Trash' ),
@@ -323,12 +341,20 @@ const trashPostAction = {
323
341
  },
324
342
  };
325
343
 
326
- function usePermanentlyDeletePostAction() {
344
+ function useTrashPostAction( resource ) {
345
+ return useCanUserEligibilityCheckPostType(
346
+ 'delete',
347
+ resource,
348
+ trashPostAction
349
+ );
350
+ }
351
+
352
+ function usePermanentlyDeletePostAction( resource ) {
327
353
  const { createSuccessNotice, createErrorNotice } =
328
354
  useDispatch( noticesStore );
329
355
  const { deleteEntityRecord } = useDispatch( coreStore );
330
356
 
331
- return useMemo(
357
+ const permanentlyDeletePostAction = useMemo(
332
358
  () => ( {
333
359
  id: 'permanently-delete',
334
360
  label: __( 'Permanently delete' ),
@@ -428,15 +454,20 @@ function usePermanentlyDeletePostAction() {
428
454
  } ),
429
455
  [ createSuccessNotice, createErrorNotice, deleteEntityRecord ]
430
456
  );
457
+ return useCanUserEligibilityCheckPostType(
458
+ 'delete',
459
+ resource,
460
+ permanentlyDeletePostAction
461
+ );
431
462
  }
432
463
 
433
- function useRestorePostAction() {
464
+ function useRestorePostAction( resource ) {
434
465
  const { createSuccessNotice, createErrorNotice } =
435
466
  useDispatch( noticesStore );
436
467
  const { editEntityRecord, saveEditedEntityRecord } =
437
468
  useDispatch( coreStore );
438
469
 
439
- return useMemo(
470
+ const restorePostAction = useMemo(
440
471
  () => ( {
441
472
  id: 'restore',
442
473
  label: __( 'Restore' ),
@@ -562,6 +593,11 @@ function useRestorePostAction() {
562
593
  saveEditedEntityRecord,
563
594
  ]
564
595
  );
596
+ return useCanUserEligibilityCheckPostType(
597
+ 'update',
598
+ resource,
599
+ restorePostAction
600
+ );
565
601
  }
566
602
 
567
603
  const viewPostAction = {
@@ -583,6 +619,7 @@ const viewPostAction = {
583
619
 
584
620
  const postRevisionsAction = {
585
621
  id: 'view-post-revisions',
622
+ context: 'list',
586
623
  label( items ) {
587
624
  const revisionsCount =
588
625
  items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
@@ -722,6 +759,14 @@ const renamePostAction = {
722
759
  },
723
760
  };
724
761
 
762
+ function useRenamePostAction( resource ) {
763
+ return useCanUserEligibilityCheckPostType(
764
+ 'update',
765
+ resource,
766
+ renamePostAction
767
+ );
768
+ }
769
+
725
770
  const duplicatePostAction = {
726
771
  id: 'duplicate-post',
727
772
  label: _x( 'Duplicate', 'action label' ),
@@ -1029,19 +1074,33 @@ export const duplicateTemplatePartAction = {
1029
1074
  },
1030
1075
  };
1031
1076
 
1032
- export function usePostActions( postType, onActionPerformed ) {
1033
- const { postTypeObject } = useSelect(
1077
+ export function usePostActions( { postType, onActionPerformed, context } ) {
1078
+ const {
1079
+ postTypeObject,
1080
+ resource,
1081
+ cachedCanUserResolvers,
1082
+ userCanCreatePostType,
1083
+ } = useSelect(
1034
1084
  ( select ) => {
1035
- const { getPostType } = select( coreStore );
1085
+ const { getPostType, getCachedResolvers, canUser } =
1086
+ select( coreStore );
1087
+ const _postTypeObject = getPostType( postType );
1088
+ const _resource = _postTypeObject?.rest_base || '';
1036
1089
  return {
1037
- postTypeObject: getPostType( postType ),
1090
+ postTypeObject: _postTypeObject,
1091
+ resource: _resource,
1092
+ cachedCanUserResolvers: getCachedResolvers()?.canUser,
1093
+ userCanCreatePostType: canUser( 'create', _resource ),
1038
1094
  };
1039
1095
  },
1040
1096
  [ postType ]
1041
1097
  );
1042
1098
 
1043
- const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
1044
- const restorePostAction = useRestorePostAction();
1099
+ const trashPostActionForPostType = useTrashPostAction( resource );
1100
+ const permanentlyDeletePostActionForPostType =
1101
+ usePermanentlyDeletePostAction( resource );
1102
+ const renamePostActionForPostType = useRenamePostAction( resource );
1103
+ const restorePostActionForPostType = useRestorePostAction( resource );
1045
1104
  const isTemplateOrTemplatePart = [
1046
1105
  TEMPLATE_POST_TYPE,
1047
1106
  TEMPLATE_PART_POST_TYPE,
@@ -1055,7 +1114,7 @@ export function usePostActions( postType, onActionPerformed ) {
1055
1114
  return [];
1056
1115
  }
1057
1116
 
1058
- const actions = [
1117
+ let actions = [
1059
1118
  postTypeObject?.viewable && viewPostAction,
1060
1119
  supportsRevisions && postRevisionsAction,
1061
1120
  globalThis.IS_GUTENBERG_PLUGIN
@@ -1063,16 +1122,33 @@ export function usePostActions( postType, onActionPerformed ) {
1063
1122
  ! isPattern &&
1064
1123
  duplicatePostAction
1065
1124
  : false,
1066
- isTemplateOrTemplatePart && duplicateTemplatePartAction,
1067
- isPattern && duplicatePatternAction,
1068
- supportsTitle && renamePostAction,
1125
+ isTemplateOrTemplatePart &&
1126
+ userCanCreatePostType &&
1127
+ duplicateTemplatePartAction,
1128
+ isPattern && userCanCreatePostType && duplicatePatternAction,
1129
+ supportsTitle && renamePostActionForPostType,
1069
1130
  isPattern && exportPatternAsJSONAction,
1070
- isTemplateOrTemplatePart ? resetTemplateAction : restorePostAction,
1131
+ isTemplateOrTemplatePart
1132
+ ? resetTemplateAction
1133
+ : restorePostActionForPostType,
1071
1134
  isTemplateOrTemplatePart || isPattern
1072
1135
  ? deletePostAction
1073
- : trashPostAction,
1074
- ! isTemplateOrTemplatePart && permanentlyDeletePostAction,
1136
+ : trashPostActionForPostType,
1137
+ ! isTemplateOrTemplatePart &&
1138
+ permanentlyDeletePostActionForPostType,
1075
1139
  ].filter( Boolean );
1140
+ // Filter actions based on provided context. If not provided
1141
+ // all actions are returned. We'll have a single entry for getting the actions
1142
+ // and the consumer should provide the context to filter the actions, if needed.
1143
+ // Actions should also provide the `context` they support, if it's specific, to
1144
+ // compare with the provided context to get all the actions.
1145
+ // Right now the only supported context is `list`.
1146
+ actions = actions.filter( ( action ) => {
1147
+ if ( ! action.context ) {
1148
+ return true;
1149
+ }
1150
+ return action.context === context;
1151
+ } );
1076
1152
 
1077
1153
  if ( onActionPerformed ) {
1078
1154
  for ( let i = 0; i < actions.length; ++i ) {
@@ -1116,15 +1192,23 @@ export function usePostActions( postType, onActionPerformed ) {
1116
1192
  }
1117
1193
 
1118
1194
  return actions;
1195
+ // We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
1196
+ // when user capabilities are resolved. This makes sure the isEligible functions of actions dependent on capabilities are re-evaluated.
1197
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1119
1198
  }, [
1120
1199
  isTemplateOrTemplatePart,
1121
1200
  isPattern,
1122
1201
  postTypeObject?.viewable,
1123
- permanentlyDeletePostAction,
1124
- restorePostAction,
1202
+ permanentlyDeletePostActionForPostType,
1203
+ restorePostActionForPostType,
1204
+ renamePostActionForPostType,
1205
+ trashPostActionForPostType,
1125
1206
  onActionPerformed,
1126
1207
  isLoaded,
1127
1208
  supportsRevisions,
1128
1209
  supportsTitle,
1210
+ context,
1211
+ userCanCreatePostType,
1212
+ cachedCanUserResolvers,
1129
1213
  ] );
1130
1214
  }
@@ -42,7 +42,7 @@ export default function PostActions( { onActionPerformed, buttonProps } ) {
42
42
  postType: _postType,
43
43
  };
44
44
  }, [] );
45
- const allActions = usePostActions( postType, onActionPerformed );
45
+ const allActions = usePostActions( { postType, onActionPerformed } );
46
46
 
47
47
  const actions = useMemo( () => {
48
48
  return allActions.filter( ( action ) => {
@@ -14,6 +14,7 @@
14
14
  flex-wrap: wrap;
15
15
  column-gap: $grid-unit-10;
16
16
  row-gap: $grid-unit-05;
17
+ word-break: break-word;
17
18
  }
18
19
  }
19
20
 
@@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
5
5
  import { ExternalLink, TextareaControl } from '@wordpress/components';
6
6
  import { useDispatch, useSelect } from '@wordpress/data';
7
7
  import { useState } from '@wordpress/element';
8
+ import { decodeEntities } from '@wordpress/html-entities';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -52,7 +53,9 @@ export default function PostExcerpt( {
52
53
  []
53
54
  );
54
55
  const { editPost } = useDispatch( editorStore );
55
- const [ localExcerpt, setLocalExcerpt ] = useState( excerpt );
56
+ const [ localExcerpt, setLocalExcerpt ] = useState(
57
+ decodeEntities( excerpt )
58
+ );
56
59
  const updatePost = ( value ) => {
57
60
  editPost( { [ usedAttribute ]: value } );
58
61
  };
@@ -13,6 +13,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
13
13
  import { useMemo, useState } from '@wordpress/element';
14
14
  import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
15
15
  import { store as coreStore } from '@wordpress/core-data';
16
+ import { decodeEntities } from '@wordpress/html-entities';
16
17
 
17
18
  /**
18
19
  * Internal dependencies
@@ -173,7 +174,7 @@ function PrivateExcerpt() {
173
174
  }
174
175
  const excerptText = !! excerpt && (
175
176
  <Text align="left" numberOfLines={ 4 } truncate>
176
- { excerpt }
177
+ { decodeEntities( excerpt ) }
177
178
  </Text>
178
179
  );
179
180
  if ( ! allowEditing ) {
@@ -196,7 +196,7 @@
196
196
  position: fixed;
197
197
  z-index: z-index(".editor-post-publish-panel");
198
198
  background: $white;
199
- top: 0;
199
+ top: $admin-bar-height-big;
200
200
  bottom: 0;
201
201
  right: 0;
202
202
  left: 0;
@@ -26,3 +26,7 @@
26
26
  .editor-post-url__input input.components-input-control__input {
27
27
  padding-inline-start: 0 !important;
28
28
  }
29
+
30
+ .editor-post-url__panel-toggle {
31
+ word-break: break-word;
32
+ }
@@ -3,6 +3,8 @@
3
3
  height: 100%;
4
4
  display: block;
5
5
  background-color: $gray-300;
6
+ // Make this a stacking context to contain the z-index of children elements.
7
+ isolation: isolate;
6
8
 
7
9
  // Centralize the editor horizontally (flex-direction is column).
8
10
  align-items: center;
@@ -34,9 +34,8 @@ const {
34
34
  */
35
35
  const withPatternOverrideControls = createHigherOrderComponent(
36
36
  ( BlockEdit ) => ( props ) => {
37
- const isSupportedBlock = Object.keys(
38
- PARTIAL_SYNCING_SUPPORTED_BLOCKS
39
- ).includes( props.name );
37
+ const isSupportedBlock =
38
+ !! PARTIAL_SYNCING_SUPPORTED_BLOCKS[ props.name ];
40
39
 
41
40
  return (
42
41
  <>
@@ -369,6 +369,13 @@ export const revertTemplate =
369
369
  export const removeTemplates =
370
370
  ( items ) =>
371
371
  async ( { registry } ) => {
372
+ const isResetting = items.every(
373
+ ( item ) =>
374
+ !! item &&
375
+ ( item.has_theme_file ||
376
+ ( item.templatePart && item.templatePart.has_theme_file ) )
377
+ );
378
+
372
379
  const promiseResult = await Promise.allSettled(
373
380
  items.map( ( item ) => {
374
381
  return registry
@@ -394,13 +401,21 @@ export const removeTemplates =
394
401
  typeof items[ 0 ].title === 'string'
395
402
  ? items[ 0 ].title
396
403
  : items[ 0 ].title?.rendered;
397
- successMessage = sprintf(
398
- /* translators: The template/part's name. */
399
- __( '"%s" deleted.' ),
400
- decodeEntities( title )
401
- );
404
+ successMessage = isResetting
405
+ ? sprintf(
406
+ /* translators: The template/part's name. */
407
+ __( '"%s" reset.' ),
408
+ decodeEntities( title )
409
+ )
410
+ : sprintf(
411
+ /* translators: The template/part's name. */
412
+ __( '"%s" deleted.' ),
413
+ decodeEntities( title )
414
+ );
402
415
  } else {
403
- successMessage = __( 'Items deleted.' );
416
+ successMessage = isResetting
417
+ ? __( 'Items reset.' )
418
+ : __( 'Items deleted.' );
404
419
  }
405
420
 
406
421
  registry
@@ -417,9 +432,9 @@ export const removeTemplates =
417
432
  if ( promiseResult[ 0 ].reason?.message ) {
418
433
  errorMessage = promiseResult[ 0 ].reason.message;
419
434
  } else {
420
- errorMessage = __(
421
- 'An error occurred while deleting the item.'
422
- );
435
+ errorMessage = isResetting
436
+ ? __( 'An error occurred while reverting the item.' )
437
+ : __( 'An error occurred while deleting the item.' );
423
438
  }
424
439
  // If we were trying to delete a multiple templates
425
440
  } else {
@@ -437,19 +452,37 @@ export const removeTemplates =
437
452
  'An error occurred while deleting the items.'
438
453
  );
439
454
  } else if ( errorMessages.size === 1 ) {
440
- errorMessage = sprintf(
441
- /* translators: %s: an error message */
442
- __( 'An error occurred while deleting the items: %s' ),
443
- [ ...errorMessages ][ 0 ]
444
- );
455
+ errorMessage = isResetting
456
+ ? sprintf(
457
+ /* translators: %s: an error message */
458
+ __(
459
+ 'An error occurred while reverting the items: %s'
460
+ ),
461
+ [ ...errorMessages ][ 0 ]
462
+ )
463
+ : sprintf(
464
+ /* translators: %s: an error message */
465
+ __(
466
+ 'An error occurred while deleting the items: %s'
467
+ ),
468
+ [ ...errorMessages ][ 0 ]
469
+ );
445
470
  } else {
446
- sprintf(
447
- /* translators: %s: a list of comma separated error messages */
448
- __(
449
- 'Some errors occurred while deleting the items: %s'
450
- ),
451
- [ ...errorMessages ].join( ',' )
452
- );
471
+ errorMessage = isResetting
472
+ ? sprintf(
473
+ /* translators: %s: a list of comma separated error messages */
474
+ __(
475
+ 'Some errors occurred while reverting the items: %s'
476
+ ),
477
+ [ ...errorMessages ].join( ',' )
478
+ )
479
+ : sprintf(
480
+ /* translators: %s: a list of comma separated error messages */
481
+ __(
482
+ 'Some errors occurred while deleting the items: %s'
483
+ ),
484
+ [ ...errorMessages ].join( ',' )
485
+ );
453
486
  }
454
487
  }
455
488
  registry