@wordpress/editor 14.5.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.
- package/CHANGELOG.md +2 -0
- package/build/bindings/post-meta.js +2 -2
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +1 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +17 -4
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +5 -2
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +6 -5
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-actions/actions.js +4 -499
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +8 -17
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +20 -20
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +2 -0
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +4 -0
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-slug/index.js +1 -0
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-url/index.js +6 -5
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +10 -7
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/template-content-panel/index.js +1 -1
- package/build/components/template-content-panel/index.js.map +1 -1
- package/build/dataviews/actions/duplicate-pattern.js +48 -0
- package/build/dataviews/actions/duplicate-pattern.js.map +1 -0
- package/build/dataviews/actions/duplicate-post.js +146 -0
- package/build/dataviews/actions/duplicate-post.js.map +1 -0
- package/build/dataviews/actions/duplicate-post.native.js +9 -0
- package/build/dataviews/actions/duplicate-post.native.js.map +1 -0
- package/build/dataviews/actions/duplicate-template-part.js +67 -0
- package/build/dataviews/actions/duplicate-template-part.js.map +1 -0
- package/build/dataviews/actions/rename-post.js +125 -0
- package/build/dataviews/actions/rename-post.js.map +1 -0
- package/build/dataviews/actions/reorder-page.js +116 -0
- package/build/dataviews/actions/reorder-page.js.map +1 -0
- package/build/dataviews/actions/reorder-page.native.js +9 -0
- package/build/dataviews/actions/reorder-page.native.js.map +1 -0
- package/build/dataviews/actions/reset-post.js +1 -1
- package/build/dataviews/actions/reset-post.js.map +1 -1
- package/build/dataviews/actions/utils.js +9 -1
- package/build/dataviews/actions/utils.js.map +1 -1
- package/build/dataviews/actions/view-post-revisions.js +49 -0
- package/build/dataviews/actions/view-post-revisions.js.map +1 -0
- package/build/dataviews/actions/view-post.js +36 -0
- package/build/dataviews/actions/view-post.js.map +1 -0
- package/build/dataviews/fields/index.js +32 -0
- package/build/dataviews/fields/index.js.map +1 -0
- package/build/dataviews/store/private-actions.js +16 -2
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/dataviews/types.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +1 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/utils/is-template-revertable.js +1 -1
- package/build/store/utils/is-template-revertable.js.map +1 -1
- package/build-module/bindings/post-meta.js +2 -2
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +1 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +17 -4
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +5 -2
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +6 -5
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-actions/actions.js +5 -501
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +8 -17
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +20 -20
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +2 -0
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js +4 -0
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-slug/index.js +1 -0
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-url/index.js +7 -6
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +10 -7
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/template-content-panel/index.js +1 -1
- package/build-module/components/template-content-panel/index.js.map +1 -1
- package/build-module/dataviews/actions/duplicate-pattern.js +39 -0
- package/build-module/dataviews/actions/duplicate-pattern.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-post.js +139 -0
- package/build-module/dataviews/actions/duplicate-post.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-post.native.js +3 -0
- package/build-module/dataviews/actions/duplicate-post.native.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-template-part.js +58 -0
- package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -0
- package/build-module/dataviews/actions/rename-post.js +118 -0
- package/build-module/dataviews/actions/rename-post.js.map +1 -0
- package/build-module/dataviews/actions/reorder-page.js +111 -0
- package/build-module/dataviews/actions/reorder-page.js.map +1 -0
- package/build-module/dataviews/actions/reorder-page.native.js +3 -0
- package/build-module/dataviews/actions/reorder-page.native.js.map +1 -0
- package/build-module/dataviews/actions/reset-post.js +1 -1
- package/build-module/dataviews/actions/reset-post.js.map +1 -1
- package/build-module/dataviews/actions/utils.js +7 -1
- package/build-module/dataviews/actions/utils.js.map +1 -1
- package/build-module/dataviews/actions/view-post-revisions.js +43 -0
- package/build-module/dataviews/actions/view-post-revisions.js.map +1 -0
- package/build-module/dataviews/actions/view-post.js +30 -0
- package/build-module/dataviews/actions/view-post.js.map +1 -0
- package/build-module/dataviews/fields/index.js +26 -0
- package/build-module/dataviews/fields/index.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +16 -2
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/dataviews/types.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +1 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/utils/is-template-revertable.js +1 -1
- package/build-module/store/utils/is-template-revertable.js.map +1 -1
- package/build-style/style-rtl.css +2 -31
- package/build-style/style.css +2 -31
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-actions/actions.d.ts +1 -26
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts +3 -2
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts +4 -2
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-slug/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -17
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/template-content-panel/index.d.ts.map +1 -1
- package/build-types/dataviews/actions/duplicate-pattern.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-post.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-post.native.d.ts +3 -0
- package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-template-part.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +1 -0
- package/build-types/dataviews/actions/rename-post.d.ts +5 -0
- package/build-types/dataviews/actions/rename-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/reorder-page.d.ts +8 -0
- package/build-types/dataviews/actions/reorder-page.d.ts.map +1 -0
- package/build-types/dataviews/actions/reorder-page.native.d.ts +3 -0
- package/build-types/dataviews/actions/reorder-page.native.d.ts.map +1 -0
- package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/utils.d.ts +5 -3
- package/build-types/dataviews/actions/utils.d.ts.map +1 -1
- package/build-types/dataviews/actions/view-post-revisions.d.ts +8 -0
- package/build-types/dataviews/actions/view-post-revisions.d.ts.map +1 -0
- package/build-types/dataviews/actions/view-post.d.ts +8 -0
- package/build-types/dataviews/actions/view-post.d.ts.map +1 -0
- package/build-types/dataviews/fields/index.d.ts +8 -0
- package/build-types/dataviews/fields/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/dataviews/types.d.ts +57 -8
- package/build-types/dataviews/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/bindings/post-meta.js +2 -2
- package/src/components/block-manager/style.scss +2 -2
- package/src/components/create-template-part-modal/index.js +1 -0
- package/src/components/error-boundary/style.native.scss +1 -1
- package/src/components/error-boundary/style.scss +1 -1
- package/src/components/global-styles-provider/index.js +16 -3
- package/src/components/inserter-sidebar/index.js +10 -4
- package/src/components/page-attributes/parent.js +13 -9
- package/src/components/post-actions/actions.js +5 -616
- package/src/components/post-actions/index.js +16 -20
- package/src/components/post-card-panel/index.js +28 -27
- package/src/components/post-discussion/style.scss +0 -9
- package/src/components/post-featured-image/index.js +2 -0
- package/src/components/post-format/style.scss +0 -6
- package/src/components/post-publish-panel/postpublish.js +8 -2
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +8 -8
- package/src/components/post-slug/index.js +1 -0
- package/src/components/post-status/style.scss +0 -19
- package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -1
- package/src/components/post-url/index.js +15 -9
- package/src/components/save-publish-panels/style.scss +3 -3
- package/src/components/sidebar/post-summary.js +20 -16
- package/src/components/site-discussion/style.scss +0 -14
- package/src/components/template-content-panel/index.js +4 -1
- package/src/dataviews/actions/duplicate-pattern.tsx +40 -0
- package/src/dataviews/actions/duplicate-post.native.tsx +3 -0
- package/src/dataviews/actions/duplicate-post.tsx +174 -0
- package/src/dataviews/actions/duplicate-template-part.tsx +70 -0
- package/src/dataviews/actions/rename-post.tsx +146 -0
- package/src/dataviews/actions/reorder-page.native.tsx +3 -0
- package/src/dataviews/actions/reorder-page.tsx +125 -0
- package/src/dataviews/actions/reset-post.tsx +2 -1
- package/src/dataviews/actions/utils.ts +14 -4
- package/src/dataviews/actions/view-post-revisions.tsx +47 -0
- package/src/dataviews/actions/view-post.tsx +30 -0
- package/src/dataviews/fields/index.ts +26 -0
- package/src/dataviews/store/private-actions.ts +42 -1
- package/src/dataviews/types.ts +47 -6
- package/src/private-apis.js +2 -0
- package/src/store/private-actions.js +1 -1
- package/src/store/utils/is-template-revertable.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,25 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.duplicateTemplatePartAction = exports.duplicatePatternAction = void 0;
|
|
7
6
|
exports.usePostActions = usePostActions;
|
|
8
|
-
var _icons = require("@wordpress/icons");
|
|
9
|
-
var _url = require("@wordpress/url");
|
|
10
7
|
var _data = require("@wordpress/data");
|
|
11
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _i18n = require("@wordpress/i18n");
|
|
14
|
-
var _notices = require("@wordpress/notices");
|
|
15
8
|
var _element = require("@wordpress/element");
|
|
16
|
-
var _patterns = require("@wordpress/patterns");
|
|
17
|
-
var _blocks = require("@wordpress/blocks");
|
|
18
|
-
var _dataviews = require("@wordpress/dataviews");
|
|
19
|
-
var _components = require("@wordpress/components");
|
|
20
|
-
var _constants = require("../../store/constants");
|
|
21
9
|
var _store = require("../../store");
|
|
22
10
|
var _lockUnlock = require("../../lock-unlock");
|
|
23
|
-
var _createTemplatePartModal = require("../create-template-part-modal");
|
|
24
|
-
var _utils = require("../../dataviews/actions/utils");
|
|
25
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
12
|
/**
|
|
27
13
|
* WordPress dependencies
|
|
@@ -31,489 +17,19 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
31
17
|
* Internal dependencies
|
|
32
18
|
*/
|
|
33
19
|
|
|
34
|
-
// Patterns.
|
|
35
|
-
const {
|
|
36
|
-
PATTERN_TYPES,
|
|
37
|
-
CreatePatternModalContents,
|
|
38
|
-
useDuplicatePatternProps
|
|
39
|
-
} = (0, _lockUnlock.unlock)(_patterns.privateApis);
|
|
40
|
-
|
|
41
|
-
// TODO: this should be shared with other components (see post-fields in edit-site).
|
|
42
|
-
const fields = [{
|
|
43
|
-
type: 'text',
|
|
44
|
-
id: 'title',
|
|
45
|
-
label: (0, _i18n.__)('Title'),
|
|
46
|
-
placeholder: (0, _i18n.__)('No title'),
|
|
47
|
-
getValue: ({
|
|
48
|
-
item
|
|
49
|
-
}) => item.title
|
|
50
|
-
}, {
|
|
51
|
-
type: 'integer',
|
|
52
|
-
id: 'menu_order',
|
|
53
|
-
label: (0, _i18n.__)('Order'),
|
|
54
|
-
description: (0, _i18n.__)('Determines the order of pages.')
|
|
55
|
-
}];
|
|
56
|
-
const formDuplicateAction = {
|
|
57
|
-
fields: ['title']
|
|
58
|
-
};
|
|
59
|
-
const formOrderAction = {
|
|
60
|
-
fields: ['menu_order']
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Check if a template is removable.
|
|
65
|
-
*
|
|
66
|
-
* @param {Object} template The template entity to check.
|
|
67
|
-
* @return {boolean} Whether the template is removable.
|
|
68
|
-
*/
|
|
69
|
-
function isTemplateRemovable(template) {
|
|
70
|
-
if (!template) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
// In patterns list page we map the templates parts to a different object
|
|
74
|
-
// than the one returned from the endpoint. This is why we need to check for
|
|
75
|
-
// two props whether is custom or has a theme file.
|
|
76
|
-
return template?.source === _constants.TEMPLATE_ORIGINS.custom && !template?.has_theme_file;
|
|
77
|
-
}
|
|
78
|
-
const viewPostAction = {
|
|
79
|
-
id: 'view-post',
|
|
80
|
-
label: (0, _i18n.__)('View'),
|
|
81
|
-
isPrimary: true,
|
|
82
|
-
icon: _icons.external,
|
|
83
|
-
isEligible(post) {
|
|
84
|
-
return post.status !== 'trash';
|
|
85
|
-
},
|
|
86
|
-
callback(posts, {
|
|
87
|
-
onActionPerformed
|
|
88
|
-
}) {
|
|
89
|
-
const post = posts[0];
|
|
90
|
-
window.open(post.link, '_blank');
|
|
91
|
-
if (onActionPerformed) {
|
|
92
|
-
onActionPerformed(posts);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const postRevisionsAction = {
|
|
97
|
-
id: 'view-post-revisions',
|
|
98
|
-
context: 'list',
|
|
99
|
-
label(items) {
|
|
100
|
-
var _items$0$_links$versi;
|
|
101
|
-
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;
|
|
102
|
-
return (0, _i18n.sprintf)( /* translators: %s: number of revisions */
|
|
103
|
-
(0, _i18n.__)('View revisions (%s)'), revisionsCount);
|
|
104
|
-
},
|
|
105
|
-
isEligible: post => {
|
|
106
|
-
var _post$_links$predeces, _post$_links$version;
|
|
107
|
-
if (post.status === 'trash') {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
|
|
111
|
-
const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
|
|
112
|
-
return lastRevisionId && revisionsCount > 1;
|
|
113
|
-
},
|
|
114
|
-
callback(posts, {
|
|
115
|
-
onActionPerformed
|
|
116
|
-
}) {
|
|
117
|
-
const post = posts[0];
|
|
118
|
-
const href = (0, _url.addQueryArgs)('revision.php', {
|
|
119
|
-
revision: post?._links?.['predecessor-version']?.[0]?.id
|
|
120
|
-
});
|
|
121
|
-
document.location.href = href;
|
|
122
|
-
if (onActionPerformed) {
|
|
123
|
-
onActionPerformed(posts);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const renamePostAction = {
|
|
128
|
-
id: 'rename-post',
|
|
129
|
-
label: (0, _i18n.__)('Rename'),
|
|
130
|
-
isEligible(post) {
|
|
131
|
-
if (post.status === 'trash') {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
// Templates, template parts and patterns have special checks for renaming.
|
|
135
|
-
if (![_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE, ...Object.values(PATTERN_TYPES)].includes(post.type)) {
|
|
136
|
-
return post.permissions?.update;
|
|
137
|
-
}
|
|
138
|
-
// In the case of templates, we can only rename custom templates.
|
|
139
|
-
if (post.type === _constants.TEMPLATE_POST_TYPE) {
|
|
140
|
-
return isTemplateRemovable(post) && post.is_custom && post.permissions?.update;
|
|
141
|
-
}
|
|
142
|
-
// Make necessary checks for template parts and patterns.
|
|
143
|
-
const isTemplatePart = post.type === _constants.TEMPLATE_PART_POST_TYPE;
|
|
144
|
-
const isUserPattern = post.type === PATTERN_TYPES.user;
|
|
145
|
-
// In patterns list page we map the templates parts to a different object
|
|
146
|
-
// than the one returned from the endpoint. This is why we need to check for
|
|
147
|
-
// two props whether is custom or has a theme file.
|
|
148
|
-
const isCustomPattern = isUserPattern || isTemplatePart && post.source === _constants.TEMPLATE_ORIGINS.custom;
|
|
149
|
-
const hasThemeFile = post?.has_theme_file;
|
|
150
|
-
return isCustomPattern && !hasThemeFile && post.permissions?.update;
|
|
151
|
-
},
|
|
152
|
-
RenderModal: ({
|
|
153
|
-
items,
|
|
154
|
-
closeModal,
|
|
155
|
-
onActionPerformed
|
|
156
|
-
}) => {
|
|
157
|
-
const [item] = items;
|
|
158
|
-
const [title, setTitle] = (0, _element.useState)(() => (0, _utils.getItemTitle)(item));
|
|
159
|
-
const {
|
|
160
|
-
editEntityRecord,
|
|
161
|
-
saveEditedEntityRecord
|
|
162
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
163
|
-
const {
|
|
164
|
-
createSuccessNotice,
|
|
165
|
-
createErrorNotice
|
|
166
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
167
|
-
async function onRename(event) {
|
|
168
|
-
event.preventDefault();
|
|
169
|
-
try {
|
|
170
|
-
await editEntityRecord('postType', item.type, item.id, {
|
|
171
|
-
title
|
|
172
|
-
});
|
|
173
|
-
// Update state before saving rerenders the list.
|
|
174
|
-
setTitle('');
|
|
175
|
-
closeModal();
|
|
176
|
-
// Persist edited entity.
|
|
177
|
-
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
178
|
-
throwOnError: true
|
|
179
|
-
});
|
|
180
|
-
createSuccessNotice((0, _i18n.__)('Name updated'), {
|
|
181
|
-
type: 'snackbar'
|
|
182
|
-
});
|
|
183
|
-
onActionPerformed?.(items);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while updating the name');
|
|
186
|
-
createErrorNotice(errorMessage, {
|
|
187
|
-
type: 'snackbar'
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
|
|
192
|
-
onSubmit: onRename,
|
|
193
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
194
|
-
spacing: "5",
|
|
195
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
|
|
196
|
-
__nextHasNoMarginBottom: true,
|
|
197
|
-
__next40pxDefaultSize: true,
|
|
198
|
-
label: (0, _i18n.__)('Name'),
|
|
199
|
-
value: title,
|
|
200
|
-
onChange: setTitle,
|
|
201
|
-
required: true
|
|
202
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
203
|
-
justify: "right",
|
|
204
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
205
|
-
__next40pxDefaultSize: true,
|
|
206
|
-
variant: "tertiary",
|
|
207
|
-
onClick: () => {
|
|
208
|
-
closeModal();
|
|
209
|
-
},
|
|
210
|
-
children: (0, _i18n.__)('Cancel')
|
|
211
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
212
|
-
__next40pxDefaultSize: true,
|
|
213
|
-
variant: "primary",
|
|
214
|
-
type: "submit",
|
|
215
|
-
children: (0, _i18n.__)('Save')
|
|
216
|
-
})]
|
|
217
|
-
})]
|
|
218
|
-
})
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
function ReorderModal({
|
|
223
|
-
items,
|
|
224
|
-
closeModal,
|
|
225
|
-
onActionPerformed
|
|
226
|
-
}) {
|
|
227
|
-
const [item, setItem] = (0, _element.useState)(items[0]);
|
|
228
|
-
const orderInput = item.menu_order;
|
|
229
|
-
const {
|
|
230
|
-
editEntityRecord,
|
|
231
|
-
saveEditedEntityRecord
|
|
232
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
233
|
-
const {
|
|
234
|
-
createSuccessNotice,
|
|
235
|
-
createErrorNotice
|
|
236
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
237
|
-
async function onOrder(event) {
|
|
238
|
-
event.preventDefault();
|
|
239
|
-
if (!(0, _dataviews.isItemValid)(item, fields, formOrderAction)) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
try {
|
|
243
|
-
await editEntityRecord('postType', item.type, item.id, {
|
|
244
|
-
menu_order: orderInput
|
|
245
|
-
});
|
|
246
|
-
closeModal();
|
|
247
|
-
// Persist edited entity.
|
|
248
|
-
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
249
|
-
throwOnError: true
|
|
250
|
-
});
|
|
251
|
-
createSuccessNotice((0, _i18n.__)('Order updated'), {
|
|
252
|
-
type: 'snackbar'
|
|
253
|
-
});
|
|
254
|
-
onActionPerformed?.(items);
|
|
255
|
-
} catch (error) {
|
|
256
|
-
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while updating the order');
|
|
257
|
-
createErrorNotice(errorMessage, {
|
|
258
|
-
type: 'snackbar'
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const isSaveDisabled = !(0, _dataviews.isItemValid)(item, fields, formOrderAction);
|
|
263
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
|
|
264
|
-
onSubmit: onOrder,
|
|
265
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
266
|
-
spacing: "5",
|
|
267
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
268
|
-
children: (0, _i18n.__)('Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.')
|
|
269
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviews.DataForm, {
|
|
270
|
-
data: item,
|
|
271
|
-
fields: fields,
|
|
272
|
-
form: formOrderAction,
|
|
273
|
-
onChange: setItem
|
|
274
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
275
|
-
justify: "right",
|
|
276
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
277
|
-
__next40pxDefaultSize: true,
|
|
278
|
-
variant: "tertiary",
|
|
279
|
-
onClick: () => {
|
|
280
|
-
closeModal();
|
|
281
|
-
},
|
|
282
|
-
children: (0, _i18n.__)('Cancel')
|
|
283
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
284
|
-
__next40pxDefaultSize: true,
|
|
285
|
-
variant: "primary",
|
|
286
|
-
type: "submit",
|
|
287
|
-
accessibleWhenDisabled: true,
|
|
288
|
-
disabled: isSaveDisabled,
|
|
289
|
-
__experimentalIsFocusable: true,
|
|
290
|
-
children: (0, _i18n.__)('Save')
|
|
291
|
-
})]
|
|
292
|
-
})]
|
|
293
|
-
})
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
function useReorderPagesAction(postType) {
|
|
297
|
-
const supportsPageAttributes = (0, _data.useSelect)(select => {
|
|
298
|
-
const {
|
|
299
|
-
getPostType
|
|
300
|
-
} = select(_coreData.store);
|
|
301
|
-
const postTypeObject = getPostType(postType);
|
|
302
|
-
return !!postTypeObject?.supports?.['page-attributes'];
|
|
303
|
-
}, [postType]);
|
|
304
|
-
return (0, _element.useMemo)(() => supportsPageAttributes && {
|
|
305
|
-
id: 'order-pages',
|
|
306
|
-
label: (0, _i18n.__)('Order'),
|
|
307
|
-
isEligible({
|
|
308
|
-
status
|
|
309
|
-
}) {
|
|
310
|
-
return status !== 'trash';
|
|
311
|
-
},
|
|
312
|
-
RenderModal: ReorderModal
|
|
313
|
-
}, [supportsPageAttributes]);
|
|
314
|
-
}
|
|
315
|
-
const useDuplicatePostAction = postType => {
|
|
316
|
-
const userCanCreatePost = (0, _data.useSelect)(select => {
|
|
317
|
-
return select(_coreData.store).canUser('create', {
|
|
318
|
-
kind: 'postType',
|
|
319
|
-
name: postType
|
|
320
|
-
});
|
|
321
|
-
}, [postType]);
|
|
322
|
-
return (0, _element.useMemo)(() => userCanCreatePost && {
|
|
323
|
-
id: 'duplicate-post',
|
|
324
|
-
label: (0, _i18n._x)('Duplicate', 'action label'),
|
|
325
|
-
isEligible({
|
|
326
|
-
status
|
|
327
|
-
}) {
|
|
328
|
-
return status !== 'trash';
|
|
329
|
-
},
|
|
330
|
-
RenderModal: ({
|
|
331
|
-
items,
|
|
332
|
-
closeModal,
|
|
333
|
-
onActionPerformed
|
|
334
|
-
}) => {
|
|
335
|
-
const [item, setItem] = (0, _element.useState)({
|
|
336
|
-
...items[0],
|
|
337
|
-
title: (0, _i18n.sprintf)( /* translators: %s: Existing template title */
|
|
338
|
-
(0, _i18n.__)('%s (Copy)'), (0, _utils.getItemTitle)(items[0]))
|
|
339
|
-
});
|
|
340
|
-
const [isCreatingPage, setIsCreatingPage] = (0, _element.useState)(false);
|
|
341
|
-
const {
|
|
342
|
-
saveEntityRecord
|
|
343
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
344
|
-
const {
|
|
345
|
-
createSuccessNotice,
|
|
346
|
-
createErrorNotice
|
|
347
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
348
|
-
async function createPage(event) {
|
|
349
|
-
event.preventDefault();
|
|
350
|
-
if (isCreatingPage) {
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
const newItemOject = {
|
|
354
|
-
status: 'draft',
|
|
355
|
-
title: item.title,
|
|
356
|
-
slug: item.title || (0, _i18n.__)('No title'),
|
|
357
|
-
comment_status: item.comment_status,
|
|
358
|
-
content: typeof item.content === 'string' ? item.content : item.content.raw,
|
|
359
|
-
excerpt: item.excerpt.raw,
|
|
360
|
-
meta: item.meta,
|
|
361
|
-
parent: item.parent,
|
|
362
|
-
password: item.password,
|
|
363
|
-
template: item.template,
|
|
364
|
-
format: item.format,
|
|
365
|
-
featured_media: item.featured_media,
|
|
366
|
-
menu_order: item.menu_order,
|
|
367
|
-
ping_status: item.ping_status
|
|
368
|
-
};
|
|
369
|
-
const assignablePropertiesPrefix = 'wp:action-assign-';
|
|
370
|
-
// Get all the properties that the current user is able to assign normally author, categories, tags,
|
|
371
|
-
// and custom taxonomies.
|
|
372
|
-
const assignableProperties = Object.keys(item?._links || {}).filter(property => property.startsWith(assignablePropertiesPrefix)).map(property => property.slice(assignablePropertiesPrefix.length));
|
|
373
|
-
assignableProperties.forEach(property => {
|
|
374
|
-
if (item[property]) {
|
|
375
|
-
newItemOject[property] = item[property];
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
setIsCreatingPage(true);
|
|
379
|
-
try {
|
|
380
|
-
const newItem = await saveEntityRecord('postType', item.type, newItemOject, {
|
|
381
|
-
throwOnError: true
|
|
382
|
-
});
|
|
383
|
-
createSuccessNotice((0, _i18n.sprintf)(
|
|
384
|
-
// translators: %s: Title of the created template e.g: "Category".
|
|
385
|
-
(0, _i18n.__)('"%s" successfully created.'), (0, _htmlEntities.decodeEntities)(newItem.title?.rendered || item.title)), {
|
|
386
|
-
id: 'duplicate-post-action',
|
|
387
|
-
type: 'snackbar'
|
|
388
|
-
});
|
|
389
|
-
if (onActionPerformed) {
|
|
390
|
-
onActionPerformed([newItem]);
|
|
391
|
-
}
|
|
392
|
-
} catch (error) {
|
|
393
|
-
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while duplicating the page.');
|
|
394
|
-
createErrorNotice(errorMessage, {
|
|
395
|
-
type: 'snackbar'
|
|
396
|
-
});
|
|
397
|
-
} finally {
|
|
398
|
-
setIsCreatingPage(false);
|
|
399
|
-
closeModal();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
|
|
403
|
-
onSubmit: createPage,
|
|
404
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
405
|
-
spacing: 3,
|
|
406
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviews.DataForm, {
|
|
407
|
-
data: item,
|
|
408
|
-
fields: fields,
|
|
409
|
-
form: formDuplicateAction,
|
|
410
|
-
onChange: setItem
|
|
411
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
412
|
-
spacing: 2,
|
|
413
|
-
justify: "end",
|
|
414
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
415
|
-
variant: "tertiary",
|
|
416
|
-
onClick: closeModal,
|
|
417
|
-
__next40pxDefaultSize: true,
|
|
418
|
-
children: (0, _i18n.__)('Cancel')
|
|
419
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
420
|
-
variant: "primary",
|
|
421
|
-
type: "submit",
|
|
422
|
-
isBusy: isCreatingPage,
|
|
423
|
-
"aria-disabled": isCreatingPage,
|
|
424
|
-
__next40pxDefaultSize: true,
|
|
425
|
-
children: (0, _i18n._x)('Duplicate', 'action label')
|
|
426
|
-
})]
|
|
427
|
-
})]
|
|
428
|
-
})
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}, [userCanCreatePost]);
|
|
432
|
-
};
|
|
433
|
-
const duplicatePatternAction = exports.duplicatePatternAction = {
|
|
434
|
-
id: 'duplicate-pattern',
|
|
435
|
-
label: (0, _i18n._x)('Duplicate', 'action label'),
|
|
436
|
-
isEligible: item => item.type !== _constants.TEMPLATE_PART_POST_TYPE,
|
|
437
|
-
modalHeader: (0, _i18n._x)('Duplicate pattern', 'action label'),
|
|
438
|
-
RenderModal: ({
|
|
439
|
-
items,
|
|
440
|
-
closeModal
|
|
441
|
-
}) => {
|
|
442
|
-
const [item] = items;
|
|
443
|
-
const duplicatedProps = useDuplicatePatternProps({
|
|
444
|
-
pattern: item,
|
|
445
|
-
onSuccess: () => closeModal()
|
|
446
|
-
});
|
|
447
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CreatePatternModalContents, {
|
|
448
|
-
onClose: closeModal,
|
|
449
|
-
confirmLabel: (0, _i18n._x)('Duplicate', 'action label'),
|
|
450
|
-
...duplicatedProps
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
const duplicateTemplatePartAction = exports.duplicateTemplatePartAction = {
|
|
455
|
-
id: 'duplicate-template-part',
|
|
456
|
-
label: (0, _i18n._x)('Duplicate', 'action label'),
|
|
457
|
-
isEligible: item => item.type === _constants.TEMPLATE_PART_POST_TYPE,
|
|
458
|
-
modalHeader: (0, _i18n._x)('Duplicate template part', 'action label'),
|
|
459
|
-
RenderModal: ({
|
|
460
|
-
items,
|
|
461
|
-
closeModal
|
|
462
|
-
}) => {
|
|
463
|
-
const [item] = items;
|
|
464
|
-
const blocks = (0, _element.useMemo)(() => {
|
|
465
|
-
var _item$blocks;
|
|
466
|
-
return (_item$blocks = item.blocks) !== null && _item$blocks !== void 0 ? _item$blocks : (0, _blocks.parse)(typeof item.content === 'string' ? item.content : item.content.raw, {
|
|
467
|
-
__unstableSkipMigrationLogs: true
|
|
468
|
-
});
|
|
469
|
-
}, [item.content, item.blocks]);
|
|
470
|
-
const {
|
|
471
|
-
createSuccessNotice
|
|
472
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
473
|
-
function onTemplatePartSuccess() {
|
|
474
|
-
createSuccessNotice((0, _i18n.sprintf)(
|
|
475
|
-
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
476
|
-
(0, _i18n.__)('"%s" duplicated.'), (0, _utils.getItemTitle)(item)), {
|
|
477
|
-
type: 'snackbar',
|
|
478
|
-
id: 'edit-site-patterns-success'
|
|
479
|
-
});
|
|
480
|
-
closeModal();
|
|
481
|
-
}
|
|
482
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_createTemplatePartModal.CreateTemplatePartModalContents, {
|
|
483
|
-
blocks: blocks,
|
|
484
|
-
defaultArea: item.area,
|
|
485
|
-
defaultTitle: (0, _i18n.sprintf)( /* translators: %s: Existing template part title */
|
|
486
|
-
(0, _i18n.__)('%s (Copy)'), (0, _utils.getItemTitle)(item)),
|
|
487
|
-
onCreate: onTemplatePartSuccess,
|
|
488
|
-
onError: closeModal,
|
|
489
|
-
confirmLabel: (0, _i18n._x)('Duplicate', 'action label')
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
20
|
function usePostActions({
|
|
494
21
|
postType,
|
|
495
22
|
onActionPerformed,
|
|
496
23
|
context
|
|
497
24
|
}) {
|
|
498
25
|
const {
|
|
499
|
-
defaultActions
|
|
500
|
-
postTypeObject,
|
|
501
|
-
userCanCreatePostType
|
|
26
|
+
defaultActions
|
|
502
27
|
} = (0, _data.useSelect)(select => {
|
|
503
|
-
const {
|
|
504
|
-
getPostType,
|
|
505
|
-
canUser
|
|
506
|
-
} = select(_coreData.store);
|
|
507
28
|
const {
|
|
508
29
|
getEntityActions
|
|
509
30
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
510
31
|
return {
|
|
511
|
-
|
|
512
|
-
defaultActions: getEntityActions('postType', postType),
|
|
513
|
-
userCanCreatePostType: canUser('create', {
|
|
514
|
-
kind: 'postType',
|
|
515
|
-
name: postType
|
|
516
|
-
})
|
|
32
|
+
defaultActions: getEntityActions('postType', postType)
|
|
517
33
|
};
|
|
518
34
|
}, [postType]);
|
|
519
35
|
const {
|
|
@@ -522,25 +38,14 @@ function usePostActions({
|
|
|
522
38
|
(0, _element.useEffect)(() => {
|
|
523
39
|
registerPostTypeActions(postType);
|
|
524
40
|
}, [registerPostTypeActions, postType]);
|
|
525
|
-
const duplicatePostAction = useDuplicatePostAction(postType);
|
|
526
|
-
const reorderPagesAction = useReorderPagesAction(postType);
|
|
527
|
-
const isTemplateOrTemplatePart = [_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE].includes(postType);
|
|
528
|
-
const isPattern = postType === _constants.PATTERN_POST_TYPE;
|
|
529
|
-
const isLoaded = !!postTypeObject;
|
|
530
|
-
const supportsRevisions = !!postTypeObject?.supports?.revisions;
|
|
531
|
-
const supportsTitle = !!postTypeObject?.supports?.title;
|
|
532
41
|
return (0, _element.useMemo)(() => {
|
|
533
|
-
if (!isLoaded) {
|
|
534
|
-
return [];
|
|
535
|
-
}
|
|
536
|
-
let actions = [postTypeObject?.viewable && viewPostAction, supportsRevisions && postRevisionsAction, globalThis.IS_GUTENBERG_PLUGIN ? !isTemplateOrTemplatePart && !isPattern && duplicatePostAction : false, isTemplateOrTemplatePart && userCanCreatePostType && duplicateTemplatePartAction, isPattern && userCanCreatePostType && duplicatePatternAction, supportsTitle && renamePostAction, reorderPagesAction, ...defaultActions].filter(Boolean);
|
|
537
42
|
// Filter actions based on provided context. If not provided
|
|
538
43
|
// all actions are returned. We'll have a single entry for getting the actions
|
|
539
44
|
// and the consumer should provide the context to filter the actions, if needed.
|
|
540
45
|
// Actions should also provide the `context` they support, if it's specific, to
|
|
541
46
|
// compare with the provided context to get all the actions.
|
|
542
47
|
// Right now the only supported context is `list`.
|
|
543
|
-
actions =
|
|
48
|
+
const actions = defaultActions.filter(action => {
|
|
544
49
|
if (!action.context) {
|
|
545
50
|
return true;
|
|
546
51
|
}
|
|
@@ -585,6 +90,6 @@ function usePostActions({
|
|
|
585
90
|
}
|
|
586
91
|
}
|
|
587
92
|
return actions;
|
|
588
|
-
}, [defaultActions,
|
|
93
|
+
}, [defaultActions, onActionPerformed, context]);
|
|
589
94
|
}
|
|
590
95
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_url","_data","_htmlEntities","_coreData","_i18n","_notices","_element","_patterns","_blocks","_dataviews","_components","_constants","_store","_lockUnlock","_createTemplatePartModal","_utils","_jsxRuntime","PATTERN_TYPES","CreatePatternModalContents","useDuplicatePatternProps","unlock","patternsPrivateApis","fields","type","id","label","__","placeholder","getValue","item","title","description","formDuplicateAction","formOrderAction","isTemplateRemovable","template","source","TEMPLATE_ORIGINS","custom","has_theme_file","viewPostAction","isPrimary","icon","external","isEligible","post","status","callback","posts","onActionPerformed","window","open","link","postRevisionsAction","context","items","_items$0$_links$versi","revisionsCount","_links","count","sprintf","_post$_links$predeces","_post$_links$version","lastRevisionId","href","addQueryArgs","revision","document","location","renamePostAction","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","Object","values","includes","permissions","update","is_custom","isTemplatePart","isUserPattern","user","isCustomPattern","hasThemeFile","RenderModal","closeModal","setTitle","useState","getItemTitle","editEntityRecord","saveEditedEntityRecord","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","onRename","event","preventDefault","throwOnError","error","errorMessage","message","code","jsx","onSubmit","children","jsxs","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","required","__experimentalHStack","justify","Button","variant","onClick","ReorderModal","setItem","orderInput","menu_order","onOrder","isItemValid","isSaveDisabled","DataForm","data","form","accessibleWhenDisabled","disabled","__experimentalIsFocusable","useReorderPagesAction","postType","supportsPageAttributes","useSelect","select","getPostType","postTypeObject","supports","useMemo","useDuplicatePostAction","userCanCreatePost","canUser","kind","name","_x","isCreatingPage","setIsCreatingPage","saveEntityRecord","createPage","newItemOject","slug","comment_status","content","raw","excerpt","meta","parent","password","format","featured_media","ping_status","assignablePropertiesPrefix","assignableProperties","keys","filter","property","startsWith","map","slice","length","forEach","newItem","decodeEntities","rendered","isBusy","duplicatePatternAction","exports","modalHeader","duplicatedProps","pattern","onSuccess","onClose","confirmLabel","duplicateTemplatePartAction","blocks","_item$blocks","parse","__unstableSkipMigrationLogs","onTemplatePartSuccess","CreateTemplatePartModalContents","defaultArea","area","defaultTitle","onCreate","onError","usePostActions","defaultActions","userCanCreatePostType","getEntityActions","editorStore","registerPostTypeActions","useEffect","duplicatePostAction","reorderPagesAction","isTemplateOrTemplatePart","isPattern","PATTERN_POST_TYPE","isLoaded","supportsRevisions","revisions","supportsTitle","actions","viewable","globalThis","IS_GUTENBERG_PLUGIN","Boolean","action","i","existingCallback","argsObject","_items","ExistingRenderModal","props"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch, useSelect } 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 { useMemo, useState, useEffect } from '@wordpress/element';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { parse } from '@wordpress/blocks';\nimport { DataForm, isItemValid } from '@wordpress/dataviews';\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_ORIGINS,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n\tPATTERN_POST_TYPE,\n} from '../../store/constants';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { CreateTemplatePartModalContents } from '../create-template-part-modal';\nimport { getItemTitle } from '../../dataviews/actions/utils';\n\n// Patterns.\nconst { PATTERN_TYPES, CreatePatternModalContents, useDuplicatePatternProps } =\n\tunlock( patternsPrivateApis );\n\n// TODO: this should be shared with other components (see post-fields in edit-site).\nconst fields = [\n\t{\n\t\ttype: 'text',\n\t\tid: 'title',\n\t\tlabel: __( 'Title' ),\n\t\tplaceholder: __( 'No title' ),\n\t\tgetValue: ( { item } ) => item.title,\n\t},\n\t{\n\t\ttype: 'integer',\n\t\tid: 'menu_order',\n\t\tlabel: __( 'Order' ),\n\t\tdescription: __( 'Determines the order of pages.' ),\n\t},\n];\n\nconst formDuplicateAction = {\n\tfields: [ 'title' ],\n};\n\nconst formOrderAction = {\n\tfields: [ 'menu_order' ],\n};\n\n/**\n * Check if a template is removable.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is removable.\n */\nfunction isTemplateRemovable( template ) {\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\ttemplate?.source === TEMPLATE_ORIGINS.custom &&\n\t\t! template?.has_theme_file\n\t);\n}\n\nconst viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nconst postRevisionsAction = {\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\nconst renamePostAction = {\n\tid: 'rename-post',\n\tlabel: __( 'Rename' ),\n\tisEligible( post ) {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Templates, template parts and patterns have special checks for renaming.\n\t\tif (\n\t\t\t! [\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t...Object.values( PATTERN_TYPES ),\n\t\t\t].includes( post.type )\n\t\t) {\n\t\t\treturn post.permissions?.update;\n\t\t}\n\t\t// In the case of templates, we can only rename custom templates.\n\t\tif ( post.type === TEMPLATE_POST_TYPE ) {\n\t\t\treturn (\n\t\t\t\tisTemplateRemovable( post ) &&\n\t\t\t\tpost.is_custom &&\n\t\t\t\tpost.permissions?.update\n\t\t\t);\n\t\t}\n\t\t// Make necessary checks for template parts and patterns.\n\t\tconst isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;\n\t\tconst isUserPattern = post.type === PATTERN_TYPES.user;\n\t\t// In patterns list page we map the templates parts to a different object\n\t\t// than the one returned from the endpoint. This is why we need to check for\n\t\t// two props whether is custom or has a theme file.\n\t\tconst isCustomPattern =\n\t\t\tisUserPattern ||\n\t\t\t( isTemplatePart && post.source === TEMPLATE_ORIGINS.custom );\n\t\tconst hasThemeFile = post?.has_theme_file;\n\t\treturn isCustomPattern && ! hasThemeFile && post.permissions?.update;\n\t},\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ item ] = items;\n\t\tconst [ title, setTitle ] = useState( () => getItemTitle( item ) );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tuseDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function onRename( event ) {\n\t\t\tevent.preventDefault();\n\t\t\ttry {\n\t\t\t\tawait editEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\ttitle,\n\t\t\t\t} );\n\t\t\t\t// Update state before saving rerenders the list.\n\t\t\t\tsetTitle( '' );\n\t\t\t\tcloseModal();\n\t\t\t\t// Persist edited entity.\n\t\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t\tcreateSuccessNotice( __( 'Name updated' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\tonActionPerformed?.( items );\n\t\t\t} catch ( error ) {\n\t\t\t\tconst errorMessage =\n\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: __( 'An error occurred while updating the name' );\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n\nfunction ReorderModal( { items, closeModal, onActionPerformed } ) {\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 ) {\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 errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.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={ setItem }\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\t__experimentalIsFocusable\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\nfunction useReorderPagesAction( postType ) {\n\tconst supportsPageAttributes = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\tconst postTypeObject = getPostType( postType );\n\n\t\t\treturn !! postTypeObject?.supports?.[ 'page-attributes' ];\n\t\t},\n\t\t[ postType ]\n\t);\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupportsPageAttributes && {\n\t\t\t\tid: 'order-pages',\n\t\t\t\tlabel: __( 'Order' ),\n\t\t\t\tisEligible( { status } ) {\n\t\t\t\t\treturn status !== 'trash';\n\t\t\t\t},\n\t\t\t\tRenderModal: ReorderModal,\n\t\t\t},\n\t\t[ supportsPageAttributes ]\n\t);\n}\n\nconst useDuplicatePostAction = ( postType ) => {\n\tconst userCanCreatePost = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tuserCanCreatePost && {\n\t\t\t\tid: 'duplicate-post',\n\t\t\t\tlabel: _x( 'Duplicate', 'action label' ),\n\t\t\t\tisEligible( { status } ) {\n\t\t\t\t\treturn status !== 'trash';\n\t\t\t\t},\n\t\t\t\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\t\t\t\tconst [ item, setItem ] = useState( {\n\t\t\t\t\t\t...items[ 0 ],\n\t\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Existing template title */\n\t\t\t\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst [ isCreatingPage, setIsCreatingPage ] =\n\t\t\t\t\t\tuseState( false );\n\n\t\t\t\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\t\t\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\t\t\t\tuseDispatch( noticesStore );\n\n\t\t\t\t\tasync function createPage( event ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tif ( isCreatingPage ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst newItemOject = {\n\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t\ttitle: item.title,\n\t\t\t\t\t\t\tslug: item.title || __( 'No title' ),\n\t\t\t\t\t\t\tcomment_status: item.comment_status,\n\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t\t\t\t: item.content.raw,\n\t\t\t\t\t\t\texcerpt: item.excerpt.raw,\n\t\t\t\t\t\t\tmeta: item.meta,\n\t\t\t\t\t\t\tparent: item.parent,\n\t\t\t\t\t\t\tpassword: item.password,\n\t\t\t\t\t\t\ttemplate: item.template,\n\t\t\t\t\t\t\tformat: item.format,\n\t\t\t\t\t\t\tfeatured_media: item.featured_media,\n\t\t\t\t\t\t\tmenu_order: item.menu_order,\n\t\t\t\t\t\t\tping_status: item.ping_status,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst assignablePropertiesPrefix = 'wp:action-assign-';\n\t\t\t\t\t\t// Get all the properties that the current user is able to assign normally author, categories, tags,\n\t\t\t\t\t\t// and custom taxonomies.\n\t\t\t\t\t\tconst assignableProperties = Object.keys(\n\t\t\t\t\t\t\titem?._links || {}\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter( ( property ) =>\n\t\t\t\t\t\t\t\tproperty.startsWith(\n\t\t\t\t\t\t\t\t\tassignablePropertiesPrefix\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.map( ( property ) =>\n\t\t\t\t\t\t\t\tproperty.slice(\n\t\t\t\t\t\t\t\t\tassignablePropertiesPrefix.length\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tassignableProperties.forEach( ( property ) => {\n\t\t\t\t\t\t\tif ( item[ property ] ) {\n\t\t\t\t\t\t\t\tnewItemOject[ property ] = item[ property ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetIsCreatingPage( true );\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst newItem = await saveEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\tnewItemOject,\n\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\tnewItem.title?.rendered || item.title\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\t{\n\t\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\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\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( [ newItem ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while duplicating the page.'\n\t\t\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tsetIsCreatingPage( false );\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t\t\t\t<DataForm\n\t\t\t\t\t\t\t\t\tdata={ item }\n\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\tform={ formDuplicateAction }\n\t\t\t\t\t\t\t\t\tonChange={ setItem }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ _x( 'Duplicate', 'action label' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t[ userCanCreatePost ]\n\t);\n};\n\nexport const duplicatePatternAction = {\n\tid: 'duplicate-pattern',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible: ( item ) => item.type !== TEMPLATE_PART_POST_TYPE,\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 const duplicateTemplatePartAction = {\n\tid: 'duplicate-template-part',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible: ( item ) => item.type === TEMPLATE_PART_POST_TYPE,\n\tmodalHeader: _x( 'Duplicate template part', 'action label' ),\n\tRenderModal: ( { items, closeModal } ) => {\n\t\tconst [ item ] = items;\n\t\tconst blocks = useMemo( () => {\n\t\t\treturn (\n\t\t\t\titem.blocks ??\n\t\t\t\tparse(\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\t\t{\n\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}, [ item.content, item.blocks ] );\n\t\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\t\tfunction onTemplatePartSuccess() {\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: The new template part's title e.g. 'Call to action (copy)'.\n\t\t\t\t\t__( '\"%s\" duplicated.' ),\n\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', id: 'edit-site-patterns-success' }\n\t\t\t);\n\t\t\tcloseModal();\n\t\t}\n\t\treturn (\n\t\t\t<CreateTemplatePartModalContents\n\t\t\t\tblocks={ blocks }\n\t\t\t\tdefaultArea={ item.area }\n\t\t\t\tdefaultTitle={ sprintf(\n\t\t\t\t\t/* translators: %s: Existing template part title */\n\t\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\t\tgetItemTitle( item )\n\t\t\t\t) }\n\t\t\t\tonCreate={ onTemplatePartSuccess }\n\t\t\t\tonError={ closeModal }\n\t\t\t\tconfirmLabel={ _x( 'Duplicate', 'action label' ) }\n\t\t\t/>\n\t\t);\n\t},\n};\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions, postTypeObject, userCanCreatePostType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tpostTypeObject: getPostType( postType ),\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t\tuserCanCreatePostType: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\tconst { registerPostTypeActions } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeActions( postType );\n\t}, [ registerPostTypeActions, postType ] );\n\n\tconst duplicatePostAction = useDuplicatePostAction( postType );\n\tconst reorderPagesAction = useReorderPagesAction( postType );\n\tconst isTemplateOrTemplatePart = [\n\t\tTEMPLATE_POST_TYPE,\n\t\tTEMPLATE_PART_POST_TYPE,\n\t].includes( postType );\n\tconst isPattern = postType === PATTERN_POST_TYPE;\n\tconst isLoaded = !! postTypeObject;\n\tconst supportsRevisions = !! postTypeObject?.supports?.revisions;\n\tconst supportsTitle = !! postTypeObject?.supports?.title;\n\treturn useMemo( () => {\n\t\tif ( ! isLoaded ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet actions = [\n\t\t\tpostTypeObject?.viewable && viewPostAction,\n\t\t\tsupportsRevisions && postRevisionsAction,\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! isTemplateOrTemplatePart &&\n\t\t\t\t ! isPattern &&\n\t\t\t\t duplicatePostAction\n\t\t\t\t: false,\n\t\t\tisTemplateOrTemplatePart &&\n\t\t\t\tuserCanCreatePostType &&\n\t\t\t\tduplicateTemplatePartAction,\n\t\t\tisPattern && userCanCreatePostType && duplicatePatternAction,\n\t\t\tsupportsTitle && renamePostAction,\n\t\t\treorderPagesAction,\n\t\t\t...defaultActions,\n\t\t].filter( Boolean );\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [\n\t\tdefaultActions,\n\t\tuserCanCreatePostType,\n\t\tisTemplateOrTemplatePart,\n\t\tisPattern,\n\t\tpostTypeObject?.viewable,\n\t\tduplicatePostAction,\n\t\treorderPagesAction,\n\t\tonActionPerformed,\n\t\tisLoaded,\n\t\tsupportsRevisions,\n\t\tsupportsTitle,\n\t\tcontext,\n\t] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AAUA,IAAAY,UAAA,GAAAZ,OAAA;AAMA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AACA,IAAAe,wBAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AAA6D,IAAAiB,WAAA,GAAAjB,OAAA;AAjC7D;AACA;AACA;;AAmBA;AACA;AACA;;AAYA;AACA,MAAM;EAAEkB,aAAa;EAAEC,0BAA0B;EAAEC;AAAyB,CAAC,GAC5E,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;;AAE9B;AACA,MAAMC,MAAM,GAAG,CACd;EACCC,IAAI,EAAE,MAAM;EACZC,EAAE,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,CAAC;YACJ;UACD,CAAC;QACF;QACA,IAAKT,OAAO,CAAEM,CAAC,CAAE,CAACzI,WAAW,EAAG;UAC/B,MAAM6I,mBAAmB,GAAGV,OAAO,CAAEM,CAAC,CAAE,CAACzI,WAAW;UACpDmI,OAAO,CAAEM,CAAC,CAAE,GAAG;YACd,GAAGN,OAAO,CAAEM,CAAC,CAAE;YACfzI,WAAW,EAAI8I,KAAK,IAAM;cACzB,oBACC,IAAAjN,WAAA,CAAAuF,GAAA,EAACyH,mBAAmB;gBAAA,GACdC,KAAK;gBACVhL,iBAAiB,EAAK8K,MAAM,IAAM;kBACjC,IAAKE,KAAK,CAAChL,iBAAiB,EAAG;oBAC9BgL,KAAK,CAAChL,iBAAiB,CAAE8K,MAAO,CAAC;kBAClC;kBACA9K,iBAAiB,CAChBqK,OAAO,CAAEM,CAAC,CAAE,CAACpM,EAAE,EACfuM,MACD,CAAC;gBACF;cAAG,CACH,CAAC;YAEJ;UACD,CAAC;QACF;MACD;IACD;IAEA,OAAOT,OAAO;EACf,CAAC,EAAE,CACFf,cAAc,EACdC,qBAAqB,EACrBO,wBAAwB,EACxBC,SAAS,EACTrE,cAAc,EAAE4E,QAAQ,EACxBV,mBAAmB,EACnBC,kBAAkB,EAClB7J,iBAAiB,EACjBiK,QAAQ,EACRC,iBAAiB,EACjBE,aAAa,EACb/J,OAAO,CACN,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_element","_store","_lockUnlock","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","registerPostTypeActions","useDispatch","useEffect","useMemo","actions","filter","action","i","length","callback","existingCallback","items","argsObject","_items","id","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { registerPostTypeActions } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeActions( postType );\n\t}, [ registerPostTypeActions, postType ] );\n\n\treturn useMemo( () => {\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tconst actions = defaultActions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [ defaultActions, onActionPerformed, context ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAV3C;AACA;AACA;;AAIA;AACA;AACA;;AAIO,SAASK,cAAcA,CAAE;EAAEC,QAAQ;EAAEC,iBAAiB;EAAEC;AAAQ,CAAC,EAAG;EAC1E,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EACjCC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAiB,CAAC,GAAG,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