@wordpress/editor 14.7.0 → 14.7.1-next.1f6eadc42.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/README.md +4 -0
- package/build/bindings/post-meta.js +2 -1
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +2 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/editor/index.js +2 -2
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-history/redo.js +2 -4
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +2 -4
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/error-boundary/index.js +2 -4
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +3 -4
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +6 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +2 -5
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -5
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-featured-image/index.js +6 -12
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-format/index.js +2 -4
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +2 -4
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +4 -8
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +2 -4
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +2 -4
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +153 -36
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-publish-panel/media-util.js +79 -0
- package/build/components/post-publish-panel/media-util.js.map +1 -0
- package/build/components/post-trash/check.js +2 -1
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-trash/index.js +22 -8
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +28 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +5 -57
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.js +34 -8
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +9 -4
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/sidebar/post-summary.js +3 -0
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/start-page-options/index.js +16 -19
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/start-template-options/index.js +2 -4
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/table-of-contents/index.js +2 -4
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/text-editor/index.js +2 -4
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +38 -0
- package/build/components/zoom-out-toggle/index.js.map +1 -0
- package/build/dataviews/actions/reset-post.js +4 -8
- package/build/dataviews/actions/reset-post.js.map +1 -1
- package/build/dataviews/actions/trash-post.js +4 -8
- package/build/dataviews/actions/trash-post.js.map +1 -1
- package/build/dataviews/store/private-actions.js +4 -10
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +7 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/bindings/post-meta.js +2 -1
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +2 -4
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/editor/index.js +2 -2
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-history/redo.js +2 -4
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +2 -4
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -4
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +3 -4
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +6 -4
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +2 -5
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -5
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +6 -12
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-format/index.js +2 -4
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +2 -4
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +4 -8
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +2 -4
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -4
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +152 -35
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-publish-panel/media-util.js +72 -0
- package/build-module/components/post-publish-panel/media-util.js.map +1 -0
- package/build-module/components/post-trash/check.js +2 -1
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-trash/index.js +23 -11
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +28 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +5 -57
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.js +35 -9
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +9 -4
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +3 -0
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/start-page-options/index.js +17 -21
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +2 -4
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +2 -4
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +2 -4
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +31 -0
- package/build-module/components/zoom-out-toggle/index.js.map +1 -0
- package/build-module/dataviews/actions/reset-post.js +4 -8
- package/build-module/dataviews/actions/reset-post.js.map +1 -1
- package/build-module/dataviews/actions/trash-post.js +4 -8
- package/build-module/dataviews/actions/trash-post.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +2 -8
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +6 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +3 -7
- package/build-style/style.css +3 -7
- package/build-types/components/editor-history/redo.d.ts.map +1 -1
- package/build-types/components/editor-history/undo.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/header/back-button.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
- package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/media-util.d.ts +20 -0
- package/build-types/components/post-publish-panel/media-util.d.ts.map +1 -0
- package/build-types/components/post-trash/check.d.ts.map +1 -1
- package/build-types/components/post-trash/index.d.ts +4 -1
- package/build-types/components/post-trash/index.d.ts.map +1 -1
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
- package/build-types/components/preferences-modal/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts +1 -0
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/text-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
- package/build-types/components/zoom-out-toggle/index.d.ts +3 -0
- package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -0
- package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/trash-post.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +8 -8
- package/build-types/store/selectors.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/bindings/post-meta.js +1 -1
- package/src/components/block-manager/index.js +1 -2
- package/src/components/editor/index.js +1 -1
- package/src/components/editor-history/redo.js +1 -2
- package/src/components/editor-history/undo.js +1 -2
- package/src/components/error-boundary/index.js +1 -6
- package/src/components/global-styles-provider/index.js +11 -7
- package/src/components/header/index.js +12 -3
- package/src/components/header/style.scss +1 -1
- package/src/components/inserter-sidebar/index.js +2 -5
- package/src/components/post-excerpt/panel.js +1 -3
- package/src/components/post-featured-image/index.js +3 -6
- package/src/components/post-featured-image/style.scss +1 -5
- package/src/components/post-format/index.js +1 -2
- package/src/components/post-last-revision/index.js +1 -2
- package/src/components/post-locked-modal/index.js +2 -4
- package/src/components/post-publish-panel/index.js +1 -2
- package/src/components/post-publish-panel/maybe-post-format-panel.js +1 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +150 -50
- package/src/components/post-publish-panel/media-util.js +87 -0
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-publish-panel/test/media-util.js +118 -0
- package/src/components/post-trash/check.js +5 -2
- package/src/components/post-trash/index.js +23 -12
- package/src/components/preferences-modal/index.js +227 -172
- package/src/components/preview-dropdown/index.js +26 -84
- package/src/components/provider/index.js +42 -10
- package/src/components/provider/use-block-editor-settings.js +11 -6
- package/src/components/sidebar/post-summary.js +4 -0
- package/src/components/start-page-options/index.js +28 -26
- package/src/components/start-template-options/index.js +1 -2
- package/src/components/table-of-contents/index.js +1 -2
- package/src/components/text-editor/index.js +1 -2
- package/src/components/text-editor/style.scss +1 -1
- package/src/components/visual-editor/edit-template-blocks-notification.js +4 -1
- package/src/components/zoom-out-toggle/index.js +34 -0
- package/src/dataviews/actions/reset-post.tsx +2 -4
- package/src/dataviews/actions/trash-post.tsx +2 -4
- package/src/dataviews/store/private-actions.ts +10 -8
- package/src/store/selectors.js +9 -3
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataviews/actions/duplicate-pattern.js +0 -48
- package/build/dataviews/actions/duplicate-pattern.js.map +0 -1
- package/build/dataviews/actions/duplicate-post.js +0 -146
- package/build/dataviews/actions/duplicate-post.js.map +0 -1
- package/build/dataviews/actions/duplicate-post.native.js +0 -9
- package/build/dataviews/actions/duplicate-post.native.js.map +0 -1
- package/build/dataviews/actions/export-pattern.js +0 -57
- package/build/dataviews/actions/export-pattern.js.map +0 -1
- package/build/dataviews/actions/export-pattern.native.js +0 -9
- package/build/dataviews/actions/export-pattern.native.js.map +0 -1
- package/build/dataviews/actions/permanently-delete-post.js +0 -109
- package/build/dataviews/actions/permanently-delete-post.js.map +0 -1
- package/build/dataviews/actions/reorder-page.js +0 -116
- package/build/dataviews/actions/reorder-page.js.map +0 -1
- package/build/dataviews/actions/reorder-page.native.js +0 -9
- package/build/dataviews/actions/reorder-page.native.js.map +0 -1
- package/build/dataviews/actions/view-post-revisions.js +0 -49
- package/build/dataviews/actions/view-post-revisions.js.map +0 -1
- package/build/dataviews/actions/view-post.js +0 -36
- package/build/dataviews/actions/view-post.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-pattern.js +0 -39
- package/build-module/dataviews/actions/duplicate-pattern.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-post.js +0 -139
- package/build-module/dataviews/actions/duplicate-post.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-post.native.js +0 -3
- package/build-module/dataviews/actions/duplicate-post.native.js.map +0 -1
- package/build-module/dataviews/actions/export-pattern.js +0 -51
- package/build-module/dataviews/actions/export-pattern.js.map +0 -1
- package/build-module/dataviews/actions/export-pattern.native.js +0 -3
- package/build-module/dataviews/actions/export-pattern.native.js.map +0 -1
- package/build-module/dataviews/actions/permanently-delete-post.js +0 -102
- package/build-module/dataviews/actions/permanently-delete-post.js.map +0 -1
- package/build-module/dataviews/actions/reorder-page.js +0 -111
- package/build-module/dataviews/actions/reorder-page.js.map +0 -1
- package/build-module/dataviews/actions/reorder-page.native.js +0 -3
- package/build-module/dataviews/actions/reorder-page.native.js.map +0 -1
- package/build-module/dataviews/actions/view-post-revisions.js +0 -43
- package/build-module/dataviews/actions/view-post-revisions.js.map +0 -1
- package/build-module/dataviews/actions/view-post.js +0 -30
- package/build-module/dataviews/actions/view-post.js.map +0 -1
- package/build-types/dataviews/actions/duplicate-pattern.d.ts +0 -5
- package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +0 -1
- package/build-types/dataviews/actions/duplicate-post.d.ts +0 -5
- package/build-types/dataviews/actions/duplicate-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/duplicate-post.native.d.ts +0 -3
- package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/export-pattern.d.ts +0 -8
- package/build-types/dataviews/actions/export-pattern.d.ts.map +0 -1
- package/build-types/dataviews/actions/export-pattern.native.d.ts +0 -3
- package/build-types/dataviews/actions/export-pattern.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/permanently-delete-post.d.ts +0 -5
- package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/reorder-page.d.ts +0 -8
- package/build-types/dataviews/actions/reorder-page.d.ts.map +0 -1
- package/build-types/dataviews/actions/reorder-page.native.d.ts +0 -3
- package/build-types/dataviews/actions/reorder-page.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/view-post-revisions.d.ts +0 -8
- package/build-types/dataviews/actions/view-post-revisions.d.ts.map +0 -1
- package/build-types/dataviews/actions/view-post.d.ts +0 -8
- package/build-types/dataviews/actions/view-post.d.ts.map +0 -1
- package/src/dataviews/actions/duplicate-pattern.tsx +0 -40
- package/src/dataviews/actions/duplicate-post.native.tsx +0 -3
- package/src/dataviews/actions/duplicate-post.tsx +0 -174
- package/src/dataviews/actions/export-pattern.native.tsx +0 -3
- package/src/dataviews/actions/export-pattern.tsx +0 -76
- package/src/dataviews/actions/permanently-delete-post.tsx +0 -118
- package/src/dataviews/actions/reorder-page.native.tsx +0 -3
- package/src/dataviews/actions/reorder-page.tsx +0 -125
- package/src/dataviews/actions/view-post-revisions.tsx +0 -47
- package/src/dataviews/actions/view-post.tsx +0 -30
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _url = require("@wordpress/url");
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const viewPostRevisions = {
|
|
18
|
-
id: 'view-post-revisions',
|
|
19
|
-
context: 'list',
|
|
20
|
-
label(items) {
|
|
21
|
-
var _items$0$_links$versi;
|
|
22
|
-
const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
|
|
23
|
-
return (0, _i18n.sprintf)( /* translators: %s: number of revisions */
|
|
24
|
-
(0, _i18n.__)('View revisions (%s)'), revisionsCount);
|
|
25
|
-
},
|
|
26
|
-
isEligible(post) {
|
|
27
|
-
var _post$_links$predeces, _post$_links$version;
|
|
28
|
-
if (post.status === 'trash') {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
|
|
32
|
-
const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
|
|
33
|
-
return !!lastRevisionId && revisionsCount > 1;
|
|
34
|
-
},
|
|
35
|
-
callback(posts, {
|
|
36
|
-
onActionPerformed
|
|
37
|
-
}) {
|
|
38
|
-
const post = posts[0];
|
|
39
|
-
const href = (0, _url.addQueryArgs)('revision.php', {
|
|
40
|
-
revision: post?._links?.['predecessor-version']?.[0]?.id
|
|
41
|
-
});
|
|
42
|
-
document.location.href = href;
|
|
43
|
-
if (onActionPerformed) {
|
|
44
|
-
onActionPerformed(posts);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var _default = exports.default = viewPostRevisions;
|
|
49
|
-
//# sourceMappingURL=view-post-revisions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_url","require","_i18n","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","sprintf","__","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","addQueryArgs","revision","document","location","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/view-post-revisions.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Post } from '../types';\n\nconst viewPostRevisions: Action< Post > = {\n\tid: 'view-post-revisions',\n\tcontext: 'list',\n\tlabel( items ) {\n\t\tconst revisionsCount =\n\t\t\titems[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn sprintf(\n\t\t\t/* translators: %s: number of revisions */\n\t\t\t__( 'View revisions (%s)' ),\n\t\t\trevisionsCount\n\t\t);\n\t},\n\tisEligible( post ) {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn !! lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport default viewPostRevisions;\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,iBAAiC,GAAG;EACzCC,EAAE,EAAE,qBAAqB;EACzBC,OAAO,EAAE,MAAM;EACfC,KAAKA,CAAEC,KAAK,EAAG;IAAA,IAAAC,qBAAA;IACd,MAAMC,cAAc,IAAAD,qBAAA,GACnBD,KAAK,CAAE,CAAC,CAAE,CAACG,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,CAAC;IAC5D,OAAO,IAAAI,aAAO,GACb;IACA,IAAAC,QAAE,EAAE,qBAAsB,CAAC,EAC3BJ,cACD,CAAC;EACF,CAAC;EACDK,UAAUA,CAAEC,IAAI,EAAG;IAAA,IAAAC,qBAAA,EAAAC,oBAAA;IAClB,IAAKF,IAAI,CAACG,MAAM,KAAK,OAAO,EAAG;MAC9B,OAAO,KAAK;IACb;IACA,MAAMC,cAAc,IAAAH,qBAAA,GACnBD,IAAI,EAAEL,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN,EAAE,cAAAY,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAMP,cAAc,IAAAQ,oBAAA,GACnBF,IAAI,EAAEL,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAM,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAO,CAAC,CAAEE,cAAc,IAAIV,cAAc,GAAG,CAAC;EAC/C,CAAC;EACDW,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMP,IAAI,GAAGM,KAAK,CAAE,CAAC,CAAE;IACvB,MAAME,IAAI,GAAG,IAAAC,iBAAY,EAAE,cAAc,EAAE;MAC1CC,QAAQ,EAAEV,IAAI,EAAEL,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN;IAC3D,CAAE,CAAC;IACHsB,QAAQ,CAACC,QAAQ,CAACJ,IAAI,GAAGA,IAAI;IAC7B,IAAKD,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3B,iBAAiB","ignoreList":[]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _icons = require("@wordpress/icons");
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const viewPost = {
|
|
18
|
-
id: 'view-post',
|
|
19
|
-
label: (0, _i18n._x)('View', 'verb'),
|
|
20
|
-
isPrimary: true,
|
|
21
|
-
icon: _icons.external,
|
|
22
|
-
isEligible(post) {
|
|
23
|
-
return post.status !== 'trash';
|
|
24
|
-
},
|
|
25
|
-
callback(posts, {
|
|
26
|
-
onActionPerformed
|
|
27
|
-
}) {
|
|
28
|
-
const post = posts[0];
|
|
29
|
-
window.open(post?.link, '_blank');
|
|
30
|
-
if (onActionPerformed) {
|
|
31
|
-
onActionPerformed(posts);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var _default = exports.default = viewPost;
|
|
36
|
-
//# sourceMappingURL=view-post.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_i18n","viewPost","id","label","_x","isPrimary","icon","external","isEligible","post","status","callback","posts","onActionPerformed","window","open","link","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/view-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { _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":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAM,EAAE,MAAO,CAAC;EAC3BC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,eAAQ;EACdC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOA,IAAI,CAACC,MAAM,KAAK,OAAO;EAC/B,CAAC;EACDC,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMJ,IAAI,GAAGG,KAAK,CAAE,CAAC,CAAE;IACvBE,MAAM,CAACC,IAAI,CAAEN,IAAI,EAAEO,IAAI,EAAE,QAAS,CAAC;IACnC,IAAKH,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalB,QAAQ","ignoreList":[]}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/editor/src/dataviews/actions/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":[]}
|
|
@@ -1,139 +0,0 @@
|
|
|
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 { getItemTitle } from '../../dataviews/actions/utils';
|
|
16
|
-
import { titleField } from '../fields';
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","decodeEntities","store","coreStore","__","sprintf","_x","noticesStore","useState","DataForm","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","getItemTitle","titleField","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/editor/src/dataviews/actions/duplicate-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport { DataForm } from '@wordpress/dataviews';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../dataviews/actions/utils';\nimport type { CoreDataError, BasePost } from '../types';\nimport { titleField } from '../fields';\n\nconst fields = [ titleField ];\nconst formDuplicateAction = {\n\tfields: [ 'title' ],\n};\n\nconst duplicatePost: Action< BasePost > = {\n\tid: 'duplicate-post',\n\tlabel: _x( 'Duplicate', 'action label' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ item, setItem ] = useState< BasePost >( {\n\t\t\t...items[ 0 ],\n\t\t\ttitle: sprintf(\n\t\t\t\t/* translators: %s: Existing template title */\n\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t),\n\t\t} );\n\n\t\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function createPage( event: React.FormEvent ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( isCreatingPage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newItemOject = {\n\t\t\t\tstatus: 'draft',\n\t\t\t\ttitle: item.title,\n\t\t\t\tslug: item.title || __( 'No title' ),\n\t\t\t\tcomment_status: item.comment_status,\n\t\t\t\tcontent:\n\t\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t: item.content.raw,\n\t\t\t\texcerpt:\n\t\t\t\t\ttypeof item.excerpt === 'string'\n\t\t\t\t\t\t? item.excerpt\n\t\t\t\t\t\t: item.excerpt?.raw,\n\t\t\t\tmeta: item.meta,\n\t\t\t\tparent: item.parent,\n\t\t\t\tpassword: item.password,\n\t\t\t\ttemplate: item.template,\n\t\t\t\tformat: item.format,\n\t\t\t\tfeatured_media: item.featured_media,\n\t\t\t\tmenu_order: item.menu_order,\n\t\t\t\tping_status: item.ping_status,\n\t\t\t};\n\t\t\tconst assignablePropertiesPrefix = 'wp:action-assign-';\n\t\t\t// Get all the properties that the current user is able to assign normally author, categories, tags,\n\t\t\t// and custom taxonomies.\n\t\t\tconst assignableProperties = Object.keys( item?._links || {} )\n\t\t\t\t.filter( ( property ) =>\n\t\t\t\t\tproperty.startsWith( assignablePropertiesPrefix )\n\t\t\t\t)\n\t\t\t\t.map( ( property ) =>\n\t\t\t\t\tproperty.slice( assignablePropertiesPrefix.length )\n\t\t\t\t);\n\t\t\tassignableProperties.forEach( ( property ) => {\n\t\t\t\tif ( item.hasOwnProperty( property ) ) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnewItemOject[ property ] = item[ property ];\n\t\t\t\t}\n\t\t\t} );\n\t\t\tsetIsCreatingPage( true );\n\t\t\ttry {\n\t\t\t\tconst newItem = await saveEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\titem.type,\n\t\t\t\t\tnewItemOject,\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\tdecodeEntities( newItem.title?.rendered || item.title )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\tonActionPerformed( [ newItem ] );\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: __( 'An error occurred while duplicating the page.' );\n\n\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} finally {\n\t\t\t\tsetIsCreatingPage( false );\n\t\t\t\tcloseModal?.();\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<DataForm\n\t\t\t\t\t\tdata={ item }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ formDuplicateAction }\n\t\t\t\t\t\tonChange={ ( changes ) =>\n\t\t\t\t\t\t\tsetItem( ( prev ) => ( {\n\t\t\t\t\t\t\t\t...prev,\n\t\t\t\t\t\t\t\t...changes,\n\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Duplicate', 'action label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n\nexport default duplicatePost;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASJ,KAAK,IAAIK,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAG9B;AACA;AACA;AACA,SAASC,YAAY,QAAQ,+BAA+B;AAE5D,SAASC,UAAU,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEvC,MAAMC,MAAM,GAAG,CAAEL,UAAU,CAAE;AAC7B,MAAMM,mBAAmB,GAAG;EAC3BD,MAAM,EAAE,CAAE,OAAO;AAClB,CAAC;AAED,MAAME,aAAiC,GAAG;EACzCC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAEnB,EAAE,CAAE,WAAW,EAAE,cAAe,CAAC;EACxCoB,UAAUA,CAAE;IAAEC;EAAO,CAAC,EAAG;IACxB,OAAOA,MAAM,KAAK,OAAO;EAC1B,CAAC;EACDC,WAAW,EAAEA,CAAE;IAAEC,KAAK;IAAEC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AC;AAED,eAAeiB,aAAa","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["duplicatePost","undefined"],"sources":["@wordpress/editor/src/dataviews/actions/duplicate-post.native.tsx"],"sourcesContent":["const duplicatePost = undefined;\n\nexport default duplicatePost;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGC,SAAS;AAE/B,eAAeD,aAAa","ignoreList":[]}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { paramCase as kebabCase } from 'change-case';
|
|
5
|
-
import { downloadZip } from 'client-zip';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { downloadBlob } from '@wordpress/blob';
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { download } from '@wordpress/icons';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { getItemTitle } from './utils';
|
|
19
|
-
function getJsonFromItem(item) {
|
|
20
|
-
return JSON.stringify({
|
|
21
|
-
__file: item.type,
|
|
22
|
-
title: getItemTitle(item),
|
|
23
|
-
content: typeof item.content === 'string' ? item.content : item.content?.raw,
|
|
24
|
-
syncStatus: item.wp_pattern_sync_status
|
|
25
|
-
}, null, 2);
|
|
26
|
-
}
|
|
27
|
-
const exportPattern = {
|
|
28
|
-
id: 'export-pattern',
|
|
29
|
-
label: __('Export as JSON'),
|
|
30
|
-
icon: download,
|
|
31
|
-
supportsBulk: true,
|
|
32
|
-
isEligible: item => item.type === 'wp_block',
|
|
33
|
-
callback: async items => {
|
|
34
|
-
if (items.length === 1) {
|
|
35
|
-
return downloadBlob(`${kebabCase(getItemTitle(items[0]) || items[0].slug)}.json`, getJsonFromItem(items[0]), 'application/json');
|
|
36
|
-
}
|
|
37
|
-
const nameCount = {};
|
|
38
|
-
const filesToZip = items.map(item => {
|
|
39
|
-
const name = kebabCase(getItemTitle(item) || item.slug);
|
|
40
|
-
nameCount[name] = (nameCount[name] || 0) + 1;
|
|
41
|
-
return {
|
|
42
|
-
name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
|
|
43
|
-
lastModified: new Date(),
|
|
44
|
-
input: getJsonFromItem(item)
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
return downloadBlob(__('patterns-export') + '.zip', await downloadZip(filesToZip).blob(), 'application/zip');
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
export default exportPattern;
|
|
51
|
-
//# sourceMappingURL=export-pattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["paramCase","kebabCase","downloadZip","downloadBlob","__","download","getItemTitle","getJsonFromItem","item","JSON","stringify","__file","type","title","content","raw","syncStatus","wp_pattern_sync_status","exportPattern","id","label","icon","supportsBulk","isEligible","callback","items","length","slug","nameCount","filesToZip","map","name","lastModified","Date","input","blob"],"sources":["@wordpress/editor/src/dataviews/actions/export-pattern.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\nimport { downloadZip } from 'client-zip';\n\n/**\n * WordPress dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\nimport { __ } from '@wordpress/i18n';\nimport { download } from '@wordpress/icons';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Pattern } from '../types';\nimport { getItemTitle } from './utils';\n\nfunction getJsonFromItem( item: Pattern ) {\n\treturn JSON.stringify(\n\t\t{\n\t\t\t__file: item.type,\n\t\t\ttitle: getItemTitle( item ),\n\t\t\tcontent:\n\t\t\t\ttypeof item.content === 'string'\n\t\t\t\t\t? item.content\n\t\t\t\t\t: item.content?.raw,\n\t\t\tsyncStatus: item.wp_pattern_sync_status,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n}\n\nconst exportPattern: Action< Pattern > = {\n\tid: 'export-pattern',\n\tlabel: __( 'Export as JSON' ),\n\ticon: download,\n\tsupportsBulk: true,\n\tisEligible: ( item ) => item.type === 'wp_block',\n\tcallback: async ( items ) => {\n\t\tif ( items.length === 1 ) {\n\t\t\treturn downloadBlob(\n\t\t\t\t`${ kebabCase(\n\t\t\t\t\tgetItemTitle( items[ 0 ] ) || items[ 0 ].slug\n\t\t\t\t) }.json`,\n\t\t\t\tgetJsonFromItem( items[ 0 ] ),\n\t\t\t\t'application/json'\n\t\t\t);\n\t\t}\n\t\tconst nameCount: Record< string, number > = {};\n\t\tconst filesToZip = items.map( ( item ) => {\n\t\t\tconst name = kebabCase( getItemTitle( item ) || item.slug );\n\t\t\tnameCount[ name ] = ( nameCount[ name ] || 0 ) + 1;\n\t\t\treturn {\n\t\t\t\tname: `${\n\t\t\t\t\tname +\n\t\t\t\t\t( nameCount[ name ] > 1\n\t\t\t\t\t\t? '-' + ( nameCount[ name ] - 1 )\n\t\t\t\t\t\t: '' )\n\t\t\t\t}.json`,\n\t\t\t\tlastModified: new Date(),\n\t\t\t\tinput: getJsonFromItem( item ),\n\t\t\t};\n\t\t} );\n\t\treturn downloadBlob(\n\t\t\t__( 'patterns-export' ) + '.zip',\n\t\t\tawait downloadZip( filesToZip ).blob(),\n\t\t\t'application/zip'\n\t\t);\n\t},\n};\n\nexport default exportPattern;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;AACpD,SAASC,WAAW,QAAQ,YAAY;;AAExC;AACA;AACA;AACA,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,kBAAkB;;AAG3C;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,SAAS;AAEtC,SAASC,eAAeA,CAAEC,IAAa,EAAG;EACzC,OAAOC,IAAI,CAACC,SAAS,CACpB;IACCC,MAAM,EAAEH,IAA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,CAAE,GAC/B,EAAE,CACL,OAAM;QACPC,YAAY,EAAE,IAAIC,IAAI,CAAC,CAAC;QACxBC,KAAK,EAAE3B,eAAe,CAAEC,IAAK;MAC9B,CAAC;IACF,CAAE,CAAC;IACH,OAAOL,YAAY,CAClBC,EAAE,CAAE,iBAAkB,CAAC,GAAG,MAAM,EAChC,MAAMF,WAAW,CAAE2B,UAAW,CAAC,CAACM,IAAI,CAAC,CAAC,EACtC,iBACD,CAAC;EACF;AACD,CAAC;AAED,eAAejB,aAAa","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["exportPattern","undefined"],"sources":["@wordpress/editor/src/dataviews/actions/export-pattern.native.tsx"],"sourcesContent":["const exportPattern = undefined;\n\nexport default exportPattern;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGC,SAAS;AAE/B,eAAeD,aAAa","ignoreList":[]}
|
|
@@ -1,102 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/editor/src/dataviews/actions/permanently-delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\nimport { trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst permanentlyDeletePost: Action< PostWithPermissions > = {\n\tid: 'permanently-delete',\n\tlabel: __( 'Permanently delete' ),\n\tsupportsBulk: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { status, permissions } = item;\n\t\treturn status === 'trash' && permissions?.delete;\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = registry.dispatch( coreStore );\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ force: true },\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'The items were permanently deleted.' );\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'permanently-delete-post-action',\n\t\t\t} );\n\t\t\tonActionPerformed?.( posts );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to permanently delete a single post.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'An error occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\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M,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":[]}
|
|
@@ -1,111 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/editor/src/dataviews/actions/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,SAASC,QAAQ,EAAEC,WAAW,QAAQ,sBAAsB;AAC5D,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;;AAG9B;AACA;AACA;;AAEA,SAASC,UAAU,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEvC,MAAMC,MAAM,GAAG,CAAEL,UAAU,CAAE;AAC7B,MAAMM,eAAe,GAAG;EACvBD,MAAM,EAAE,CAAE,YAAY;AACvB,CAAC;AAED,SAASE,YAAYA,CAAE;EACtBC,KAAK;EACLC,UAAU;EACVC;AAC6B,CAAC,EAAG;EACjC,MAAM,CAAEC,IAAI,EAAEC,OAAO,CAAE,GAAGpB,QAAQ,CAAEgB,KAAK,CAAE,CAAC,CAAG,CAAC;EAChD,MAAMK,UAAU,GAAGF,IAAI,CAACG,UAAU;EAClC,MAAM;IAAEC,gBAAgB;IAAEC;EAAuB,CAAC,GACjD7B,WAAW,CAAEE,SAAU,CAAC;EACzB,MAAM;IAAE4B,mBAAmB;IAAEC;EAAk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