@wordpress/editor 14.4.0 → 14.6.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 (375) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/bindings/post-meta.js +12 -0
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/blog-title/index.js +1 -1
  5. package/build/components/blog-title/index.js.map +1 -1
  6. package/build/components/commands/index.js +8 -2
  7. package/build/components/commands/index.js.map +1 -1
  8. package/build/components/create-template-part-modal/index.js +1 -0
  9. package/build/components/create-template-part-modal/index.js.map +1 -1
  10. package/build/components/document-bar/index.js +1 -1
  11. package/build/components/document-bar/index.js.map +1 -1
  12. package/build/components/global-styles-provider/index.js +17 -4
  13. package/build/components/global-styles-provider/index.js.map +1 -1
  14. package/build/components/header/index.js +2 -3
  15. package/build/components/header/index.js.map +1 -1
  16. package/build/components/inserter-sidebar/index.js +5 -2
  17. package/build/components/inserter-sidebar/index.js.map +1 -1
  18. package/build/components/page-attributes/parent.js +11 -6
  19. package/build/components/page-attributes/parent.js.map +1 -1
  20. package/build/components/post-actions/actions.js +10 -811
  21. package/build/components/post-actions/actions.js.map +1 -1
  22. package/build/components/post-actions/index.js +20 -19
  23. package/build/components/post-actions/index.js.map +1 -1
  24. package/build/components/post-author/hook.js +10 -3
  25. package/build/components/post-author/hook.js.map +1 -1
  26. package/build/components/post-author/panel.js +2 -1
  27. package/build/components/post-author/panel.js.map +1 -1
  28. package/build/components/post-card-panel/index.js +21 -21
  29. package/build/components/post-card-panel/index.js.map +1 -1
  30. package/build/components/post-comments/index.js +6 -20
  31. package/build/components/post-comments/index.js.map +1 -1
  32. package/build/components/post-featured-image/index.js +2 -0
  33. package/build/components/post-featured-image/index.js.map +1 -1
  34. package/build/components/post-publish-panel/postpublish.js +4 -0
  35. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  36. package/build/components/post-slug/index.js +1 -0
  37. package/build/components/post-slug/index.js.map +1 -1
  38. package/build/components/post-status/index.js +17 -41
  39. package/build/components/post-status/index.js.map +1 -1
  40. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -1
  41. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  42. package/build/components/post-template/create-new-template-modal.js +3 -0
  43. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  44. package/build/components/post-url/index.js +6 -5
  45. package/build/components/post-url/index.js.map +1 -1
  46. package/build/components/post-url/panel.js +3 -2
  47. package/build/components/post-url/panel.js.map +1 -1
  48. package/build/components/preview-dropdown/index.js +82 -17
  49. package/build/components/preview-dropdown/index.js.map +1 -1
  50. package/build/components/provider/disable-non-page-content-blocks.js +14 -18
  51. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  52. package/build/components/sidebar/post-summary.js +10 -7
  53. package/build/components/sidebar/post-summary.js.map +1 -1
  54. package/build/components/site-discussion/index.js +6 -20
  55. package/build/components/site-discussion/index.js.map +1 -1
  56. package/build/components/template-content-panel/index.js +15 -13
  57. package/build/components/template-content-panel/index.js.map +1 -1
  58. package/build/components/visual-editor/index.js +2 -1
  59. package/build/components/visual-editor/index.js.map +1 -1
  60. package/build/dataviews/actions/duplicate-pattern.js +48 -0
  61. package/build/dataviews/actions/duplicate-pattern.js.map +1 -0
  62. package/build/dataviews/actions/duplicate-post.js +146 -0
  63. package/build/dataviews/actions/duplicate-post.js.map +1 -0
  64. package/build/dataviews/actions/duplicate-post.native.js +9 -0
  65. package/build/dataviews/actions/duplicate-post.native.js.map +1 -0
  66. package/build/dataviews/actions/duplicate-template-part.js +67 -0
  67. package/build/dataviews/actions/duplicate-template-part.js.map +1 -0
  68. package/build/dataviews/actions/export-pattern.native.js +9 -0
  69. package/build/dataviews/actions/export-pattern.native.js.map +1 -0
  70. package/build/dataviews/actions/permanently-delete-post.js +107 -0
  71. package/build/dataviews/actions/permanently-delete-post.js.map +1 -0
  72. package/build/dataviews/actions/rename-post.js +125 -0
  73. package/build/dataviews/actions/rename-post.js.map +1 -0
  74. package/build/dataviews/actions/reorder-page.js +116 -0
  75. package/build/dataviews/actions/reorder-page.js.map +1 -0
  76. package/build/dataviews/actions/reorder-page.native.js +9 -0
  77. package/build/dataviews/actions/reorder-page.native.js.map +1 -0
  78. package/build/dataviews/actions/reset-post.js +1 -1
  79. package/build/dataviews/actions/reset-post.js.map +1 -1
  80. package/build/dataviews/actions/restore-post.js +112 -0
  81. package/build/dataviews/actions/restore-post.js.map +1 -0
  82. package/build/dataviews/actions/trash-post.js +142 -0
  83. package/build/dataviews/actions/trash-post.js.map +1 -0
  84. package/build/dataviews/actions/utils.js +9 -1
  85. package/build/dataviews/actions/utils.js.map +1 -1
  86. package/build/dataviews/actions/view-post-revisions.js +49 -0
  87. package/build/dataviews/actions/view-post-revisions.js.map +1 -0
  88. package/build/dataviews/actions/view-post.js +36 -0
  89. package/build/dataviews/actions/view-post.js.map +1 -0
  90. package/build/dataviews/fields/index.js +32 -0
  91. package/build/dataviews/fields/index.js.map +1 -0
  92. package/build/dataviews/store/private-actions.js +59 -0
  93. package/build/dataviews/store/private-actions.js.map +1 -1
  94. package/build/dataviews/store/private-selectors.js +10 -10
  95. package/build/dataviews/store/private-selectors.js.map +1 -1
  96. package/build/dataviews/store/reducer.js +15 -1
  97. package/build/dataviews/store/reducer.js.map +1 -1
  98. package/build/dataviews/types.js.map +1 -1
  99. package/build/private-apis.js +2 -2
  100. package/build/private-apis.js.map +1 -1
  101. package/build/store/actions.js +16 -2
  102. package/build/store/actions.js.map +1 -1
  103. package/build/store/private-actions.js +9 -2
  104. package/build/store/private-actions.js.map +1 -1
  105. package/build/store/private-selectors.js +33 -2
  106. package/build/store/private-selectors.js.map +1 -1
  107. package/build/store/utils/is-template-revertable.js +1 -1
  108. package/build/store/utils/is-template-revertable.js.map +1 -1
  109. package/build-module/bindings/post-meta.js +12 -0
  110. package/build-module/bindings/post-meta.js.map +1 -1
  111. package/build-module/components/blog-title/index.js +1 -1
  112. package/build-module/components/blog-title/index.js.map +1 -1
  113. package/build-module/components/commands/index.js +8 -2
  114. package/build-module/components/commands/index.js.map +1 -1
  115. package/build-module/components/create-template-part-modal/index.js +1 -0
  116. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  117. package/build-module/components/document-bar/index.js +1 -1
  118. package/build-module/components/document-bar/index.js.map +1 -1
  119. package/build-module/components/global-styles-provider/index.js +17 -4
  120. package/build-module/components/global-styles-provider/index.js.map +1 -1
  121. package/build-module/components/header/index.js +2 -3
  122. package/build-module/components/header/index.js.map +1 -1
  123. package/build-module/components/inserter-sidebar/index.js +5 -2
  124. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  125. package/build-module/components/page-attributes/parent.js +12 -7
  126. package/build-module/components/page-attributes/parent.js.map +1 -1
  127. package/build-module/components/post-actions/actions.js +12 -814
  128. package/build-module/components/post-actions/actions.js.map +1 -1
  129. package/build-module/components/post-actions/index.js +20 -19
  130. package/build-module/components/post-actions/index.js.map +1 -1
  131. package/build-module/components/post-author/hook.js +10 -3
  132. package/build-module/components/post-author/hook.js.map +1 -1
  133. package/build-module/components/post-author/panel.js +2 -1
  134. package/build-module/components/post-author/panel.js.map +1 -1
  135. package/build-module/components/post-card-panel/index.js +21 -21
  136. package/build-module/components/post-card-panel/index.js.map +1 -1
  137. package/build-module/components/post-comments/index.js +7 -23
  138. package/build-module/components/post-comments/index.js.map +1 -1
  139. package/build-module/components/post-featured-image/index.js +2 -0
  140. package/build-module/components/post-featured-image/index.js.map +1 -1
  141. package/build-module/components/post-publish-panel/postpublish.js +4 -0
  142. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  143. package/build-module/components/post-slug/index.js +1 -0
  144. package/build-module/components/post-slug/index.js.map +1 -1
  145. package/build-module/components/post-status/index.js +19 -43
  146. package/build-module/components/post-status/index.js.map +1 -1
  147. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  148. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  149. package/build-module/components/post-template/create-new-template-modal.js +3 -0
  150. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  151. package/build-module/components/post-url/index.js +7 -6
  152. package/build-module/components/post-url/index.js.map +1 -1
  153. package/build-module/components/post-url/panel.js +4 -5
  154. package/build-module/components/post-url/panel.js.map +1 -1
  155. package/build-module/components/preview-dropdown/index.js +84 -19
  156. package/build-module/components/preview-dropdown/index.js.map +1 -1
  157. package/build-module/components/provider/disable-non-page-content-blocks.js +15 -19
  158. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  159. package/build-module/components/sidebar/post-summary.js +10 -7
  160. package/build-module/components/sidebar/post-summary.js.map +1 -1
  161. package/build-module/components/site-discussion/index.js +7 -21
  162. package/build-module/components/site-discussion/index.js.map +1 -1
  163. package/build-module/components/template-content-panel/index.js +16 -14
  164. package/build-module/components/template-content-panel/index.js.map +1 -1
  165. package/build-module/components/visual-editor/index.js +2 -1
  166. package/build-module/components/visual-editor/index.js.map +1 -1
  167. package/build-module/dataviews/actions/duplicate-pattern.js +39 -0
  168. package/build-module/dataviews/actions/duplicate-pattern.js.map +1 -0
  169. package/build-module/dataviews/actions/duplicate-post.js +139 -0
  170. package/build-module/dataviews/actions/duplicate-post.js.map +1 -0
  171. package/build-module/dataviews/actions/duplicate-post.native.js +3 -0
  172. package/build-module/dataviews/actions/duplicate-post.native.js.map +1 -0
  173. package/build-module/dataviews/actions/duplicate-template-part.js +58 -0
  174. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -0
  175. package/build-module/dataviews/actions/export-pattern.native.js +3 -0
  176. package/build-module/dataviews/actions/export-pattern.native.js.map +1 -0
  177. package/build-module/dataviews/actions/permanently-delete-post.js +99 -0
  178. package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -0
  179. package/build-module/dataviews/actions/rename-post.js +118 -0
  180. package/build-module/dataviews/actions/rename-post.js.map +1 -0
  181. package/build-module/dataviews/actions/reorder-page.js +111 -0
  182. package/build-module/dataviews/actions/reorder-page.js.map +1 -0
  183. package/build-module/dataviews/actions/reorder-page.native.js +3 -0
  184. package/build-module/dataviews/actions/reorder-page.native.js.map +1 -0
  185. package/build-module/dataviews/actions/reset-post.js +1 -1
  186. package/build-module/dataviews/actions/reset-post.js.map +1 -1
  187. package/build-module/dataviews/actions/restore-post.js +104 -0
  188. package/build-module/dataviews/actions/restore-post.js.map +1 -0
  189. package/build-module/dataviews/actions/trash-post.js +135 -0
  190. package/build-module/dataviews/actions/trash-post.js.map +1 -0
  191. package/build-module/dataviews/actions/utils.js +7 -1
  192. package/build-module/dataviews/actions/utils.js.map +1 -1
  193. package/build-module/dataviews/actions/view-post-revisions.js +43 -0
  194. package/build-module/dataviews/actions/view-post-revisions.js.map +1 -0
  195. package/build-module/dataviews/actions/view-post.js +30 -0
  196. package/build-module/dataviews/actions/view-post.js.map +1 -0
  197. package/build-module/dataviews/fields/index.js +26 -0
  198. package/build-module/dataviews/fields/index.js.map +1 -0
  199. package/build-module/dataviews/store/private-actions.js +54 -0
  200. package/build-module/dataviews/store/private-actions.js.map +1 -1
  201. package/build-module/dataviews/store/private-selectors.js +8 -9
  202. package/build-module/dataviews/store/private-selectors.js.map +1 -1
  203. package/build-module/dataviews/store/reducer.js +15 -1
  204. package/build-module/dataviews/store/reducer.js.map +1 -1
  205. package/build-module/dataviews/types.js.map +1 -1
  206. package/build-module/private-apis.js +2 -2
  207. package/build-module/private-apis.js.map +1 -1
  208. package/build-module/store/actions.js +16 -2
  209. package/build-module/store/actions.js.map +1 -1
  210. package/build-module/store/private-actions.js +9 -2
  211. package/build-module/store/private-actions.js.map +1 -1
  212. package/build-module/store/private-selectors.js +32 -2
  213. package/build-module/store/private-selectors.js.map +1 -1
  214. package/build-module/store/utils/is-template-revertable.js +1 -1
  215. package/build-module/store/utils/is-template-revertable.js.map +1 -1
  216. package/build-style/style-rtl.css +21 -34
  217. package/build-style/style.css +21 -34
  218. package/build-types/bindings/post-meta.d.ts +6 -0
  219. package/build-types/bindings/post-meta.d.ts.map +1 -1
  220. package/build-types/components/commands/index.d.ts.map +1 -1
  221. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  222. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  223. package/build-types/components/header/index.d.ts.map +1 -1
  224. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  225. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  226. package/build-types/components/post-actions/actions.d.ts +1 -26
  227. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  228. package/build-types/components/post-actions/index.d.ts +3 -2
  229. package/build-types/components/post-actions/index.d.ts.map +1 -1
  230. package/build-types/components/post-author/hook.d.ts +1 -1
  231. package/build-types/components/post-author/hook.d.ts.map +1 -1
  232. package/build-types/components/post-author/panel.d.ts.map +1 -1
  233. package/build-types/components/post-card-panel/index.d.ts +4 -2
  234. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  235. package/build-types/components/post-comments/index.d.ts.map +1 -1
  236. package/build-types/components/post-slug/index.d.ts.map +1 -1
  237. package/build-types/components/post-status/index.d.ts +2 -1
  238. package/build-types/components/post-status/index.d.ts.map +1 -1
  239. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -17
  240. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  241. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  242. package/build-types/components/post-url/index.d.ts.map +1 -1
  243. package/build-types/components/post-url/panel.d.ts.map +1 -1
  244. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  245. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  246. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  247. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  248. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  249. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  250. package/build-types/dataviews/actions/duplicate-pattern.d.ts +5 -0
  251. package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +1 -0
  252. package/build-types/dataviews/actions/duplicate-post.d.ts +5 -0
  253. package/build-types/dataviews/actions/duplicate-post.d.ts.map +1 -0
  254. package/build-types/dataviews/actions/duplicate-post.native.d.ts +3 -0
  255. package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +1 -0
  256. package/build-types/dataviews/actions/duplicate-template-part.d.ts +5 -0
  257. package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +1 -0
  258. package/build-types/dataviews/actions/export-pattern.native.d.ts +3 -0
  259. package/build-types/dataviews/actions/export-pattern.native.d.ts.map +1 -0
  260. package/build-types/dataviews/actions/permanently-delete-post.d.ts +5 -0
  261. package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -0
  262. package/build-types/dataviews/actions/rename-post.d.ts +5 -0
  263. package/build-types/dataviews/actions/rename-post.d.ts.map +1 -0
  264. package/build-types/dataviews/actions/reorder-page.d.ts +8 -0
  265. package/build-types/dataviews/actions/reorder-page.d.ts.map +1 -0
  266. package/build-types/dataviews/actions/reorder-page.native.d.ts +3 -0
  267. package/build-types/dataviews/actions/reorder-page.native.d.ts.map +1 -0
  268. package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
  269. package/build-types/dataviews/actions/restore-post.d.ts +5 -0
  270. package/build-types/dataviews/actions/restore-post.d.ts.map +1 -0
  271. package/build-types/dataviews/actions/trash-post.d.ts +5 -0
  272. package/build-types/dataviews/actions/trash-post.d.ts.map +1 -0
  273. package/build-types/dataviews/actions/utils.d.ts +5 -3
  274. package/build-types/dataviews/actions/utils.d.ts.map +1 -1
  275. package/build-types/dataviews/actions/view-post-revisions.d.ts +8 -0
  276. package/build-types/dataviews/actions/view-post-revisions.d.ts.map +1 -0
  277. package/build-types/dataviews/actions/view-post.d.ts +8 -0
  278. package/build-types/dataviews/actions/view-post.d.ts.map +1 -0
  279. package/build-types/dataviews/fields/index.d.ts +8 -0
  280. package/build-types/dataviews/fields/index.d.ts.map +1 -0
  281. package/build-types/dataviews/store/private-actions.d.ts +8 -3
  282. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  283. package/build-types/dataviews/store/private-selectors.d.ts +2 -1
  284. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  285. package/build-types/dataviews/store/reducer.d.ts +4 -1
  286. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  287. package/build-types/dataviews/types.d.ts +66 -8
  288. package/build-types/dataviews/types.d.ts.map +1 -1
  289. package/build-types/store/actions.d.ts.map +1 -1
  290. package/build-types/store/private-actions.d.ts.map +1 -1
  291. package/build-types/store/private-selectors.d.ts +11 -0
  292. package/build-types/store/private-selectors.d.ts.map +1 -1
  293. package/build-types/store/reducer.d.ts +1 -0
  294. package/build-types/store/reducer.d.ts.map +1 -1
  295. package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
  296. package/package.json +36 -36
  297. package/src/bindings/post-meta.js +20 -0
  298. package/src/components/block-manager/style.scss +2 -2
  299. package/src/components/blog-title/index.js +1 -1
  300. package/src/components/commands/index.js +4 -2
  301. package/src/components/create-template-part-modal/index.js +1 -0
  302. package/src/components/document-bar/index.js +1 -1
  303. package/src/components/document-bar/style.scss +1 -1
  304. package/src/components/editor-interface/style.scss +5 -0
  305. package/src/components/error-boundary/style.native.scss +1 -1
  306. package/src/components/error-boundary/style.scss +1 -1
  307. package/src/components/global-styles-provider/index.js +16 -3
  308. package/src/components/header/index.js +1 -2
  309. package/src/components/inserter-sidebar/index.js +10 -4
  310. package/src/components/list-view-sidebar/style.scss +4 -0
  311. package/src/components/page-attributes/parent.js +38 -16
  312. package/src/components/post-actions/actions.js +10 -1044
  313. package/src/components/post-actions/index.js +25 -17
  314. package/src/components/post-author/hook.js +11 -3
  315. package/src/components/post-author/panel.js +3 -1
  316. package/src/components/post-card-panel/index.js +29 -28
  317. package/src/components/post-comments/index.js +7 -20
  318. package/src/components/post-discussion/style.scss +0 -9
  319. package/src/components/post-featured-image/index.js +2 -0
  320. package/src/components/post-format/style.scss +0 -6
  321. package/src/components/post-publish-panel/postpublish.js +8 -2
  322. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +10 -10
  323. package/src/components/post-slug/index.js +1 -0
  324. package/src/components/post-status/index.js +11 -41
  325. package/src/components/post-status/style.scss +0 -19
  326. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -1
  327. package/src/components/post-template/create-new-template-modal.js +7 -1
  328. package/src/components/post-url/index.js +15 -9
  329. package/src/components/post-url/panel.js +8 -2
  330. package/src/components/preview-dropdown/index.js +113 -35
  331. package/src/components/preview-dropdown/style.scss +5 -0
  332. package/src/components/provider/disable-non-page-content-blocks.js +27 -24
  333. package/src/components/save-publish-panels/style.scss +3 -3
  334. package/src/components/sidebar/post-summary.js +20 -16
  335. package/src/components/site-discussion/index.js +7 -19
  336. package/src/components/site-discussion/style.scss +0 -14
  337. package/src/components/template-content-panel/index.js +40 -22
  338. package/src/components/visual-editor/index.js +8 -6
  339. package/src/components/visual-editor/style.scss +1 -3
  340. package/src/dataviews/actions/duplicate-pattern.tsx +40 -0
  341. package/src/dataviews/actions/duplicate-post.native.tsx +3 -0
  342. package/src/dataviews/actions/duplicate-post.tsx +174 -0
  343. package/src/dataviews/actions/duplicate-template-part.tsx +70 -0
  344. package/src/dataviews/actions/export-pattern.native.tsx +3 -0
  345. package/src/dataviews/actions/permanently-delete-post.tsx +116 -0
  346. package/src/dataviews/actions/rename-post.tsx +146 -0
  347. package/src/dataviews/actions/reorder-page.native.tsx +3 -0
  348. package/src/dataviews/actions/reorder-page.tsx +125 -0
  349. package/src/dataviews/actions/reset-post.tsx +2 -1
  350. package/src/dataviews/actions/restore-post.tsx +134 -0
  351. package/src/dataviews/actions/trash-post.tsx +196 -0
  352. package/src/dataviews/actions/utils.ts +14 -4
  353. package/src/dataviews/actions/view-post-revisions.tsx +47 -0
  354. package/src/dataviews/actions/view-post.tsx +30 -0
  355. package/src/dataviews/fields/index.ts +26 -0
  356. package/src/dataviews/store/private-actions.ts +109 -0
  357. package/src/dataviews/store/private-selectors.ts +9 -17
  358. package/src/dataviews/store/reducer.ts +20 -1
  359. package/src/dataviews/types.ts +58 -6
  360. package/src/private-apis.js +2 -2
  361. package/src/store/actions.js +36 -13
  362. package/src/store/private-actions.js +9 -5
  363. package/src/store/private-selectors.js +45 -2
  364. package/src/store/test/private-selectors.js +78 -0
  365. package/src/store/utils/is-template-revertable.js +2 -1
  366. package/tsconfig.tsbuildinfo +1 -1
  367. package/build/dataviews/actions/index.js +0 -32
  368. package/build/dataviews/actions/index.js.map +0 -1
  369. package/build-module/dataviews/actions/index.js +0 -24
  370. package/build-module/dataviews/actions/index.js.map +0 -1
  371. package/build-types/dataviews/actions/index.d.ts +0 -2
  372. package/build-types/dataviews/actions/index.d.ts.map +0 -1
  373. package/src/components/document-outline/test/__snapshots__/index.js.snap +0 -111
  374. package/src/components/document-outline/test/index.js +0 -185
  375. package/src/dataviews/actions/index.ts +0 -25
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@wordpress/icons");
8
+ var _coreData = require("@wordpress/core-data");
9
+ var _i18n = require("@wordpress/i18n");
10
+ var _notices = require("@wordpress/notices");
11
+ var _utils = require("./utils");
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+
20
+ const restorePost = {
21
+ id: 'restore',
22
+ label: (0, _i18n.__)('Restore'),
23
+ isPrimary: true,
24
+ icon: _icons.backup,
25
+ supportsBulk: true,
26
+ isEligible(item) {
27
+ return !(0, _utils.isTemplateOrTemplatePart)(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
28
+ },
29
+ async callback(posts, {
30
+ registry,
31
+ onActionPerformed
32
+ }) {
33
+ const {
34
+ createSuccessNotice,
35
+ createErrorNotice
36
+ } = registry.dispatch(_notices.store);
37
+ const {
38
+ editEntityRecord,
39
+ saveEditedEntityRecord
40
+ } = registry.dispatch(_coreData.store);
41
+ await Promise.allSettled(posts.map(post => {
42
+ return editEntityRecord('postType', post.type, post.id, {
43
+ status: 'draft'
44
+ });
45
+ }));
46
+ const promiseResult = await Promise.allSettled(posts.map(post => {
47
+ return saveEditedEntityRecord('postType', post.type, post.id, {
48
+ throwOnError: true
49
+ });
50
+ }));
51
+ if (promiseResult.every(({
52
+ status
53
+ }) => status === 'fulfilled')) {
54
+ let successMessage;
55
+ if (posts.length === 1) {
56
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
57
+ (0, _i18n.__)('"%s" has been restored.'), (0, _utils.getItemTitle)(posts[0]));
58
+ } else if (posts[0].type === 'page') {
59
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
60
+ (0, _i18n.__)('%d pages have been restored.'), posts.length);
61
+ } else {
62
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
63
+ (0, _i18n.__)('%d posts have been restored.'), posts.length);
64
+ }
65
+ createSuccessNotice(successMessage, {
66
+ type: 'snackbar',
67
+ id: 'restore-post-action'
68
+ });
69
+ if (onActionPerformed) {
70
+ onActionPerformed(posts);
71
+ }
72
+ } else {
73
+ // If there was at lease one failure.
74
+ let errorMessage;
75
+ // If we were trying to move a single post to the trash.
76
+ if (promiseResult.length === 1) {
77
+ const typedError = promiseResult[0];
78
+ if (typedError.reason?.message) {
79
+ errorMessage = typedError.reason.message;
80
+ } else {
81
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the post.');
82
+ }
83
+ // If we were trying to move multiple posts to the trash
84
+ } else {
85
+ const errorMessages = new Set();
86
+ const failedPromises = promiseResult.filter(({
87
+ status
88
+ }) => status === 'rejected');
89
+ for (const failedPromise of failedPromises) {
90
+ const typedError = failedPromise;
91
+ if (typedError.reason?.message) {
92
+ errorMessages.add(typedError.reason.message);
93
+ }
94
+ }
95
+ if (errorMessages.size === 0) {
96
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the posts.');
97
+ } else if (errorMessages.size === 1) {
98
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
99
+ (0, _i18n.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
100
+ } else {
101
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
102
+ (0, _i18n.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
103
+ }
104
+ }
105
+ createErrorNotice(errorMessage, {
106
+ type: 'snackbar'
107
+ });
108
+ }
109
+ }
110
+ };
111
+ var _default = exports.default = restorePost;
112
+ //# sourceMappingURL=restore-post.js.map
@@ -0,0 +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/editor/src/dataviews/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} );\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AAG,IAAAlC,QAAE,EAChB,6CACD,CAAC;QACF;QACA;MACD,CAAC,MAAM;QACN,MAAMsC,aAAa,GAAG,IAAIC,GAAG,CAAC,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,GACrB;UACA,IAAAhC,QAAE,EAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGsC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,GACrB;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":[]}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@wordpress/icons");
8
+ var _data = require("@wordpress/data");
9
+ var _coreData = require("@wordpress/core-data");
10
+ var _i18n = require("@wordpress/i18n");
11
+ var _notices = require("@wordpress/notices");
12
+ var _element = require("@wordpress/element");
13
+ var _components = require("@wordpress/components");
14
+ var _utils = require("./utils");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ const trashPost = {
25
+ id: 'move-to-trash',
26
+ label: (0, _i18n.__)('Move to trash'),
27
+ isPrimary: true,
28
+ icon: _icons.trash,
29
+ isEligible(item) {
30
+ if ((0, _utils.isTemplateOrTemplatePart)(item) || item.type === 'wp_block') {
31
+ return false;
32
+ }
33
+ return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
34
+ },
35
+ supportsBulk: true,
36
+ hideModalHeader: true,
37
+ RenderModal: ({
38
+ items,
39
+ closeModal,
40
+ onActionPerformed
41
+ }) => {
42
+ const [isBusy, setIsBusy] = (0, _element.useState)(false);
43
+ const {
44
+ createSuccessNotice,
45
+ createErrorNotice
46
+ } = (0, _data.useDispatch)(_notices.store);
47
+ const {
48
+ deleteEntityRecord
49
+ } = (0, _data.useDispatch)(_coreData.store);
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
51
+ spacing: "5",
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
53
+ children: items.length === 1 ? (0, _i18n.sprintf)(
54
+ // translators: %s: The item's title.
55
+ (0, _i18n.__)('Are you sure you want to move "%s" to the trash?'), (0, _utils.getItemTitle)(items[0])) : (0, _i18n.sprintf)(
56
+ // translators: %d: The number of items (2 or more).
57
+ (0, _i18n._n)('Are you sure you want to move %d item to the trash ?', 'Are you sure you want to move %d items to the trash ?', items.length), items.length)
58
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
59
+ justify: "right",
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
61
+ variant: "tertiary",
62
+ onClick: closeModal,
63
+ disabled: isBusy,
64
+ accessibleWhenDisabled: true,
65
+ children: (0, _i18n.__)('Cancel')
66
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
67
+ variant: "primary",
68
+ onClick: async () => {
69
+ setIsBusy(true);
70
+ const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
71
+ throwOnError: true
72
+ })));
73
+ // If all the promises were fulfilled with success.
74
+ if (promiseResult.every(({
75
+ status
76
+ }) => status === 'fulfilled')) {
77
+ let successMessage;
78
+ if (promiseResult.length === 1) {
79
+ successMessage = (0, _i18n.sprintf)( /* translators: The item's title. */
80
+ (0, _i18n.__)('"%s" moved to the trash.'), (0, _utils.getItemTitle)(items[0]));
81
+ } else {
82
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of items. */
83
+ (0, _i18n._n)('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
84
+ }
85
+ createSuccessNotice(successMessage, {
86
+ type: 'snackbar',
87
+ id: 'move-to-trash-action'
88
+ });
89
+ } else {
90
+ // If there was at least one failure.
91
+ let errorMessage;
92
+ // If we were trying to delete a single item.
93
+ if (promiseResult.length === 1) {
94
+ const typedError = promiseResult[0];
95
+ if (typedError.reason?.message) {
96
+ errorMessage = typedError.reason.message;
97
+ } else {
98
+ errorMessage = (0, _i18n.__)('An error occurred while moving the item to the trash.');
99
+ }
100
+ // If we were trying to delete multiple items.
101
+ } else {
102
+ const errorMessages = new Set();
103
+ const failedPromises = promiseResult.filter(({
104
+ status
105
+ }) => status === 'rejected');
106
+ for (const failedPromise of failedPromises) {
107
+ const typedError = failedPromise;
108
+ if (typedError.reason?.message) {
109
+ errorMessages.add(typedError.reason.message);
110
+ }
111
+ }
112
+ if (errorMessages.size === 0) {
113
+ errorMessage = (0, _i18n.__)('An error occurred while moving the items to the trash.');
114
+ } else if (errorMessages.size === 1) {
115
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
116
+ (0, _i18n.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
117
+ } else {
118
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
119
+ (0, _i18n.__)('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
120
+ }
121
+ }
122
+ createErrorNotice(errorMessage, {
123
+ type: 'snackbar'
124
+ });
125
+ }
126
+ if (onActionPerformed) {
127
+ onActionPerformed(items);
128
+ }
129
+ setIsBusy(false);
130
+ closeModal?.();
131
+ },
132
+ isBusy: isBusy,
133
+ disabled: isBusy,
134
+ accessibleWhenDisabled: true,
135
+ children: (0, _i18n._x)('Trash', 'verb')
136
+ })]
137
+ })]
138
+ });
139
+ }
140
+ };
141
+ var _default = exports.default = trashPost;
142
+ //# sourceMappingURL=trash-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_components","_utils","_jsxRuntime","trashPost","id","label","__","isPrimary","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","getItemTitle","_n","__experimentalHStack","justify","Button","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_x","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\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';\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 trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: 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\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\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{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 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 items (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 move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\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</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>\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 promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\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 item'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( items[ 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 = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\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: 'move-to-trash-action',\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 least 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 delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.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 item 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 delete multiple items.\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\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.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\ttypedError.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 items 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 item 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 items 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}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\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( items );\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>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\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 trashPost;\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;AACA,IAAAM,WAAA,GAAAN,OAAA;AAWA,IAAAO,MAAA,GAAAP,OAAA;AAAiE,IAAAQ,WAAA,GAAAR,OAAA;AApBjE;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMS,SAAwC,GAAG;EAChDC,EAAE,EAAE,eAAe;EACnBC,KAAK,EAAE,IAAAC,QAAE,EAAE,eAAgB,CAAC;EAC5BC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,YAAK;EACXC,UAAUA,CAAEC,IAAI,EAAG;IAClB,IAAK,IAAAC,+BAAwB,EAAED,IAAK,CAAC,IAAIA,IAAI,CAACE,IAAI,KAAK,UAAU,EAAG;MACnE,OAAO,KAAK;IACb;IAEA,OACC,CAAC,CAAEF,IAAI,CAACG,MAAM,IACd,CAAE,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B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBwB,QAAQ,EAAGxB,MAAQ;UACnByB,sBAAsB;UAAAb,QAAA,EAEpB,IAAAkC,QAAE,EAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatE,SAAS","ignoreList":[]}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getItemTitle = getItemTitle;
7
+ exports.isTemplate = isTemplate;
7
8
  exports.isTemplateOrTemplatePart = isTemplateOrTemplatePart;
9
+ exports.isTemplatePart = isTemplatePart;
8
10
  exports.isTemplateRemovable = isTemplateRemovable;
9
11
  var _htmlEntities = require("@wordpress/html-entities");
10
12
  var _constants = require("../../store/constants");
@@ -16,6 +18,12 @@ var _constants = require("../../store/constants");
16
18
  * Internal dependencies
17
19
  */
18
20
 
21
+ function isTemplate(post) {
22
+ return post.type === _constants.TEMPLATE_POST_TYPE;
23
+ }
24
+ function isTemplatePart(post) {
25
+ return post.type === _constants.TEMPLATE_PART_POST_TYPE;
26
+ }
19
27
  function isTemplateOrTemplatePart(p) {
20
28
  return p.type === _constants.TEMPLATE_POST_TYPE || p.type === _constants.TEMPLATE_PART_POST_TYPE;
21
29
  }
@@ -45,6 +53,6 @@ function isTemplateRemovable(template) {
45
53
  // In patterns list page we map the templates parts to a different object
46
54
  // than the one returned from the endpoint. This is why we need to check for
47
55
  // two props whether is custom or has a theme file.
48
- return [template.source, template.source].includes(_constants.TEMPLATE_ORIGINS.custom) && !template.has_theme_file;
56
+ return [template.source, template.source].includes(_constants.TEMPLATE_ORIGINS.custom) && !Boolean(template.type === 'wp_template' && template?.plugin) && !template.has_theme_file;
49
57
  }
50
58
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_htmlEntities","require","_constants","isTemplateOrTemplatePart","p","type","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","getItemTitle","item","title","decodeEntities","rendered","raw","isTemplateRemovable","template","source","includes","TEMPLATE_ORIGINS","custom","has_theme_file"],"sources":["@wordpress/editor/src/dataviews/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_ORIGINS,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nimport type { Post, TemplateOrTemplatePart } from '../types';\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is TemplateOrTemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\n}\n\n/**\n * Check if a template is removable.\n *\n * @param template The template entity to check.\n * @return Whether the template is removable.\n */\nexport function isTemplateRemovable( template: TemplateOrTemplatePart ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t// In patterns list page we map the templates parts to a different object\n\t// than the one returned from the endpoint. This is why we need to check for\n\t// two props whether is custom or has a theme file.\n\treturn (\n\t\t[ template.source, template.source ].includes(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) && ! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AASO,SAASE,wBAAwBA,CACvCC,CAAO,EACuB;EAC9B,OAAOA,CAAC,CAACC,IAAI,KAAKC,6BAAkB,IAAIF,CAAC,CAACC,IAAI,KAAKE,kCAAuB;AAC3E;AAEO,SAASC,YAAYA,CAAEC,IAAU,EAAG;EAC1C,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,IAAK,UAAU,IAAID,IAAI,CAACC,KAAK,EAAG;IAC/B,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACE,QAAS,CAAC;EAC7C;EACA,IAAK,KAAK,IAAIH,IAAI,CAACC,KAAK,EAAG;IAC1B,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACG,GAAI,CAAC;EACxC;EACA,OAAO,EAAE;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAEC,QAAgC,EAAG;EACvE,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA;EACA;EACA,OACC,CAAEA,QAAQ,CAACC,MAAM,EAAED,QAAQ,CAACC,MAAM,CAAE,CAACC,QAAQ,CAC5CC,2BAAgB,CAACC,MAClB,CAAC,IAAI,CAAEJ,QAAQ,CAACK,cAAc;AAEhC","ignoreList":[]}
1
+ {"version":3,"names":["_htmlEntities","require","_constants","isTemplate","post","type","TEMPLATE_POST_TYPE","isTemplatePart","TEMPLATE_PART_POST_TYPE","isTemplateOrTemplatePart","p","getItemTitle","item","title","decodeEntities","rendered","raw","isTemplateRemovable","template","source","includes","TEMPLATE_ORIGINS","custom","Boolean","plugin","has_theme_file"],"sources":["@wordpress/editor/src/dataviews/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_ORIGINS,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === TEMPLATE_POST_TYPE;\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\n}\n\n/**\n * Check if a template is removable.\n *\n * @param template The template entity to check.\n * @return Whether the template is removable.\n */\nexport function isTemplateRemovable( template: Template | TemplatePart ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t// In patterns list page we map the templates parts to a different object\n\t// than the one returned from the endpoint. This is why we need to check for\n\t// two props whether is custom or has a theme file.\n\treturn (\n\t\t[ template.source, template.source ].includes(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AASO,SAASE,UAAUA,CAAEC,IAAU,EAAqB;EAC1D,OAAOA,IAAI,CAACC,IAAI,KAAKC,6BAAkB;AACxC;AAEO,SAASC,cAAcA,CAAEH,IAAU,EAAyB;EAClE,OAAOA,IAAI,CAACC,IAAI,KAAKG,kCAAuB;AAC7C;AAEO,SAASC,wBAAwBA,CACvCC,CAAO,EACwB;EAC/B,OAAOA,CAAC,CAACL,IAAI,KAAKC,6BAAkB,IAAII,CAAC,CAACL,IAAI,KAAKG,kCAAuB;AAC3E;AAEO,SAASG,YAAYA,CAAEC,IAAU,EAAG;EAC1C,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,IAAK,UAAU,IAAID,IAAI,CAACC,KAAK,EAAG;IAC/B,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACE,QAAS,CAAC;EAC7C;EACA,IAAK,KAAK,IAAIH,IAAI,CAACC,KAAK,EAAG;IAC1B,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACG,GAAI,CAAC;EACxC;EACA,OAAO,EAAE;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAEC,QAAiC,EAAG;EACxE,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA;EACA;EACA,OACC,CAAEA,QAAQ,CAACC,MAAM,EAAED,QAAQ,CAACC,MAAM,CAAE,CAACC,QAAQ,CAC5CC,2BAAgB,CAACC,MAClB,CAAC,IACD,CAAEC,OAAO,CAAEL,QAAQ,CAACb,IAAI,KAAK,aAAa,IAAIa,QAAQ,EAAEM,MAAO,CAAC,IAChE,CAAEN,QAAQ,CAACO,cAAc;AAE3B","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _url = require("@wordpress/url");
8
+ var _i18n = require("@wordpress/i18n");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+
17
+ const viewPostRevisions = {
18
+ id: 'view-post-revisions',
19
+ context: 'list',
20
+ label(items) {
21
+ var _items$0$_links$versi;
22
+ const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
23
+ return (0, _i18n.sprintf)( /* translators: %s: number of revisions */
24
+ (0, _i18n.__)('View revisions (%s)'), revisionsCount);
25
+ },
26
+ isEligible(post) {
27
+ var _post$_links$predeces, _post$_links$version;
28
+ if (post.status === 'trash') {
29
+ return false;
30
+ }
31
+ const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
32
+ const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
33
+ return !!lastRevisionId && revisionsCount > 1;
34
+ },
35
+ callback(posts, {
36
+ onActionPerformed
37
+ }) {
38
+ const post = posts[0];
39
+ const href = (0, _url.addQueryArgs)('revision.php', {
40
+ revision: post?._links?.['predecessor-version']?.[0]?.id
41
+ });
42
+ document.location.href = href;
43
+ if (onActionPerformed) {
44
+ onActionPerformed(posts);
45
+ }
46
+ }
47
+ };
48
+ var _default = exports.default = viewPostRevisions;
49
+ //# sourceMappingURL=view-post-revisions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_url","require","_i18n","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","sprintf","__","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","addQueryArgs","revision","document","location","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/view-post-revisions.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Post } from '../types';\n\nconst viewPostRevisions: Action< Post > = {\n\tid: 'view-post-revisions',\n\tcontext: 'list',\n\tlabel( items ) {\n\t\tconst revisionsCount =\n\t\t\titems[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn sprintf(\n\t\t\t/* translators: %s: number of revisions */\n\t\t\t__( 'View revisions (%s)' ),\n\t\t\trevisionsCount\n\t\t);\n\t},\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 default viewPostRevisions;\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,iBAAiC,GAAG;EACzCC,EAAE,EAAE,qBAAqB;EACzBC,OAAO,EAAE,MAAM;EACfC,KAAKA,CAAEC,KAAK,EAAG;IAAA,IAAAC,qBAAA;IACd,MAAMC,cAAc,IAAAD,qBAAA,GACnBD,KAAK,CAAE,CAAC,CAAE,CAACG,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,CAAC;IAC5D,OAAO,IAAAI,aAAO,GACb;IACA,IAAAC,QAAE,EAAE,qBAAsB,CAAC,EAC3BJ,cACD,CAAC;EACF,CAAC;EACDK,UAAUA,CAAEC,IAAI,EAAG;IAAA,IAAAC,qBAAA,EAAAC,oBAAA;IAClB,IAAKF,IAAI,CAACG,MAAM,KAAK,OAAO,EAAG;MAC9B,OAAO,KAAK;IACb;IACA,MAAMC,cAAc,IAAAH,qBAAA,GACnBD,IAAI,EAAEL,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN,EAAE,cAAAY,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAMP,cAAc,IAAAQ,oBAAA,GACnBF,IAAI,EAAEL,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAM,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAO,CAAC,CAAEE,cAAc,IAAIV,cAAc,GAAG,CAAC;EAC/C,CAAC;EACDW,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMP,IAAI,GAAGM,KAAK,CAAE,CAAC,CAAE;IACvB,MAAME,IAAI,GAAG,IAAAC,iBAAY,EAAE,cAAc,EAAE;MAC1CC,QAAQ,EAAEV,IAAI,EAAEL,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN;IAC3D,CAAE,CAAC;IACHsB,QAAQ,CAACC,QAAQ,CAACJ,IAAI,GAAGA,IAAI;IAC7B,IAAKD,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3B,iBAAiB","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@wordpress/icons");
8
+ var _i18n = require("@wordpress/i18n");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+
17
+ const viewPost = {
18
+ id: 'view-post',
19
+ label: (0, _i18n.__)('View'),
20
+ isPrimary: true,
21
+ icon: _icons.external,
22
+ isEligible(post) {
23
+ return post.status !== 'trash';
24
+ },
25
+ callback(posts, {
26
+ onActionPerformed
27
+ }) {
28
+ const post = posts[0];
29
+ window.open(post?.link, '_blank');
30
+ if (onActionPerformed) {
31
+ onActionPerformed(posts);
32
+ }
33
+ }
34
+ };
35
+ var _default = exports.default = viewPost;
36
+ //# sourceMappingURL=view-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_icons","require","_i18n","viewPost","id","label","__","isPrimary","icon","external","isEligible","post","status","callback","posts","onActionPerformed","window","open","link","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/view-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\n\nconst viewPost: Action< BasePost > = {\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 default viewPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,eAAQ;EACdC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOA,IAAI,CAACC,MAAM,KAAK,OAAO;EAC/B,CAAC;EACDC,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMJ,IAAI,GAAGG,KAAK,CAAE,CAAC,CAAE;IACvBE,MAAM,CAACC,IAAI,CAAEN,IAAI,EAAEO,IAAI,EAAE,QAAS,CAAC;IACnC,IAAKH,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalB,QAAQ","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.titleField = exports.orderField = void 0;
7
+ var _i18n = require("@wordpress/i18n");
8
+ var _utils = require("../actions/utils");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+
17
+ const titleField = exports.titleField = {
18
+ type: 'text',
19
+ id: 'title',
20
+ label: (0, _i18n.__)('Title'),
21
+ placeholder: (0, _i18n.__)('No title'),
22
+ getValue: ({
23
+ item
24
+ }) => (0, _utils.getItemTitle)(item)
25
+ };
26
+ const orderField = exports.orderField = {
27
+ type: 'integer',
28
+ id: 'menu_order',
29
+ label: (0, _i18n.__)('Order'),
30
+ description: (0, _i18n.__)('Determines the order of pages.')
31
+ };
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_utils","titleField","exports","type","id","label","__","placeholder","getValue","item","getItemTitle","orderField","description"],"sources":["@wordpress/editor/src/dataviews/fields/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\nimport { getItemTitle } from '../actions/utils';\n\nexport const titleField: Field< BasePost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n};\n\nexport const orderField: Field< BasePost > = {\n\ttype: 'integer',\n\tid: 'menu_order',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIO,MAAME,UAA6B,GAAAC,OAAA,CAAAD,UAAA,GAAG;EAC5CE,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,UAAW,CAAC;EAC7BE,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAM,IAAAC,mBAAY,EAAED,IAAK;AAC9C,CAAC;AAEM,MAAME,UAA6B,GAAAT,OAAA,CAAAS,UAAA,GAAG;EAC5CR,IAAI,EAAE,SAAS;EACfC,EAAE,EAAE,YAAY;EAChBC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBM,WAAW,EAAE,IAAAN,QAAE,EAAE,gCAAiC;AACnD,CAAC","ignoreList":[]}
@@ -1,14 +1,38 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.registerEntityAction = registerEntityAction;
8
+ exports.registerPostTypeActions = void 0;
9
+ exports.setIsReady = setIsReady;
7
10
  exports.unregisterEntityAction = unregisterEntityAction;
11
+ var _coreData = require("@wordpress/core-data");
12
+ var _hooks = require("@wordpress/hooks");
13
+ var _deletePost = _interopRequireDefault(require("../actions/delete-post"));
14
+ var _duplicatePattern = _interopRequireDefault(require("../actions/duplicate-pattern"));
15
+ var _duplicateTemplatePart = _interopRequireDefault(require("../actions/duplicate-template-part"));
16
+ var _exportPattern = _interopRequireDefault(require("../actions/export-pattern"));
17
+ var _resetPost = _interopRequireDefault(require("../actions/reset-post"));
18
+ var _trashPost = _interopRequireDefault(require("../actions/trash-post"));
19
+ var _permanentlyDeletePost = _interopRequireDefault(require("../actions/permanently-delete-post"));
20
+ var _renamePost = _interopRequireDefault(require("../actions/rename-post"));
21
+ var _reorderPage = _interopRequireDefault(require("../actions/reorder-page"));
22
+ var _restorePost = _interopRequireDefault(require("../actions/restore-post"));
23
+ var _store = require("../../store");
24
+ var _lockUnlock = require("../../lock-unlock");
25
+ var _duplicatePost = _interopRequireDefault(require("../actions/duplicate-post"));
26
+ var _viewPostRevisions = _interopRequireDefault(require("../actions/view-post-revisions"));
27
+ var _viewPost = _interopRequireDefault(require("../actions/view-post"));
8
28
  /**
9
29
  * WordPress dependencies
10
30
  */
11
31
 
32
+ /**
33
+ * Internal dependencies
34
+ */
35
+
12
36
  function registerEntityAction(kind, name, config) {
13
37
  return {
14
38
  type: 'REGISTER_ENTITY_ACTION',
@@ -25,4 +49,39 @@ function unregisterEntityAction(kind, name, actionId) {
25
49
  actionId
26
50
  };
27
51
  }
52
+ function setIsReady(kind, name) {
53
+ return {
54
+ type: 'SET_IS_READY',
55
+ kind,
56
+ name
57
+ };
58
+ }
59
+ const registerPostTypeActions = postType => async ({
60
+ registry
61
+ }) => {
62
+ const isReady = (0, _lockUnlock.unlock)(registry.select(_store.store)).isEntityReady('postType', postType);
63
+ if (isReady) {
64
+ return;
65
+ }
66
+ (0, _lockUnlock.unlock)(registry.dispatch(_store.store)).setIsReady('postType', postType);
67
+ const postTypeConfig = await registry.resolveSelect(_coreData.store).getPostType(postType);
68
+ const canCreate = await registry.resolveSelect(_coreData.store).canUser('create', {
69
+ kind: 'postType',
70
+ name: postType
71
+ });
72
+ const currentTheme = await registry.resolveSelect(_coreData.store).getCurrentTheme();
73
+ const actions = [postTypeConfig.viewable ? _viewPost.default : undefined, !!postTypeConfig?.supports?.revisions ? _viewPostRevisions.default : undefined,
74
+ // @ts-ignore
75
+ globalThis.IS_GUTENBERG_PLUGIN ? !['wp_template', 'wp_block', 'wp_template_part'].includes(postTypeConfig.slug) && canCreate && _duplicatePost.default : undefined, postTypeConfig.slug === 'wp_template_part' && canCreate && currentTheme?.is_block_theme ? _duplicateTemplatePart.default : undefined, canCreate && postTypeConfig.slug === 'wp_block' ? _duplicatePattern.default : undefined, postTypeConfig.supports?.title ? _renamePost.default : undefined, postTypeConfig?.supports?.['page-attributes'] ? _reorderPage.default : undefined, postTypeConfig.slug === 'wp_block' ? _exportPattern.default : undefined, _resetPost.default, _restorePost.default, _deletePost.default, _trashPost.default, _permanentlyDeletePost.default];
76
+ registry.batch(() => {
77
+ actions.forEach(action => {
78
+ if (!action) {
79
+ return;
80
+ }
81
+ (0, _lockUnlock.unlock)(registry.dispatch(_store.store)).registerEntityAction('postType', postType, action);
82
+ });
83
+ });
84
+ (0, _hooks.doAction)('core.registerPostTypeActions', postType);
85
+ };
86
+ exports.registerPostTypeActions = registerPostTypeActions;
28
87
  //# sourceMappingURL=private-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Action } from '@wordpress/dataviews';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAGO,SAASA,oBAAoBA,CACnCC,IAAY,EACZC,IAAY,EACZC,MAAsB,EACrB;EACD,OAAO;IACNC,IAAI,EAAE,wBAAiC;IACvCH,IAAI;IACJC,IAAI;IACJC;EACD,CAAC;AACF;AAEO,SAASE,sBAAsBA,CACrCJ,IAAY,EACZC,IAAY,EACZI,QAAgB,EACf;EACD,OAAO;IACNF,IAAI,EAAE,0BAAmC;IACzCH,IAAI;IACJC,IAAI;IACJI;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_hooks","_deletePost","_interopRequireDefault","_duplicatePattern","_duplicateTemplatePart","_exportPattern","_resetPost","_trashPost","_permanentlyDeletePost","_renamePost","_reorderPage","_restorePost","_store","_lockUnlock","_duplicatePost","_viewPostRevisions","_viewPost","registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId","setIsReady","registerPostTypeActions","postType","registry","isReady","unlock","select","editorStore","isEntityReady","dispatch","postTypeConfig","resolveSelect","coreStore","getPostType","canCreate","canUser","currentTheme","getCurrentTheme","actions","viewable","viewPost","undefined","supports","revisions","viewPostRevisions","globalThis","IS_GUTENBERG_PLUGIN","includes","slug","duplicatePost","is_block_theme","duplicateTemplatePart","duplicatePattern","title","renamePost","reorderPage","exportPattern","resetPost","restorePost","deletePost","trashPost","permanentlyDeletePost","batch","forEach","action","doAction","exports"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport deletePost from '../actions/delete-post';\nimport duplicatePattern from '../actions/duplicate-pattern';\nimport duplicateTemplatePart from '../actions/duplicate-template-part';\nimport exportPattern from '../actions/export-pattern';\nimport resetPost from '../actions/reset-post';\nimport trashPost from '../actions/trash-post';\nimport permanentlyDeletePost from '../actions/permanently-delete-post';\nimport renamePost from '../actions/rename-post';\nimport reorderPage from '../actions/reorder-page';\nimport restorePost from '../actions/restore-post';\nimport type { PostType } from '../types';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport duplicatePost from '../actions/duplicate-post';\nimport viewPostRevisions from '../actions/view-post-revisions';\nimport viewPost from '../actions/view-post';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeActions =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig?.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! [ 'wp_template', 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\t\t\tpostTypeConfig.slug\n\t\t\t\t ) &&\n\t\t\t\t canCreate &&\n\t\t\t\t duplicatePost\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig?.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\tresetPost,\n\t\t\trestorePost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t];\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tif ( ! action ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeActions', postType );\n\t};\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,sBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,cAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,UAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,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AAK,CAAE,MAAM;IACrBxB,OAAO,CAACyB,OAAO,CAAIC,MAAM,IAAM;MAC9B,IAAK,CAAEA,MAAM,EAAG;QACf;MACD;MACA,IAAAvC,kBAAM,EAAEF,QAAQ,CAACM,QAAQ,CAAEF,YAAY,CAAE,CAAC,CAACd,oBAAoB,CAC9D,UAAU,EACVS,QAAQ,EACR0C,MACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,IAAAC,eAAQ,EAAE,8BAA8B,EAAE3C,QAAS,CAAC;AACrD,CAAC;AAAC4C,OAAA,CAAA7C,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -3,18 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getEntityActions = void 0;
7
- var _data = require("@wordpress/data");
8
- /**
9
- * WordPress dependencies
10
- */
11
-
6
+ exports.getEntityActions = getEntityActions;
7
+ exports.isEntityReady = isEntityReady;
12
8
  /**
13
9
  * Internal dependencies
14
10
  */
15
11
 
16
- const getEntityActions = exports.getEntityActions = (0, _data.createSelector)((state, kind, name) => {
17
- var _state$actions$kind$n, _state$actions$kind$;
18
- return [...((_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : []), ...((_state$actions$kind$ = state.actions[kind]?.['*']) !== null && _state$actions$kind$ !== void 0 ? _state$actions$kind$ : [])];
19
- }, (state, kind, name) => [state.actions[kind]?.[name], state.actions[kind]?.['*']]);
12
+ const EMPTY_ARRAY = [];
13
+ function getEntityActions(state, kind, name) {
14
+ var _state$actions$kind$n;
15
+ return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : EMPTY_ARRAY;
16
+ }
17
+ function isEntityReady(state, kind, name) {
18
+ return state.isReady[kind]?.[name];
19
+ }
20
20
  //# sourceMappingURL=private-selectors.js.map