@wordpress/editor 14.7.1-next.5368f64a9.0 → 14.8.1
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/README.md +1 -1
- package/build/bindings/post-meta.js +42 -7
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +45 -66
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/document-bar/index.js +20 -28
- package/build/components/document-bar/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/editor-interface/index.js +1 -2
- package/build/components/editor-interface/index.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 +21 -12
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +4 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -0
- package/build/components/media-categories/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 +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-status/index.js +1 -0
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +2 -4
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-url/index.js +8 -7
- package/build/components/post-url/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/save-publish-panels/index.js +4 -10
- package/build/components/save-publish-panels/index.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/store/private-actions.js +4 -10
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build-module/bindings/post-meta.js +40 -7
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +46 -67
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +22 -28
- package/build-module/components/document-bar/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/editor-interface/index.js +1 -2
- package/build-module/components/editor-interface/index.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 +21 -12
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +4 -4
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -0
- package/build-module/components/media-categories/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 +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -0
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +2 -4
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-url/index.js +9 -8
- package/build-module/components/post-url/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/save-publish-panels/index.js +4 -10
- package/build-module/components/save-publish-panels/index.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/store/private-actions.js +2 -8
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +38 -23
- package/build-style/style.css +38 -23
- package/build-types/bindings/post-meta.d.ts +4 -1
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/block-manager/index.d.ts +1 -2
- package/build-types/components/block-manager/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +7 -6
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- 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/editor-interface/index.d.ts +1 -2
- package/build-types/components/editor-interface/index.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/index.d.ts +2 -2
- package/build-types/components/header/index.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.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.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/store/private-actions.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/bindings/post-meta.js +56 -20
- package/src/components/block-manager/index.js +50 -67
- package/src/components/document-bar/index.js +29 -41
- package/src/components/document-bar/style.scss +33 -15
- package/src/components/editor-history/redo.js +1 -2
- package/src/components/editor-history/undo.js +1 -2
- package/src/components/editor-interface/index.js +1 -2
- package/src/components/error-boundary/index.js +1 -6
- package/src/components/global-styles-provider/index.js +50 -36
- package/src/components/header/index.js +8 -2
- 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-panel-row/style.scss +1 -0
- 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 +1 -2
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-status/index.js +1 -0
- package/src/components/post-status/style.scss +5 -0
- package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -2
- package/src/components/post-taxonomies/most-used-terms.js +1 -2
- package/src/components/post-taxonomies/style.scss +0 -4
- package/src/components/post-url/index.js +9 -7
- package/src/components/preview-dropdown/index.js +26 -84
- package/src/components/save-publish-panels/index.js +2 -6
- package/src/components/zoom-out-toggle/index.js +34 -0
- package/src/dataviews/store/private-actions.ts +10 -8
- package/tsconfig.json +1 -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["reorderPage","undefined"],"sources":["@wordpress/editor/src/dataviews/actions/reorder-page.native.tsx"],"sourcesContent":["const reorderPage = undefined;\n\nexport default reorderPage;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGC,SAAS;AAE7B,eAAeD,WAAW","ignoreList":[]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
5
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const viewPostRevisions = {
|
|
12
|
-
id: 'view-post-revisions',
|
|
13
|
-
context: 'list',
|
|
14
|
-
label(items) {
|
|
15
|
-
var _items$0$_links$versi;
|
|
16
|
-
const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
|
|
17
|
-
return sprintf( /* translators: %s: number of revisions */
|
|
18
|
-
__('View revisions (%s)'), revisionsCount);
|
|
19
|
-
},
|
|
20
|
-
isEligible(post) {
|
|
21
|
-
var _post$_links$predeces, _post$_links$version;
|
|
22
|
-
if (post.status === 'trash') {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
|
|
26
|
-
const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
|
|
27
|
-
return !!lastRevisionId && revisionsCount > 1;
|
|
28
|
-
},
|
|
29
|
-
callback(posts, {
|
|
30
|
-
onActionPerformed
|
|
31
|
-
}) {
|
|
32
|
-
const post = posts[0];
|
|
33
|
-
const href = addQueryArgs('revision.php', {
|
|
34
|
-
revision: post?._links?.['predecessor-version']?.[0]?.id
|
|
35
|
-
});
|
|
36
|
-
document.location.href = href;
|
|
37
|
-
if (onActionPerformed) {
|
|
38
|
-
onActionPerformed(posts);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
export default viewPostRevisions;
|
|
43
|
-
//# sourceMappingURL=view-post-revisions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["addQueryArgs","__","sprintf","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","revision","document","location"],"sources":["@wordpress/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":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAG7C;AACA;AACA;;AAGA,MAAMC,iBAAiC,GAAG;EACzCC,EAAE,EAAE,qBAAqB;EACzBC,OAAO,EAAE,MAAM;EACfC,KAAKA,CAAEC,KAAK,EAAG;IAAA,IAAAC,qBAAA;IACd,MAAMC,cAAc,IAAAD,qBAAA,GACnBD,KAAK,CAAE,CAAC,CAAE,CAACG,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,CAAC;IAC5D,OAAON,OAAO,EACb;IACAD,EAAE,CAAE,qBAAsB,CAAC,EAC3BQ,cACD,CAAC;EACF,CAAC;EACDG,UAAUA,CAAEC,IAAI,EAAG;IAAA,IAAAC,qBAAA,EAAAC,oBAAA;IAClB,IAAKF,IAAI,CAACG,MAAM,KAAK,OAAO,EAAG;MAC9B,OAAO,KAAK;IACb;IACA,MAAMC,cAAc,IAAAH,qBAAA,GACnBD,IAAI,EAAEH,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN,EAAE,cAAAU,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAML,cAAc,IAAAM,oBAAA,GACnBF,IAAI,EAAEH,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEC,KAAK,cAAAI,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAO,CAAC,CAAEE,cAAc,IAAIR,cAAc,GAAG,CAAC;EAC/C,CAAC;EACDS,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMP,IAAI,GAAGM,KAAK,CAAE,CAAC,CAAE;IACvB,MAAME,IAAI,GAAGrB,YAAY,CAAE,cAAc,EAAE;MAC1CsB,QAAQ,EAAET,IAAI,EAAEH,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN;IAC3D,CAAE,CAAC;IACHmB,QAAQ,CAACC,QAAQ,CAACH,IAAI,GAAGA,IAAI;IAC7B,IAAKD,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAED,eAAehB,iBAAiB","ignoreList":[]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { external } from '@wordpress/icons';
|
|
5
|
-
import { _x } from '@wordpress/i18n';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const viewPost = {
|
|
12
|
-
id: 'view-post',
|
|
13
|
-
label: _x('View', 'verb'),
|
|
14
|
-
isPrimary: true,
|
|
15
|
-
icon: external,
|
|
16
|
-
isEligible(post) {
|
|
17
|
-
return post.status !== 'trash';
|
|
18
|
-
},
|
|
19
|
-
callback(posts, {
|
|
20
|
-
onActionPerformed
|
|
21
|
-
}) {
|
|
22
|
-
const post = posts[0];
|
|
23
|
-
window.open(post?.link, '_blank');
|
|
24
|
-
if (onActionPerformed) {
|
|
25
|
-
onActionPerformed(posts);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export default viewPost;
|
|
30
|
-
//# sourceMappingURL=view-post.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["external","_x","viewPost","id","label","isPrimary","icon","isEligible","post","status","callback","posts","onActionPerformed","window","open","link"],"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":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;;AAGpC;AACA;AACA;;AAGA,MAAMC,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,MAAO,CAAC;EAC3BI,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEN,QAAQ;EACdO,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOA,IAAI,CAACC,MAAM,KAAK,OAAO;EAC/B,CAAC;EACDC,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMJ,IAAI,GAAGG,KAAK,CAAE,CAAC,CAAE;IACvBE,MAAM,CAACC,IAAI,CAAEN,IAAI,EAAEO,IAAI,EAAE,QAAS,CAAC;IACnC,IAAKH,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAED,eAAeT,QAAQ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-pattern.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/duplicate-pattern.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAE,OAAO,CAmBtC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/duplicate-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQxD,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,QAAQ,CA8IpC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-post.native.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/duplicate-post.native.tsx"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,WAAY,CAAC;AAEhC,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-pattern.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/export-pattern.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAmBxC,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,OAAO,CAqCnC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-pattern.native.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/export-pattern.native.tsx"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,WAAY,CAAC;AAEhC,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permanently-delete-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/permanently-delete-post.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAOnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEnE,QAAA,MAAM,qBAAqB,EAAE,MAAM,CAAE,mBAAmB,CAoGvD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reorder-page.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/reorder-page.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgGxD,QAAA,MAAM,WAAW,EAAE,MAAM,CAAE,QAAQ,CAOlC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reorder-page.native.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/reorder-page.native.tsx"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW,WAAY,CAAC;AAE9B,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-post-revisions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/view-post-revisions.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAE,IAAI,CAgCpC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/view-post.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAE,QAAQ,CAe/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,40 +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
|
-
import type { Action } from '@wordpress/dataviews';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { unlock } from '../../lock-unlock';
|
|
13
|
-
import type { Pattern } from '../types';
|
|
14
|
-
|
|
15
|
-
// Patterns.
|
|
16
|
-
const { CreatePatternModalContents, useDuplicatePatternProps } =
|
|
17
|
-
unlock( patternsPrivateApis );
|
|
18
|
-
|
|
19
|
-
const duplicatePattern: Action< Pattern > = {
|
|
20
|
-
id: 'duplicate-pattern',
|
|
21
|
-
label: _x( 'Duplicate', 'action label' ),
|
|
22
|
-
isEligible: ( item ) => item.type !== 'wp_template_part',
|
|
23
|
-
modalHeader: _x( 'Duplicate pattern', 'action label' ),
|
|
24
|
-
RenderModal: ( { items, closeModal } ) => {
|
|
25
|
-
const [ item ] = items;
|
|
26
|
-
const duplicatedProps = useDuplicatePatternProps( {
|
|
27
|
-
pattern: item,
|
|
28
|
-
onSuccess: () => closeModal?.(),
|
|
29
|
-
} );
|
|
30
|
-
return (
|
|
31
|
-
<CreatePatternModalContents
|
|
32
|
-
onClose={ closeModal }
|
|
33
|
-
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
34
|
-
{ ...duplicatedProps }
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default duplicatePattern;
|
|
@@ -1,174 +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 {
|
|
12
|
-
Button,
|
|
13
|
-
__experimentalHStack as HStack,
|
|
14
|
-
__experimentalVStack as VStack,
|
|
15
|
-
} from '@wordpress/components';
|
|
16
|
-
import type { Action } from '@wordpress/dataviews';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
import { getItemTitle } from '../../dataviews/actions/utils';
|
|
22
|
-
import type { CoreDataError, BasePost } from '../types';
|
|
23
|
-
import { titleField } from '../fields';
|
|
24
|
-
|
|
25
|
-
const fields = [ titleField ];
|
|
26
|
-
const formDuplicateAction = {
|
|
27
|
-
fields: [ 'title' ],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const duplicatePost: Action< BasePost > = {
|
|
31
|
-
id: 'duplicate-post',
|
|
32
|
-
label: _x( 'Duplicate', 'action label' ),
|
|
33
|
-
isEligible( { status } ) {
|
|
34
|
-
return status !== 'trash';
|
|
35
|
-
},
|
|
36
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
37
|
-
const [ item, setItem ] = useState< BasePost >( {
|
|
38
|
-
...items[ 0 ],
|
|
39
|
-
title: sprintf(
|
|
40
|
-
/* translators: %s: Existing template title */
|
|
41
|
-
__( '%s (Copy)' ),
|
|
42
|
-
getItemTitle( items[ 0 ] )
|
|
43
|
-
),
|
|
44
|
-
} );
|
|
45
|
-
|
|
46
|
-
const [ isCreatingPage, setIsCreatingPage ] = useState( false );
|
|
47
|
-
const { saveEntityRecord } = useDispatch( coreStore );
|
|
48
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
49
|
-
useDispatch( noticesStore );
|
|
50
|
-
|
|
51
|
-
async function createPage( event: React.FormEvent ) {
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
|
|
54
|
-
if ( isCreatingPage ) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const newItemOject = {
|
|
59
|
-
status: 'draft',
|
|
60
|
-
title: item.title,
|
|
61
|
-
slug: item.title || __( 'No title' ),
|
|
62
|
-
comment_status: item.comment_status,
|
|
63
|
-
content:
|
|
64
|
-
typeof item.content === 'string'
|
|
65
|
-
? item.content
|
|
66
|
-
: item.content.raw,
|
|
67
|
-
excerpt:
|
|
68
|
-
typeof item.excerpt === 'string'
|
|
69
|
-
? item.excerpt
|
|
70
|
-
: item.excerpt?.raw,
|
|
71
|
-
meta: item.meta,
|
|
72
|
-
parent: item.parent,
|
|
73
|
-
password: item.password,
|
|
74
|
-
template: item.template,
|
|
75
|
-
format: item.format,
|
|
76
|
-
featured_media: item.featured_media,
|
|
77
|
-
menu_order: item.menu_order,
|
|
78
|
-
ping_status: item.ping_status,
|
|
79
|
-
};
|
|
80
|
-
const assignablePropertiesPrefix = 'wp:action-assign-';
|
|
81
|
-
// Get all the properties that the current user is able to assign normally author, categories, tags,
|
|
82
|
-
// and custom taxonomies.
|
|
83
|
-
const assignableProperties = Object.keys( item?._links || {} )
|
|
84
|
-
.filter( ( property ) =>
|
|
85
|
-
property.startsWith( assignablePropertiesPrefix )
|
|
86
|
-
)
|
|
87
|
-
.map( ( property ) =>
|
|
88
|
-
property.slice( assignablePropertiesPrefix.length )
|
|
89
|
-
);
|
|
90
|
-
assignableProperties.forEach( ( property ) => {
|
|
91
|
-
if ( item.hasOwnProperty( property ) ) {
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
newItemOject[ property ] = item[ property ];
|
|
94
|
-
}
|
|
95
|
-
} );
|
|
96
|
-
setIsCreatingPage( true );
|
|
97
|
-
try {
|
|
98
|
-
const newItem = await saveEntityRecord(
|
|
99
|
-
'postType',
|
|
100
|
-
item.type,
|
|
101
|
-
newItemOject,
|
|
102
|
-
{ throwOnError: true }
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
createSuccessNotice(
|
|
106
|
-
sprintf(
|
|
107
|
-
// translators: %s: Title of the created template e.g: "Category".
|
|
108
|
-
__( '"%s" successfully created.' ),
|
|
109
|
-
decodeEntities( newItem.title?.rendered || item.title )
|
|
110
|
-
),
|
|
111
|
-
{
|
|
112
|
-
id: 'duplicate-post-action',
|
|
113
|
-
type: 'snackbar',
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
if ( onActionPerformed ) {
|
|
118
|
-
onActionPerformed( [ newItem ] );
|
|
119
|
-
}
|
|
120
|
-
} catch ( error ) {
|
|
121
|
-
const typedError = error as CoreDataError;
|
|
122
|
-
const errorMessage =
|
|
123
|
-
typedError.message && typedError.code !== 'unknown_error'
|
|
124
|
-
? typedError.message
|
|
125
|
-
: __( 'An error occurred while duplicating the page.' );
|
|
126
|
-
|
|
127
|
-
createErrorNotice( errorMessage, {
|
|
128
|
-
type: 'snackbar',
|
|
129
|
-
} );
|
|
130
|
-
} finally {
|
|
131
|
-
setIsCreatingPage( false );
|
|
132
|
-
closeModal?.();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<form onSubmit={ createPage }>
|
|
138
|
-
<VStack spacing={ 3 }>
|
|
139
|
-
<DataForm
|
|
140
|
-
data={ item }
|
|
141
|
-
fields={ fields }
|
|
142
|
-
form={ formDuplicateAction }
|
|
143
|
-
onChange={ ( changes ) =>
|
|
144
|
-
setItem( ( prev ) => ( {
|
|
145
|
-
...prev,
|
|
146
|
-
...changes,
|
|
147
|
-
} ) )
|
|
148
|
-
}
|
|
149
|
-
/>
|
|
150
|
-
<HStack spacing={ 2 } justify="end">
|
|
151
|
-
<Button
|
|
152
|
-
variant="tertiary"
|
|
153
|
-
onClick={ closeModal }
|
|
154
|
-
__next40pxDefaultSize
|
|
155
|
-
>
|
|
156
|
-
{ __( 'Cancel' ) }
|
|
157
|
-
</Button>
|
|
158
|
-
<Button
|
|
159
|
-
variant="primary"
|
|
160
|
-
type="submit"
|
|
161
|
-
isBusy={ isCreatingPage }
|
|
162
|
-
aria-disabled={ isCreatingPage }
|
|
163
|
-
__next40pxDefaultSize
|
|
164
|
-
>
|
|
165
|
-
{ _x( 'Duplicate', 'action label' ) }
|
|
166
|
-
</Button>
|
|
167
|
-
</HStack>
|
|
168
|
-
</VStack>
|
|
169
|
-
</form>
|
|
170
|
-
);
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export default duplicatePost;
|
|
@@ -1,76 +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
|
-
import type { Action } from '@wordpress/dataviews';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import type { Pattern } from '../types';
|
|
19
|
-
import { getItemTitle } from './utils';
|
|
20
|
-
|
|
21
|
-
function getJsonFromItem( item: Pattern ) {
|
|
22
|
-
return JSON.stringify(
|
|
23
|
-
{
|
|
24
|
-
__file: item.type,
|
|
25
|
-
title: getItemTitle( item ),
|
|
26
|
-
content:
|
|
27
|
-
typeof item.content === 'string'
|
|
28
|
-
? item.content
|
|
29
|
-
: item.content?.raw,
|
|
30
|
-
syncStatus: item.wp_pattern_sync_status,
|
|
31
|
-
},
|
|
32
|
-
null,
|
|
33
|
-
2
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const exportPattern: Action< Pattern > = {
|
|
38
|
-
id: 'export-pattern',
|
|
39
|
-
label: __( 'Export as JSON' ),
|
|
40
|
-
icon: download,
|
|
41
|
-
supportsBulk: true,
|
|
42
|
-
isEligible: ( item ) => item.type === 'wp_block',
|
|
43
|
-
callback: async ( items ) => {
|
|
44
|
-
if ( items.length === 1 ) {
|
|
45
|
-
return downloadBlob(
|
|
46
|
-
`${ kebabCase(
|
|
47
|
-
getItemTitle( items[ 0 ] ) || items[ 0 ].slug
|
|
48
|
-
) }.json`,
|
|
49
|
-
getJsonFromItem( items[ 0 ] ),
|
|
50
|
-
'application/json'
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
const nameCount: Record< string, number > = {};
|
|
54
|
-
const filesToZip = items.map( ( item ) => {
|
|
55
|
-
const name = kebabCase( getItemTitle( item ) || item.slug );
|
|
56
|
-
nameCount[ name ] = ( nameCount[ name ] || 0 ) + 1;
|
|
57
|
-
return {
|
|
58
|
-
name: `${
|
|
59
|
-
name +
|
|
60
|
-
( nameCount[ name ] > 1
|
|
61
|
-
? '-' + ( nameCount[ name ] - 1 )
|
|
62
|
-
: '' )
|
|
63
|
-
}.json`,
|
|
64
|
-
lastModified: new Date(),
|
|
65
|
-
input: getJsonFromItem( item ),
|
|
66
|
-
};
|
|
67
|
-
} );
|
|
68
|
-
return downloadBlob(
|
|
69
|
-
__( 'patterns-export' ) + '.zip',
|
|
70
|
-
await downloadZip( filesToZip ).blob(),
|
|
71
|
-
'application/zip'
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default exportPattern;
|
|
@@ -1,118 +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 type { Action } from '@wordpress/dataviews';
|
|
8
|
-
import { trash } from '@wordpress/icons';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
14
|
-
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
15
|
-
|
|
16
|
-
const permanentlyDeletePost: Action< PostWithPermissions > = {
|
|
17
|
-
id: 'permanently-delete',
|
|
18
|
-
label: __( 'Permanently delete' ),
|
|
19
|
-
supportsBulk: true,
|
|
20
|
-
icon: trash,
|
|
21
|
-
isEligible( item ) {
|
|
22
|
-
if ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const { status, permissions } = item;
|
|
26
|
-
return status === 'trash' && permissions?.delete;
|
|
27
|
-
},
|
|
28
|
-
async callback( posts, { registry, onActionPerformed } ) {
|
|
29
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
30
|
-
registry.dispatch( noticesStore );
|
|
31
|
-
const { deleteEntityRecord } = registry.dispatch( coreStore );
|
|
32
|
-
const promiseResult = await Promise.allSettled(
|
|
33
|
-
posts.map( ( post ) => {
|
|
34
|
-
return deleteEntityRecord(
|
|
35
|
-
'postType',
|
|
36
|
-
post.type,
|
|
37
|
-
post.id,
|
|
38
|
-
{ force: true },
|
|
39
|
-
{ throwOnError: true }
|
|
40
|
-
);
|
|
41
|
-
} )
|
|
42
|
-
);
|
|
43
|
-
// If all the promises were fulfilled with success.
|
|
44
|
-
if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
|
|
45
|
-
let successMessage;
|
|
46
|
-
if ( promiseResult.length === 1 ) {
|
|
47
|
-
successMessage = sprintf(
|
|
48
|
-
/* translators: The posts's title. */
|
|
49
|
-
__( '"%s" permanently deleted.' ),
|
|
50
|
-
getItemTitle( posts[ 0 ] )
|
|
51
|
-
);
|
|
52
|
-
} else {
|
|
53
|
-
successMessage = __( 'The items were permanently deleted.' );
|
|
54
|
-
}
|
|
55
|
-
createSuccessNotice( successMessage, {
|
|
56
|
-
type: 'snackbar',
|
|
57
|
-
id: 'permanently-delete-post-action',
|
|
58
|
-
} );
|
|
59
|
-
onActionPerformed?.( posts );
|
|
60
|
-
} else {
|
|
61
|
-
// If there was at lease one failure.
|
|
62
|
-
let errorMessage;
|
|
63
|
-
// If we were trying to permanently delete a single post.
|
|
64
|
-
if ( promiseResult.length === 1 ) {
|
|
65
|
-
const typedError = promiseResult[ 0 ] as {
|
|
66
|
-
reason?: CoreDataError;
|
|
67
|
-
};
|
|
68
|
-
if ( typedError.reason?.message ) {
|
|
69
|
-
errorMessage = typedError.reason.message;
|
|
70
|
-
} else {
|
|
71
|
-
errorMessage = __(
|
|
72
|
-
'An error occurred while permanently deleting the item.'
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
// If we were trying to permanently delete multiple posts
|
|
76
|
-
} else {
|
|
77
|
-
const errorMessages = new Set();
|
|
78
|
-
const failedPromises = promiseResult.filter(
|
|
79
|
-
( { status } ) => status === 'rejected'
|
|
80
|
-
);
|
|
81
|
-
for ( const failedPromise of failedPromises ) {
|
|
82
|
-
const typedError = failedPromise as {
|
|
83
|
-
reason?: CoreDataError;
|
|
84
|
-
};
|
|
85
|
-
if ( typedError.reason?.message ) {
|
|
86
|
-
errorMessages.add( typedError.reason.message );
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if ( errorMessages.size === 0 ) {
|
|
90
|
-
errorMessage = __(
|
|
91
|
-
'An error occurred while permanently deleting the items.'
|
|
92
|
-
);
|
|
93
|
-
} else if ( errorMessages.size === 1 ) {
|
|
94
|
-
errorMessage = sprintf(
|
|
95
|
-
/* translators: %s: an error message */
|
|
96
|
-
__(
|
|
97
|
-
'An error occurred while permanently deleting the items: %s'
|
|
98
|
-
),
|
|
99
|
-
[ ...errorMessages ][ 0 ]
|
|
100
|
-
);
|
|
101
|
-
} else {
|
|
102
|
-
errorMessage = sprintf(
|
|
103
|
-
/* translators: %s: a list of comma separated error messages */
|
|
104
|
-
__(
|
|
105
|
-
'Some errors occurred while permanently deleting the items: %s'
|
|
106
|
-
),
|
|
107
|
-
[ ...errorMessages ].join( ',' )
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
createErrorNotice( errorMessage, {
|
|
112
|
-
type: 'snackbar',
|
|
113
|
-
} );
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export default permanentlyDeletePost;
|