@wordpress/fields 0.24.0 → 0.24.1-next.ff1cebbba.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 +1 -1
- package/build/actions/delete-post.js +168 -117
- package/build/actions/delete-post.js.map +7 -1
- package/build/actions/duplicate-pattern.js +42 -43
- package/build/actions/duplicate-pattern.js.map +7 -1
- package/build/actions/duplicate-post.js +104 -93
- package/build/actions/duplicate-post.js.map +7 -1
- package/build/actions/duplicate-template-part.js +71 -63
- package/build/actions/duplicate-template-part.js.map +7 -1
- package/build/actions/export-pattern.js +60 -45
- package/build/actions/export-pattern.js.map +7 -1
- package/build/actions/index.js +71 -94
- package/build/actions/index.js.map +7 -1
- package/build/actions/permanently-delete-post.js +161 -132
- package/build/actions/permanently-delete-post.js.map +7 -1
- package/build/actions/rename-post.js +77 -83
- package/build/actions/rename-post.js.map +7 -1
- package/build/actions/reorder-page.js +76 -73
- package/build/actions/reorder-page.js.map +7 -1
- package/build/actions/reset-post.js +214 -165
- package/build/actions/reset-post.js.map +7 -1
- package/build/actions/restore-post.js +91 -75
- package/build/actions/restore-post.js.map +7 -1
- package/build/actions/trash-post.js +167 -127
- package/build/actions/trash-post.js.map +7 -1
- package/build/actions/utils.js +48 -41
- package/build/actions/utils.js.map +7 -1
- package/build/actions/view-post-revisions.js +39 -35
- package/build/actions/view-post-revisions.js.map +7 -1
- package/build/actions/view-post.js +31 -28
- package/build/actions/view-post.js.map +7 -1
- package/build/components/create-template-part-modal/index.js +213 -169
- package/build/components/create-template-part-modal/index.js.map +7 -1
- package/build/components/create-template-part-modal/utils.js +48 -48
- package/build/components/create-template-part-modal/utils.js.map +7 -1
- package/build/fields/author/author-view.js +63 -69
- package/build/fields/author/author-view.js.map +7 -1
- package/build/fields/author/index.js +43 -29
- package/build/fields/author/index.js.map +7 -1
- package/build/fields/comment-status/index.js +42 -32
- package/build/fields/comment-status/index.js.map +7 -1
- package/build/fields/date/date-view.js +84 -58
- package/build/fields/date/date-view.js.map +7 -1
- package/build/fields/date/index.js +39 -25
- package/build/fields/date/index.js.map +7 -1
- package/build/fields/discussion/index.js +36 -32
- package/build/fields/discussion/index.js.map +7 -1
- package/build/fields/featured-image/featured-image-edit.js +115 -97
- package/build/fields/featured-image/featured-image-edit.js.map +7 -1
- package/build/fields/featured-image/featured-image-view.js +41 -34
- package/build/fields/featured-image/featured-image-view.js.map +7 -1
- package/build/fields/featured-image/index.js +31 -26
- package/build/fields/featured-image/index.js.map +7 -1
- package/build/fields/index.js +83 -118
- package/build/fields/index.js.map +7 -1
- package/build/fields/order/index.js +28 -23
- package/build/fields/order/index.js.map +7 -1
- package/build/fields/page-title/index.js +42 -30
- package/build/fields/page-title/index.js.map +7 -1
- package/build/fields/page-title/view.js +38 -41
- package/build/fields/page-title/view.js.map +7 -1
- package/build/fields/parent/index.js +31 -26
- package/build/fields/parent/index.js.map +7 -1
- package/build/fields/parent/parent-edit.js +200 -168
- package/build/fields/parent/parent-edit.js.map +7 -1
- package/build/fields/parent/parent-view.js +40 -31
- package/build/fields/parent/parent-view.js.map +7 -1
- package/build/fields/parent/utils.js +29 -16
- package/build/fields/parent/utils.js.map +7 -1
- package/build/fields/password/edit.js +67 -53
- package/build/fields/password/edit.js.map +7 -1
- package/build/fields/password/index.js +40 -26
- package/build/fields/password/index.js.map +7 -1
- package/build/fields/pattern-title/index.js +42 -30
- package/build/fields/pattern-title/index.js.map +7 -1
- package/build/fields/pattern-title/view.js +43 -41
- package/build/fields/pattern-title/view.js.map +7 -1
- package/build/fields/ping-status/index.js +66 -47
- package/build/fields/ping-status/index.js.map +7 -1
- package/build/fields/slug/index.js +41 -27
- package/build/fields/slug/index.js.map +7 -1
- package/build/fields/slug/slug-edit.js +116 -107
- package/build/fields/slug/slug-edit.js.map +7 -1
- package/build/fields/slug/slug-view.js +30 -23
- package/build/fields/slug/slug-view.js.map +7 -1
- package/build/fields/slug/utils.js +32 -20
- package/build/fields/slug/utils.js.map +7 -1
- package/build/fields/status/index.js +43 -29
- package/build/fields/status/index.js.map +7 -1
- package/build/fields/status/status-elements.js +58 -44
- package/build/fields/status/status-elements.js.map +7 -1
- package/build/fields/status/status-view.js +42 -36
- package/build/fields/status/status-view.js.map +7 -1
- package/build/fields/template/index.js +29 -24
- package/build/fields/template/index.js.map +7 -1
- package/build/fields/template/template-edit.js +167 -142
- package/build/fields/template/template-edit.js.map +7 -1
- package/build/fields/template-title/index.js +42 -30
- package/build/fields/template-title/index.js.map +7 -1
- package/build/fields/title/index.js +42 -32
- package/build/fields/title/index.js.map +7 -1
- package/build/fields/title/view.js +57 -39
- package/build/fields/title/view.js.map +7 -1
- package/build/index.js +39 -36
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/mutation/index.js +91 -76
- package/build/mutation/index.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build-module/actions/delete-post.js +155 -107
- package/build-module/actions/delete-post.js.map +7 -1
- package/build-module/actions/duplicate-pattern.js +24 -36
- package/build-module/actions/duplicate-pattern.js.map +7 -1
- package/build-module/actions/duplicate-post.js +87 -84
- package/build-module/actions/duplicate-post.js.map +7 -1
- package/build-module/actions/duplicate-template-part.js +51 -58
- package/build-module/actions/duplicate-template-part.js.map +7 -1
- package/build-module/actions/export-pattern.js +40 -39
- package/build-module/actions/export-pattern.js.map +7 -1
- package/build-module/actions/index.js +29 -14
- package/build-module/actions/index.js.map +7 -1
- package/build-module/actions/permanently-delete-post.js +146 -125
- package/build-module/actions/permanently-delete-post.js.map +7 -1
- package/build-module/actions/rename-post.js +63 -77
- package/build-module/actions/rename-post.js.map +7 -1
- package/build-module/actions/reorder-page.js +58 -65
- package/build-module/actions/reorder-page.js.map +7 -1
- package/build-module/actions/reset-post.js +185 -152
- package/build-module/actions/reset-post.js.map +7 -1
- package/build-module/actions/restore-post.js +72 -68
- package/build-module/actions/restore-post.js.map +7 -1
- package/build-module/actions/trash-post.js +152 -119
- package/build-module/actions/trash-post.js.map +7 -1
- package/build-module/actions/utils.js +23 -34
- package/build-module/actions/utils.js.map +7 -1
- package/build-module/actions/view-post-revisions.js +21 -31
- package/build-module/actions/view-post-revisions.js.map +7 -1
- package/build-module/actions/view-post.js +12 -23
- package/build-module/actions/view-post.js.map +7 -1
- package/build-module/components/create-template-part-modal/index.js +201 -154
- package/build-module/components/create-template-part-modal/index.js.map +7 -1
- package/build-module/components/create-template-part-modal/utils.js +26 -43
- package/build-module/components/create-template-part-modal/utils.js.map +7 -1
- package/build-module/fields/author/author-view.js +34 -62
- package/build-module/fields/author/author-view.js.map +7 -1
- package/build-module/fields/author/index.js +14 -24
- package/build-module/fields/author/index.js.map +7 -1
- package/build-module/fields/comment-status/index.js +24 -29
- package/build-module/fields/comment-status/index.js.map +7 -1
- package/build-module/fields/date/date-view.js +66 -53
- package/build-module/fields/date/date-view.js.map +7 -1
- package/build-module/fields/date/index.js +10 -20
- package/build-module/fields/date/index.js.map +7 -1
- package/build-module/fields/discussion/index.js +18 -29
- package/build-module/fields/discussion/index.js.map +7 -1
- package/build-module/fields/featured-image/featured-image-edit.js +93 -90
- package/build-module/fields/featured-image/featured-image-edit.js.map +7 -1
- package/build-module/fields/featured-image/featured-image-view.js +20 -29
- package/build-module/fields/featured-image/featured-image-view.js.map +7 -1
- package/build-module/fields/featured-image/index.js +11 -21
- package/build-module/fields/featured-image/index.js.map +7 -1
- package/build-module/fields/index.js +35 -17
- package/build-module/fields/index.js.map +7 -1
- package/build-module/fields/order/index.js +10 -20
- package/build-module/fields/order/index.js.map +7 -1
- package/build-module/fields/page-title/index.js +13 -25
- package/build-module/fields/page-title/index.js.map +7 -1
- package/build-module/fields/page-title/view.js +20 -37
- package/build-module/fields/page-title/view.js.map +7 -1
- package/build-module/fields/parent/index.js +11 -21
- package/build-module/fields/parent/index.js.map +7 -1
- package/build-module/fields/parent/parent-edit.js +172 -160
- package/build-module/fields/parent/parent-edit.js.map +7 -1
- package/build-module/fields/parent/parent-view.js +19 -27
- package/build-module/fields/parent/parent-view.js.map +7 -1
- package/build-module/fields/parent/utils.js +8 -13
- package/build-module/fields/parent/utils.js.map +7 -1
- package/build-module/fields/password/edit.js +53 -48
- package/build-module/fields/password/edit.js.map +7 -1
- package/build-module/fields/password/index.js +11 -21
- package/build-module/fields/password/index.js.map +7 -1
- package/build-module/fields/pattern-title/index.js +13 -25
- package/build-module/fields/pattern-title/index.js.map +7 -1
- package/build-module/fields/pattern-title/view.js +21 -34
- package/build-module/fields/pattern-title/view.js.map +7 -1
- package/build-module/fields/ping-status/index.js +48 -43
- package/build-module/fields/ping-status/index.js.map +7 -1
- package/build-module/fields/slug/index.js +11 -21
- package/build-module/fields/slug/index.js.map +7 -1
- package/build-module/fields/slug/slug-edit.js +101 -100
- package/build-module/fields/slug/slug-edit.js.map +7 -1
- package/build-module/fields/slug/slug-view.js +9 -16
- package/build-module/fields/slug/slug-view.js.map +7 -1
- package/build-module/fields/slug/utils.js +9 -13
- package/build-module/fields/slug/utils.js.map +7 -1
- package/build-module/fields/status/index.js +13 -23
- package/build-module/fields/status/index.js.map +7 -1
- package/build-module/fields/status/status-elements.js +47 -40
- package/build-module/fields/status/status-elements.js.map +7 -1
- package/build-module/fields/status/status-view.js +14 -31
- package/build-module/fields/status/status-view.js.map +7 -1
- package/build-module/fields/template/index.js +10 -18
- package/build-module/fields/template/index.js.map +7 -1
- package/build-module/fields/template/template-edit.js +147 -130
- package/build-module/fields/template/template-edit.js.map +7 -1
- package/build-module/fields/template-title/index.js +13 -25
- package/build-module/fields/template-title/index.js.map +7 -1
- package/build-module/fields/title/index.js +13 -27
- package/build-module/fields/title/index.js.map +7 -1
- package/build-module/fields/title/view.js +25 -32
- package/build-module/fields/title/view.js.map +7 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/mutation/index.js +70 -72
- package/build-module/mutation/index.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-style/style-rtl.css +4 -139
- package/build-style/style.css +4 -139
- package/build-types/fields/author/author-view.d.ts.map +1 -1
- package/build-types/fields/discussion/index.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-edit.d.ts +2 -2
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-view.d.ts +5 -2
- package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts +3 -3
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/types.d.ts +18 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +34 -27
- package/src/components/create-template-part-modal/style.scss +4 -0
- package/src/fields/author/author-view.tsx +3 -17
- package/src/fields/discussion/index.tsx +1 -0
- package/src/fields/featured-image/featured-image-edit.tsx +2 -2
- package/src/fields/featured-image/featured-image-view.tsx +3 -15
- package/src/fields/featured-image/index.ts +3 -3
- package/src/fields/featured-image/style.scss +3 -0
- package/src/fields/template/style.scss +4 -0
- package/src/fields/title/style.scss +1 -1
- package/src/style.scss +9 -8
- package/src/types.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/index.native.js +0 -2
- package/build/index.native.js.map +0 -1
- package/build-module/index.native.js +0 -2
- package/build-module/index.native.js.map +0 -1
|
@@ -1,91 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var restore_post_exports = {};
|
|
20
|
+
__export(restore_post_exports, {
|
|
21
|
+
default: () => restore_post_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
23
|
+
module.exports = __toCommonJS(restore_post_exports);
|
|
24
|
+
var import_icons = require("@wordpress/icons");
|
|
25
|
+
var import_core_data = require("@wordpress/core-data");
|
|
26
|
+
var import_i18n = require("@wordpress/i18n");
|
|
27
|
+
var import_notices = require("@wordpress/notices");
|
|
28
|
+
var import_utils = require("./utils");
|
|
20
29
|
const restorePost = {
|
|
21
|
-
id:
|
|
22
|
-
label: (0,
|
|
30
|
+
id: "restore",
|
|
31
|
+
label: (0, import_i18n.__)("Restore"),
|
|
23
32
|
isPrimary: true,
|
|
24
|
-
icon:
|
|
33
|
+
icon: import_icons.backup,
|
|
25
34
|
supportsBulk: true,
|
|
26
35
|
isEligible(item) {
|
|
27
|
-
return !(0,
|
|
36
|
+
return !(0, import_utils.isTemplateOrTemplatePart)(item) && item.type !== "wp_block" && item.status === "trash" && item.permissions?.update;
|
|
28
37
|
},
|
|
29
|
-
async callback(posts, {
|
|
30
|
-
registry
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return saveEditedEntityRecord('postType', post.type, post.id, {
|
|
48
|
-
throwOnError: true
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
|
-
if (promiseResult.every(({
|
|
52
|
-
status
|
|
53
|
-
}) => status === 'fulfilled')) {
|
|
38
|
+
async callback(posts, { registry, onActionPerformed }) {
|
|
39
|
+
const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices.store);
|
|
40
|
+
const { editEntityRecord, saveEditedEntityRecord } = registry.dispatch(import_core_data.store);
|
|
41
|
+
await Promise.allSettled(
|
|
42
|
+
posts.map((post) => {
|
|
43
|
+
return editEntityRecord("postType", post.type, post.id, {
|
|
44
|
+
status: "draft"
|
|
45
|
+
});
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const promiseResult = await Promise.allSettled(
|
|
49
|
+
posts.map((post) => {
|
|
50
|
+
return saveEditedEntityRecord("postType", post.type, post.id, {
|
|
51
|
+
throwOnError: true
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
if (promiseResult.every(({ status }) => status === "fulfilled")) {
|
|
54
56
|
let successMessage;
|
|
55
57
|
if (posts.length === 1) {
|
|
56
|
-
successMessage = (0,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
successMessage = (0, import_i18n.sprintf)(
|
|
59
|
+
/* translators: %s: The number of posts. */
|
|
60
|
+
(0, import_i18n.__)('"%s" has been restored.'),
|
|
61
|
+
(0, import_utils.getItemTitle)(posts[0])
|
|
62
|
+
);
|
|
63
|
+
} else if (posts[0].type === "page") {
|
|
64
|
+
successMessage = (0, import_i18n.sprintf)(
|
|
65
|
+
/* translators: %d: The number of posts. */
|
|
66
|
+
(0, import_i18n.__)("%d pages have been restored."),
|
|
67
|
+
posts.length
|
|
68
|
+
);
|
|
61
69
|
} else {
|
|
62
|
-
successMessage = (0,
|
|
63
|
-
|
|
70
|
+
successMessage = (0, import_i18n.sprintf)(
|
|
71
|
+
/* translators: %d: The number of posts. */
|
|
72
|
+
(0, import_i18n.__)("%d posts have been restored."),
|
|
73
|
+
posts.length
|
|
74
|
+
);
|
|
64
75
|
}
|
|
65
76
|
createSuccessNotice(successMessage, {
|
|
66
|
-
type:
|
|
67
|
-
id:
|
|
77
|
+
type: "snackbar",
|
|
78
|
+
id: "restore-post-action"
|
|
68
79
|
});
|
|
69
80
|
if (onActionPerformed) {
|
|
70
81
|
onActionPerformed(posts);
|
|
71
82
|
}
|
|
72
83
|
} else {
|
|
73
|
-
// If there was at lease one failure.
|
|
74
84
|
let errorMessage;
|
|
75
|
-
// If we were trying to move a single post to the trash.
|
|
76
85
|
if (promiseResult.length === 1) {
|
|
77
86
|
const typedError = promiseResult[0];
|
|
78
87
|
if (typedError.reason?.message) {
|
|
79
88
|
errorMessage = typedError.reason.message;
|
|
80
89
|
} else {
|
|
81
|
-
errorMessage = (0,
|
|
90
|
+
errorMessage = (0, import_i18n.__)(
|
|
91
|
+
"An error occurred while restoring the post."
|
|
92
|
+
);
|
|
82
93
|
}
|
|
83
|
-
// If we were trying to move multiple posts to the trash
|
|
84
94
|
} else {
|
|
85
|
-
const errorMessages = new Set();
|
|
86
|
-
const failedPromises = promiseResult.filter(
|
|
87
|
-
status
|
|
88
|
-
|
|
95
|
+
const errorMessages = /* @__PURE__ */ new Set();
|
|
96
|
+
const failedPromises = promiseResult.filter(
|
|
97
|
+
({ status }) => status === "rejected"
|
|
98
|
+
);
|
|
89
99
|
for (const failedPromise of failedPromises) {
|
|
90
100
|
const typedError = failedPromise;
|
|
91
101
|
if (typedError.reason?.message) {
|
|
@@ -93,24 +103,30 @@ const restorePost = {
|
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
if (errorMessages.size === 0) {
|
|
96
|
-
errorMessage = (0,
|
|
106
|
+
errorMessage = (0, import_i18n.__)(
|
|
107
|
+
"An error occurred while restoring the posts."
|
|
108
|
+
);
|
|
97
109
|
} else if (errorMessages.size === 1) {
|
|
98
|
-
errorMessage = (0,
|
|
99
|
-
|
|
110
|
+
errorMessage = (0, import_i18n.sprintf)(
|
|
111
|
+
/* translators: %s: an error message */
|
|
112
|
+
(0, import_i18n.__)("An error occurred while restoring the posts: %s"),
|
|
113
|
+
[...errorMessages][0]
|
|
114
|
+
);
|
|
100
115
|
} else {
|
|
101
|
-
errorMessage = (0,
|
|
102
|
-
|
|
116
|
+
errorMessage = (0, import_i18n.sprintf)(
|
|
117
|
+
/* translators: %s: a list of comma separated error messages */
|
|
118
|
+
(0, import_i18n.__)(
|
|
119
|
+
"Some errors occurred while restoring the posts: %s"
|
|
120
|
+
),
|
|
121
|
+
[...errorMessages].join(",")
|
|
122
|
+
);
|
|
103
123
|
}
|
|
104
124
|
}
|
|
105
125
|
createErrorNotice(errorMessage, {
|
|
106
|
-
type:
|
|
126
|
+
type: "snackbar"
|
|
107
127
|
});
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
130
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* Restore action for PostWithPermissions.
|
|
114
|
-
*/
|
|
115
|
-
var _default = exports.default = restorePost;
|
|
116
|
-
//# sourceMappingURL=restore-post.js.map
|
|
131
|
+
var restore_post_default = restorePost;
|
|
132
|
+
//# sourceMappingURL=restore-post.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actions/restore-post.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: %s: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: %d: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: %d: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set< string >();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\n/**\n * Restore action for PostWithPermissions.\n */\nexport default restorePost;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAuB;AACvB,uBAAmC;AACnC,kBAA4B;AAC5B,qBAAsC;AAMtC,mBAAuD;AAGvD,MAAM,cAA6C;AAAA,EAClD,IAAI;AAAA,EACJ,WAAO,gBAAI,SAAU;AAAA,EACrB,WAAW;AAAA,EACX,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAY,MAAO;AAClB,WACC,KAAE,uCAA0B,IAAK,KACjC,KAAK,SAAS,cACd,KAAK,WAAW,WAChB,KAAK,aAAa;AAAA,EAEpB;AAAA,EACA,MAAM,SAAU,OAAO,EAAE,UAAU,kBAAkB,GAAI;AACxD,UAAM,EAAE,qBAAqB,kBAAkB,IAC9C,SAAS,SAAU,eAAAA,KAAa;AACjC,UAAM,EAAE,kBAAkB,uBAAuB,IAChD,SAAS,SAAU,iBAAAC,KAAU;AAC9B,UAAM,QAAQ;AAAA,MACb,MAAM,IAAK,CAAE,SAAU;AACtB,eAAO,iBAAkB,YAAY,KAAK,MAAM,KAAK,IAAI;AAAA,UACxD,QAAQ;AAAA,QACT,CAAE;AAAA,MACH,CAAE;AAAA,IACH;AACA,UAAM,gB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cAAc,SAAS,GAAI;AAC/B,6BAAe;AAAA,YACd;AAAA,UACD;AAAA,QACD,WAAY,cAAc,SAAS,GAAI;AACtC,6BAAe;AAAA;AAAA,gBAEd,gBAAI,iDAAkD;AAAA,YACtD,CAAE,GAAG,aAAc,EAAG,CAAE;AAAA,UACzB;AAAA,QACD,OAAO;AACN,6BAAe;AAAA;AAAA,gBAEd;AAAA,cACC;AAAA,YACD;AAAA,YACA,CAAE,GAAG,aAAc,EAAE,KAAM,GAAI;AAAA,UAChC;AAAA,QACD;AAAA,MACD;AACA,wBAAmB,cAAc;AAAA,QAChC,MAAM;AAAA,MACP,CAAE;AAAA,IACH;AAAA,EACD;AACD;AAKA,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["noticesStore", "coreStore"]
|
|
7
|
+
}
|
|
@@ -1,149 +1,189 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var trash_post_exports = {};
|
|
20
|
+
__export(trash_post_exports, {
|
|
21
|
+
default: () => trash_post_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
23
|
+
module.exports = __toCommonJS(trash_post_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_icons = require("@wordpress/icons");
|
|
26
|
+
var import_data = require("@wordpress/data");
|
|
27
|
+
var import_core_data = require("@wordpress/core-data");
|
|
28
|
+
var import_i18n = require("@wordpress/i18n");
|
|
29
|
+
var import_notices = require("@wordpress/notices");
|
|
30
|
+
var import_element = require("@wordpress/element");
|
|
31
|
+
var import_components = require("@wordpress/components");
|
|
32
|
+
var import_utils = require("./utils");
|
|
24
33
|
const trashPost = {
|
|
25
|
-
id:
|
|
26
|
-
label: (0,
|
|
34
|
+
id: "move-to-trash",
|
|
35
|
+
label: (0, import_i18n.__)("Move to trash"),
|
|
27
36
|
isPrimary: true,
|
|
28
|
-
icon:
|
|
37
|
+
icon: import_icons.trash,
|
|
29
38
|
isEligible(item) {
|
|
30
|
-
if (item.type ===
|
|
39
|
+
if (item.type === "wp_template_part" || item.type === "wp_block") {
|
|
31
40
|
return false;
|
|
32
41
|
}
|
|
33
|
-
return !!item.status && ![
|
|
42
|
+
return !!item.status && !["auto-draft", "trash"].includes(item.status) && item.permissions?.delete;
|
|
34
43
|
},
|
|
35
44
|
supportsBulk: true,
|
|
36
45
|
hideModalHeader: true,
|
|
37
|
-
modalFocusOnMount:
|
|
38
|
-
RenderModal: ({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
createSuccessNotice,
|
|
46
|
-
createErrorNotice
|
|
47
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
48
|
-
const {
|
|
49
|
-
deleteEntityRecord
|
|
50
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
51
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
52
|
-
spacing: "5",
|
|
53
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
|
|
54
|
-
children: items.length === 1 ? (0, _i18n.sprintf)(
|
|
46
|
+
modalFocusOnMount: "firstContentElement",
|
|
47
|
+
RenderModal: ({ items, closeModal, onActionPerformed }) => {
|
|
48
|
+
const [isBusy, setIsBusy] = (0, import_element.useState)(false);
|
|
49
|
+
const { createSuccessNotice, createErrorNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
50
|
+
const { deleteEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "5", children: [
|
|
52
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { children: items.length === 1 ? (0, import_i18n.sprintf)(
|
|
55
53
|
// translators: %s: The item's title.
|
|
56
|
-
(0,
|
|
54
|
+
(0, import_i18n.__)(
|
|
55
|
+
'Are you sure you want to move "%s" to the trash?'
|
|
56
|
+
),
|
|
57
|
+
(0, import_utils.getItemTitle)(items[0])
|
|
58
|
+
) : (0, import_i18n.sprintf)(
|
|
57
59
|
// translators: %d: The number of items (2 or more).
|
|
58
|
-
(0,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
60
|
+
(0, import_i18n._n)(
|
|
61
|
+
"Are you sure you want to move %d item to the trash ?",
|
|
62
|
+
"Are you sure you want to move %d items to the trash ?",
|
|
63
|
+
items.length
|
|
64
|
+
),
|
|
65
|
+
items.length
|
|
66
|
+
) }),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
import_components.Button,
|
|
70
|
+
{
|
|
71
|
+
__next40pxDefaultSize: true,
|
|
72
|
+
variant: "tertiary",
|
|
73
|
+
onClick: closeModal,
|
|
74
|
+
disabled: isBusy,
|
|
75
|
+
accessibleWhenDisabled: true,
|
|
76
|
+
children: (0, import_i18n.__)("Cancel")
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
import_components.Button,
|
|
81
|
+
{
|
|
82
|
+
__next40pxDefaultSize: true,
|
|
83
|
+
variant: "primary",
|
|
84
|
+
onClick: async () => {
|
|
85
|
+
setIsBusy(true);
|
|
86
|
+
const promiseResult = await Promise.allSettled(
|
|
87
|
+
items.map(
|
|
88
|
+
(item) => deleteEntityRecord(
|
|
89
|
+
"postType",
|
|
90
|
+
item.type,
|
|
91
|
+
item.id.toString(),
|
|
92
|
+
{},
|
|
93
|
+
{ throwOnError: true }
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
if (promiseResult.every(
|
|
98
|
+
({ status }) => status === "fulfilled"
|
|
99
|
+
)) {
|
|
100
|
+
let successMessage;
|
|
101
|
+
if (promiseResult.length === 1) {
|
|
102
|
+
successMessage = (0, import_i18n.sprintf)(
|
|
103
|
+
/* translators: %s: The item's title. */
|
|
104
|
+
(0, import_i18n.__)('"%s" moved to the trash.'),
|
|
105
|
+
(0, import_utils.getItemTitle)(items[0])
|
|
106
|
+
);
|
|
100
107
|
} else {
|
|
101
|
-
|
|
108
|
+
successMessage = (0, import_i18n.sprintf)(
|
|
109
|
+
/* translators: %d: The number of items. */
|
|
110
|
+
(0, import_i18n._n)(
|
|
111
|
+
"%d item moved to the trash.",
|
|
112
|
+
"%d items moved to the trash.",
|
|
113
|
+
items.length
|
|
114
|
+
),
|
|
115
|
+
items.length
|
|
116
|
+
);
|
|
102
117
|
}
|
|
103
|
-
|
|
118
|
+
createSuccessNotice(successMessage, {
|
|
119
|
+
type: "snackbar",
|
|
120
|
+
id: "move-to-trash-action"
|
|
121
|
+
});
|
|
104
122
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}) => status === 'rejected');
|
|
109
|
-
for (const failedPromise of failedPromises) {
|
|
110
|
-
const typedError = failedPromise;
|
|
123
|
+
let errorMessage;
|
|
124
|
+
if (promiseResult.length === 1) {
|
|
125
|
+
const typedError = promiseResult[0];
|
|
111
126
|
if (typedError.reason?.message) {
|
|
112
|
-
|
|
127
|
+
errorMessage = typedError.reason.message;
|
|
128
|
+
} else {
|
|
129
|
+
errorMessage = (0, import_i18n.__)(
|
|
130
|
+
"An error occurred while moving the item to the trash."
|
|
131
|
+
);
|
|
113
132
|
}
|
|
114
|
-
}
|
|
115
|
-
if (errorMessages.size === 0) {
|
|
116
|
-
errorMessage = (0, _i18n.__)('An error occurred while moving the items to the trash.');
|
|
117
|
-
} else if (errorMessages.size === 1) {
|
|
118
|
-
errorMessage = (0, _i18n.sprintf)(/* translators: %s: an error message */
|
|
119
|
-
(0, _i18n.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
|
|
120
133
|
} else {
|
|
121
|
-
|
|
122
|
-
|
|
134
|
+
const errorMessages = /* @__PURE__ */ new Set();
|
|
135
|
+
const failedPromises = promiseResult.filter(
|
|
136
|
+
({ status }) => status === "rejected"
|
|
137
|
+
);
|
|
138
|
+
for (const failedPromise of failedPromises) {
|
|
139
|
+
const typedError = failedPromise;
|
|
140
|
+
if (typedError.reason?.message) {
|
|
141
|
+
errorMessages.add(
|
|
142
|
+
typedError.reason.message
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (errorMessages.size === 0) {
|
|
147
|
+
errorMessage = (0, import_i18n.__)(
|
|
148
|
+
"An error occurred while moving the items to the trash."
|
|
149
|
+
);
|
|
150
|
+
} else if (errorMessages.size === 1) {
|
|
151
|
+
errorMessage = (0, import_i18n.sprintf)(
|
|
152
|
+
/* translators: %s: an error message */
|
|
153
|
+
(0, import_i18n.__)(
|
|
154
|
+
"An error occurred while moving the item to the trash: %s"
|
|
155
|
+
),
|
|
156
|
+
[...errorMessages][0]
|
|
157
|
+
);
|
|
158
|
+
} else {
|
|
159
|
+
errorMessage = (0, import_i18n.sprintf)(
|
|
160
|
+
/* translators: %s: a list of comma separated error messages */
|
|
161
|
+
(0, import_i18n.__)(
|
|
162
|
+
"Some errors occurred while moving the items to the trash: %s"
|
|
163
|
+
),
|
|
164
|
+
[...errorMessages].join(",")
|
|
165
|
+
);
|
|
166
|
+
}
|
|
123
167
|
}
|
|
168
|
+
createErrorNotice(errorMessage, {
|
|
169
|
+
type: "snackbar"
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (onActionPerformed) {
|
|
173
|
+
onActionPerformed(items);
|
|
124
174
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
disabled: isBusy,
|
|
137
|
-
accessibleWhenDisabled: true,
|
|
138
|
-
children: (0, _i18n._x)('Trash', 'verb')
|
|
139
|
-
})]
|
|
140
|
-
})]
|
|
141
|
-
});
|
|
175
|
+
setIsBusy(false);
|
|
176
|
+
closeModal?.();
|
|
177
|
+
},
|
|
178
|
+
isBusy,
|
|
179
|
+
disabled: isBusy,
|
|
180
|
+
accessibleWhenDisabled: true,
|
|
181
|
+
children: (0, import_i18n._x)("Trash", "verb")
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] })
|
|
185
|
+
] });
|
|
142
186
|
}
|
|
143
187
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
* Trash action for PostWithPermissions.
|
|
147
|
-
*/
|
|
148
|
-
var _default = exports.default = trashPost;
|
|
149
|
-
//# sourceMappingURL=trash-post.js.map
|
|
188
|
+
var trash_post_default = trashPost;
|
|
189
|
+
//# sourceMappingURL=trash-post.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_components","_utils","_jsxRuntime","trashPost","id","label","__","isPrimary","icon","trash","isEligible","item","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","modalFocusOnMount","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","getItemTitle","_n","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_x","_default","exports","default"],"sources":["@wordpress/fields/src/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( item.type === 'wp_template_part' || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tmodalFocusOnMount: 'firstContentElement',\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %d: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%d item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%d items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set< string >();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\n/**\n * Trash action for PostWithPermissions.\n */\nexport default trashPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAWA,IAAAO,MAAA,GAAAP,OAAA;AAAuC,IAAAQ,WAAA,GAAAR,OAAA;AApBvC;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMS,SAAwC,GAAG;EAChDC,EAAE,EAAE,eAAe;EACnBC,KAAK,EAAE,IAAAC,QAAE,EAAE,eAAgB,CAAC;EAC5BC,SAAS,EAAE,IAAI;EACf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nB,aAAO,EACrB;kBACA,IAAAlC,QAAE,EACD,8DACD,CAAC,EACD,CAAE,GAAGyD,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACA1C,iBAAiB,CAAE+B,YAAY,EAAE;gBAChC/C,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKW,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjByB,QAAQ,EAAGzB,MAAQ;UACnB0B,sBAAsB;UAAAd,QAAA,EAEpB,IAAAmC,QAAE,EAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGevE,SAAS","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actions/trash-post.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( item.type === 'wp_template_part' || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tmodalFocusOnMount: 'firstContentElement',\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %d: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%d item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%d items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set< string >();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\n/**\n * Trash action for PostWithPermissions.\n */\nexport default trashPost;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiDI;AA9CJ,mBAAsB;AACtB,kBAA4B;AAC5B,uBAAmC;AACnC,kBAAoC;AACpC,qBAAsC;AACtC,qBAAyB;AACzB,wBAKO;AAMP,mBAA6B;AAG7B,MAAM,YAA2C;AAAA,EAChD,IAAI;AAAA,EACJ,WAAO,gBAAI,eAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAY,MAAO;AAClB,QAAK,KAAK,SAAS,sBAAsB,KAAK,SAAS,YAAa;AACnE,aAAO;AAAA,IACR;AAEA,WACC,CAAC,CAAE,KAAK,UACR,CAAE,CAAE,cAAc,OAAQ,EAAE,SAAU,KAAK,MAAO,KAClD,KAAK,aAAa;AAAA,EAEpB;AAAA,EACA,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,aAAa,CAAE,EAAE,OAAO,YAAY,kBAAkB,MAAO;AAC5D,UAAM,CAAE,QAAQ,SAAU,QAAI,yBAAU,KAAM;AAC9C,UAAM,EAAE,qBAAqB,kBAAkB,QAC9C,yBAAa,eAAAA,KAAa;AAC3B,UAAM,EAAE,mBAAmB,QAAI,yBAAa,iBAAAC,KAAU;AACtD,WACC,6CAAC,kBAAAC,sBAAA,EAAO,SAAQ,KACf;AAAA,kDAAC,kBAAAC,oBAAA,EACE,gBAAM,WAAW,QAChB;AAAA;A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