@wordpress/fields 0.0.2

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 (165) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE.md +788 -0
  3. package/README.md +73 -0
  4. package/build/actions/base-post/duplicate-post.js +146 -0
  5. package/build/actions/base-post/duplicate-post.js.map +1 -0
  6. package/build/actions/base-post/duplicate-post.native.js +9 -0
  7. package/build/actions/base-post/duplicate-post.native.js.map +1 -0
  8. package/build/actions/base-post/index.js +42 -0
  9. package/build/actions/base-post/index.js.map +1 -0
  10. package/build/actions/base-post/reorder-page.js +116 -0
  11. package/build/actions/base-post/reorder-page.js.map +1 -0
  12. package/build/actions/base-post/reorder-page.native.js +9 -0
  13. package/build/actions/base-post/reorder-page.native.js.map +1 -0
  14. package/build/actions/base-post/view-post.js +36 -0
  15. package/build/actions/base-post/view-post.js.map +1 -0
  16. package/build/actions/common/index.js +21 -0
  17. package/build/actions/common/index.js.map +1 -0
  18. package/build/actions/common/permanently-delete-post.js +109 -0
  19. package/build/actions/common/permanently-delete-post.js.map +1 -0
  20. package/build/actions/common/view-post-revisions.js +49 -0
  21. package/build/actions/common/view-post-revisions.js.map +1 -0
  22. package/build/actions/index.js +39 -0
  23. package/build/actions/index.js.map +1 -0
  24. package/build/actions/pattern/duplicate-pattern.js +48 -0
  25. package/build/actions/pattern/duplicate-pattern.js.map +1 -0
  26. package/build/actions/pattern/export-pattern.js +57 -0
  27. package/build/actions/pattern/export-pattern.js.map +1 -0
  28. package/build/actions/pattern/export-pattern.native.js +9 -0
  29. package/build/actions/pattern/export-pattern.native.js.map +1 -0
  30. package/build/actions/pattern/index.js +28 -0
  31. package/build/actions/pattern/index.js.map +1 -0
  32. package/build/actions/utils.js +65 -0
  33. package/build/actions/utils.js.map +1 -0
  34. package/build/fields/index.js +21 -0
  35. package/build/fields/index.js.map +1 -0
  36. package/build/fields/order/index.js +23 -0
  37. package/build/fields/order/index.js.map +1 -0
  38. package/build/fields/title/index.js +27 -0
  39. package/build/fields/title/index.js.map +1 -0
  40. package/build/index.js +28 -0
  41. package/build/index.js.map +1 -0
  42. package/build/index.native.js +28 -0
  43. package/build/index.native.js.map +1 -0
  44. package/build/lock-unlock.js +18 -0
  45. package/build/lock-unlock.js.map +1 -0
  46. package/build/types.js +6 -0
  47. package/build/types.js.map +1 -0
  48. package/build/wordpress-editor.d.js +2 -0
  49. package/build/wordpress-editor.d.js.map +1 -0
  50. package/build-module/actions/base-post/duplicate-post.js +139 -0
  51. package/build-module/actions/base-post/duplicate-post.js.map +1 -0
  52. package/build-module/actions/base-post/duplicate-post.native.js +3 -0
  53. package/build-module/actions/base-post/duplicate-post.native.js.map +1 -0
  54. package/build-module/actions/base-post/index.js +6 -0
  55. package/build-module/actions/base-post/index.js.map +1 -0
  56. package/build-module/actions/base-post/reorder-page.js +111 -0
  57. package/build-module/actions/base-post/reorder-page.js.map +1 -0
  58. package/build-module/actions/base-post/reorder-page.native.js +3 -0
  59. package/build-module/actions/base-post/reorder-page.native.js.map +1 -0
  60. package/build-module/actions/base-post/view-post.js +30 -0
  61. package/build-module/actions/base-post/view-post.js.map +1 -0
  62. package/build-module/actions/common/index.js +3 -0
  63. package/build-module/actions/common/index.js.map +1 -0
  64. package/build-module/actions/common/permanently-delete-post.js +102 -0
  65. package/build-module/actions/common/permanently-delete-post.js.map +1 -0
  66. package/build-module/actions/common/view-post-revisions.js +43 -0
  67. package/build-module/actions/common/view-post-revisions.js.map +1 -0
  68. package/build-module/actions/index.js +4 -0
  69. package/build-module/actions/index.js.map +1 -0
  70. package/build-module/actions/pattern/duplicate-pattern.js +39 -0
  71. package/build-module/actions/pattern/duplicate-pattern.js.map +1 -0
  72. package/build-module/actions/pattern/export-pattern.js +51 -0
  73. package/build-module/actions/pattern/export-pattern.js.map +1 -0
  74. package/build-module/actions/pattern/export-pattern.native.js +3 -0
  75. package/build-module/actions/pattern/export-pattern.native.js.map +1 -0
  76. package/build-module/actions/pattern/index.js +4 -0
  77. package/build-module/actions/pattern/index.js.map +1 -0
  78. package/build-module/actions/utils.js +54 -0
  79. package/build-module/actions/utils.js.map +1 -0
  80. package/build-module/fields/index.js +3 -0
  81. package/build-module/fields/index.js.map +1 -0
  82. package/build-module/fields/order/index.js +17 -0
  83. package/build-module/fields/order/index.js.map +1 -0
  84. package/build-module/fields/title/index.js +22 -0
  85. package/build-module/fields/title/index.js.map +1 -0
  86. package/build-module/index.js +3 -0
  87. package/build-module/index.js.map +1 -0
  88. package/build-module/index.native.js +3 -0
  89. package/build-module/index.native.js.map +1 -0
  90. package/build-module/lock-unlock.js +9 -0
  91. package/build-module/lock-unlock.js.map +1 -0
  92. package/build-module/types.js +2 -0
  93. package/build-module/types.js.map +1 -0
  94. package/build-module/wordpress-editor.d.js +2 -0
  95. package/build-module/wordpress-editor.d.js.map +1 -0
  96. package/build-types/actions/base-post/duplicate-post.d.ts +5 -0
  97. package/build-types/actions/base-post/duplicate-post.d.ts.map +1 -0
  98. package/build-types/actions/base-post/duplicate-post.native.d.ts +3 -0
  99. package/build-types/actions/base-post/duplicate-post.native.d.ts.map +1 -0
  100. package/build-types/actions/base-post/index.d.ts +6 -0
  101. package/build-types/actions/base-post/index.d.ts.map +1 -0
  102. package/build-types/actions/base-post/reorder-page.d.ts +8 -0
  103. package/build-types/actions/base-post/reorder-page.d.ts.map +1 -0
  104. package/build-types/actions/base-post/reorder-page.native.d.ts +3 -0
  105. package/build-types/actions/base-post/reorder-page.native.d.ts.map +1 -0
  106. package/build-types/actions/base-post/view-post.d.ts +8 -0
  107. package/build-types/actions/base-post/view-post.d.ts.map +1 -0
  108. package/build-types/actions/common/index.d.ts +3 -0
  109. package/build-types/actions/common/index.d.ts.map +1 -0
  110. package/build-types/actions/common/permanently-delete-post.d.ts +5 -0
  111. package/build-types/actions/common/permanently-delete-post.d.ts.map +1 -0
  112. package/build-types/actions/common/view-post-revisions.d.ts +8 -0
  113. package/build-types/actions/common/view-post-revisions.d.ts.map +1 -0
  114. package/build-types/actions/index.d.ts +4 -0
  115. package/build-types/actions/index.d.ts.map +1 -0
  116. package/build-types/actions/pattern/duplicate-pattern.d.ts +5 -0
  117. package/build-types/actions/pattern/duplicate-pattern.d.ts.map +1 -0
  118. package/build-types/actions/pattern/export-pattern.d.ts +8 -0
  119. package/build-types/actions/pattern/export-pattern.d.ts.map +1 -0
  120. package/build-types/actions/pattern/export-pattern.native.d.ts +3 -0
  121. package/build-types/actions/pattern/export-pattern.native.d.ts.map +1 -0
  122. package/build-types/actions/pattern/index.d.ts +4 -0
  123. package/build-types/actions/pattern/index.d.ts.map +1 -0
  124. package/build-types/actions/utils.d.ts +23 -0
  125. package/build-types/actions/utils.d.ts.map +1 -0
  126. package/build-types/fields/index.d.ts +3 -0
  127. package/build-types/fields/index.d.ts.map +1 -0
  128. package/build-types/fields/order/index.d.ts +11 -0
  129. package/build-types/fields/order/index.d.ts.map +1 -0
  130. package/build-types/fields/title/index.d.ts +11 -0
  131. package/build-types/fields/title/index.d.ts.map +1 -0
  132. package/build-types/index.d.ts +3 -0
  133. package/build-types/index.d.ts.map +1 -0
  134. package/build-types/index.native.d.ts +3 -0
  135. package/build-types/index.native.d.ts.map +1 -0
  136. package/build-types/lock-unlock.d.ts +2 -0
  137. package/build-types/lock-unlock.d.ts.map +1 -0
  138. package/build-types/types.d.ts +92 -0
  139. package/build-types/types.d.ts.map +1 -0
  140. package/package.json +63 -0
  141. package/src/actions/base-post/duplicate-post.native.tsx +3 -0
  142. package/src/actions/base-post/duplicate-post.tsx +174 -0
  143. package/src/actions/base-post/index.ts +5 -0
  144. package/src/actions/base-post/reorder-page.native.tsx +3 -0
  145. package/src/actions/base-post/reorder-page.tsx +125 -0
  146. package/src/actions/base-post/view-post.tsx +30 -0
  147. package/src/actions/common/index.ts +2 -0
  148. package/src/actions/common/permanently-delete-post.tsx +118 -0
  149. package/src/actions/common/view-post-revisions.tsx +47 -0
  150. package/src/actions/index.ts +3 -0
  151. package/src/actions/pattern/duplicate-pattern.tsx +40 -0
  152. package/src/actions/pattern/export-pattern.native.tsx +3 -0
  153. package/src/actions/pattern/export-pattern.tsx +76 -0
  154. package/src/actions/pattern/index.ts +3 -0
  155. package/src/actions/utils.ts +66 -0
  156. package/src/fields/index.ts +2 -0
  157. package/src/fields/order/index.ts +18 -0
  158. package/src/fields/title/index.ts +21 -0
  159. package/src/index.native.ts +2 -0
  160. package/src/index.ts +2 -0
  161. package/src/lock-unlock.ts +9 -0
  162. package/src/types.ts +85 -0
  163. package/src/wordpress-editor.d.ts +1 -0
  164. package/tsconfig.json +29 -0
  165. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { decodeEntities } from '@wordpress/html-entities';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+ import { __, sprintf, _x } from '@wordpress/i18n';
8
+ import { store as noticesStore } from '@wordpress/notices';
9
+ import { useState } from '@wordpress/element';
10
+ import { DataForm } from '@wordpress/dataviews';
11
+ import { Button, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { titleField } from '../../fields';
16
+ import { getItemTitle } from '../utils';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ const fields = [titleField];
20
+ const formDuplicateAction = {
21
+ fields: ['title']
22
+ };
23
+ const duplicatePost = {
24
+ id: 'duplicate-post',
25
+ label: _x('Duplicate', 'action label'),
26
+ isEligible({
27
+ status
28
+ }) {
29
+ return status !== 'trash';
30
+ },
31
+ RenderModal: ({
32
+ items,
33
+ closeModal,
34
+ onActionPerformed
35
+ }) => {
36
+ const [item, setItem] = useState({
37
+ ...items[0],
38
+ title: sprintf( /* translators: %s: Existing template title */
39
+ __('%s (Copy)'), getItemTitle(items[0]))
40
+ });
41
+ const [isCreatingPage, setIsCreatingPage] = useState(false);
42
+ const {
43
+ saveEntityRecord
44
+ } = useDispatch(coreStore);
45
+ const {
46
+ createSuccessNotice,
47
+ createErrorNotice
48
+ } = useDispatch(noticesStore);
49
+ async function createPage(event) {
50
+ event.preventDefault();
51
+ if (isCreatingPage) {
52
+ return;
53
+ }
54
+ const newItemOject = {
55
+ status: 'draft',
56
+ title: item.title,
57
+ slug: item.title || __('No title'),
58
+ comment_status: item.comment_status,
59
+ content: typeof item.content === 'string' ? item.content : item.content.raw,
60
+ excerpt: typeof item.excerpt === 'string' ? item.excerpt : item.excerpt?.raw,
61
+ meta: item.meta,
62
+ parent: item.parent,
63
+ password: item.password,
64
+ template: item.template,
65
+ format: item.format,
66
+ featured_media: item.featured_media,
67
+ menu_order: item.menu_order,
68
+ ping_status: item.ping_status
69
+ };
70
+ const assignablePropertiesPrefix = 'wp:action-assign-';
71
+ // Get all the properties that the current user is able to assign normally author, categories, tags,
72
+ // and custom taxonomies.
73
+ const assignableProperties = Object.keys(item?._links || {}).filter(property => property.startsWith(assignablePropertiesPrefix)).map(property => property.slice(assignablePropertiesPrefix.length));
74
+ assignableProperties.forEach(property => {
75
+ if (item.hasOwnProperty(property)) {
76
+ // @ts-ignore
77
+ newItemOject[property] = item[property];
78
+ }
79
+ });
80
+ setIsCreatingPage(true);
81
+ try {
82
+ const newItem = await saveEntityRecord('postType', item.type, newItemOject, {
83
+ throwOnError: true
84
+ });
85
+ createSuccessNotice(sprintf(
86
+ // translators: %s: Title of the created template e.g: "Category".
87
+ __('"%s" successfully created.'), decodeEntities(newItem.title?.rendered || item.title)), {
88
+ id: 'duplicate-post-action',
89
+ type: 'snackbar'
90
+ });
91
+ if (onActionPerformed) {
92
+ onActionPerformed([newItem]);
93
+ }
94
+ } catch (error) {
95
+ const typedError = error;
96
+ const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : __('An error occurred while duplicating the page.');
97
+ createErrorNotice(errorMessage, {
98
+ type: 'snackbar'
99
+ });
100
+ } finally {
101
+ setIsCreatingPage(false);
102
+ closeModal?.();
103
+ }
104
+ }
105
+ return /*#__PURE__*/_jsx("form", {
106
+ onSubmit: createPage,
107
+ children: /*#__PURE__*/_jsxs(VStack, {
108
+ spacing: 3,
109
+ children: [/*#__PURE__*/_jsx(DataForm, {
110
+ data: item,
111
+ fields: fields,
112
+ form: formDuplicateAction,
113
+ onChange: changes => setItem(prev => ({
114
+ ...prev,
115
+ ...changes
116
+ }))
117
+ }), /*#__PURE__*/_jsxs(HStack, {
118
+ spacing: 2,
119
+ justify: "end",
120
+ children: [/*#__PURE__*/_jsx(Button, {
121
+ variant: "tertiary",
122
+ onClick: closeModal,
123
+ __next40pxDefaultSize: true,
124
+ children: __('Cancel')
125
+ }), /*#__PURE__*/_jsx(Button, {
126
+ variant: "primary",
127
+ type: "submit",
128
+ isBusy: isCreatingPage,
129
+ "aria-disabled": isCreatingPage,
130
+ __next40pxDefaultSize: true,
131
+ children: _x('Duplicate', 'action label')
132
+ })]
133
+ })]
134
+ })
135
+ });
136
+ }
137
+ };
138
+ export default duplicatePost;
139
+ //# sourceMappingURL=duplicate-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDispatch","decodeEntities","store","coreStore","__","sprintf","_x","noticesStore","useState","DataForm","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","titleField","getItemTitle","jsx","_jsx","jsxs","_jsxs","fields","formDuplicateAction","duplicatePost","id","label","isEligible","status","RenderModal","items","closeModal","onActionPerformed","item","setItem","title","isCreatingPage","setIsCreatingPage","saveEntityRecord","createSuccessNotice","createErrorNotice","createPage","event","preventDefault","newItemOject","slug","comment_status","content","raw","excerpt","meta","parent","password","template","format","featured_media","menu_order","ping_status","assignablePropertiesPrefix","assignableProperties","Object","keys","_links","filter","property","startsWith","map","slice","length","forEach","hasOwnProperty","newItem","type","throwOnError","rendered","error","typedError","errorMessage","message","code","onSubmit","children","spacing","data","form","onChange","changes","prev","justify","variant","onClick","__next40pxDefaultSize","isBusy"],"sources":["@wordpress/fields/src/actions/base-post/duplicate-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport { DataForm } from '@wordpress/dataviews';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { titleField } from '../../fields';\nimport type { BasePost, CoreDataError } from '../../types';\nimport { getItemTitle } from '../utils';\n\nconst fields = [ titleField ];\nconst formDuplicateAction = {\n\tfields: [ 'title' ],\n};\n\nconst duplicatePost: Action< BasePost > = {\n\tid: 'duplicate-post',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ item, setItem ] = useState< BasePost >( {\n\t\t\t...items[ 0 ],\n\t\t\ttitle: sprintf(\n\t\t\t\t/* translators: %s: Existing template title */\n\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t),\n\t\t} );\n\n\t\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function createPage( event: React.FormEvent ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( isCreatingPage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newItemOject = {\n\t\t\t\tstatus: 'draft',\n\t\t\t\ttitle: item.title,\n\t\t\t\tslug: item.title || __( 'No title' ),\n\t\t\t\tcomment_status: item.comment_status,\n\t\t\t\tcontent:\n\t\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t: item.content.raw,\n\t\t\t\texcerpt:\n\t\t\t\t\ttypeof item.excerpt === 'string'\n\t\t\t\t\t\t? item.excerpt\n\t\t\t\t\t\t: item.excerpt?.raw,\n\t\t\t\tmeta: item.meta,\n\t\t\t\tparent: item.parent,\n\t\t\t\tpassword: item.password,\n\t\t\t\ttemplate: item.template,\n\t\t\t\tformat: item.format,\n\t\t\t\tfeatured_media: item.featured_media,\n\t\t\t\tmenu_order: item.menu_order,\n\t\t\t\tping_status: item.ping_status,\n\t\t\t};\n\t\t\tconst assignablePropertiesPrefix = 'wp:action-assign-';\n\t\t\t// Get all the properties that the current user is able to assign normally author, categories, tags,\n\t\t\t// and custom taxonomies.\n\t\t\tconst assignableProperties = Object.keys( item?._links || {} )\n\t\t\t\t.filter( ( property ) =>\n\t\t\t\t\tproperty.startsWith( assignablePropertiesPrefix )\n\t\t\t\t)\n\t\t\t\t.map( ( property ) =>\n\t\t\t\t\tproperty.slice( assignablePropertiesPrefix.length )\n\t\t\t\t);\n\t\t\tassignableProperties.forEach( ( property ) => {\n\t\t\t\tif ( item.hasOwnProperty( property ) ) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnewItemOject[ property ] = item[ property ];\n\t\t\t\t}\n\t\t\t} );\n\t\t\tsetIsCreatingPage( true );\n\t\t\ttry {\n\t\t\t\tconst newItem = await saveEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\titem.type,\n\t\t\t\t\tnewItemOject,\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\tdecodeEntities( newItem.title?.rendered || item.title )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\tonActionPerformed( [ newItem ] );\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: __( 'An error occurred while duplicating the page.' );\n\n\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} finally {\n\t\t\t\tsetIsCreatingPage( false );\n\t\t\t\tcloseModal?.();\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<DataForm\n\t\t\t\t\t\tdata={ item }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ formDuplicateAction }\n\t\t\t\t\t\tonChange={ ( changes ) =>\n\t\t\t\t\t\t\tsetItem( ( prev ) => ( {\n\t\t\t\t\t\t\t\t...prev,\n\t\t\t\t\t\t\t\t...changes,\n\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isC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ourceMappingURL=duplicate-post.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["duplicatePost","undefined"],"sources":["@wordpress/fields/src/actions/base-post/duplicate-post.native.tsx"],"sourcesContent":["const duplicatePost = undefined;\n\nexport default duplicatePost;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGC,SAAS;AAE/B,eAAeD,aAAa","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ export { default as viewPost } from './view-post';
2
+ export { default as reorderPage } from './reorder-page';
3
+ export { default as reorderPageNative } from './reorder-page.native';
4
+ export { default as duplicatePost } from './duplicate-post';
5
+ export { default as duplicatePostNative } from './duplicate-post.native';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","viewPost","reorderPage","reorderPageNative","duplicatePost","duplicatePostNative"],"sources":["@wordpress/fields/src/actions/base-post/index.ts"],"sourcesContent":["export { default as viewPost } from './view-post';\nexport { default as reorderPage } from './reorder-page';\nexport { default as reorderPageNative } from './reorder-page.native';\nexport { default as duplicatePost } from './duplicate-post';\nexport { default as duplicatePostNative } from './duplicate-post.native';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAAQ,QAAQ,aAAa;AACjD,SAASD,OAAO,IAAIE,WAAW,QAAQ,gBAAgB;AACvD,SAASF,OAAO,IAAIG,iBAAiB,QAAQ,uBAAuB;AACpE,SAASH,OAAO,IAAII,aAAa,QAAQ,kBAAkB;AAC3D,SAASJ,OAAO,IAAIK,mBAAmB,QAAQ,yBAAyB","ignoreList":[]}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { store as noticesStore } from '@wordpress/notices';
8
+ import { useState } from '@wordpress/element';
9
+ import { DataForm, isItemValid } from '@wordpress/dataviews';
10
+ import { Button, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { orderField } from '../../fields';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ const fields = [orderField];
20
+ const formOrderAction = {
21
+ fields: ['menu_order']
22
+ };
23
+ function ReorderModal({
24
+ items,
25
+ closeModal,
26
+ onActionPerformed
27
+ }) {
28
+ const [item, setItem] = useState(items[0]);
29
+ const orderInput = item.menu_order;
30
+ const {
31
+ editEntityRecord,
32
+ saveEditedEntityRecord
33
+ } = useDispatch(coreStore);
34
+ const {
35
+ createSuccessNotice,
36
+ createErrorNotice
37
+ } = useDispatch(noticesStore);
38
+ async function onOrder(event) {
39
+ event.preventDefault();
40
+ if (!isItemValid(item, fields, formOrderAction)) {
41
+ return;
42
+ }
43
+ try {
44
+ await editEntityRecord('postType', item.type, item.id, {
45
+ menu_order: orderInput
46
+ });
47
+ closeModal?.();
48
+ // Persist edited entity.
49
+ await saveEditedEntityRecord('postType', item.type, item.id, {
50
+ throwOnError: true
51
+ });
52
+ createSuccessNotice(__('Order updated.'), {
53
+ type: 'snackbar'
54
+ });
55
+ onActionPerformed?.(items);
56
+ } catch (error) {
57
+ const typedError = error;
58
+ const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : __('An error occurred while updating the order');
59
+ createErrorNotice(errorMessage, {
60
+ type: 'snackbar'
61
+ });
62
+ }
63
+ }
64
+ const isSaveDisabled = !isItemValid(item, fields, formOrderAction);
65
+ return /*#__PURE__*/_jsx("form", {
66
+ onSubmit: onOrder,
67
+ children: /*#__PURE__*/_jsxs(VStack, {
68
+ spacing: "5",
69
+ children: [/*#__PURE__*/_jsx("div", {
70
+ children: __('Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.')
71
+ }), /*#__PURE__*/_jsx(DataForm, {
72
+ data: item,
73
+ fields: fields,
74
+ form: formOrderAction,
75
+ onChange: changes => setItem({
76
+ ...item,
77
+ ...changes
78
+ })
79
+ }), /*#__PURE__*/_jsxs(HStack, {
80
+ justify: "right",
81
+ children: [/*#__PURE__*/_jsx(Button, {
82
+ __next40pxDefaultSize: true,
83
+ variant: "tertiary",
84
+ onClick: () => {
85
+ closeModal?.();
86
+ },
87
+ children: __('Cancel')
88
+ }), /*#__PURE__*/_jsx(Button, {
89
+ __next40pxDefaultSize: true,
90
+ variant: "primary",
91
+ type: "submit",
92
+ accessibleWhenDisabled: true,
93
+ disabled: isSaveDisabled,
94
+ children: __('Save')
95
+ })]
96
+ })]
97
+ })
98
+ });
99
+ }
100
+ const reorderPage = {
101
+ id: 'order-pages',
102
+ label: __('Order'),
103
+ isEligible({
104
+ status
105
+ }) {
106
+ return status !== 'trash';
107
+ },
108
+ RenderModal: ReorderModal
109
+ };
110
+ export default reorderPage;
111
+ //# sourceMappingURL=reorder-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDispatch","store","coreStore","__","noticesStore","useState","DataForm","isItemValid","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","orderField","jsx","_jsx","jsxs","_jsxs","fields","formOrderAction","ReorderModal","items","closeModal","onActionPerformed","item","setItem","orderInput","menu_order","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","onOrder","event","preventDefault","type","id","throwOnError","error","typedError","errorMessage","message","code","isSaveDisabled","onSubmit","children","spacing","data","form","onChange","changes","justify","__next40pxDefaultSize","variant","onClick","accessibleWhenDisabled","disabled","reorderPage","label","isEligible","status","RenderModal"],"sources":["@wordpress/fields/src/actions/base-post/reorder-page.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport { DataForm, isItemValid } from '@wordpress/dataviews';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action, RenderModalProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, BasePost } from '../../types';\nimport { orderField } from '../../fields';\n\nconst fields = [ orderField ];\nconst formOrderAction = {\n\tfields: [ 'menu_order' ],\n};\n\nfunction ReorderModal( {\n\titems,\n\tcloseModal,\n\tonActionPerformed,\n}: RenderModalProps< BasePost > ) {\n\tconst [ item, setItem ] = useState( items[ 0 ] );\n\tconst orderInput = item.menu_order;\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function onOrder( event: React.FormEvent ) {\n\t\tevent.preventDefault();\n\n\t\tif ( ! isItemValid( item, fields, formOrderAction ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tmenu_order: orderInput,\n\t\t\t} );\n\t\t\tcloseModal?.();\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\tcreateSuccessNotice( __( 'Order updated.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\tonActionPerformed?.( items );\n\t\t} catch ( error ) {\n\t\t\tconst typedError = error as CoreDataError;\n\t\t\tconst errorMessage =\n\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t? typedError.message\n\t\t\t\t\t: __( 'An error occurred while updating the order' );\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t}\n\tconst isSaveDisabled = ! isItemValid( item, fields, formOrderAction );\n\treturn (\n\t\t<form onSubmit={ onOrder }>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<div>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<DataForm\n\t\t\t\t\tdata={ item }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ formOrderAction }\n\t\t\t\t\tonChange={ ( changes ) =>\n\t\t\t\t\t\tsetItem( {\n\t\t\t\t\t\t\t...item,\n\t\t\t\t\t\t\t...changes,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\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{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isSaveDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nconst reorderPage: Action< BasePost > = {\n\tid: 'order-pages',\n\tlabel: __( 'Order' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tRenderModal: ReorderModal,\n};\n\nexport default reorderPage;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASF,KAAK,IAAIG,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,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AAS;UACjBlB,IAAI,EAAC,QAAQ;UACboB,sBAAsB;UACtBC,QAAQ,EAAGb,cAAgB;UAAAE,QAAA,EAEzB1C,EAAE,CAAE,MAAO;QAAC,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET;AAEA,MAAMsD,WAA+B,GAAG;EACvCrB,EAAE,EAAE,aAAa;EACjBsB,KAAK,EAAEvD,EAAE,CAAE,OAAQ,CAAC;EACpBwD,UAAUA,CAAE;IAAEC;EAAO,CAAC,EAAG;IACxB,OAAOA,MAAM,KAAK,OAAO;EAC1B,CAAC;EACDC,WAAW,EAAEzC;AACd,CAAC;AAED,eAAeqC,WAAW","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ const reorderPage = undefined;
2
+ export default reorderPage;
3
+ //# sourceMappingURL=reorder-page.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["reorderPage","undefined"],"sources":["@wordpress/fields/src/actions/base-post/reorder-page.native.tsx"],"sourcesContent":["const reorderPage = undefined;\n\nexport default reorderPage;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGC,SAAS;AAE7B,eAAeD,WAAW","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { external } from '@wordpress/icons';
5
+ import { _x } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ const viewPost = {
12
+ id: 'view-post',
13
+ label: _x('View', 'verb'),
14
+ isPrimary: true,
15
+ icon: external,
16
+ isEligible(post) {
17
+ return post.status !== 'trash';
18
+ },
19
+ callback(posts, {
20
+ onActionPerformed
21
+ }) {
22
+ const post = posts[0];
23
+ window.open(post?.link, '_blank');
24
+ if (onActionPerformed) {
25
+ onActionPerformed(posts);
26
+ }
27
+ }
28
+ };
29
+ export default viewPost;
30
+ //# sourceMappingURL=view-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["external","_x","viewPost","id","label","isPrimary","icon","isEligible","post","status","callback","posts","onActionPerformed","window","open","link"],"sources":["@wordpress/fields/src/actions/base-post/view-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { _x } 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: _x( 'View', 'verb' ),\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":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;;AAGpC;AACA;AACA;;AAGA,MAAMC,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,MAAO,CAAC;EAC3BI,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEN,QAAQ;EACdO,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;AAED,eAAeT,QAAQ","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export { default as viewPostRevisions } from './view-post-revisions';
2
+ export { default as permanentlyDeletePost } from './permanently-delete-post';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","viewPostRevisions","permanentlyDeletePost"],"sources":["@wordpress/fields/src/actions/common/index.ts"],"sourcesContent":["export { default as viewPostRevisions } from './view-post-revisions';\nexport { default as permanentlyDeletePost } from './permanently-delete-post';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,uBAAuB;AACpE,SAASD,OAAO,IAAIE,qBAAqB,QAAQ,2BAA2B","ignoreList":[]}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as coreStore } from '@wordpress/core-data';
5
+ import { __, sprintf } from '@wordpress/i18n';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+ import { trash } from '@wordpress/icons';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { getItemTitle, isTemplateOrTemplatePart } from '../utils';
13
+ const permanentlyDeletePost = {
14
+ id: 'permanently-delete',
15
+ label: __('Permanently delete'),
16
+ supportsBulk: true,
17
+ icon: trash,
18
+ isEligible(item) {
19
+ if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
20
+ return false;
21
+ }
22
+ const {
23
+ status,
24
+ permissions
25
+ } = item;
26
+ return status === 'trash' && permissions?.delete;
27
+ },
28
+ async callback(posts, {
29
+ registry,
30
+ onActionPerformed
31
+ }) {
32
+ const {
33
+ createSuccessNotice,
34
+ createErrorNotice
35
+ } = registry.dispatch(noticesStore);
36
+ const {
37
+ deleteEntityRecord
38
+ } = registry.dispatch(coreStore);
39
+ const promiseResult = await Promise.allSettled(posts.map(post => {
40
+ return deleteEntityRecord('postType', post.type, post.id, {
41
+ force: true
42
+ }, {
43
+ throwOnError: true
44
+ });
45
+ }));
46
+ // If all the promises were fulfilled with success.
47
+ if (promiseResult.every(({
48
+ status
49
+ }) => status === 'fulfilled')) {
50
+ let successMessage;
51
+ if (promiseResult.length === 1) {
52
+ successMessage = sprintf( /* translators: The posts's title. */
53
+ __('"%s" permanently deleted.'), getItemTitle(posts[0]));
54
+ } else {
55
+ successMessage = __('The items were permanently deleted.');
56
+ }
57
+ createSuccessNotice(successMessage, {
58
+ type: 'snackbar',
59
+ id: 'permanently-delete-post-action'
60
+ });
61
+ onActionPerformed?.(posts);
62
+ } else {
63
+ // If there was at lease one failure.
64
+ let errorMessage;
65
+ // If we were trying to permanently delete a single post.
66
+ if (promiseResult.length === 1) {
67
+ const typedError = promiseResult[0];
68
+ if (typedError.reason?.message) {
69
+ errorMessage = typedError.reason.message;
70
+ } else {
71
+ errorMessage = __('An error occurred while permanently deleting the item.');
72
+ }
73
+ // If we were trying to permanently delete multiple posts
74
+ } else {
75
+ const errorMessages = new Set();
76
+ const failedPromises = promiseResult.filter(({
77
+ status
78
+ }) => status === 'rejected');
79
+ for (const failedPromise of failedPromises) {
80
+ const typedError = failedPromise;
81
+ if (typedError.reason?.message) {
82
+ errorMessages.add(typedError.reason.message);
83
+ }
84
+ }
85
+ if (errorMessages.size === 0) {
86
+ errorMessage = __('An error occurred while permanently deleting the items.');
87
+ } else if (errorMessages.size === 1) {
88
+ errorMessage = sprintf( /* translators: %s: an error message */
89
+ __('An error occurred while permanently deleting the items: %s'), [...errorMessages][0]);
90
+ } else {
91
+ errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
92
+ __('Some errors occurred while permanently deleting the items: %s'), [...errorMessages].join(','));
93
+ }
94
+ }
95
+ createErrorNotice(errorMessage, {
96
+ type: 'snackbar'
97
+ });
98
+ }
99
+ }
100
+ };
101
+ export default permanentlyDeletePost;
102
+ //# sourceMappingURL=permanently-delete-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["store","coreStore","__","sprintf","noticesStore","trash","getItemTitle","isTemplateOrTemplatePart","permanentlyDeletePost","id","label","supportsBulk","icon","isEligible","item","type","status","permissions","delete","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","deleteEntityRecord","promiseResult","Promise","allSettled","map","post","force","throwOnError","every","successMessage","length","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join"],"sources":["@wordpress/fields/src/actions/common/permanently-delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\nimport { trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from '../utils';\nimport type { CoreDataError, PostWithPermissions } from '../../types';\n\nconst permanentlyDeletePost: Action< PostWithPermissions > = {\n\tid: 'permanently-delete',\n\tlabel: __( 'Permanently delete' ),\n\tsupportsBulk: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { status, permissions } = item;\n\t\treturn status === 'trash' && permissions?.delete;\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = registry.dispatch( coreStore );\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ force: true },\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'The items were permanently deleted.' );\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'permanently-delete-post-action',\n\t\t\t} );\n\t\t\tonActionPerformed?.( posts );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to permanently delete a single post.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'An error occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default permanentlyDeletePost;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASH,KAAK,IAAII,YAAY,QAAQ,oBAAoB;AAE1D,SAASC,KAAK,QAAQ,kBAAkB;;AAExC;AACA;AACA;AACA,SAASC,YAAY,EAAEC,wBAAwB,QAAQ,UAAU;AAGjE,MAAMC,qBAAoD,GAAG;EAC5DC,EAAE,EAAE,oBAAoB;EACxBC,KAAK,EAAER,EAAE,CAAE,oBAAqB,CAAC;EACjCS,YAAY,EAAE,IAAI;EAClBC,IAAI,EAAEP,KAAK;EACXQ,UAAUA,CAAEC,IAAI,EAAG;IAClB,IAAKP,wBAAwB,CAAEO,IAAK,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAK,UAAU,EAAG;MACnE,OAAO,KAAK;IACb;IACA,MAAM;MAAEC,MAAM;MAAEC;IAAY,CAAC,GAAGH,IAAI;IACpC,OAAOE,MAAM,KAAK,OAAO,IAAIC,WAAW,EAAEC,MAAM;EACjD,CAAC;EACD,MAAMC,QAAQA,CAAEC,KAAK,EAAE;IAAEC,QAAQ;IAAEC;EAAkB,CAAC,EAAG;IACxD,MAAM;MAAEC,mBAAmB;MAAEC;IAAkB,CAAC,GAC/CH,QAAQ,CAACI,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AAMuC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAAC;QAC/B,MAAMC,cAAc,GAAGhB,aAAa,CAACiB,MAAM,CAC1C,CAAE;UAAE5B;QAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;QACD,KAAM,MAAM6B,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,GAAGnC,EAAE,CAChB,yDACD,CAAC;QACF,CAAC,MAAM,IAAKuC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CACD,4DACD,CAAC,EACD,CAAE,GAAGuC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CACD,+DACD,CAAC,EACD,CAAE,GAAGuC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACAxB,iBAAiB,CAAEa,YAAY,EAAE;QAChCtB,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAED,eAAeP,qBAAqB","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { addQueryArgs } from '@wordpress/url';
5
+ import { __, sprintf } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ const viewPostRevisions = {
12
+ id: 'view-post-revisions',
13
+ context: 'list',
14
+ label(items) {
15
+ var _items$0$_links$versi;
16
+ 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;
17
+ return sprintf( /* translators: %s: number of revisions */
18
+ __('View revisions (%s)'), revisionsCount);
19
+ },
20
+ isEligible(post) {
21
+ var _post$_links$predeces, _post$_links$version;
22
+ if (post.status === 'trash') {
23
+ return false;
24
+ }
25
+ const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
26
+ const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
27
+ return !!lastRevisionId && revisionsCount > 1;
28
+ },
29
+ callback(posts, {
30
+ onActionPerformed
31
+ }) {
32
+ const post = posts[0];
33
+ const href = addQueryArgs('revision.php', {
34
+ revision: post?._links?.['predecessor-version']?.[0]?.id
35
+ });
36
+ document.location.href = href;
37
+ if (onActionPerformed) {
38
+ onActionPerformed(posts);
39
+ }
40
+ }
41
+ };
42
+ export default viewPostRevisions;
43
+ //# sourceMappingURL=view-post-revisions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["addQueryArgs","__","sprintf","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","revision","document","location"],"sources":["@wordpress/fields/src/actions/common/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":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAG7C;AACA;AACA;;AAGA,MAAMC,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,OAAON,OAAO,EACb;IACAD,EAAE,CAAE,qBAAsB,CAAC,EAC3BQ,cACD,CAAC;EACF,CAAC;EACDG,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,EAAEH,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN,EAAE,cAAAU,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAML,cAAc,IAAAM,oBAAA,GACnBF,IAAI,EAAEH,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAI,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAO,CAAC,CAAEE,cAAc,IAAIR,cAAc,GAAG,CAAC;EAC/C,CAAC;EACDS,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMP,IAAI,GAAGM,KAAK,CAAE,CAAC,CAAE;IACvB,MAAME,IAAI,GAAGrB,YAAY,CAAE,cAAc,EAAE;MAC1CsB,QAAQ,EAAET,IAAI,EAAEH,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN;IAC3D,CAAE,CAAC;IACHmB,QAAQ,CAACC,QAAQ,CAACH,IAAI,GAAGA,IAAI;IAC7B,IAAKD,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAED,eAAehB,iBAAiB","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from './base-post';
2
+ export * from './common';
3
+ export * from './pattern';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/fields/src/actions/index.ts"],"sourcesContent":["export * from './base-post';\nexport * from './common';\nexport * from './pattern';\n"],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,WAAW","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { _x } from '@wordpress/i18n';
5
+ // @ts-ignore
6
+ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { unlock } from '../../lock-unlock';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ // Patterns.
13
+ const {
14
+ CreatePatternModalContents,
15
+ useDuplicatePatternProps
16
+ } = unlock(patternsPrivateApis);
17
+ const duplicatePattern = {
18
+ id: 'duplicate-pattern',
19
+ label: _x('Duplicate', 'action label'),
20
+ isEligible: item => item.type !== 'wp_template_part',
21
+ modalHeader: _x('Duplicate pattern', 'action label'),
22
+ RenderModal: ({
23
+ items,
24
+ closeModal
25
+ }) => {
26
+ const [item] = items;
27
+ const duplicatedProps = useDuplicatePatternProps({
28
+ pattern: item,
29
+ onSuccess: () => closeModal?.()
30
+ });
31
+ return /*#__PURE__*/_jsx(CreatePatternModalContents, {
32
+ onClose: closeModal,
33
+ confirmLabel: _x('Duplicate', 'action label'),
34
+ ...duplicatedProps
35
+ });
36
+ }
37
+ };
38
+ export default duplicatePattern;
39
+ //# sourceMappingURL=duplicate-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_x","privateApis","patternsPrivateApis","unlock","jsx","_jsx","CreatePatternModalContents","useDuplicatePatternProps","duplicatePattern","id","label","isEligible","item","type","modalHeader","RenderModal","items","closeModal","duplicatedProps","pattern","onSuccess","onClose","confirmLabel"],"sources":["@wordpress/fields/src/actions/pattern/duplicate-pattern.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n// @ts-ignore\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { Pattern } from '../../types';\n\n// Patterns.\nconst { CreatePatternModalContents, useDuplicatePatternProps } =\n\tunlock( patternsPrivateApis );\n\nconst duplicatePattern: Action< Pattern > = {\n\tid: 'duplicate-pattern',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible: ( item ) => item.type !== 'wp_template_part',\n\tmodalHeader: _x( 'Duplicate pattern', 'action label' ),\n\tRenderModal: ( { items, closeModal } ) => {\n\t\tconst [ item ] = items;\n\t\tconst duplicatedProps = useDuplicatePatternProps( {\n\t\t\tpattern: item,\n\t\t\tonSuccess: () => closeModal?.(),\n\t\t} );\n\t\treturn (\n\t\t\t<CreatePatternModalContents\n\t\t\t\tonClose={ closeModal }\n\t\t\t\tconfirmLabel={ _x( 'Duplicate', 'action label' ) }\n\t\t\t\t{ ...duplicatedProps }\n\t\t\t/>\n\t\t);\n\t},\n};\n\nexport default duplicatePattern;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC;AACA,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AAGxE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG3C;AACA,MAAM;EAAEC,0BAA0B;EAAEC;AAAyB,CAAC,GAC7DJ,MAAM,CAAED,mBAAoB,CAAC;AAE9B,MAAMM,gBAAmC,GAAG;EAC3CC,EAAE,EAAE,mBAAmB;EACvBC,KAAK,EAAEV,EAAE,CAAE,WAAW,EAAE,cAAe,CAAC;EACxCW,UAAU,EAAIC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAK,kBAAkB;EACxDC,WAAW,EAAEd,EAAE,CAAE,mBAAmB,EAAE,cAAe,CAAC;EACtDe,WAAW,EAAEA,CAAE;IAAEC,KAAK;IAAEC;EAAW,CAAC,KAAM;IACzC,MAAM,CAAEL,IAAI,CAAE,GAAGI,KAAK;IACtB,MAAME,eAAe,GAAGX,wBAAwB,CAAE;MACjDY,OAAO,EAAEP,IAAI;MACbQ,SAAS,EAAEA,CAAA,KAAMH,UAAU,GAAG;IAC/B,CAAE,CAAC;IACH,oBACCZ,IAAA,CAACC,0BAA0B;MAC1Be,OAAO,EAAGJ,UAAY;MACtBK,YAAY,EAAGtB,EAAE,CAAE,WAAW,EAAE,cAAe,CAAG;MAAA,GAC7CkB;IAAe,CACpB,CAAC;EAEJ;AACD,CAAC;AAED,eAAeV,gBAAgB","ignoreList":[]}