@wordpress/editor 13.30.0 → 13.32.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 (219) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +857 -0
  3. package/build/bindings/index.js +3 -1
  4. package/build/bindings/index.js.map +1 -1
  5. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +107 -0
  6. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  7. package/build/components/commands/index.js +1 -1
  8. package/build/components/commands/index.js.map +1 -1
  9. package/build/components/deprecated.js +158 -0
  10. package/build/components/deprecated.js.map +1 -1
  11. package/build/components/document-bar/index.js +7 -10
  12. package/build/components/document-bar/index.js.map +1 -1
  13. package/build/components/document-outline/index.js +1 -1
  14. package/build/components/document-outline/index.js.map +1 -1
  15. package/build/components/editor-canvas/edit-template-blocks-notification.js +2 -39
  16. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  17. package/build/components/editor-canvas/index.js +3 -0
  18. package/build/components/editor-canvas/index.js.map +1 -1
  19. package/build/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  20. package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  21. package/build/components/entities-saved-states/index.js +28 -88
  22. package/build/components/entities-saved-states/index.js.map +1 -1
  23. package/build/components/error-boundary/index.native.js +133 -0
  24. package/build/components/error-boundary/index.native.js.map +1 -0
  25. package/build/components/index.js +33 -8
  26. package/build/components/index.js.map +1 -1
  27. package/build/components/index.native.js +9 -1
  28. package/build/components/index.native.js.map +1 -1
  29. package/build/components/inserter-sidebar/index.js +5 -1
  30. package/build/components/inserter-sidebar/index.js.map +1 -1
  31. package/build/components/list-view-sidebar/index.js +2 -1
  32. package/build/components/list-view-sidebar/index.js.map +1 -1
  33. package/build/components/pattern-overrides-panel/index.js +30 -0
  34. package/build/components/pattern-overrides-panel/index.js.map +1 -0
  35. package/build/components/plugin-document-setting-panel/index.js +123 -0
  36. package/build/components/plugin-document-setting-panel/index.js.map +1 -0
  37. package/build/components/plugin-post-publish-panel/index.js +68 -0
  38. package/build/components/plugin-post-publish-panel/index.js.map +1 -0
  39. package/build/components/plugin-pre-publish-panel/index.js +71 -0
  40. package/build/components/plugin-pre-publish-panel/index.js.map +1 -0
  41. package/build/components/post-actions/actions.js +455 -0
  42. package/build/components/post-actions/actions.js.map +1 -0
  43. package/build/components/post-card-panel/index.js +93 -0
  44. package/build/components/post-card-panel/index.js.map +1 -0
  45. package/build/components/post-featured-image/index.js +3 -8
  46. package/build/components/post-featured-image/index.js.map +1 -1
  47. package/build/components/post-featured-image/panel.js +7 -3
  48. package/build/components/post-featured-image/panel.js.map +1 -1
  49. package/build/components/post-sync-status/index.js +0 -72
  50. package/build/components/post-sync-status/index.js.map +1 -1
  51. package/build/components/post-taxonomies/flat-term-selector.js +7 -3
  52. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  53. package/build/components/post-title/index.native.js +1 -1
  54. package/build/components/post-title/index.native.js.map +1 -1
  55. package/build/components/provider/disable-non-page-content-blocks.js +36 -20
  56. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  57. package/build/components/provider/index.js +1 -1
  58. package/build/components/provider/index.js.map +1 -1
  59. package/build/components/provider/use-block-editor-settings.js +8 -9
  60. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  61. package/build/components/provider/use-hide-blocks-from-inserter.js +4 -3
  62. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  63. package/build/components/template-areas/index.js +70 -0
  64. package/build/components/template-areas/index.js.map +1 -0
  65. package/build/hooks/use-select-nearest-editable-block.js +87 -0
  66. package/build/hooks/use-select-nearest-editable-block.js.map +1 -0
  67. package/build/private-apis.js +6 -2
  68. package/build/private-apis.js.map +1 -1
  69. package/build/store/actions.js +46 -6
  70. package/build/store/actions.js.map +1 -1
  71. package/build/store/constants.js +3 -1
  72. package/build/store/constants.js.map +1 -1
  73. package/build/store/private-actions.js +80 -1
  74. package/build/store/private-actions.js.map +1 -1
  75. package/build/store/private-selectors.js +56 -3
  76. package/build/store/private-selectors.js.map +1 -1
  77. package/build/store/reducer.js +14 -1
  78. package/build/store/reducer.js.map +1 -1
  79. package/build/store/selectors.js +21 -11
  80. package/build/store/selectors.js.map +1 -1
  81. package/build/store/utils/get-filtered-template-parts.js +71 -0
  82. package/build/store/utils/get-filtered-template-parts.js.map +1 -0
  83. package/build-module/bindings/index.js +3 -1
  84. package/build-module/bindings/index.js.map +1 -1
  85. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +100 -0
  86. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  87. package/build-module/components/commands/index.js +1 -1
  88. package/build-module/components/commands/index.js.map +1 -1
  89. package/build-module/components/deprecated.js +159 -0
  90. package/build-module/components/deprecated.js.map +1 -1
  91. package/build-module/components/document-bar/index.js +8 -11
  92. package/build-module/components/document-bar/index.js.map +1 -1
  93. package/build-module/components/document-outline/index.js +1 -1
  94. package/build-module/components/document-outline/index.js.map +1 -1
  95. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +4 -41
  96. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  97. package/build-module/components/editor-canvas/index.js +3 -0
  98. package/build-module/components/editor-canvas/index.js.map +1 -1
  99. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  100. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  101. package/build-module/components/entities-saved-states/index.js +29 -89
  102. package/build-module/components/entities-saved-states/index.js.map +1 -1
  103. package/build-module/components/error-boundary/index.native.js +125 -0
  104. package/build-module/components/error-boundary/index.native.js.map +1 -0
  105. package/build-module/components/index.js +5 -1
  106. package/build-module/components/index.js.map +1 -1
  107. package/build-module/components/index.native.js +1 -0
  108. package/build-module/components/index.native.js.map +1 -1
  109. package/build-module/components/inserter-sidebar/index.js +5 -1
  110. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  111. package/build-module/components/list-view-sidebar/index.js +2 -1
  112. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  113. package/build-module/components/pattern-overrides-panel/index.js +23 -0
  114. package/build-module/components/pattern-overrides-panel/index.js.map +1 -0
  115. package/build-module/components/plugin-document-setting-panel/index.js +115 -0
  116. package/build-module/components/plugin-document-setting-panel/index.js.map +1 -0
  117. package/build-module/components/plugin-post-publish-panel/index.js +61 -0
  118. package/build-module/components/plugin-post-publish-panel/index.js.map +1 -0
  119. package/build-module/components/plugin-pre-publish-panel/index.js +64 -0
  120. package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -0
  121. package/build-module/components/post-actions/actions.js +444 -0
  122. package/build-module/components/post-actions/actions.js.map +1 -0
  123. package/build-module/components/post-card-panel/index.js +85 -0
  124. package/build-module/components/post-card-panel/index.js.map +1 -0
  125. package/build-module/components/post-featured-image/index.js +4 -9
  126. package/build-module/components/post-featured-image/index.js.map +1 -1
  127. package/build-module/components/post-featured-image/panel.js +6 -2
  128. package/build-module/components/post-featured-image/panel.js.map +1 -1
  129. package/build-module/components/post-sync-status/index.js +2 -73
  130. package/build-module/components/post-sync-status/index.js.map +1 -1
  131. package/build-module/components/post-taxonomies/flat-term-selector.js +7 -3
  132. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  133. package/build-module/components/post-title/index.native.js +1 -1
  134. package/build-module/components/post-title/index.native.js.map +1 -1
  135. package/build-module/components/provider/disable-non-page-content-blocks.js +36 -20
  136. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  137. package/build-module/components/provider/index.js +1 -1
  138. package/build-module/components/provider/index.js.map +1 -1
  139. package/build-module/components/provider/use-block-editor-settings.js +9 -10
  140. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  141. package/build-module/components/provider/use-hide-blocks-from-inserter.js +4 -3
  142. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  143. package/build-module/components/template-areas/index.js +63 -0
  144. package/build-module/components/template-areas/index.js.map +1 -0
  145. package/build-module/hooks/use-select-nearest-editable-block.js +80 -0
  146. package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -0
  147. package/build-module/private-apis.js +6 -2
  148. package/build-module/private-apis.js.map +1 -1
  149. package/build-module/store/actions.js +37 -3
  150. package/build-module/store/actions.js.map +1 -1
  151. package/build-module/store/constants.js +2 -0
  152. package/build-module/store/constants.js.map +1 -1
  153. package/build-module/store/private-actions.js +78 -0
  154. package/build-module/store/private-actions.js.map +1 -1
  155. package/build-module/store/private-selectors.js +54 -3
  156. package/build-module/store/private-selectors.js.map +1 -1
  157. package/build-module/store/reducer.js +13 -1
  158. package/build-module/store/reducer.js.map +1 -1
  159. package/build-module/store/selectors.js +19 -10
  160. package/build-module/store/selectors.js.map +1 -1
  161. package/build-module/store/utils/get-filtered-template-parts.js +64 -0
  162. package/build-module/store/utils/get-filtered-template-parts.js.map +1 -0
  163. package/build-style/style-rtl.css +76 -33
  164. package/build-style/style.css +76 -33
  165. package/package.json +35 -33
  166. package/src/bindings/index.js +4 -1
  167. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +108 -0
  168. package/src/components/commands/index.js +1 -1
  169. package/src/components/deprecated.js +157 -0
  170. package/src/components/document-bar/index.js +12 -17
  171. package/src/components/document-bar/style.scss +9 -12
  172. package/src/components/document-outline/index.js +2 -1
  173. package/src/components/document-tools/style.scss +4 -11
  174. package/src/components/editor-canvas/edit-template-blocks-notification.js +6 -56
  175. package/src/components/editor-canvas/index.js +4 -0
  176. package/src/components/entities-saved-states/hooks/use-is-dirty.js +18 -22
  177. package/src/components/entities-saved-states/index.js +45 -121
  178. package/src/components/entities-saved-states/test/use-is-dirty.js +3 -0
  179. package/src/components/error-boundary/index.native.js +192 -0
  180. package/src/components/error-boundary/style.native.scss +116 -0
  181. package/src/components/index.js +5 -4
  182. package/src/components/index.native.js +1 -0
  183. package/src/components/inserter-sidebar/index.js +7 -1
  184. package/src/components/list-view-sidebar/index.js +1 -0
  185. package/src/components/list-view-sidebar/style.scss +1 -1
  186. package/src/components/pattern-overrides-panel/index.js +26 -0
  187. package/src/components/plugin-document-setting-panel/index.js +121 -0
  188. package/src/components/plugin-post-publish-panel/index.js +64 -0
  189. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +39 -0
  190. package/src/components/plugin-post-publish-panel/test/index.js +33 -0
  191. package/src/components/plugin-pre-publish-panel/index.js +67 -0
  192. package/src/components/plugin-pre-publish-panel/test/index.js +33 -0
  193. package/src/components/post-actions/actions.js +582 -0
  194. package/src/components/post-card-panel/index.js +108 -0
  195. package/src/components/post-card-panel/style.scss +32 -0
  196. package/src/components/post-featured-image/index.js +6 -15
  197. package/src/components/post-featured-image/panel.js +9 -3
  198. package/src/components/post-featured-image/style.scss +9 -13
  199. package/src/components/post-sync-status/index.js +1 -94
  200. package/src/components/post-taxonomies/flat-term-selector.js +13 -8
  201. package/src/components/post-title/index.native.js +1 -1
  202. package/src/components/provider/disable-non-page-content-blocks.js +40 -20
  203. package/src/components/provider/index.js +1 -1
  204. package/src/components/provider/test/disable-non-page-content-blocks.js +35 -14
  205. package/src/components/provider/use-block-editor-settings.js +11 -11
  206. package/src/components/provider/use-hide-blocks-from-inserter.js +5 -3
  207. package/src/components/template-areas/index.js +85 -0
  208. package/src/components/template-areas/style.scss +23 -0
  209. package/src/hooks/use-select-nearest-editable-block.js +95 -0
  210. package/src/private-apis.js +6 -2
  211. package/src/store/actions.js +37 -3
  212. package/src/store/constants.js +2 -0
  213. package/src/store/private-actions.js +111 -0
  214. package/src/store/private-selectors.js +105 -17
  215. package/src/store/reducer.js +13 -0
  216. package/src/store/selectors.js +50 -40
  217. package/src/store/utils/get-filtered-template-parts.js +69 -0
  218. package/src/store/utils/test/get-filtered-template-parts.js +189 -0
  219. package/src/style.scss +2 -0
@@ -0,0 +1,455 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.trashPostAction = exports.renamePostAction = exports.postRevisionsAction = exports.editPostAction = void 0;
7
+ exports.usePermanentlyDeletePostAction = usePermanentlyDeletePostAction;
8
+ exports.usePostActions = usePostActions;
9
+ exports.useRestorePostAction = useRestorePostAction;
10
+ exports.viewPostAction = void 0;
11
+ var _react = require("react");
12
+ var _icons = require("@wordpress/icons");
13
+ var _url = require("@wordpress/url");
14
+ var _data = require("@wordpress/data");
15
+ var _htmlEntities = require("@wordpress/html-entities");
16
+ var _coreData = require("@wordpress/core-data");
17
+ var _i18n = require("@wordpress/i18n");
18
+ var _notices = require("@wordpress/notices");
19
+ var _element = require("@wordpress/element");
20
+ var _components = require("@wordpress/components");
21
+ /**
22
+ * WordPress dependencies
23
+ */
24
+
25
+ function getItemTitle(item) {
26
+ if (typeof item.title === 'string') {
27
+ return (0, _htmlEntities.decodeEntities)(item.title);
28
+ }
29
+ return (0, _htmlEntities.decodeEntities)(item.title?.rendered || '');
30
+ }
31
+ const trashPostAction = exports.trashPostAction = {
32
+ id: 'move-to-trash',
33
+ label: (0, _i18n.__)('Move to Trash'),
34
+ isPrimary: true,
35
+ icon: _icons.trash,
36
+ isEligible({
37
+ status
38
+ }) {
39
+ return status !== 'trash';
40
+ },
41
+ supportsBulk: true,
42
+ hideModalHeader: true,
43
+ RenderModal: ({
44
+ items: posts,
45
+ closeModal,
46
+ onActionPerformed
47
+ }) => {
48
+ const {
49
+ createSuccessNotice,
50
+ createErrorNotice
51
+ } = (0, _data.useDispatch)(_notices.store);
52
+ const {
53
+ deleteEntityRecord
54
+ } = (0, _data.useDispatch)(_coreData.store);
55
+ return (0, _react.createElement)(_components.__experimentalVStack, {
56
+ spacing: "5"
57
+ }, (0, _react.createElement)(_components.__experimentalText, null, posts.length === 1 ? (0, _i18n.sprintf)(
58
+ // translators: %s: The page's title.
59
+ (0, _i18n.__)('Are you sure you want to delete "%s"?'), getItemTitle(posts[0])) : (0, _i18n.sprintf)(
60
+ // translators: %d: The number of pages (2 or more).
61
+ (0, _i18n._n)('Are you sure you want to delete %d page?', 'Are you sure you want to delete %d pages?', posts.length), posts.length)), (0, _react.createElement)(_components.__experimentalHStack, {
62
+ justify: "right"
63
+ }, (0, _react.createElement)(_components.Button, {
64
+ variant: "tertiary",
65
+ onClick: closeModal
66
+ }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
67
+ variant: "primary",
68
+ onClick: async () => {
69
+ const promiseResult = await Promise.allSettled(posts.map(post => {
70
+ return deleteEntityRecord('postType', post.type, post.id, {}, {
71
+ throwOnError: true
72
+ });
73
+ }));
74
+ // If all the promises were fulfilled with success.
75
+ if (promiseResult.every(({
76
+ status
77
+ }) => status === 'fulfilled')) {
78
+ let successMessage;
79
+ if (promiseResult.length === 1) {
80
+ successMessage = (0, _i18n.sprintf)( /* translators: The posts's title. */
81
+ (0, _i18n.__)('"%s" moved to the Trash.'), getItemTitle(posts[0]));
82
+ } else {
83
+ successMessage = (0, _i18n.__)('Pages moved to the Trash.');
84
+ }
85
+ createSuccessNotice(successMessage, {
86
+ type: 'snackbar',
87
+ id: 'edit-site-page-trashed'
88
+ });
89
+ } else {
90
+ // If there was at lease one failure.
91
+ let errorMessage;
92
+ // If we were trying to move a single post to the trash.
93
+ if (promiseResult.length === 1) {
94
+ if (promiseResult[0].reason?.message) {
95
+ errorMessage = promiseResult[0].reason.message;
96
+ } else {
97
+ errorMessage = (0, _i18n.__)('An error occurred while moving the post to the trash.');
98
+ }
99
+ // If we were trying to move multiple posts to the trash
100
+ } else {
101
+ const errorMessages = new Set();
102
+ const failedPromises = promiseResult.filter(({
103
+ status
104
+ }) => status === 'rejected');
105
+ for (const failedPromise of failedPromises) {
106
+ if (failedPromise.reason?.message) {
107
+ errorMessages.add(failedPromise.reason.message);
108
+ }
109
+ }
110
+ if (errorMessages.size === 0) {
111
+ errorMessage = (0, _i18n.__)('An error occurred while moving the posts to the trash.');
112
+ } else if (errorMessages.size === 1) {
113
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
114
+ (0, _i18n.__)('An error occurred while moving the posts to the trash: %s'), [...errorMessages][0]);
115
+ } else {
116
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
117
+ (0, _i18n.__)('Some errors occurred while moving the pages to the trash: %s'), [...errorMessages].join(','));
118
+ }
119
+ createErrorNotice(errorMessage, {
120
+ type: 'snackbar'
121
+ });
122
+ }
123
+ }
124
+ if (onActionPerformed) {
125
+ onActionPerformed(posts);
126
+ }
127
+ closeModal();
128
+ }
129
+ }, (0, _i18n.__)('Delete'))));
130
+ }
131
+ };
132
+ function usePermanentlyDeletePostAction() {
133
+ const {
134
+ createSuccessNotice,
135
+ createErrorNotice
136
+ } = (0, _data.useDispatch)(_notices.store);
137
+ const {
138
+ deleteEntityRecord
139
+ } = (0, _data.useDispatch)(_coreData.store);
140
+ return (0, _element.useMemo)(() => ({
141
+ id: 'permanently-delete',
142
+ label: (0, _i18n.__)('Permanently delete'),
143
+ supportsBulk: true,
144
+ isEligible({
145
+ status
146
+ }) {
147
+ return status === 'trash';
148
+ },
149
+ async callback(posts, onActionPerformed) {
150
+ const promiseResult = await Promise.allSettled(posts.map(post => {
151
+ return deleteEntityRecord('postType', post.type, post.id, {
152
+ force: true
153
+ }, {
154
+ throwOnError: true
155
+ });
156
+ }));
157
+ // If all the promises were fulfilled with success.
158
+ if (promiseResult.every(({
159
+ status
160
+ }) => status === 'fulfilled')) {
161
+ let successMessage;
162
+ if (promiseResult.length === 1) {
163
+ successMessage = (0, _i18n.sprintf)( /* translators: The posts's title. */
164
+ (0, _i18n.__)('"%s" permanently deleted.'), getItemTitle(posts[0]));
165
+ } else {
166
+ successMessage = (0, _i18n.__)('The posts were permanently deleted.');
167
+ }
168
+ createSuccessNotice(successMessage, {
169
+ type: 'snackbar',
170
+ id: 'edit-site-post-permanently-deleted'
171
+ });
172
+ if (onActionPerformed) {
173
+ onActionPerformed(posts);
174
+ }
175
+ } else {
176
+ // If there was at lease one failure.
177
+ let errorMessage;
178
+ // If we were trying to permanently delete a single post.
179
+ if (promiseResult.length === 1) {
180
+ if (promiseResult[0].reason?.message) {
181
+ errorMessage = promiseResult[0].reason.message;
182
+ } else {
183
+ errorMessage = (0, _i18n.__)('An error occurred while permanently deleting the post.');
184
+ }
185
+ // If we were trying to permanently delete multiple posts
186
+ } else {
187
+ const errorMessages = new Set();
188
+ const failedPromises = promiseResult.filter(({
189
+ status
190
+ }) => status === 'rejected');
191
+ for (const failedPromise of failedPromises) {
192
+ if (failedPromise.reason?.message) {
193
+ errorMessages.add(failedPromise.reason.message);
194
+ }
195
+ }
196
+ if (errorMessages.size === 0) {
197
+ errorMessage = (0, _i18n.__)('An error occurred while permanently deleting the posts.');
198
+ } else if (errorMessages.size === 1) {
199
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
200
+ (0, _i18n.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
201
+ } else {
202
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
203
+ (0, _i18n.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
204
+ }
205
+ createErrorNotice(errorMessage, {
206
+ type: 'snackbar'
207
+ });
208
+ }
209
+ }
210
+ }
211
+ }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]);
212
+ }
213
+ function useRestorePostAction() {
214
+ const {
215
+ createSuccessNotice,
216
+ createErrorNotice
217
+ } = (0, _data.useDispatch)(_notices.store);
218
+ const {
219
+ editEntityRecord,
220
+ saveEditedEntityRecord
221
+ } = (0, _data.useDispatch)(_coreData.store);
222
+ return (0, _element.useMemo)(() => ({
223
+ id: 'restore',
224
+ label: (0, _i18n.__)('Restore'),
225
+ isPrimary: true,
226
+ icon: _icons.backup,
227
+ supportsBulk: true,
228
+ isEligible({
229
+ status
230
+ }) {
231
+ return status === 'trash';
232
+ },
233
+ async callback(posts, onActionPerformed) {
234
+ try {
235
+ for (const post of posts) {
236
+ await editEntityRecord('postType', post.type, post.id, {
237
+ status: 'draft'
238
+ });
239
+ await saveEditedEntityRecord('postType', post.type, post.id, {
240
+ throwOnError: true
241
+ });
242
+ }
243
+ createSuccessNotice(posts.length > 1 ? (0, _i18n.sprintf)( /* translators: The number of posts. */
244
+ (0, _i18n.__)('%d posts have been restored.'), posts.length) : (0, _i18n.sprintf)( /* translators: The number of posts. */
245
+ (0, _i18n.__)('"%s" has been restored.'), getItemTitle(posts[0])), {
246
+ type: 'snackbar',
247
+ id: 'edit-site-post-restored'
248
+ });
249
+ if (onActionPerformed) {
250
+ onActionPerformed(posts);
251
+ }
252
+ } catch (error) {
253
+ let errorMessage;
254
+ if (error.message && error.code !== 'unknown_error' && error.message) {
255
+ errorMessage = error.message;
256
+ } else if (posts.length > 1) {
257
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the posts.');
258
+ } else {
259
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the post.');
260
+ }
261
+ createErrorNotice(errorMessage, {
262
+ type: 'snackbar'
263
+ });
264
+ }
265
+ }
266
+ }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]);
267
+ }
268
+ const viewPostAction = exports.viewPostAction = {
269
+ id: 'view-post',
270
+ label: (0, _i18n.__)('View'),
271
+ isPrimary: true,
272
+ icon: _icons.external,
273
+ isEligible(post) {
274
+ return post.status !== 'trash';
275
+ },
276
+ callback(posts, onActionPerformed) {
277
+ const post = posts[0];
278
+ window.open(post.link, '_blank');
279
+ if (onActionPerformed) {
280
+ onActionPerformed(posts);
281
+ }
282
+ }
283
+ };
284
+ const editPostAction = exports.editPostAction = {
285
+ id: 'edit-post',
286
+ label: (0, _i18n.__)('Edit'),
287
+ isPrimary: true,
288
+ icon: _icons.edit,
289
+ isEligible({
290
+ status
291
+ }) {
292
+ return status !== 'trash';
293
+ },
294
+ callback(posts, onActionPerformed) {
295
+ if (onActionPerformed) {
296
+ onActionPerformed(posts);
297
+ }
298
+ }
299
+ };
300
+ const postRevisionsAction = exports.postRevisionsAction = {
301
+ id: 'view-post-revisions',
302
+ label: (0, _i18n.__)('View revisions'),
303
+ isPrimary: false,
304
+ isEligible: post => {
305
+ var _post$_links$predeces, _post$_links$version;
306
+ if (post.status === 'trash') {
307
+ return false;
308
+ }
309
+ const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
310
+ const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
311
+ return lastRevisionId && revisionsCount > 1;
312
+ },
313
+ callback(posts, onActionPerformed) {
314
+ const post = posts[0];
315
+ const href = (0, _url.addQueryArgs)('revision.php', {
316
+ revision: post?._links?.['predecessor-version']?.[0]?.id
317
+ });
318
+ document.location.href = href;
319
+ if (onActionPerformed) {
320
+ onActionPerformed(posts);
321
+ }
322
+ }
323
+ };
324
+ const renamePostAction = exports.renamePostAction = {
325
+ id: 'rename-post',
326
+ label: (0, _i18n.__)('Rename'),
327
+ isEligible(post) {
328
+ return post.status !== 'trash';
329
+ },
330
+ RenderModal: ({
331
+ items,
332
+ closeModal
333
+ }) => {
334
+ const [item] = items;
335
+ const originalTitle = (0, _htmlEntities.decodeEntities)(typeof item.title === 'string' ? item.title : item.title.rendered);
336
+ const [title, setTitle] = (0, _element.useState)(() => originalTitle);
337
+ const {
338
+ editEntityRecord,
339
+ saveEditedEntityRecord
340
+ } = (0, _data.useDispatch)(_coreData.store);
341
+ const {
342
+ createSuccessNotice,
343
+ createErrorNotice
344
+ } = (0, _data.useDispatch)(_notices.store);
345
+ async function onRename(event) {
346
+ event.preventDefault();
347
+ try {
348
+ await editEntityRecord('postType', item.type, item.id, {
349
+ title
350
+ });
351
+ // Update state before saving rerenders the list.
352
+ setTitle('');
353
+ closeModal();
354
+ // Persist edited entity.
355
+ await saveEditedEntityRecord('postType', item.type, item.id, {
356
+ throwOnError: true
357
+ });
358
+ createSuccessNotice((0, _i18n.__)('Name updated'), {
359
+ type: 'snackbar'
360
+ });
361
+ } catch (error) {
362
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while updating the name');
363
+ createErrorNotice(errorMessage, {
364
+ type: 'snackbar'
365
+ });
366
+ }
367
+ }
368
+ return (0, _react.createElement)("form", {
369
+ onSubmit: onRename
370
+ }, (0, _react.createElement)(_components.__experimentalVStack, {
371
+ spacing: "5"
372
+ }, (0, _react.createElement)(_components.TextControl, {
373
+ __nextHasNoMarginBottom: true,
374
+ __next40pxDefaultSize: true,
375
+ label: (0, _i18n.__)('Name'),
376
+ value: title,
377
+ onChange: setTitle,
378
+ required: true
379
+ }), (0, _react.createElement)(_components.__experimentalHStack, {
380
+ justify: "right"
381
+ }, (0, _react.createElement)(_components.Button, {
382
+ __next40pxDefaultSize: true,
383
+ variant: "tertiary",
384
+ onClick: () => {
385
+ closeModal();
386
+ }
387
+ }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
388
+ __next40pxDefaultSize: true,
389
+ variant: "primary",
390
+ type: "submit"
391
+ }, (0, _i18n.__)('Save')))));
392
+ }
393
+ };
394
+ function usePostActions(onActionPerformed, actionIds = null) {
395
+ const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
396
+ const restorePostAction = useRestorePostAction();
397
+ return (0, _element.useMemo)(() => {
398
+ // By default, return all actions...
399
+ const defaultActions = [editPostAction, viewPostAction, restorePostAction, permanentlyDeletePostAction, postRevisionsAction, renamePostAction, trashPostAction];
400
+
401
+ // ... unless `actionIds` was specified, in which case we find the
402
+ // actions matching the given IDs.
403
+ const actions = actionIds ? actionIds.map(actionId => defaultActions.find(({
404
+ id
405
+ }) => actionId === id)) : defaultActions;
406
+ if (onActionPerformed) {
407
+ for (let i = 0; i < actions.length; ++i) {
408
+ if (actions[i].callback) {
409
+ const existingCallback = actions[i].callback;
410
+ actions[i] = {
411
+ ...actions[i],
412
+ callback: (items, _onActionPerformed) => {
413
+ existingCallback(items, _items => {
414
+ if (_onActionPerformed) {
415
+ _onActionPerformed(_items);
416
+ }
417
+ onActionPerformed(actions[i].id, _items);
418
+ });
419
+ }
420
+ };
421
+ }
422
+ if (actions[i].RenderModal) {
423
+ const ExistingRenderModal = actions[i].RenderModal;
424
+ actions[i] = {
425
+ ...actions[i],
426
+ RenderModal: props => {
427
+ return (0, _react.createElement)(ExistingRenderModal, {
428
+ items: props.items,
429
+ closeModal: props.closeModal,
430
+ onActionPerformed: _items => {
431
+ if (props.onActionPerformed) {
432
+ props.onActionPerformed(_items);
433
+ }
434
+ onActionPerformed(actions[i].id, _items);
435
+ }
436
+ });
437
+ }
438
+ };
439
+ }
440
+ }
441
+ }
442
+ return actions;
443
+ },
444
+ // Disable reason: if provided, `actionIds` is a shallow array of
445
+ // strings, and the strings themselves should be part of the useMemo
446
+ // dependencies. Two different disable statements are needed, as the
447
+ // first flags what it thinks are missing dependencies, and the second
448
+ // flags the array spread operation.
449
+ //
450
+ // eslint-disable-next-line react-hooks/exhaustive-deps
451
+ [
452
+ // eslint-disable-next-line react-hooks/exhaustive-deps
453
+ ...(actionIds || []), permanentlyDeletePostAction, restorePostAction, onActionPerformed]);
454
+ }
455
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_icons","require","_url","_data","_htmlEntities","_coreData","_i18n","_notices","_element","_components","getItemTitle","item","title","decodeEntities","rendered","trashPostAction","exports","id","label","__","isPrimary","icon","trash","isEligible","status","supportsBulk","hideModalHeader","RenderModal","items","posts","closeModal","onActionPerformed","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","_react","createElement","__experimentalVStack","spacing","__experimentalText","length","sprintf","_n","__experimentalHStack","justify","Button","variant","onClick","promiseResult","Promise","allSettled","map","post","type","throwOnError","every","successMessage","errorMessage","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","usePermanentlyDeletePostAction","useMemo","callback","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","backup","error","code","viewPostAction","external","window","open","link","editPostAction","edit","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","href","addQueryArgs","revision","document","location","renamePostAction","originalTitle","setTitle","useState","onRename","event","preventDefault","onSubmit","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","required","usePostActions","actionIds","permanentlyDeletePostAction","restorePostAction","defaultActions","actions","actionId","find","i","existingCallback","_onActionPerformed","_items","ExistingRenderModal","props"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, edit, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo, useState } from '@wordpress/element';\n\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nfunction getItemTitle( item ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\treturn decodeEntities( item.title?.rendered || '' );\n}\n\nexport const trashPostAction = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items: posts, closeModal, onActionPerformed } ) => {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ posts.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The page's title.\n\t\t\t\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\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: %d: The number of pages (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to delete %d page?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to delete %d pages?',\n\t\t\t\t\t\t\t\t\tposts.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tposts.length\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 variant=\"tertiary\" onClick={ closeModal }>\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\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\tposts.map( ( post ) => {\n\t\t\t\t\t\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\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\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the Trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = __(\n\t\t\t\t\t\t\t\t\t\t'Pages moved to the Trash.'\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\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'edit-site-page-trashed',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at lease one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to move a single post to the trash.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\tpromiseResult[ 0 ].reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the post to the trash.'\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\t// If we were trying to move multiple posts to the trash\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\tfailedPromise.reason.message\n\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\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the posts to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the posts to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the pages to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\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\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\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\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\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 function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tsupportsBulk: true,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( posts, onActionPerformed ) {\n\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\tposts.map( ( post ) => {\n\t\t\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t);\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\tif (\n\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet successMessage;\n\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsuccessMessage = __(\n\t\t\t\t\t\t\t'The posts were permanently deleted.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t} );\n\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If there was at lease one failure.\n\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t// If we were trying to permanently delete a single post.\n\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\tfailedPromise.reason.message\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the posts.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the posts: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terrorMessage = sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the posts: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\ttype: 'snackbar',\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\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tsupportsBulk: true,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( posts, onActionPerformed ) {\n\t\t\t\ttry {\n\t\t\t\t\tfor ( const post of posts ) {\n\t\t\t\t\t\tawait editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tposts.length > 1\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\t\t\t\t\tposts.length\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tlet errorMessage;\n\t\t\t\t\tif (\n\t\t\t\t\t\terror.message &&\n\t\t\t\t\t\terror.code !== 'unknown_error' &&\n\t\t\t\t\t\terror.message\n\t\t\t\t\t) {\n\t\t\t\t\t\terrorMessage = error.message;\n\t\t\t\t\t} else if ( posts.length > 1 ) {\n\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport const editPostAction = {\n\tid: 'edit-post',\n\tlabel: __( 'Edit' ),\n\tisPrimary: true,\n\ticon: edit,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport const renamePostAction = {\n\tid: 'rename-post',\n\tlabel: __( 'Rename' ),\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal } ) => {\n\t\tconst [ item ] = items;\n\t\tconst originalTitle = decodeEntities(\n\t\t\ttypeof item.title === 'string' ? item.title : item.title.rendered\n\t\t);\n\t\tconst [ title, setTitle ] = useState( () => originalTitle );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tuseDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function onRename( event ) {\n\t\t\tevent.preventDefault();\n\t\t\ttry {\n\t\t\t\tawait editEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\ttitle,\n\t\t\t\t} );\n\t\t\t\t// Update state before saving rerenders the list.\n\t\t\t\tsetTitle( '' );\n\t\t\t\tcloseModal();\n\t\t\t\t// Persist edited entity.\n\t\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t\tcreateSuccessNotice( __( 'Name updated' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} catch ( error ) {\n\t\t\t\tconst errorMessage =\n\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: __( 'An error occurred while updating the name' );\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\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\t__next40pxDefaultSize\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>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\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 function usePostActions( onActionPerformed, actionIds = null ) {\n\tconst permanentlyDeletePostAction = usePermanentlyDeletePostAction();\n\tconst restorePostAction = useRestorePostAction();\n\treturn useMemo(\n\t\t() => {\n\t\t\t// By default, return all actions...\n\t\t\tconst defaultActions = [\n\t\t\t\teditPostAction,\n\t\t\t\tviewPostAction,\n\t\t\t\trestorePostAction,\n\t\t\t\tpermanentlyDeletePostAction,\n\t\t\t\tpostRevisionsAction,\n\t\t\t\trenamePostAction,\n\t\t\t\ttrashPostAction,\n\t\t\t];\n\n\t\t\t// ... unless `actionIds` was specified, in which case we find the\n\t\t\t// actions matching the given IDs.\n\t\t\tconst actions = actionIds\n\t\t\t\t? actionIds.map( ( actionId ) =>\n\t\t\t\t\t\tdefaultActions.find( ( { id } ) => actionId === id )\n\t\t\t\t )\n\t\t\t\t: defaultActions;\n\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\t\tcallback: ( items, _onActionPerformed ) => {\n\t\t\t\t\t\t\t\texistingCallback( items, ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( _onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t_onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t\titems={ props.items }\n\t\t\t\t\t\t\t\t\t\tcloseModal={ props.closeModal }\n\t\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\t\t\t_items\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}\n\t\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t\t_items\n\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\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn actions;\n\t\t},\n\n\t\t// Disable reason: if provided, `actionIds` is a shallow array of\n\t\t// strings, and the strings themselves should be part of the useMemo\n\t\t// dependencies. Two different disable statements are needed, as the\n\t\t// first flags what it thinks are missing dependencies, and the second\n\t\t// flags the array spread operation.\n\t\t//\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t...( actionIds || [] ),\n\t\t\tpermanentlyDeletePostAction,\n\t\t\trestorePostAction,\n\t\t\tonActionPerformed,\n\t\t]\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,WAAA,GAAAR,OAAA;AAZA;AACA;AACA;;AAkBA,SAASS,YAAYA,CAAEC,IAAI,EAAG;EAC7B,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,EAAEE,QAAQ,IAAI,EAAG,CAAC;AACpD;AAEO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAC9BE,EAAE,EAAE,eAAe;EACnBC,KAAK,EAAE,IAAAC,QAAE,EAAE,eAAgB,CAAC;EAC5BC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,YAAK;EACXC,UAAUA,CAAE;IAAEC;EAAO,CAAC,EAAG;IACxB,OAAOA,MAAM,KAAK,OAAO;EAC1B,CAAC;EACDC,YAAY,EAAE,IAAI;EAClBC,eAAe,EAAE,IAAI;EACrBC,WAAW,EAAEA,CAAE;IAAEC,KA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AAW,EAAIoG,KAAK,IAAM;cACzB,OACC,IAAAzF,MAAA,CAAAC,aAAA,EAACuF,mBAAmB;gBACnBlG,KAAK,EAAGmG,KAAK,CAACnG,KAAO;gBACrBE,UAAU,EAAGiG,KAAK,CAACjG,UAAY;gBAC/BC,iBAAiB,EAAK8F,MAAM,IAAM;kBACjC,IAAKE,KAAK,CAAChG,iBAAiB,EAAG;oBAC9BgG,KAAK,CAAChG,iBAAiB,CACtB8F,MACD,CAAC;kBACF;kBACA9F,iBAAiB,CAChBwF,OAAO,CAAEG,CAAC,CAAE,CAACzG,EAAE,EACf4G,MACD,CAAC;gBACF;cAAG,CACH,CAAC;YAEJ;UACD,CAAC;QACF;MACD;IACD;IACA,OAAON,OAAO;EACf,CAAC;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACC;EACA,IAAKJ,SAAS,IAAI,EAAE,CAAE,EACtBC,2BAA2B,EAC3BC,iBAAiB,EACjBtF,iBAAiB,CAEnB,CAAC;AACF"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = PostCardPanel;
8
+ var _react = require("react");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _components = require("@wordpress/components");
11
+ var _coreData = require("@wordpress/core-data");
12
+ var _data = require("@wordpress/data");
13
+ var _i18n = require("@wordpress/i18n");
14
+ var _date = require("@wordpress/date");
15
+ var _htmlEntities = require("@wordpress/html-entities");
16
+ var _store = require("../../store");
17
+ var _constants = require("../../store/constants");
18
+ var _lockUnlock = require("../../lock-unlock");
19
+ var _templateAreas = _interopRequireDefault(require("../template-areas"));
20
+ /**
21
+ * External dependencies
22
+ */
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+
32
+ function PostCardPanel({
33
+ className,
34
+ actions
35
+ }) {
36
+ const {
37
+ modified,
38
+ title,
39
+ templateInfo,
40
+ icon,
41
+ postType
42
+ } = (0, _data.useSelect)(select => {
43
+ const {
44
+ getEditedPostAttribute,
45
+ getCurrentPostType,
46
+ getCurrentPostId,
47
+ __experimentalGetTemplateInfo
48
+ } = select(_store.store);
49
+ const {
50
+ getEditedEntityRecord
51
+ } = select(_coreData.store);
52
+ const _type = getCurrentPostType();
53
+ const _id = getCurrentPostId();
54
+ const _record = getEditedEntityRecord('postType', _type, _id);
55
+ const _templateInfo = __experimentalGetTemplateInfo(_record);
56
+ return {
57
+ title: _templateInfo?.title || getEditedPostAttribute('title'),
58
+ modified: getEditedPostAttribute('modified'),
59
+ id: _id,
60
+ postType: _type,
61
+ templateInfo: _templateInfo,
62
+ icon: (0, _lockUnlock.unlock)(select(_store.store)).getPostIcon(_type, {
63
+ area: _record?.area
64
+ })
65
+ };
66
+ });
67
+ const description = templateInfo?.description;
68
+ const lastEditedText = modified && (0, _i18n.sprintf)(
69
+ // translators: %s: Human-readable time difference, e.g. "2 days ago".
70
+ (0, _i18n.__)('Last edited %s.'), (0, _date.humanTimeDiff)(modified));
71
+ return (0, _react.createElement)(_components.PanelBody, null, (0, _react.createElement)("div", {
72
+ className: (0, _classnames.default)('editor-post-card-panel', className)
73
+ }, (0, _react.createElement)(_components.__experimentalHStack, {
74
+ spacing: 2,
75
+ className: "editor-post-card-panel__header",
76
+ align: "flex-start"
77
+ }, (0, _react.createElement)(_components.Icon, {
78
+ className: "editor-post-card-panel__icon",
79
+ icon: icon
80
+ }), (0, _react.createElement)(_components.__experimentalText, {
81
+ numberOfLines: 2,
82
+ truncate: true,
83
+ className: "editor-post-card-panel__title",
84
+ weight: 500,
85
+ as: "h2"
86
+ }, title ? (0, _htmlEntities.decodeEntities)(title) : (0, _i18n.__)('No Title')), actions), (0, _react.createElement)(_components.__experimentalVStack, {
87
+ className: "editor-post-card-panel__content"
88
+ }, (description || lastEditedText) && (0, _react.createElement)(_components.__experimentalVStack, {
89
+ className: "editor-post-card-panel__description",
90
+ spacing: 2
91
+ }, description && (0, _react.createElement)(_components.__experimentalText, null, description), lastEditedText && (0, _react.createElement)(_components.__experimentalText, null, lastEditedText)), postType === _constants.TEMPLATE_POST_TYPE && (0, _react.createElement)(_templateAreas.default, null))));
92
+ }
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_components","_coreData","_data","_i18n","_date","_htmlEntities","_store","_constants","_lockUnlock","_templateAreas","PostCardPanel","className","actions","modified","title","templateInfo","icon","postType","useSelect","select","getEditedPostAttribute","getCurrentPostType","getCurrentPostId","__experimentalGetTemplateInfo","editorStore","getEditedEntityRecord","coreStore","_type","_id","_record","_templateInfo","id","unlock","getPostIcon","area","description","lastEditedText","sprintf","__","humanTimeDiff","_react","createElement","PanelBody","classnames","__experimentalHStack","spacing","align","Icon","__experimentalText","numberOfLines","truncate","weight","as","decodeEntities","__experimentalVStack","TEMPLATE_POST_TYPE","default"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tPanelBody,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { humanTimeDiff } from '@wordpress/date';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport TemplateAreas from '../template-areas';\n\nexport default function PostCardPanel( { className, actions } ) {\n\tconst { modified, title, templateInfo, icon, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\t__experimentalGetTemplateInfo,\n\t\t\t} = select( editorStore );\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\tconst _type = getCurrentPostType();\n\t\t\tconst _id = getCurrentPostId();\n\t\t\tconst _record = getEditedEntityRecord( 'postType', _type, _id );\n\t\t\tconst _templateInfo = __experimentalGetTemplateInfo( _record );\n\t\t\treturn {\n\t\t\t\ttitle:\n\t\t\t\t\t_templateInfo?.title || getEditedPostAttribute( 'title' ),\n\t\t\t\tmodified: getEditedPostAttribute( 'modified' ),\n\t\t\t\tid: _id,\n\t\t\t\tpostType: _type,\n\t\t\t\ttemplateInfo: _templateInfo,\n\t\t\t\ticon: unlock( select( editorStore ) ).getPostIcon( _type, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t};\n\t\t}\n\t);\n\tconst description = templateInfo?.description;\n\tconst lastEditedText =\n\t\tmodified &&\n\t\tsprintf(\n\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t__( 'Last edited %s.' ),\n\t\t\thumanTimeDiff( modified )\n\t\t);\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'editor-post-card-panel', className ) }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__icon\"\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\t\ttruncate\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tas=\"h2\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title ? decodeEntities( title ) : __( 'No Title' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ actions }\n\t\t\t\t</HStack>\n\t\t\t\t<VStack className=\"editor-post-card-panel__content\">\n\t\t\t\t\t{ ( description || lastEditedText ) && (\n\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\tclassName=\"editor-post-card-panel__description\"\n\t\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t\t\t\t{ lastEditedText && (\n\t\t\t\t\t\t\t\t<Text>{ lastEditedText }</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t) }\n\t\t\t\t\t{ postType === TEMPLATE_POST_TYPE && <TemplateAreas /> }\n\t\t\t\t</VStack>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAX,sBAAA,CAAAC,OAAA;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAMe,SAASW,aAAaA,CAAE;EAAEC,SAAS;EAAEC;AAAQ,CAAC,EAAG;EAC/D,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,YAAY;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAChEC,MAAM,IAAM;IACb,MAAM;MACLC,sBAAsB;MACtB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