@wordpress/fields 0.1.0 → 0.3.0

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 (135) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +12 -0
  3. package/build/actions/delete-post.js +9 -9
  4. package/build/actions/delete-post.js.map +1 -1
  5. package/build/actions/duplicate-post.js +3 -3
  6. package/build/actions/duplicate-post.js.map +1 -1
  7. package/build/actions/export-pattern.js.map +1 -1
  8. package/build/actions/permanently-delete-post.js +4 -3
  9. package/build/actions/permanently-delete-post.js.map +1 -1
  10. package/build/actions/reset-post.js +2 -2
  11. package/build/actions/reset-post.js.map +1 -1
  12. package/build/actions/restore-post.js +6 -5
  13. package/build/actions/restore-post.js.map +1 -1
  14. package/build/actions/trash-post.js +5 -4
  15. package/build/actions/trash-post.js.map +1 -1
  16. package/build/actions/view-post-revisions.js +1 -1
  17. package/build/actions/view-post-revisions.js.map +1 -1
  18. package/build/fields/featured-image/featured-image-edit.js +113 -0
  19. package/build/fields/featured-image/featured-image-edit.js.map +1 -0
  20. package/build/fields/featured-image/featured-image-view.js +41 -0
  21. package/build/fields/featured-image/featured-image-view.js.map +1 -0
  22. package/build/fields/featured-image/index.js +30 -0
  23. package/build/fields/featured-image/index.js.map +1 -0
  24. package/build/fields/index.js +21 -0
  25. package/build/fields/index.js.map +1 -1
  26. package/build/fields/parent/index.js +34 -0
  27. package/build/fields/parent/index.js.map +1 -0
  28. package/build/fields/parent/parent-edit.js +243 -0
  29. package/build/fields/parent/parent-edit.js.map +1 -0
  30. package/build/fields/parent/parent-view.js +39 -0
  31. package/build/fields/parent/parent-view.js.map +1 -0
  32. package/build/fields/parent/utils.js +20 -0
  33. package/build/fields/parent/utils.js.map +1 -0
  34. package/build/fields/slug/index.js +30 -0
  35. package/build/fields/slug/index.js.map +1 -0
  36. package/build/fields/slug/slug-edit.js +132 -0
  37. package/build/fields/slug/slug-edit.js.map +1 -0
  38. package/build/fields/slug/slug-view.js +30 -0
  39. package/build/fields/slug/slug-view.js.map +1 -0
  40. package/build/mutation/index.js +3 -2
  41. package/build/mutation/index.js.map +1 -1
  42. package/build/types.js.map +1 -1
  43. package/build-module/actions/delete-post.js +11 -12
  44. package/build-module/actions/delete-post.js.map +1 -1
  45. package/build-module/actions/duplicate-post.js +4 -5
  46. package/build-module/actions/duplicate-post.js.map +1 -1
  47. package/build-module/actions/export-pattern.js.map +1 -1
  48. package/build-module/actions/permanently-delete-post.js +4 -3
  49. package/build-module/actions/permanently-delete-post.js.map +1 -1
  50. package/build-module/actions/rename-post.js +1 -2
  51. package/build-module/actions/rename-post.js.map +1 -1
  52. package/build-module/actions/reorder-page.js +1 -2
  53. package/build-module/actions/reorder-page.js.map +1 -1
  54. package/build-module/actions/reset-post.js +3 -4
  55. package/build-module/actions/reset-post.js.map +1 -1
  56. package/build-module/actions/restore-post.js +6 -5
  57. package/build-module/actions/restore-post.js.map +1 -1
  58. package/build-module/actions/trash-post.js +6 -6
  59. package/build-module/actions/trash-post.js.map +1 -1
  60. package/build-module/actions/view-post-revisions.js +1 -1
  61. package/build-module/actions/view-post-revisions.js.map +1 -1
  62. package/build-module/fields/featured-image/featured-image-edit.js +105 -0
  63. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -0
  64. package/build-module/fields/featured-image/featured-image-view.js +33 -0
  65. package/build-module/fields/featured-image/featured-image-view.js.map +1 -0
  66. package/build-module/fields/featured-image/index.js +24 -0
  67. package/build-module/fields/featured-image/index.js.map +1 -0
  68. package/build-module/fields/index.js +3 -0
  69. package/build-module/fields/index.js.map +1 -1
  70. package/build-module/fields/parent/index.js +28 -0
  71. package/build-module/fields/parent/index.js.map +1 -0
  72. package/build-module/fields/parent/parent-edit.js +230 -0
  73. package/build-module/fields/parent/parent-edit.js.map +1 -0
  74. package/build-module/fields/parent/parent-view.js +32 -0
  75. package/build-module/fields/parent/parent-view.js.map +1 -0
  76. package/build-module/fields/parent/utils.js +14 -0
  77. package/build-module/fields/parent/utils.js.map +1 -0
  78. package/build-module/fields/slug/index.js +23 -0
  79. package/build-module/fields/slug/index.js.map +1 -0
  80. package/build-module/fields/slug/slug-edit.js +125 -0
  81. package/build-module/fields/slug/slug-edit.js.map +1 -0
  82. package/build-module/fields/slug/slug-view.js +24 -0
  83. package/build-module/fields/slug/slug-view.js.map +1 -0
  84. package/build-module/mutation/index.js +3 -2
  85. package/build-module/mutation/index.js.map +1 -1
  86. package/build-module/types.js.map +1 -1
  87. package/build-style/styles-rtl.css +134 -0
  88. package/build-style/styles.css +134 -0
  89. package/build-types/actions/delete-post.d.ts.map +1 -1
  90. package/build-types/fields/featured-image/featured-image-edit.d.ts +7 -0
  91. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -0
  92. package/build-types/fields/featured-image/featured-image-view.d.ts +7 -0
  93. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -0
  94. package/build-types/fields/featured-image/index.d.ts +11 -0
  95. package/build-types/fields/featured-image/index.d.ts.map +1 -0
  96. package/build-types/fields/index.d.ts +3 -0
  97. package/build-types/fields/index.d.ts.map +1 -1
  98. package/build-types/fields/parent/index.d.ts +14 -0
  99. package/build-types/fields/parent/index.d.ts.map +1 -0
  100. package/build-types/fields/parent/parent-edit.d.ts +9 -0
  101. package/build-types/fields/parent/parent-edit.d.ts.map +1 -0
  102. package/build-types/fields/parent/parent-view.d.ts +7 -0
  103. package/build-types/fields/parent/parent-view.d.ts.map +1 -0
  104. package/build-types/fields/parent/utils.d.ts +6 -0
  105. package/build-types/fields/parent/utils.d.ts.map +1 -0
  106. package/build-types/fields/slug/index.d.ts +11 -0
  107. package/build-types/fields/slug/index.d.ts.map +1 -0
  108. package/build-types/fields/slug/slug-edit.d.ts +8 -0
  109. package/build-types/fields/slug/slug-edit.d.ts.map +1 -0
  110. package/build-types/fields/slug/slug-view.d.ts +9 -0
  111. package/build-types/fields/slug/slug-view.d.ts.map +1 -0
  112. package/build-types/types.d.ts +2 -0
  113. package/build-types/types.d.ts.map +1 -1
  114. package/package.json +27 -23
  115. package/src/actions/delete-post.tsx +8 -5
  116. package/src/actions/duplicate-post.tsx +2 -2
  117. package/src/actions/view-post-revisions.tsx +1 -1
  118. package/src/fields/featured-image/featured-image-edit.tsx +122 -0
  119. package/src/fields/featured-image/featured-image-view.tsx +38 -0
  120. package/src/fields/featured-image/index.ts +24 -0
  121. package/src/fields/featured-image/style.scss +95 -0
  122. package/src/fields/index.ts +3 -0
  123. package/src/fields/parent/index.ts +27 -0
  124. package/src/fields/parent/parent-edit.tsx +348 -0
  125. package/src/fields/parent/parent-view.tsx +33 -0
  126. package/src/fields/parent/utils.ts +18 -0
  127. package/src/fields/slug/index.ts +23 -0
  128. package/src/fields/slug/slug-edit.tsx +156 -0
  129. package/src/fields/slug/slug-view.tsx +26 -0
  130. package/src/fields/slug/style.scss +22 -0
  131. package/src/mutation/index.ts +3 -3
  132. package/src/styles.scss +1 -0
  133. package/src/types.ts +2 -0
  134. package/tsconfig.json +3 -1
  135. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.0 (2024-10-30)
6
+
7
+ ## 0.2.0 (2024-10-16)
8
+
5
9
  ## 0.1.0 (2024-10-03)
6
10
 
7
11
  Initial release.
package/README.md CHANGED
@@ -38,10 +38,18 @@ Undocumented declaration.
38
38
 
39
39
  Undocumented declaration.
40
40
 
41
+ ### featuredImageField
42
+
43
+ Undocumented declaration.
44
+
41
45
  ### orderField
42
46
 
43
47
  Undocumented declaration.
44
48
 
49
+ ### parentField
50
+
51
+ This field is used to display the post parent.
52
+
45
53
  ### permanentlyDeletePost
46
54
 
47
55
  Undocumented declaration.
@@ -66,6 +74,10 @@ Undocumented declaration.
66
74
 
67
75
  Undocumented declaration.
68
76
 
77
+ ### slugField
78
+
79
+ Undocumented declaration.
80
+
69
81
  ### titleField
70
82
 
71
83
  Undocumented declaration.
@@ -58,8 +58,8 @@ const deletePostAction = {
58
58
  children: items.length > 1 ? (0, _i18n.sprintf)(
59
59
  // translators: %d: number of items to delete.
60
60
  (0, _i18n._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0, _i18n.sprintf)(
61
- // translators: %s: The template or template part's titles
62
- (0, _i18n.__)('Delete "%s"?'), (0, _utils.getItemTitle)(items[0]))
61
+ // translators: %s: The template or template part's title
62
+ (0, _i18n._x)('Delete "%s"?', 'template part'), (0, _utils.getItemTitle)(items[0]))
63
63
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
64
64
  justify: "right",
65
65
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
@@ -77,9 +77,9 @@ const deletePostAction = {
77
77
  success: {
78
78
  messages: {
79
79
  getMessage: item => {
80
- return isResetting ? (0, _i18n.sprintf)( /* translators: The template/part's name. */
81
- (0, _i18n.__)('"%s" reset.'), (0, _htmlEntities.decodeEntities)((0, _utils.getItemTitle)(item))) : (0, _i18n.sprintf)( /* translators: The template/part's name. */
82
- (0, _i18n.__)('"%s" deleted.'), (0, _htmlEntities.decodeEntities)((0, _utils.getItemTitle)(item)));
80
+ return isResetting ? (0, _i18n.sprintf)(/* translators: The template/part's name. */
81
+ (0, _i18n.__)('"%s" reset.'), (0, _htmlEntities.decodeEntities)((0, _utils.getItemTitle)(item))) : (0, _i18n.sprintf)(/* translators: %s: The template/part's name. */
82
+ (0, _i18n._x)('"%s" deleted.', 'template part'), (0, _htmlEntities.decodeEntities)((0, _utils.getItemTitle)(item)));
83
83
  },
84
84
  getBatchMessage: () => {
85
85
  return isResetting ? (0, _i18n.__)('Items reset.') : (0, _i18n.__)('Items deleted.');
@@ -99,12 +99,12 @@ const deletePostAction = {
99
99
  return isResetting ? (0, _i18n.__)('An error occurred while reverting the items.') : (0, _i18n.__)('An error occurred while deleting the items.');
100
100
  }
101
101
  if (errors.size === 1) {
102
- return isResetting ? (0, _i18n.sprintf)( /* translators: %s: an error message */
103
- (0, _i18n.__)('An error occurred while reverting the items: %s'), [...errors][0]) : (0, _i18n.sprintf)( /* translators: %s: an error message */
102
+ return isResetting ? (0, _i18n.sprintf)(/* translators: %s: an error message */
103
+ (0, _i18n.__)('An error occurred while reverting the items: %s'), [...errors][0]) : (0, _i18n.sprintf)(/* translators: %s: an error message */
104
104
  (0, _i18n.__)('An error occurred while deleting the items: %s'), [...errors][0]);
105
105
  }
106
- return isResetting ? (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
107
- (0, _i18n.__)('Some errors occurred while reverting the items: %s'), [...errors].join(',')) : (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
106
+ return isResetting ? (0, _i18n.sprintf)(/* translators: %s: a list of comma separated error messages */
107
+ (0, _i18n.__)('Some errors occurred while reverting the items: %s'), [...errors].join(',')) : (0, _i18n.sprintf)(/* translators: %s: a list of comma separated error messages */
108
108
  (0, _i18n.__)('Some errors occurred while deleting the items: %s'), [...errors].join(','));
109
109
  }
110
110
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_i18n","_element","_components","_patterns","_htmlEntities","_utils","_mutation","_lockUnlock","_jsxRuntime","PATTERN_TYPES","unlock","patternsPrivateApis","deletePostAction","id","label","__","isPrimary","icon","trash","isEligible","post","isTemplateOrTemplatePart","isTemplateRemovable","type","user","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","isResetting","every","item","has_theme_file","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","_n","getItemTitle","__experimentalHStack","justify","Button","variant","onClick","disabled","accessibleWhenDisabled","__next40pxDefaultSize","notice","success","messages","getMessage","decodeEntities","getBatchMessage","error","size","errors","join","deletePostWithNotices","_default","exports","default"],"sources":["@wordpress/fields/src/actions/delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n// @ts-ignore\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport type { Action } from '@wordpress/dataviews';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetItemTitle,\n\tisTemplateOrTemplatePart,\n\tisTemplateRemovable,\n} from './utils';\nimport type { Pattern, Template, TemplatePart } from '../types';\nimport type { NoticeSettings } from '../mutation';\nimport { deletePostWithNotices } from '../mutation';\nimport { unlock } from '../lock-unlock';\n\nconst { PATTERN_TYPES } = unlock( patternsPrivateApis );\n\n// This action is used for templates, patterns and template parts.\n// Every other post type uses the similar `trashPostAction` which\n// moves the post to trash.\nconst deletePostAction: Action< Template | TemplatePart | Pattern > = {\n\tid: 'delete-post',\n\tlabel: __( 'Delete' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( post ) {\n\t\tif ( isTemplateOrTemplatePart( post ) ) {\n\t\t\treturn isTemplateRemovable( post );\n\t\t}\n\t\t// We can only remove user patterns.\n\t\treturn post.type === PATTERN_TYPES.user;\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst isResetting = items.every(\n\t\t\t( item ) => isTemplateOrTemplatePart( item ) && item?.has_theme_file\n\t\t);\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: number of items to delete.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Delete %d item?',\n\t\t\t\t\t\t\t\t\t'Delete %d items?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The template or template part's titles\n\t\t\t\t\t\t\t\t__( 'Delete \"%s\"?' ),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst notice: NoticeSettings<\n\t\t\t\t\t\t\t\tTemplate | TemplatePart | Pattern\n\t\t\t\t\t\t\t> = {\n\t\t\t\t\t\t\t\tsuccess: {\n\t\t\t\t\t\t\t\t\tmessages: {\n\t\t\t\t\t\t\t\t\t\tgetMessage: ( item ) => {\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tgetBatchMessage: () => {\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\t\tmessages: {\n\t\t\t\t\t\t\t\t\t\tgetMessage: ( error ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( error.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn [ ...error ][ 0 ];\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the item.'\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the item.'\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tgetBatchMessage: ( errors ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( errors.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items.'\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif ( errors.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ].join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ].join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tawait deletePostWithNotices( items, notice, {\n\t\t\t\t\t\t\t\tonActionPerformed,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default deletePostAction;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAA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KAAK,EAAE4B,MAAM,EAAE;cAC3C1B;YACD,CAAE,CAAC;YACHE,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBsB,QAAQ,EAAGtB,MAAQ;UACnBuB,sBAAsB;UACtBC,qBAAqB;UAAAd,QAAA,EAEnB,IAAA1B,QAAE,EAAE,QAAS;QAAC,CACT,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAoD,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazD,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_i18n","_element","_components","_patterns","_htmlEntities","_utils","_mutation","_lockUnlock","_jsxRuntime","PATTERN_TYPES","unlock","patternsPrivateApis","deletePostAction","id","label","__","isPrimary","icon","trash","isEligible","post","isTemplateOrTemplatePart","isTemplateRemovable","type","user","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","isResetting","every","item","has_theme_file","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","_n","_x","getItemTitle","__experimentalHStack","justify","Button","variant","onClick","disabled","accessibleWhenDisabled","__next40pxDefaultSize","notice","success","messages","getMessage","decodeEntities","getBatchMessage","error","size","errors","join","deletePostWithNotices","_default","exports","default"],"sources":["@wordpress/fields/src/actions/delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n// @ts-ignore\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport type { Action } from '@wordpress/dataviews';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetItemTitle,\n\tisTemplateOrTemplatePart,\n\tisTemplateRemovable,\n} from './utils';\nimport type { Pattern, Template, TemplatePart } from '../types';\nimport type { NoticeSettings } from '../mutation';\nimport { deletePostWithNotices } from '../mutation';\nimport { unlock } from '../lock-unlock';\n\nconst { PATTERN_TYPES } = unlock( patternsPrivateApis );\n\n// This action is used for templates, patterns and template parts.\n// Every other post type uses the similar `trashPostAction` which\n// moves the post to trash.\nconst deletePostAction: Action< Template | TemplatePart | Pattern > = {\n\tid: 'delete-post',\n\tlabel: __( 'Delete' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( post ) {\n\t\tif ( isTemplateOrTemplatePart( post ) ) {\n\t\t\treturn isTemplateRemovable( post );\n\t\t}\n\t\t// We can only remove user patterns.\n\t\treturn post.type === PATTERN_TYPES.user;\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst isResetting = items.every(\n\t\t\t( item ) => isTemplateOrTemplatePart( item ) && item?.has_theme_file\n\t\t);\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: number of items to delete.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Delete %d item?',\n\t\t\t\t\t\t\t\t\t'Delete %d items?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The template or template part's title\n\t\t\t\t\t\t\t\t_x( 'Delete \"%s\"?', 'template part' ),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst notice: NoticeSettings<\n\t\t\t\t\t\t\t\tTemplate | TemplatePart | Pattern\n\t\t\t\t\t\t\t> = {\n\t\t\t\t\t\t\t\tsuccess: {\n\t\t\t\t\t\t\t\t\tmessages: {\n\t\t\t\t\t\t\t\t\t\tgetMessage: ( item ) => {\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'\"%s\" deleted.',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'template part'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tgetBatchMessage: () => {\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\t\tmessages: {\n\t\t\t\t\t\t\t\t\t\tgetMessage: ( error ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( error.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn [ ...error ][ 0 ];\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the item.'\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the item.'\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tgetBatchMessage: ( errors ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( errors.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items.'\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif ( errors.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\treturn isResetting\n\t\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ].join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ ...errors ].join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tawait deletePostWithNotices( items, notice, {\n\t\t\t\t\t\t\t\tonActionPerformed,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default deletePostAction;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,aAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAOA,IAAAO,SAAA,GAAAP,O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CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBuB,QAAQ,EAAGvB,MAAQ;UACnBwB,sBAAsB;UACtBC,qBAAqB;UAAAf,QAAA,EAEnB,IAAA1B,QAAE,EAAE,QAAS;QAAC,CACT,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAqD,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa1D,gBAAgB","ignoreList":[]}
@@ -42,8 +42,8 @@ const duplicatePost = {
42
42
  }) => {
43
43
  const [item, setItem] = (0, _element.useState)({
44
44
  ...items[0],
45
- title: (0, _i18n.sprintf)( /* translators: %s: Existing template title */
46
- (0, _i18n.__)('%s (Copy)'), (0, _utils.getItemTitle)(items[0]))
45
+ title: (0, _i18n.sprintf)(/* translators: %s: Existing template title */
46
+ (0, _i18n._x)('%s (Copy)', 'template'), (0, _utils.getItemTitle)(items[0]))
47
47
  });
48
48
  const [isCreatingPage, setIsCreatingPage] = (0, _element.useState)(false);
49
49
  const {
@@ -90,7 +90,7 @@ const duplicatePost = {
90
90
  throwOnError: true
91
91
  });
92
92
  createSuccessNotice((0, _i18n.sprintf)(
93
- // translators: %s: Title of the created template e.g: "Category".
93
+ // translators: %s: Title of the created post or template, e.g: "Hello world".
94
94
  (0, _i18n.__)('"%s" successfully created.'), (0, _htmlEntities.decodeEntities)(newItem.title?.rendered || item.title)), {
95
95
  id: 'duplicate-post-action',
96
96
  type: 'snackbar'
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_htmlEntities","_coreData","_i18n","_notices","_element","_dataviews","_components","_fields","_utils","_jsxRuntime","fields","titleField","formDuplicateAction","duplicatePost","id","label","_x","isEligible","status","RenderModal","items","closeModal","onActionPerformed","item","setItem","useState","title","sprintf","__","getItemTitle","isCreatingPage","setIsCreatingPage","saveEntityRecord","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","createPage","event","preventDefault","newItemOject","slug","comment_status","content","raw","excerpt","meta","parent","password","template","format","featured_media","menu_order","ping_status","assignablePropertiesPrefix","assignableProperties","Object","keys","_links","filter","property","startsWith","map","slice","length","forEach","hasOwnProperty","newItem","type","throwOnError","decodeEntities","rendered","error","typedError","errorMessage","message","code","jsx","onSubmit","children","jsxs","__experimentalVStack","spacing","DataForm","data","form","onChange","changes","prev","__experimentalHStack","justify","Button","variant","onClick","__next40pxDefaultSize","isBusy","_default","exports","default"],"sources":["@wordpress/fields/src/actions/duplicate-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport { DataForm } from '@wordpress/dataviews';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { titleField } from '../fields';\nimport type { BasePost, CoreDataError } from '../types';\nimport { getItemTitle } from './utils';\n\nconst fields = [ titleField ];\nconst formDuplicateAction = {\n\tfields: [ 'title' ],\n};\n\nconst duplicatePost: Action< BasePost > = {\n\tid: 'duplicate-post',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ item, setItem ] = useState< BasePost >( {\n\t\t\t...items[ 0 ],\n\t\t\ttitle: sprintf(\n\t\t\t\t/* translators: %s: Existing template title */\n\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t),\n\t\t} );\n\n\t\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function createPage( event: React.FormEvent ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( isCreatingPage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newItemOject = {\n\t\t\t\tstatus: 'draft',\n\t\t\t\ttitle: item.title,\n\t\t\t\tslug: item.title || __( 'No title' ),\n\t\t\t\tcomment_status: item.comment_status,\n\t\t\t\tcontent:\n\t\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t: item.content.raw,\n\t\t\t\texcerpt:\n\t\t\t\t\ttypeof item.excerpt === 'string'\n\t\t\t\t\t\t? item.excerpt\n\t\t\t\t\t\t: item.excerpt?.raw,\n\t\t\t\tmeta: item.meta,\n\t\t\t\tparent: item.parent,\n\t\t\t\tpassword: item.password,\n\t\t\t\ttemplate: item.template,\n\t\t\t\tformat: item.format,\n\t\t\t\tfeatured_media: item.featured_media,\n\t\t\t\tmenu_order: item.menu_order,\n\t\t\t\tping_status: item.ping_status,\n\t\t\t};\n\t\t\tconst assignablePropertiesPrefix = 'wp:action-assign-';\n\t\t\t// Get all the properties that the current user is able to assign normally author, categories, tags,\n\t\t\t// and custom taxonomies.\n\t\t\tconst assignableProperties = Object.keys( item?._links || {} )\n\t\t\t\t.filter( ( property ) =>\n\t\t\t\t\tproperty.startsWith( assignablePropertiesPrefix )\n\t\t\t\t)\n\t\t\t\t.map( ( property ) =>\n\t\t\t\t\tproperty.slice( assignablePropertiesPrefix.length )\n\t\t\t\t);\n\t\t\tassignableProperties.forEach( ( property ) => {\n\t\t\t\tif ( item.hasOwnProperty( property ) ) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnewItemOject[ property ] = item[ property ];\n\t\t\t\t}\n\t\t\t} );\n\t\t\tsetIsCreatingPage( true );\n\t\t\ttry {\n\t\t\t\tconst newItem = await saveEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\titem.type,\n\t\t\t\t\tnewItemOject,\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\tdecodeEntities( newItem.title?.rendered || item.title )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\tonActionPerformed( [ newItem ] );\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: __( 'An error occurred while duplicating the page.' );\n\n\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} finally {\n\t\t\t\tsetIsCreatingPage( false );\n\t\t\t\tcloseModal?.();\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<DataForm\n\t\t\t\t\t\tdata={ item }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ formDuplicateAction }\n\t\t\t\t\t\tonChange={ ( changes ) =>\n\t\t\t\t\t\t\tsetItem( ( prev ) => ( {\n\t\t\t\t\t\t\t\t...prev,\n\t\t\t\t\t\t\t\t...changes,\n\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Duplicate', 'action label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n\nexport default duplicatePost;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAUA,IAAAQ,OAAA,GAAAR,OAAA;AAEA,IAAAS,MAAA,GAAAT,OAAA;AAAuC,IAAAU,WAAA,GAAAV,OAAA;AAtBvC;AACA;AACA;;AAeA;AACA;AACA;;AAKA,MAAMW,MAAM,GAAG,CAAEC,kBAAU,CAAE;AAC7B,MAAMC,mBAAmB,GAAG;EAC3BF,MAAM,EAAE,CAAE,OAAO;AAClB,CAAC;AAED,MAAMG,aAAiC,GAAG;EACzCC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAE,IAAAC,QAAE,EAAE,WAAW,EAAE,cAAe,CAAC;EACxCC,UAAUA,CAAE;IAAEC;EAAO,CAAC,EAAG;IACxB,OAAOA,MAAM,KAAK,OAAO;EAC1B,CAAC;EACDC,WAAW,EAAEA,CAAE;IAA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ACT,IAAAnB,WAAA,CAAAqE,GAAA,EAACxE,WAAA,CAAAsF,MAAM;YACNC,OAAO,EAAC,SAAS;YACjBxB,IAAI,EAAC,QAAQ;YACb2B,MAAM,EAAGlE,cAAgB;YACzB,iBAAgBA,cAAgB;YAChCiE,qBAAqB;YAAAf,QAAA,EAEnB,IAAAhE,QAAE,EAAE,WAAW,EAAE,cAAe;UAAC,CAC5B,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ,CAAC;EAET;AACD,CAAC;AAAC,IAAAiF,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatF,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_htmlEntities","_coreData","_i18n","_notices","_element","_dataviews","_components","_fields","_utils","_jsxRuntime","fields","titleField","formDuplicateAction","duplicatePost","id","label","_x","isEligible","status","RenderModal","items","closeModal","onActionPerformed","item","setItem","useState","title","sprintf","getItemTitle","isCreatingPage","setIsCreatingPage","saveEntityRecord","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","createPage","event","preventDefault","newItemOject","slug","__","comment_status","content","raw","excerpt","meta","parent","password","template","format","featured_media","menu_order","ping_status","assignablePropertiesPrefix","assignableProperties","Object","keys","_links","filter","property","startsWith","map","slice","length","forEach","hasOwnProperty","newItem","type","throwOnError","decodeEntities","rendered","error","typedError","errorMessage","message","code","jsx","onSubmit","children","jsxs","__experimentalVStack","spacing","DataForm","data","form","onChange","changes","prev","__experimentalHStack","justify","Button","variant","onClick","__next40pxDefaultSize","isBusy","_default","exports","default"],"sources":["@wordpress/fields/src/actions/duplicate-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport { DataForm } from '@wordpress/dataviews';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { titleField } from '../fields';\nimport type { BasePost, CoreDataError } from '../types';\nimport { getItemTitle } from './utils';\n\nconst fields = [ titleField ];\nconst formDuplicateAction = {\n\tfields: [ 'title' ],\n};\n\nconst duplicatePost: Action< BasePost > = {\n\tid: 'duplicate-post',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ item, setItem ] = useState< BasePost >( {\n\t\t\t...items[ 0 ],\n\t\t\ttitle: sprintf(\n\t\t\t\t/* translators: %s: Existing template title */\n\t\t\t\t_x( '%s (Copy)', 'template' ),\n\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t),\n\t\t} );\n\n\t\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function createPage( event: React.FormEvent ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( isCreatingPage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newItemOject = {\n\t\t\t\tstatus: 'draft',\n\t\t\t\ttitle: item.title,\n\t\t\t\tslug: item.title || __( 'No title' ),\n\t\t\t\tcomment_status: item.comment_status,\n\t\t\t\tcontent:\n\t\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t: item.content.raw,\n\t\t\t\texcerpt:\n\t\t\t\t\ttypeof item.excerpt === 'string'\n\t\t\t\t\t\t? item.excerpt\n\t\t\t\t\t\t: item.excerpt?.raw,\n\t\t\t\tmeta: item.meta,\n\t\t\t\tparent: item.parent,\n\t\t\t\tpassword: item.password,\n\t\t\t\ttemplate: item.template,\n\t\t\t\tformat: item.format,\n\t\t\t\tfeatured_media: item.featured_media,\n\t\t\t\tmenu_order: item.menu_order,\n\t\t\t\tping_status: item.ping_status,\n\t\t\t};\n\t\t\tconst assignablePropertiesPrefix = 'wp:action-assign-';\n\t\t\t// Get all the properties that the current user is able to assign normally author, categories, tags,\n\t\t\t// and custom taxonomies.\n\t\t\tconst assignableProperties = Object.keys( item?._links || {} )\n\t\t\t\t.filter( ( property ) =>\n\t\t\t\t\tproperty.startsWith( assignablePropertiesPrefix )\n\t\t\t\t)\n\t\t\t\t.map( ( property ) =>\n\t\t\t\t\tproperty.slice( assignablePropertiesPrefix.length )\n\t\t\t\t);\n\t\t\tassignableProperties.forEach( ( property ) => {\n\t\t\t\tif ( item.hasOwnProperty( property ) ) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnewItemOject[ property ] = item[ property ];\n\t\t\t\t}\n\t\t\t} );\n\t\t\tsetIsCreatingPage( true );\n\t\t\ttry {\n\t\t\t\tconst newItem = await saveEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\titem.type,\n\t\t\t\t\tnewItemOject,\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\tdecodeEntities( newItem.title?.rendered || item.title )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\tonActionPerformed( [ newItem ] );\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: __( 'An error occurred while duplicating the page.' );\n\n\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} finally {\n\t\t\t\tsetIsCreatingPage( false );\n\t\t\t\tcloseModal?.();\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<DataForm\n\t\t\t\t\t\tdata={ item }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ formDuplicateAction }\n\t\t\t\t\t\tonChange={ ( changes ) =>\n\t\t\t\t\t\t\tsetItem( ( prev ) => ( {\n\t\t\t\t\t\t\t\t...prev,\n\t\t\t\t\t\t\t\t...changes,\n\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Duplicate', 'action label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n\nexport default duplicatePost;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,I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QAAA,eAC5B,IAAAvE,WAAA,CAAAwE,IAAA,EAAC3E,WAAA,CAAA4E,oBAAM;QAACC,OAAO,EAAG,CAAG;QAAAH,QAAA,gBACpB,IAAAvE,WAAA,CAAAqE,GAAA,EAACzE,UAAA,CAAA+E,QAAQ;UACRC,IAAI,EAAG9D,IAAM;UACbb,MAAM,EAAGA,MAAQ;UACjB4E,IAAI,EAAG1E,mBAAqB;UAC5B2E,QAAQ,EAAKC,OAAO,IACnBhE,OAAO,CAAIiE,IAAI,KAAQ;YACtB,GAAGA,IAAI;YACP,GAAGD;UACJ,CAAC,CAAG;QACJ,CACD,CAAC,eACF,IAAA/E,WAAA,CAAAwE,IAAA,EAAC3E,WAAA,CAAAoF,oBAAM;UAACP,OAAO,EAAG,CAAG;UAACQ,OAAO,EAAC,KAAK;UAAAX,QAAA,gBAClC,IAAAvE,WAAA,CAAAqE,GAAA,EAACxE,WAAA,CAAAsF,MAAM;YACNC,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAGzE,UAAY;YACtB0E,qBAAqB;YAAAf,QAAA,EAEnB,IAAAtC,QAAE,EAAE,QAAS;UAAC,CACT,CAAC,eACT,IAAAjC,WAAA,CAAAqE,GAAA,EAACxE,WAAA,CAAAsF,MAAM;YACNC,OAAO,EAAC,SAAS;YACjBxB,IAAI,EAAC,QAAQ;YACb2B,MAAM,EAAGnE,cAAgB;YACzB,iBAAgBA,cAAgB;YAChCkE,qBAAqB;YAAAf,QAAA,EAEnB,IAAAhE,QAAE,EAAE,WAAW,EAAE,cAAe;UAAC,CAC5B,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ,CAAC;EAET;AACD,CAAC;AAAC,IAAAiF,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatF,aAAa","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_changeCase","require","_clientZip","_blob","_i18n","_icons","_utils","getJsonFromItem","item","JSON","stringify","__file","type","title","getItemTitle","content","raw","syncStatus","wp_pattern_sync_status","exportPattern","id","label","__","icon","download","supportsBulk","isEligible","callback","items","length","downloadBlob","kebabCase","slug","nameCount","filesToZip","map","name","lastModified","Date","input","downloadZip","blob","_default","exports","default"],"sources":["@wordpress/fields/src/actions/export-pattern.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\nimport { downloadZip } from 'client-zip';\n\n/**\n * WordPress dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\nimport { __ } from '@wordpress/i18n';\nimport { download } from '@wordpress/icons';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Pattern } from '../types';\nimport { getItemTitle } from './utils';\n\nfunction getJsonFromItem( item: Pattern ) {\n\treturn JSON.stringify(\n\t\t{\n\t\t\t__file: item.type,\n\t\t\ttitle: getItemTitle( item ),\n\t\t\tcontent:\n\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t? item.content\n\t\t\t\t\t: item.content?.raw,\n\t\t\tsyncStatus: item.wp_pattern_sync_status,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n}\n\nconst exportPattern: Action< Pattern > = {\n\tid: 'export-pattern',\n\tlabel: __( 'Export as JSON' ),\n\ticon: download,\n\tsupportsBulk: true,\n\tisEligible: ( item ) => item.type === 'wp_block',\n\tcallback: async ( items ) => {\n\t\tif ( items.length === 1 ) {\n\t\t\treturn downloadBlob(\n\t\t\t\t`${ kebabCase(\n\t\t\t\t\tgetItemTitle( items[ 0 ] ) || items[ 0 ].slug\n\t\t\t\t) }.json`,\n\t\t\t\tgetJsonFromItem( items[ 0 ] ),\n\t\t\t\t'application/json'\n\t\t\t);\n\t\t}\n\t\tconst nameCount: Record< string, number > = {};\n\t\tconst filesToZip = items.map( ( item ) => {\n\t\t\tconst name = kebabCase( getItemTitle( item ) || item.slug );\n\t\t\tnameCount[ name ] = ( nameCount[ name ] || 0 ) + 1;\n\t\t\treturn {\n\t\t\t\tname: `${\n\t\t\t\t\tname +\n\t\t\t\t\t( nameCount[ name ] > 1\n\t\t\t\t\t\t? '-' + ( nameCount[ name ] - 1 )\n\t\t\t\t\t\t: '' )\n\t\t\t\t}.json`,\n\t\t\t\tlastModified: new Date(),\n\t\t\t\tinput: getJsonFromItem( item ),\n\t\t\t};\n\t\t} );\n\t\treturn downloadBlob(\n\t\t\t__( 'patterns-export' ) + '.zip',\n\t\t\tawait downloadZip( filesToZip ).blob(),\n\t\t\t'application/zip'\n\t\t);\n\t},\n};\n\nexport default exportPattern;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAOA,IAAAK,MAAA,GAAAL,OAAA;AAlBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAIA,SAASM,eAAeA,CAAEC,IAAa,EAAG;EACzC,OAAOC,IAAI,CAACC,SAAS,CACpB;IACCC,MAAM,EAAEH,IAAI,CAACI,IAAI;IACjBC,KAAK,EAAE,IAAAC,mBAAY,EAAEN,IAAK,CAAC;IAC3BO,OAAO,EACN,OAAOP,IAAI,CAACO,OAAO,KAAK,QAAQ,GAC7BP,IAAI,CAACO,OAAO,GACZP,IAAI,CAACO,OAAO,EAAEC,GAAG;IACrBC,UAAU,EAAET,IAAI,CAACU;EAClB,CAAC,EACD,IAAI,EACJ,CACD,CAAC;AACF;AAEA,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAE,IAAAC,QAAE,EAAE,gBAAiB,CAAC;EAC7BC,IAAI,EAAEC,eAAQ;EACdC,YAAY,EAAE,IAAI;EAClBC,UAAU,EAAIlB,IAAI,IAAMA,IAAI,CAACI,IAAI,KAAK,UAAU;EAChDe,QAAQ,EAAE,MAAQC,KAAK,IAAM;IAC5B,IAAKA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAG;MACzB,OAAO,IAAAC,kBAAY,EACjB,GAAG,IAAAC,qBAAS,EACZ,IAAAjB,mBAAY,EAAEc,KAAK,CAAE,CAAC,CAAG,CAAC,IAAIA,KAAK,CAAE,CAAC,CAAE,CAACI,IAC1C,CAAG,OAAM,EACTzB,eAAe,CAAEqB,KAAK,CAAE,CAAC,CAAG,CAAC,EAC7B,kBACD,CAAC;IACF;IACA,MAAMK,SAAmC,GAAG,CAAC,CAAC;IAC9C,MAAMC,UAAU,GAAGN,KAAK,CAACO,GAAG,CAAI3B,IAAI,IAAM;MACzC,MAAM4B,IAAI,GAAG,IAAAL,qBAAS,EAAE,IAAAjB,mBAAY,EAAEN,IAAK,CAAC,IAAIA,IAAI,CAACwB,IAAK,CAAC;MAC3DC,SAAS,CAAEG,IAAI,CAAE,GAAG,CAAEH,SAAS,CAAEG,IAAI,CAAE,IAAI,CAAC,IAAK,CAAC;MAClD,OAAO;QACNA,IAAI,EAAG,GACNA,IAAI,IACFH,SAAS,CAAEG,IAAI,CAAE,GAAG,CAAC,GACpB,GAAG,IAAKH,SAAS,CAAEG,IAAI,CAAE,GAAG,CAAC,CAAE,GAC/B,EAAE,CACL,OAAM;QACPC,YAAY,EAAE,IAAIC,IAAI,CAAC,CAAC;QACxBC,KAAK,EAAEhC,eAAe,CAAEC,IAAK;MAC9B,CAAC;IACF,CAAE,CAAC;IACH,OAAO,IAAAsB,kBAAY,EAClB,IAAAR,QAAE,EAAE,iBAAkB,CAAC,GAAG,MAAM,EAChC,MAAM,IAAAkB,sBAAW,EAAEN,UAAW,CAAC,CAACO,IAAI,CAAC,CAAC,EACtC,iBACD,CAAC;EACF;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazB,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_changeCase","require","_clientZip","_blob","_i18n","_icons","_utils","getJsonFromItem","item","JSON","stringify","__file","type","title","getItemTitle","content","raw","syncStatus","wp_pattern_sync_status","exportPattern","id","label","__","icon","download","supportsBulk","isEligible","callback","items","length","downloadBlob","kebabCase","slug","nameCount","filesToZip","map","name","lastModified","Date","input","downloadZip","blob","_default","exports","default"],"sources":["@wordpress/fields/src/actions/export-pattern.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\nimport { downloadZip } from 'client-zip';\n\n/**\n * WordPress dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\nimport { __ } from '@wordpress/i18n';\nimport { download } from '@wordpress/icons';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Pattern } from '../types';\nimport { getItemTitle } from './utils';\n\nfunction getJsonFromItem( item: Pattern ) {\n\treturn JSON.stringify(\n\t\t{\n\t\t\t__file: item.type,\n\t\t\ttitle: getItemTitle( item ),\n\t\t\tcontent:\n\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t? item.content\n\t\t\t\t\t: item.content?.raw,\n\t\t\tsyncStatus: item.wp_pattern_sync_status,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n}\n\nconst exportPattern: Action< Pattern > = {\n\tid: 'export-pattern',\n\tlabel: __( 'Export as JSON' ),\n\ticon: download,\n\tsupportsBulk: true,\n\tisEligible: ( item ) => item.type === 'wp_block',\n\tcallback: async ( items ) => {\n\t\tif ( items.length === 1 ) {\n\t\t\treturn downloadBlob(\n\t\t\t\t`${ kebabCase(\n\t\t\t\t\tgetItemTitle( items[ 0 ] ) || items[ 0 ].slug\n\t\t\t\t) }.json`,\n\t\t\t\tgetJsonFromItem( items[ 0 ] ),\n\t\t\t\t'application/json'\n\t\t\t);\n\t\t}\n\t\tconst nameCount: Record< string, number > = {};\n\t\tconst filesToZip = items.map( ( item ) => {\n\t\t\tconst name = kebabCase( getItemTitle( item ) || item.slug );\n\t\t\tnameCount[ name ] = ( nameCount[ name ] || 0 ) + 1;\n\t\t\treturn {\n\t\t\t\tname: `${\n\t\t\t\t\tname +\n\t\t\t\t\t( nameCount[ name ] > 1\n\t\t\t\t\t\t? '-' + ( nameCount[ name ] - 1 )\n\t\t\t\t\t\t: '' )\n\t\t\t\t}.json`,\n\t\t\t\tlastModified: new Date(),\n\t\t\t\tinput: getJsonFromItem( item ),\n\t\t\t};\n\t\t} );\n\t\treturn downloadBlob(\n\t\t\t__( 'patterns-export' ) + '.zip',\n\t\t\tawait downloadZip( filesToZip ).blob(),\n\t\t\t'application/zip'\n\t\t);\n\t},\n};\n\nexport default exportPattern;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAOA,IAAAK,MAAA,GAAAL,OAAA;AAlBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAIA,SAASM,eAAeA,CAAEC,IAAa,EAAG;EACzC,OAAOC,IAAI,CAACC,SAAS,CACpB;IACCC,MAAM,EAAEH,IAAI,CAACI,IAAI;IACjBC,KAAK,EAAE,IAAAC,mBAAY,EAAEN,IAAK,CAAC;IAC3BO,OAAO,EACN,OAAOP,IAAI,CAACO,OAAO,KAAK,QAAQ,GAC7BP,IAAI,CAACO,OAAO,GACZP,IAAI,CAACO,OAAO,EAAEC,GAAG;IACrBC,UAAU,EAAET,IAAI,CAACU;EAClB,CAAC,EACD,IAAI,EACJ,CACD,CAAC;AACF;AAEA,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAE,IAAAC,QAAE,EAAE,gBAAiB,CAAC;EAC7BC,IAAI,EAAEC,eAAQ;EACdC,YAAY,EAAE,IAAI;EAClBC,UAAU,EAAIlB,IAAI,IAAMA,IAAI,CAACI,IAAI,KAAK,UAAU;EAChDe,QAAQ,EAAE,MAAQC,KAAK,IAAM;IAC5B,IAAKA,KAAK,CAAC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 const permanentlyDeletePost = {
56
57
  }) => status === 'fulfilled')) {
57
58
  let successMessage;
58
59
  if (promiseResult.length === 1) {
59
- successMessage = (0, _i18n.sprintf)( /* translators: The posts's title. */
60
+ successMessage = (0, _i18n.sprintf)(/* translators: The posts's title. */
60
61
  (0, _i18n.__)('"%s" permanently deleted.'), (0, _utils.getItemTitle)(posts[0]));
61
62
  } else {
62
63
  successMessage = (0, _i18n.__)('The items were permanently deleted.');
@@ -92,10 +93,10 @@ const permanentlyDeletePost = {
92
93
  if (errorMessages.size === 0) {
93
94
  errorMessage = (0, _i18n.__)('An error occurred while permanently deleting the items.');
94
95
  } else if (errorMessages.size === 1) {
95
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
96
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: an error message */
96
97
  (0, _i18n.__)('An error occurred while permanently deleting the items: %s'), [...errorMessages][0]);
97
98
  } else {
98
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
99
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: a list of comma separated error messages */
99
100
  (0, _i18n.__)('Some errors occurred while permanently deleting the items: %s'), [...errorMessages].join(','));
100
101
  }
101
102
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_i18n","_notices","_icons","_utils","permanentlyDeletePost","id","label","__","supportsBulk","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","delete","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","deleteEntityRecord","coreStore","promiseResult","Promise","allSettled","map","post","force","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/fields/src/actions/permanently-delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\nimport { trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst permanentlyDeletePost: Action< PostWithPermissions > = {\n\tid: 'permanently-delete',\n\tlabel: __( 'Permanently delete' ),\n\tsupportsBulk: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { status, permissions } = item;\n\t\treturn status === 'trash' && permissions?.delete;\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = registry.dispatch( coreStore );\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ force: true },\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'The items were permanently deleted.' );\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'permanently-delete-post-action',\n\t\t\t} );\n\t\t\tonActionPerformed?.( posts );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to permanently delete a single post.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'An error occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\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AM,EAAEC,OAAO,EAAG;YACjCC,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAG,IAAAjC,QAAE,EAChB,yDACD,CAAC;QACF,CAAC,MAAM,IAAKqC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAG,IAAAF,aAAO,GACrB;UACA,IAAA/B,QAAE,EACD,4DACD,CAAC,EACD,CAAE,GAAGqC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,GACrB;UACA,IAAA/B,QAAE,EACD,+DACD,CAAC,EACD,CAAE,GAAGqC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalD,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_i18n","_notices","_icons","_utils","permanentlyDeletePost","id","label","__","supportsBulk","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","delete","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","deleteEntityRecord","coreStore","promiseResult","Promise","allSettled","map","post","force","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/fields/src/actions/permanently-delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\nimport { trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst permanentlyDeletePost: Action< PostWithPermissions > = {\n\tid: 'permanently-delete',\n\tlabel: __( 'Permanently delete' ),\n\tsupportsBulk: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { status, permissions } = item;\n\t\treturn status === 'trash' && permissions?.delete;\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = registry.dispatch( coreStore );\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ force: true },\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'The items were permanently deleted.' );\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'permanently-delete-post-action',\n\t\t\t} );\n\t\t\tonActionPerformed?.( posts );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to permanently delete a single post.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'An error occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\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C,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAG,IAAAjC,QAAE,EAChB,yDACD,CAAC;QACF,CAAC,MAAM,IAAKqC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAG,IAAAF,aAAO,EACrB;UACA,IAAA/B,QAAE,EACD,4DACD,CAAC,EACD,CAAE,GAAGqC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,EACrB;UACA,IAAA/B,QAAE,EACD,+DACD,CAAC,EACD,CAAE,GAAGqC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalD,qBAAqB","ignoreList":[]}
@@ -150,8 +150,8 @@ const resetPostAction = {
150
150
  });
151
151
  await saveEditedEntityRecord('postType', template.type, template.id);
152
152
  }
153
- createSuccessNotice(items.length > 1 ? (0, _i18n.sprintf)( /* translators: The number of items. */
154
- (0, _i18n.__)('%s items reset.'), items.length) : (0, _i18n.sprintf)( /* translators: The template/part's name. */
153
+ createSuccessNotice(items.length > 1 ? (0, _i18n.sprintf)(/* translators: The number of items. */
154
+ (0, _i18n.__)('%s items reset.'), items.length) : (0, _i18n.sprintf)(/* translators: The template/part's name. */
155
155
  (0, _i18n.__)('"%s" reset.'), (0, _utils.getItemTitle)(items[0])), {
156
156
  type: 'snackbar',
157
157
  id: 'revert-template-action'
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_blocks","_components","_url","_apiFetch","_interopRequireDefault","_utils","_jsxRuntime","isTemplateRevertable","templateOrTemplatePart","source","TEMPLATE_ORIGINS","custom","Boolean","plugin","has_theme_file","revertTemplate","template","allowUndo","noticeId","dispatch","noticesStore","removeNotice","createErrorNotice","__","type","templateEntityConfig","select","coreStore","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","id","context","origin","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","editEntityRecord","content","undoIgnore","parse","raw","undoRevert","createSuccessNotice","actions","label","onClick","error","errorMessage","message","code","resetPostAction","isEligible","item","isTemplateOrTemplatePart","icon","backup","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","saveEditedEntityRecord","useDispatch","onConfirm","length","sprintf","getItemTitle","fallbackErrorMessage","TEMPLATE_POST_TYPE","typedError","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","disabled","accessibleWhenDisabled","_default","exports","default"],"sources":["@wordpress/fields/src/actions/reset-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { dispatch, select, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetItemTitle,\n\tisTemplateOrTemplatePart,\n\tTEMPLATE_ORIGINS,\n\tTEMPLATE_POST_TYPE,\n} from './utils';\nimport type { CoreDataError, Template, TemplatePart } from '../types';\n\nconst isTemplateRevertable = (\n\ttemplateOrTemplatePart: Template | TemplatePart\n) => {\n\tif ( ! templateOrTemplatePart ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttemplateOrTemplatePart.source === TEMPLATE_ORIGINS.custom &&\n\t\t( Boolean( templateOrTemplatePart?.plugin ) ||\n\t\t\ttemplateOrTemplatePart?.has_theme_file )\n\t);\n};\n\n/**\n * Copied - pasted from https://github.com/WordPress/gutenberg/blob/bf1462ad37d4637ebbf63270b9c244b23c69e2a8/packages/editor/src/store/private-actions.js#L233-L365\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nconst revertTemplate = async (\n\ttemplate: TemplatePart | Template,\n\t{ allowUndo = true } = {}\n) => {\n\tconst noticeId = 'edit-site-template-reverted';\n\tdispatch( noticesStore ).removeNotice( noticeId );\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\n\t\tif ( ! templateEntityConfig ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: template.origin }\n\t\t);\n\n\t\tconst fileTemplate = ( await apiFetch( {\n\t\t\tpath: fileTemplatePath,\n\t\t} ) ) as any;\n\t\tif ( ! fileTemplate ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = select( coreStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t) as any;\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tdispatch( noticesStore ).createSuccessNotice(\n\t\t\t\t__( 'Template reset.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: noticeId,\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} catch ( error: any ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\n\t\tdispatch( noticesStore ).createErrorNotice( errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\nconst resetPostAction: Action< Template | TemplatePart > = {\n\tid: 'reset-post',\n\tlabel: __( 'Reset' ),\n\tisEligible: ( item ) => {\n\t\treturn (\n\t\t\tisTemplateOrTemplatePart( item ) &&\n\t\t\titem?.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t( Boolean( item.type === 'wp_template' && item?.plugin ) ||\n\t\t\t\titem?.has_theme_file )\n\t\t);\n\t},\n\ticon: backup,\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\t\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst onConfirm = async () => {\n\t\t\ttry {\n\t\t\t\tfor ( const template of items ) {\n\t\t\t\t\tawait revertTemplate( template, {\n\t\t\t\t\t\tallowUndo: false,\n\t\t\t\t\t} );\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\ttemplate.id\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\titems.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t__( '%s items reset.' ),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t ),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'revert-template-action',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tlet fallbackErrorMessage;\n\t\t\t\tif ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {\n\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\titems.length === 1\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the templates.'\n\t\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\titems.length === 1\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template parts.'\n\t\t\t\t\t\t\t );\n\t\t\t\t}\n\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t};\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ __( 'Reset to default and clear all customizations?' ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tawait onConfirm();\n\t\t\t\t\t\t\tonActionPerformed?.( items );\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default resetPostAction;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAOA,IAAAQ,IAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAC,sBAAA,CAAAV,OAAA;AAKA,IAAAW,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AK,CAAC;YACjB,MAAMI,SAAS,CAAC,CAAC;YACjBN,iBAAiB,GAAIF,KAAM,CAAC;YAC5BI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBuB,QAAQ,EAAGvB,MAAQ;UACnBwB,sBAAsB;UAAAT,QAAA,EAEpB,IAAA9D,QAAE,EAAE,OAAQ;QAAC,CACR,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAwE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavC,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_blocks","_components","_url","_apiFetch","_interopRequireDefault","_utils","_jsxRuntime","isTemplateRevertable","templateOrTemplatePart","source","TEMPLATE_ORIGINS","custom","Boolean","plugin","has_theme_file","revertTemplate","template","allowUndo","noticeId","dispatch","noticesStore","removeNotice","createErrorNotice","__","type","templateEntityConfig","select","coreStore","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","id","context","origin","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","editEntityRecord","content","undoIgnore","parse","raw","undoRevert","createSuccessNotice","actions","label","onClick","error","errorMessage","message","code","resetPostAction","isEligible","item","isTemplateOrTemplatePart","icon","backup","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","saveEditedEntityRecord","useDispatch","onConfirm","length","sprintf","getItemTitle","fallbackErrorMessage","TEMPLATE_POST_TYPE","typedError","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","disabled","accessibleWhenDisabled","_default","exports","default"],"sources":["@wordpress/fields/src/actions/reset-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { dispatch, select, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetItemTitle,\n\tisTemplateOrTemplatePart,\n\tTEMPLATE_ORIGINS,\n\tTEMPLATE_POST_TYPE,\n} from './utils';\nimport type { CoreDataError, Template, TemplatePart } from '../types';\n\nconst isTemplateRevertable = (\n\ttemplateOrTemplatePart: Template | TemplatePart\n) => {\n\tif ( ! templateOrTemplatePart ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttemplateOrTemplatePart.source === TEMPLATE_ORIGINS.custom &&\n\t\t( Boolean( templateOrTemplatePart?.plugin ) ||\n\t\t\ttemplateOrTemplatePart?.has_theme_file )\n\t);\n};\n\n/**\n * Copied - pasted from https://github.com/WordPress/gutenberg/blob/bf1462ad37d4637ebbf63270b9c244b23c69e2a8/packages/editor/src/store/private-actions.js#L233-L365\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nconst revertTemplate = async (\n\ttemplate: TemplatePart | Template,\n\t{ allowUndo = true } = {}\n) => {\n\tconst noticeId = 'edit-site-template-reverted';\n\tdispatch( noticesStore ).removeNotice( noticeId );\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\n\t\tif ( ! templateEntityConfig ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: template.origin }\n\t\t);\n\n\t\tconst fileTemplate = ( await apiFetch( {\n\t\t\tpath: fileTemplatePath,\n\t\t} ) ) as any;\n\t\tif ( ! fileTemplate ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = select( coreStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t) as any;\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tdispatch( noticesStore ).createSuccessNotice(\n\t\t\t\t__( 'Template reset.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: noticeId,\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} catch ( error: any ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\n\t\tdispatch( noticesStore ).createErrorNotice( errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\nconst resetPostAction: Action< Template | TemplatePart > = {\n\tid: 'reset-post',\n\tlabel: __( 'Reset' ),\n\tisEligible: ( item ) => {\n\t\treturn (\n\t\t\tisTemplateOrTemplatePart( item ) &&\n\t\t\titem?.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t( Boolean( item.type === 'wp_template' && item?.plugin ) ||\n\t\t\t\titem?.has_theme_file )\n\t\t);\n\t},\n\ticon: backup,\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\t\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst onConfirm = async () => {\n\t\t\ttry {\n\t\t\t\tfor ( const template of items ) {\n\t\t\t\t\tawait revertTemplate( template, {\n\t\t\t\t\t\tallowUndo: false,\n\t\t\t\t\t} );\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\ttemplate.id\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\titems.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t__( '%s items reset.' ),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t ),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'revert-template-action',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tlet fallbackErrorMessage;\n\t\t\t\tif ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {\n\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\titems.length === 1\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the templates.'\n\t\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\titems.length === 1\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template parts.'\n\t\t\t\t\t\t\t );\n\t\t\t\t}\n\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t};\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ __( 'Reset to default and clear all customizations?' ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tawait onConfirm();\n\t\t\t\t\t\t\tonActionPerformed?.( items );\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t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AAA,CAAA4E,IAAA,EAACjF,WAAA,CAAAuF,oBAAM;QAACC,OAAO,EAAC,OAAO;QAAAJ,QAAA,gBACtB,IAAA/E,WAAA,CAAAgF,GAAA,EAACrF,WAAA,CAAAyF,MAAM;UACNC,qBAAqB;UACrBC,OAAO,EAAC,UAAU;UAClBvC,OAAO,EAAGe,UAAY;UACtByB,QAAQ,EAAGvB,MAAQ;UACnBwB,sBAAsB;UAAAT,QAAA,EAEpB,IAAA9D,QAAE,EAAE,QAAS;QAAC,CACT,CAAC,eACT,IAAAjB,WAAA,CAAAgF,GAAA,EAACrF,WAAA,CAAAyF,MAAM;UACNC,qBAAqB;UACrBC,OAAO,EAAC,SAAS;UACjBvC,OAAO,EAAG,MAAAA,CAAA,KAAY;YACrBkB,SAAS,CAAE,IAAK,CAAC;YACjB,MAAMI,SAAS,CAAC,CAAC;YACjBN,iBAAiB,GAAIF,KAAM,CAAC;YAC5BI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBuB,QAAQ,EAAGvB,MAAQ;UACnBwB,sBAAsB;UAAAT,QAAA,EAEpB,IAAA9D,QAAE,EAAE,OAAQ;QAAC,CACR,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAwE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavC,eAAe","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -53,13 +54,13 @@ const restorePost = {
53
54
  }) => status === 'fulfilled')) {
54
55
  let successMessage;
55
56
  if (posts.length === 1) {
56
- successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
57
+ successMessage = (0, _i18n.sprintf)(/* translators: The number of posts. */
57
58
  (0, _i18n.__)('"%s" has been restored.'), (0, _utils.getItemTitle)(posts[0]));
58
59
  } else if (posts[0].type === 'page') {
59
- successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
60
+ successMessage = (0, _i18n.sprintf)(/* translators: The number of posts. */
60
61
  (0, _i18n.__)('%d pages have been restored.'), posts.length);
61
62
  } else {
62
- successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
63
+ successMessage = (0, _i18n.sprintf)(/* translators: The number of posts. */
63
64
  (0, _i18n.__)('%d posts have been restored.'), posts.length);
64
65
  }
65
66
  createSuccessNotice(successMessage, {
@@ -95,10 +96,10 @@ const restorePost = {
95
96
  if (errorMessages.size === 0) {
96
97
  errorMessage = (0, _i18n.__)('An error occurred while restoring the posts.');
97
98
  } else if (errorMessages.size === 1) {
98
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
99
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: an error message */
99
100
  (0, _i18n.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
100
101
  } else {
101
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
102
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: a list of comma separated error messages */
102
103
  (0, _i18n.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
103
104
  }
104
105
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_coreData","_i18n","_notices","_utils","restorePost","id","label","__","isPrimary","icon","backup","supportsBulk","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","editEntityRecord","saveEditedEntityRecord","coreStore","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/fields/src/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default restorePost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMK,WAA0C,GAAG;EAClDC,EAAE,EAAE,SAAS;EACbC,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;EACtBC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,aAAM;EACZC,YAAY,EAAE,IAAI;EAClBC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OACC,CAAE,IAAAC,+BAAwB,EAAED,IAAK,CAAC,IAClCA,IAAI,CAACE,IAAI,KAAK,UAAU,IACxBF,IAAI,CAACG,MAAM,KAAK,OAAO,IACvBH,IAAI,CAACI,WAAW,EAAEC,MAAM;EAE1B,CAAC;EACD,MAAMC,QAAQA,CAAEC,KAAK,EAAE;IAAEC,QAAQ;IAAEC;EAAkB,CAAC,EAAG;IACxD,MAAM;MAAEC,mBAAmB;MAAEC;IAAkB,CAAC,GAC/CH,QAAQ,CAACI,QAAQ,CAAEC,cAAa,CAAC;IAClC,MA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D,CAAC,EACD,CAAE,GAAGsC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanD,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_coreData","_i18n","_notices","_utils","restorePost","id","label","__","isPrimary","icon","backup","supportsBulk","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","editEntityRecord","saveEditedEntityRecord","coreStore","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/fields/src/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default restorePost;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD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C,CAAC;QAC/B,MAAMC,cAAc,GAAGb,aAAa,CAACc,MAAM,CAC1C,CAAE;UAAEhC;QAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;QACD,KAAM,MAAMiC,aAAa,IAAIF,cAAc,EAAG;UAC7C,MAAML,UAAU,GAAGO,aAElB;UACD,IAAKP,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;YACjCC,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAG,IAAAlC,QAAE,EAChB,8CACD,CAAC;QACF,CAAC,MAAM,IAAKsC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAG,IAAAF,aAAO,EACrB;UACA,IAAAhC,QAAE,EAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGsC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,EACrB;UACA,IAAAhC,QAAE,EACD,oDACD,CAAC,EACD,CAAE,GAAGsC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanD,WAAW","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -78,10 +79,10 @@ const trashPost = {
78
79
  }) => status === 'fulfilled')) {
79
80
  let successMessage;
80
81
  if (promiseResult.length === 1) {
81
- successMessage = (0, _i18n.sprintf)( /* translators: The item's title. */
82
+ successMessage = (0, _i18n.sprintf)(/* translators: The item's title. */
82
83
  (0, _i18n.__)('"%s" moved to the trash.'), (0, _utils.getItemTitle)(items[0]));
83
84
  } else {
84
- successMessage = (0, _i18n.sprintf)( /* translators: The number of items. */
85
+ successMessage = (0, _i18n.sprintf)(/* translators: The number of items. */
85
86
  (0, _i18n._n)('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
86
87
  }
87
88
  createSuccessNotice(successMessage, {
@@ -114,10 +115,10 @@ const trashPost = {
114
115
  if (errorMessages.size === 0) {
115
116
  errorMessage = (0, _i18n.__)('An error occurred while moving the items to the trash.');
116
117
  } else if (errorMessages.size === 1) {
117
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
118
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: an error message */
118
119
  (0, _i18n.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
119
120
  } else {
120
- errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
121
+ errorMessage = (0, _i18n.sprintf)(/* translators: %s: a list of comma separated error messages */
121
122
  (0, _i18n.__)('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
122
123
  }
123
124
  }