@wordpress/fields 0.0.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +20 -0
- package/build/actions/delete-post.js +130 -0
- package/build/actions/delete-post.js.map +1 -0
- package/build/actions/{pattern/duplicate-pattern.js → duplicate-pattern.js} +1 -1
- package/build/actions/duplicate-pattern.js.map +1 -0
- package/build/actions/{base-post/duplicate-post.js → duplicate-post.js} +3 -3
- package/build/actions/duplicate-post.js.map +1 -0
- package/build/actions/duplicate-post.native.js.map +1 -0
- package/build/actions/{pattern/export-pattern.js → export-pattern.js} +1 -1
- package/build/actions/export-pattern.js.map +1 -0
- package/build/actions/export-pattern.native.js.map +1 -0
- package/build/actions/index.js +105 -32
- package/build/actions/index.js.map +1 -1
- package/build/actions/{common/permanently-delete-post.js → permanently-delete-post.js} +5 -4
- package/build/actions/permanently-delete-post.js.map +1 -0
- package/build/actions/rename-post.js +124 -0
- package/build/actions/rename-post.js.map +1 -0
- package/build/actions/{base-post/reorder-page.js → reorder-page.js} +1 -1
- package/build/actions/reorder-page.js.map +1 -0
- package/build/actions/reorder-page.native.js.map +1 -0
- package/build/actions/reset-post.js +206 -0
- package/build/actions/reset-post.js.map +1 -0
- package/build/actions/restore-post.js +113 -0
- package/build/actions/restore-post.js.map +1 -0
- package/build/actions/trash-post.js +145 -0
- package/build/actions/trash-post.js.map +1 -0
- package/build/actions/{common/view-post-revisions.js → view-post-revisions.js} +1 -1
- package/build/actions/view-post-revisions.js.map +1 -0
- package/build/actions/view-post.js.map +1 -0
- package/build/index.native.js +2 -2
- package/build/index.native.js.map +1 -1
- package/build/mutation/index.js +140 -0
- package/build/mutation/index.js.map +1 -0
- package/build/types.js.map +1 -1
- package/build-module/actions/delete-post.js +122 -0
- package/build-module/actions/delete-post.js.map +1 -0
- package/build-module/actions/{pattern/duplicate-pattern.js → duplicate-pattern.js} +1 -1
- package/build-module/actions/duplicate-pattern.js.map +1 -0
- package/build-module/actions/{base-post/duplicate-post.js → duplicate-post.js} +4 -5
- package/build-module/actions/duplicate-post.js.map +1 -0
- package/build-module/actions/duplicate-post.native.js.map +1 -0
- package/build-module/actions/{pattern/export-pattern.js → export-pattern.js} +1 -1
- package/build-module/actions/export-pattern.js.map +1 -0
- package/build-module/actions/export-pattern.native.js.map +1 -0
- package/build-module/actions/index.js +15 -3
- package/build-module/actions/index.js.map +1 -1
- package/build-module/actions/{common/permanently-delete-post.js → permanently-delete-post.js} +5 -4
- package/build-module/actions/permanently-delete-post.js.map +1 -0
- package/build-module/actions/rename-post.js +117 -0
- package/build-module/actions/rename-post.js.map +1 -0
- package/build-module/actions/{base-post/reorder-page.js → reorder-page.js} +2 -3
- package/build-module/actions/reorder-page.js.map +1 -0
- package/build-module/actions/reorder-page.native.js.map +1 -0
- package/build-module/actions/reset-post.js +197 -0
- package/build-module/actions/reset-post.js.map +1 -0
- package/build-module/actions/restore-post.js +105 -0
- package/build-module/actions/restore-post.js.map +1 -0
- package/build-module/actions/trash-post.js +137 -0
- package/build-module/actions/trash-post.js.map +1 -0
- package/build-module/actions/{common/view-post-revisions.js → view-post-revisions.js} +1 -1
- package/build-module/actions/view-post-revisions.js.map +1 -0
- package/build-module/actions/view-post.js.map +1 -0
- package/build-module/index.native.js +2 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/mutation/index.js +132 -0
- package/build-module/mutation/index.js.map +1 -0
- package/build-module/types.js.map +1 -1
- package/build-types/actions/delete-post.d.ts +5 -0
- package/build-types/actions/delete-post.d.ts.map +1 -0
- package/build-types/actions/{pattern/duplicate-pattern.d.ts → duplicate-pattern.d.ts} +1 -1
- package/build-types/actions/duplicate-pattern.d.ts.map +1 -0
- package/build-types/actions/{base-post/duplicate-post.d.ts → duplicate-post.d.ts} +1 -1
- package/build-types/actions/duplicate-post.d.ts.map +1 -0
- package/build-types/actions/duplicate-post.native.d.ts.map +1 -0
- package/build-types/actions/{pattern/export-pattern.d.ts → export-pattern.d.ts} +1 -1
- package/build-types/actions/export-pattern.d.ts.map +1 -0
- package/build-types/actions/export-pattern.native.d.ts.map +1 -0
- package/build-types/actions/index.d.ts +15 -3
- package/build-types/actions/index.d.ts.map +1 -1
- package/build-types/actions/{common/permanently-delete-post.d.ts → permanently-delete-post.d.ts} +1 -1
- package/build-types/actions/permanently-delete-post.d.ts.map +1 -0
- package/build-types/actions/rename-post.d.ts +5 -0
- package/build-types/actions/rename-post.d.ts.map +1 -0
- package/build-types/actions/{base-post/reorder-page.d.ts → reorder-page.d.ts} +1 -1
- package/build-types/actions/reorder-page.d.ts.map +1 -0
- package/build-types/actions/reorder-page.native.d.ts.map +1 -0
- package/build-types/actions/reset-post.d.ts +5 -0
- package/build-types/actions/reset-post.d.ts.map +1 -0
- package/build-types/actions/restore-post.d.ts +5 -0
- package/build-types/actions/restore-post.d.ts.map +1 -0
- package/build-types/actions/trash-post.d.ts +5 -0
- package/build-types/actions/trash-post.d.ts.map +1 -0
- package/build-types/actions/{common/view-post-revisions.d.ts → view-post-revisions.d.ts} +1 -1
- package/build-types/actions/view-post-revisions.d.ts.map +1 -0
- package/build-types/actions/{base-post/view-post.d.ts → view-post.d.ts} +1 -1
- package/build-types/actions/view-post.d.ts.map +1 -0
- package/build-types/index.native.d.ts +2 -2
- package/build-types/index.native.d.ts.map +1 -1
- package/build-types/mutation/index.d.ts +34 -0
- package/build-types/mutation/index.d.ts.map +1 -0
- package/build-types/types.d.ts +1 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +22 -21
- package/src/actions/delete-post.tsx +203 -0
- package/src/actions/{pattern/duplicate-pattern.tsx → duplicate-pattern.tsx} +2 -2
- package/src/actions/{base-post/duplicate-post.tsx → duplicate-post.tsx} +3 -3
- package/src/actions/{pattern/export-pattern.tsx → export-pattern.tsx} +2 -2
- package/src/actions/index.ts +15 -3
- package/src/actions/{common/permanently-delete-post.tsx → permanently-delete-post.tsx} +2 -2
- package/src/actions/rename-post.tsx +145 -0
- package/src/actions/{base-post/reorder-page.tsx → reorder-page.tsx} +2 -2
- package/src/actions/reset-post.tsx +300 -0
- package/src/actions/restore-post.tsx +134 -0
- package/src/actions/trash-post.tsx +198 -0
- package/src/actions/{common/view-post-revisions.tsx → view-post-revisions.tsx} +1 -1
- package/src/actions/{base-post/view-post.tsx → view-post.tsx} +1 -1
- package/src/index.native.ts +2 -2
- package/src/mutation/index.ts +184 -0
- package/src/types.ts +1 -0
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/actions/base-post/duplicate-post.js.map +0 -1
- package/build/actions/base-post/duplicate-post.native.js.map +0 -1
- package/build/actions/base-post/index.js +0 -42
- package/build/actions/base-post/index.js.map +0 -1
- package/build/actions/base-post/reorder-page.js.map +0 -1
- package/build/actions/base-post/reorder-page.native.js.map +0 -1
- package/build/actions/base-post/view-post.js.map +0 -1
- package/build/actions/common/index.js +0 -21
- package/build/actions/common/index.js.map +0 -1
- package/build/actions/common/permanently-delete-post.js.map +0 -1
- package/build/actions/common/view-post-revisions.js.map +0 -1
- package/build/actions/pattern/duplicate-pattern.js.map +0 -1
- package/build/actions/pattern/export-pattern.js.map +0 -1
- package/build/actions/pattern/export-pattern.native.js.map +0 -1
- package/build/actions/pattern/index.js +0 -28
- package/build/actions/pattern/index.js.map +0 -1
- package/build/wordpress-editor.d.js +0 -2
- package/build/wordpress-editor.d.js.map +0 -1
- package/build-module/actions/base-post/duplicate-post.js.map +0 -1
- package/build-module/actions/base-post/duplicate-post.native.js.map +0 -1
- package/build-module/actions/base-post/index.js +0 -6
- package/build-module/actions/base-post/index.js.map +0 -1
- package/build-module/actions/base-post/reorder-page.js.map +0 -1
- package/build-module/actions/base-post/reorder-page.native.js.map +0 -1
- package/build-module/actions/base-post/view-post.js.map +0 -1
- package/build-module/actions/common/index.js +0 -3
- package/build-module/actions/common/index.js.map +0 -1
- package/build-module/actions/common/permanently-delete-post.js.map +0 -1
- package/build-module/actions/common/view-post-revisions.js.map +0 -1
- package/build-module/actions/pattern/duplicate-pattern.js.map +0 -1
- package/build-module/actions/pattern/export-pattern.js.map +0 -1
- package/build-module/actions/pattern/export-pattern.native.js.map +0 -1
- package/build-module/actions/pattern/index.js +0 -4
- package/build-module/actions/pattern/index.js.map +0 -1
- package/build-module/wordpress-editor.d.js +0 -2
- package/build-module/wordpress-editor.d.js.map +0 -1
- package/build-types/actions/base-post/duplicate-post.d.ts.map +0 -1
- package/build-types/actions/base-post/duplicate-post.native.d.ts.map +0 -1
- package/build-types/actions/base-post/index.d.ts +0 -6
- package/build-types/actions/base-post/index.d.ts.map +0 -1
- package/build-types/actions/base-post/reorder-page.d.ts.map +0 -1
- package/build-types/actions/base-post/reorder-page.native.d.ts.map +0 -1
- package/build-types/actions/base-post/view-post.d.ts.map +0 -1
- package/build-types/actions/common/index.d.ts +0 -3
- package/build-types/actions/common/index.d.ts.map +0 -1
- package/build-types/actions/common/permanently-delete-post.d.ts.map +0 -1
- package/build-types/actions/common/view-post-revisions.d.ts.map +0 -1
- package/build-types/actions/pattern/duplicate-pattern.d.ts.map +0 -1
- package/build-types/actions/pattern/export-pattern.d.ts.map +0 -1
- package/build-types/actions/pattern/export-pattern.native.d.ts.map +0 -1
- package/build-types/actions/pattern/index.d.ts +0 -4
- package/build-types/actions/pattern/index.d.ts.map +0 -1
- package/src/actions/base-post/index.ts +0 -5
- package/src/actions/common/index.ts +0 -2
- package/src/actions/pattern/index.ts +0 -3
- package/src/wordpress-editor.d.ts +0 -1
- /package/build/actions/{base-post/duplicate-post.native.js → duplicate-post.native.js} +0 -0
- /package/build/actions/{pattern/export-pattern.native.js → export-pattern.native.js} +0 -0
- /package/build/actions/{base-post/reorder-page.native.js → reorder-page.native.js} +0 -0
- /package/build/actions/{base-post/view-post.js → view-post.js} +0 -0
- /package/build-module/actions/{base-post/duplicate-post.native.js → duplicate-post.native.js} +0 -0
- /package/build-module/actions/{pattern/export-pattern.native.js → export-pattern.native.js} +0 -0
- /package/build-module/actions/{base-post/reorder-page.native.js → reorder-page.native.js} +0 -0
- /package/build-module/actions/{base-post/view-post.js → view-post.js} +0 -0
- /package/build-types/actions/{base-post/duplicate-post.native.d.ts → duplicate-post.native.d.ts} +0 -0
- /package/build-types/actions/{pattern/export-pattern.native.d.ts → export-pattern.native.d.ts} +0 -0
- /package/build-types/actions/{base-post/reorder-page.native.d.ts → reorder-page.native.d.ts} +0 -0
- /package/src/actions/{base-post/duplicate-post.native.tsx → duplicate-post.native.tsx} +0 -0
- /package/src/actions/{pattern/export-pattern.native.tsx → export-pattern.native.tsx} +0 -0
- /package/src/actions/{base-post/reorder-page.native.tsx → reorder-page.native.tsx} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Post } from '../types';
|
|
5
|
+
export type NoticeSettings<T extends Post> = {
|
|
6
|
+
success: {
|
|
7
|
+
id?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
messages: {
|
|
10
|
+
getMessage: (posts: T) => string;
|
|
11
|
+
getBatchMessage: (posts: T[]) => string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
error: {
|
|
15
|
+
id?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
messages: {
|
|
18
|
+
getMessage: (errors: Set<string>) => string;
|
|
19
|
+
getBatchMessage: (errors: Set<string>) => string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const deletePostWithNotices: <T extends Post>(posts: T[], notice: NoticeSettings<T>, callbacks: {
|
|
24
|
+
onActionPerformed?: (posts: T[]) => void;
|
|
25
|
+
onActionError?: () => void;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
export declare const editPostWithNotices: <T extends Post>(postsWithUpdates: {
|
|
28
|
+
originalPost: T;
|
|
29
|
+
changes: Partial<T>;
|
|
30
|
+
}[], notice: NoticeSettings<T>, callbacks: {
|
|
31
|
+
onActionPerformed?: (posts: T[]) => void;
|
|
32
|
+
onActionError?: () => void;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutation/index.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,UAAU,CAAC;AA8BpD,MAAM,MAAM,cAAc,CAAE,CAAC,SAAS,IAAI,IAAK;IAC9C,OAAO,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE;YACT,UAAU,EAAE,CAAE,KAAK,EAAE,CAAC,KAAM,MAAM,CAAC;YACnC,eAAe,EAAE,CAAE,KAAK,EAAE,CAAC,EAAE,KAAM,MAAM,CAAC;SAC1C,CAAC;KACF,CAAC;IACF,KAAK,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE;YACT,UAAU,EAAE,CAAE,MAAM,EAAE,GAAG,CAAE,MAAM,CAAE,KAAM,MAAM,CAAC;YAChD,eAAe,EAAE,CAAE,MAAM,EAAE,GAAG,CAAE,MAAM,CAAE,KAAM,MAAM,CAAC;SACrD,CAAC;KACF,CAAC;CACF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAW,CAAC,SAAS,IAAI,SACnD,CAAC,EAAE,UACF,cAAc,CAAE,CAAC,CAAE,aAChB;IACV,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,CAAC,EAAE,KAAM,IAAI,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,kBA4CD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAW,CAAC,SAAS,IAAI,oBACtC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,OAAO,EAAE,OAAO,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AE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,25 +31,26 @@
|
|
|
31
31
|
"src/**/*.scss"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/runtime": "
|
|
35
|
-
"@wordpress/
|
|
36
|
-
"@wordpress/
|
|
37
|
-
"@wordpress/
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
40
|
-
"@wordpress/data": "^10.
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
34
|
+
"@babel/runtime": "7.25.7",
|
|
35
|
+
"@wordpress/api-fetch": "^7.10.0",
|
|
36
|
+
"@wordpress/blob": "^4.10.0",
|
|
37
|
+
"@wordpress/blocks": "^13.10.0",
|
|
38
|
+
"@wordpress/components": "^28.10.0",
|
|
39
|
+
"@wordpress/compose": "^7.10.0",
|
|
40
|
+
"@wordpress/core-data": "^7.10.0",
|
|
41
|
+
"@wordpress/data": "^10.10.0",
|
|
42
|
+
"@wordpress/dataviews": "^4.6.0",
|
|
43
|
+
"@wordpress/element": "^6.10.0",
|
|
44
|
+
"@wordpress/hooks": "^4.10.0",
|
|
45
|
+
"@wordpress/html-entities": "^4.10.0",
|
|
46
|
+
"@wordpress/i18n": "^5.10.0",
|
|
47
|
+
"@wordpress/icons": "^10.10.0",
|
|
48
|
+
"@wordpress/notices": "^5.10.0",
|
|
49
|
+
"@wordpress/patterns": "^2.10.0",
|
|
50
|
+
"@wordpress/primitives": "^4.10.0",
|
|
51
|
+
"@wordpress/private-apis": "^1.10.0",
|
|
52
|
+
"@wordpress/url": "^4.10.0",
|
|
53
|
+
"@wordpress/warning": "^3.10.0",
|
|
53
54
|
"change-case": "4.1.2",
|
|
54
55
|
"client-zip": "^2.4.5"
|
|
55
56
|
},
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"publishConfig": {
|
|
60
61
|
"access": "public"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "ab34a7ac935fd1478eac63b596242d83270897ee"
|
|
63
64
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { trash } from '@wordpress/icons';
|
|
5
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
__experimentalText as Text,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
__experimentalVStack as VStack,
|
|
12
|
+
} from '@wordpress/components';
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
15
|
+
import type { Action } from '@wordpress/dataviews';
|
|
16
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import {
|
|
22
|
+
getItemTitle,
|
|
23
|
+
isTemplateOrTemplatePart,
|
|
24
|
+
isTemplateRemovable,
|
|
25
|
+
} from './utils';
|
|
26
|
+
import type { Pattern, Template, TemplatePart } from '../types';
|
|
27
|
+
import type { NoticeSettings } from '../mutation';
|
|
28
|
+
import { deletePostWithNotices } from '../mutation';
|
|
29
|
+
import { unlock } from '../lock-unlock';
|
|
30
|
+
|
|
31
|
+
const { PATTERN_TYPES } = unlock( patternsPrivateApis );
|
|
32
|
+
|
|
33
|
+
// This action is used for templates, patterns and template parts.
|
|
34
|
+
// Every other post type uses the similar `trashPostAction` which
|
|
35
|
+
// moves the post to trash.
|
|
36
|
+
const deletePostAction: Action< Template | TemplatePart | Pattern > = {
|
|
37
|
+
id: 'delete-post',
|
|
38
|
+
label: __( 'Delete' ),
|
|
39
|
+
isPrimary: true,
|
|
40
|
+
icon: trash,
|
|
41
|
+
isEligible( post ) {
|
|
42
|
+
if ( isTemplateOrTemplatePart( post ) ) {
|
|
43
|
+
return isTemplateRemovable( post );
|
|
44
|
+
}
|
|
45
|
+
// We can only remove user patterns.
|
|
46
|
+
return post.type === PATTERN_TYPES.user;
|
|
47
|
+
},
|
|
48
|
+
supportsBulk: true,
|
|
49
|
+
hideModalHeader: true,
|
|
50
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
51
|
+
const [ isBusy, setIsBusy ] = useState( false );
|
|
52
|
+
const isResetting = items.every(
|
|
53
|
+
( item ) => isTemplateOrTemplatePart( item ) && item?.has_theme_file
|
|
54
|
+
);
|
|
55
|
+
return (
|
|
56
|
+
<VStack spacing="5">
|
|
57
|
+
<Text>
|
|
58
|
+
{ items.length > 1
|
|
59
|
+
? sprintf(
|
|
60
|
+
// translators: %d: number of items to delete.
|
|
61
|
+
_n(
|
|
62
|
+
'Delete %d item?',
|
|
63
|
+
'Delete %d items?',
|
|
64
|
+
items.length
|
|
65
|
+
),
|
|
66
|
+
items.length
|
|
67
|
+
)
|
|
68
|
+
: sprintf(
|
|
69
|
+
// translators: %s: The template or template part's titles
|
|
70
|
+
__( 'Delete "%s"?' ),
|
|
71
|
+
getItemTitle( items[ 0 ] )
|
|
72
|
+
) }
|
|
73
|
+
</Text>
|
|
74
|
+
<HStack justify="right">
|
|
75
|
+
<Button
|
|
76
|
+
variant="tertiary"
|
|
77
|
+
onClick={ closeModal }
|
|
78
|
+
disabled={ isBusy }
|
|
79
|
+
accessibleWhenDisabled
|
|
80
|
+
__next40pxDefaultSize
|
|
81
|
+
>
|
|
82
|
+
{ __( 'Cancel' ) }
|
|
83
|
+
</Button>
|
|
84
|
+
<Button
|
|
85
|
+
variant="primary"
|
|
86
|
+
onClick={ async () => {
|
|
87
|
+
setIsBusy( true );
|
|
88
|
+
const notice: NoticeSettings<
|
|
89
|
+
Template | TemplatePart | Pattern
|
|
90
|
+
> = {
|
|
91
|
+
success: {
|
|
92
|
+
messages: {
|
|
93
|
+
getMessage: ( item ) => {
|
|
94
|
+
return isResetting
|
|
95
|
+
? sprintf(
|
|
96
|
+
/* translators: The template/part's name. */
|
|
97
|
+
__( '"%s" reset.' ),
|
|
98
|
+
decodeEntities(
|
|
99
|
+
getItemTitle( item )
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
: sprintf(
|
|
103
|
+
/* translators: The template/part's name. */
|
|
104
|
+
__( '"%s" deleted.' ),
|
|
105
|
+
decodeEntities(
|
|
106
|
+
getItemTitle( item )
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
getBatchMessage: () => {
|
|
111
|
+
return isResetting
|
|
112
|
+
? __( 'Items reset.' )
|
|
113
|
+
: __( 'Items deleted.' );
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
error: {
|
|
118
|
+
messages: {
|
|
119
|
+
getMessage: ( error ) => {
|
|
120
|
+
if ( error.size === 1 ) {
|
|
121
|
+
return [ ...error ][ 0 ];
|
|
122
|
+
}
|
|
123
|
+
return isResetting
|
|
124
|
+
? __(
|
|
125
|
+
'An error occurred while reverting the item.'
|
|
126
|
+
)
|
|
127
|
+
: __(
|
|
128
|
+
'An error occurred while deleting the item.'
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
getBatchMessage: ( errors ) => {
|
|
132
|
+
if ( errors.size === 0 ) {
|
|
133
|
+
return isResetting
|
|
134
|
+
? __(
|
|
135
|
+
'An error occurred while reverting the items.'
|
|
136
|
+
)
|
|
137
|
+
: __(
|
|
138
|
+
'An error occurred while deleting the items.'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if ( errors.size === 1 ) {
|
|
143
|
+
return isResetting
|
|
144
|
+
? sprintf(
|
|
145
|
+
/* translators: %s: an error message */
|
|
146
|
+
__(
|
|
147
|
+
'An error occurred while reverting the items: %s'
|
|
148
|
+
),
|
|
149
|
+
[ ...errors ][ 0 ]
|
|
150
|
+
)
|
|
151
|
+
: sprintf(
|
|
152
|
+
/* translators: %s: an error message */
|
|
153
|
+
__(
|
|
154
|
+
'An error occurred while deleting the items: %s'
|
|
155
|
+
),
|
|
156
|
+
[ ...errors ][ 0 ]
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return isResetting
|
|
161
|
+
? sprintf(
|
|
162
|
+
/* translators: %s: a list of comma separated error messages */
|
|
163
|
+
__(
|
|
164
|
+
'Some errors occurred while reverting the items: %s'
|
|
165
|
+
),
|
|
166
|
+
[ ...errors ].join(
|
|
167
|
+
','
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
: sprintf(
|
|
171
|
+
/* translators: %s: a list of comma separated error messages */
|
|
172
|
+
__(
|
|
173
|
+
'Some errors occurred while deleting the items: %s'
|
|
174
|
+
),
|
|
175
|
+
[ ...errors ].join(
|
|
176
|
+
','
|
|
177
|
+
)
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
await deletePostWithNotices( items, notice, {
|
|
185
|
+
onActionPerformed,
|
|
186
|
+
} );
|
|
187
|
+
setIsBusy( false );
|
|
188
|
+
closeModal?.();
|
|
189
|
+
} }
|
|
190
|
+
isBusy={ isBusy }
|
|
191
|
+
disabled={ isBusy }
|
|
192
|
+
accessibleWhenDisabled
|
|
193
|
+
__next40pxDefaultSize
|
|
194
|
+
>
|
|
195
|
+
{ __( 'Delete' ) }
|
|
196
|
+
</Button>
|
|
197
|
+
</HStack>
|
|
198
|
+
</VStack>
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export default deletePostAction;
|
|
@@ -9,8 +9,8 @@ import type { Action } from '@wordpress/dataviews';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import { unlock } from '
|
|
13
|
-
import type { Pattern } from '
|
|
12
|
+
import { unlock } from '../lock-unlock';
|
|
13
|
+
import type { Pattern } from '../types';
|
|
14
14
|
|
|
15
15
|
// Patterns.
|
|
16
16
|
const { CreatePatternModalContents, useDuplicatePatternProps } =
|
|
@@ -18,9 +18,9 @@ import type { Action } from '@wordpress/dataviews';
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
|
-
import { titleField } from '
|
|
22
|
-
import type { BasePost, CoreDataError } from '
|
|
23
|
-
import { getItemTitle } from '
|
|
21
|
+
import { titleField } from '../fields';
|
|
22
|
+
import type { BasePost, CoreDataError } from '../types';
|
|
23
|
+
import { getItemTitle } from './utils';
|
|
24
24
|
|
|
25
25
|
const fields = [ titleField ];
|
|
26
26
|
const formDuplicateAction = {
|
|
@@ -15,8 +15,8 @@ import type { Action } from '@wordpress/dataviews';
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
|
-
import type { Pattern } from '
|
|
19
|
-
import { getItemTitle } from '
|
|
18
|
+
import type { Pattern } from '../types';
|
|
19
|
+
import { getItemTitle } from './utils';
|
|
20
20
|
|
|
21
21
|
function getJsonFromItem( item: Pattern ) {
|
|
22
22
|
return JSON.stringify(
|
package/src/actions/index.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { default as viewPost } from './view-post';
|
|
2
|
+
export { default as reorderPage } from './reorder-page';
|
|
3
|
+
export { default as reorderPageNative } from './reorder-page.native';
|
|
4
|
+
export { default as duplicatePost } from './duplicate-post';
|
|
5
|
+
export { default as duplicatePostNative } from './duplicate-post.native';
|
|
6
|
+
export { default as renamePost } from './rename-post';
|
|
7
|
+
export { default as resetPost } from './reset-post';
|
|
8
|
+
export { default as duplicatePattern } from './duplicate-pattern';
|
|
9
|
+
export { default as exportPattern } from './export-pattern';
|
|
10
|
+
export { default as exportPatternNative } from './export-pattern.native';
|
|
11
|
+
export { default as viewPostRevisions } from './view-post-revisions';
|
|
12
|
+
export { default as permanentlyDeletePost } from './permanently-delete-post';
|
|
13
|
+
export { default as restorePost } from './restore-post';
|
|
14
|
+
export { default as trashPost } from './trash-post';
|
|
15
|
+
export { default as deletePost } from './delete-post';
|
|
@@ -10,8 +10,8 @@ import { trash } from '@wordpress/icons';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import { getItemTitle, isTemplateOrTemplatePart } from '
|
|
14
|
-
import type { CoreDataError, PostWithPermissions } from '
|
|
13
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
14
|
+
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
15
15
|
|
|
16
16
|
const permanentlyDeletePost: Action< PostWithPermissions > = {
|
|
17
17
|
id: 'permanently-delete',
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useState } from '@wordpress/element';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
TextControl,
|
|
13
|
+
__experimentalHStack as HStack,
|
|
14
|
+
__experimentalVStack as VStack,
|
|
15
|
+
} from '@wordpress/components';
|
|
16
|
+
import type { Action } from '@wordpress/dataviews';
|
|
17
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { unlock } from '../lock-unlock';
|
|
24
|
+
import {
|
|
25
|
+
getItemTitle,
|
|
26
|
+
isTemplateRemovable,
|
|
27
|
+
isTemplate,
|
|
28
|
+
isTemplatePart,
|
|
29
|
+
TEMPLATE_ORIGINS,
|
|
30
|
+
TEMPLATE_PART_POST_TYPE,
|
|
31
|
+
TEMPLATE_POST_TYPE,
|
|
32
|
+
} from './utils';
|
|
33
|
+
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
34
|
+
|
|
35
|
+
// Patterns.
|
|
36
|
+
const { PATTERN_TYPES } = unlock( patternsPrivateApis );
|
|
37
|
+
|
|
38
|
+
const renamePost: Action< PostWithPermissions > = {
|
|
39
|
+
id: 'rename-post',
|
|
40
|
+
label: __( 'Rename' ),
|
|
41
|
+
isEligible( post ) {
|
|
42
|
+
if ( post.status === 'trash' ) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
// Templates, template parts and patterns have special checks for renaming.
|
|
46
|
+
if (
|
|
47
|
+
! [
|
|
48
|
+
TEMPLATE_POST_TYPE,
|
|
49
|
+
TEMPLATE_PART_POST_TYPE,
|
|
50
|
+
...Object.values( PATTERN_TYPES ),
|
|
51
|
+
].includes( post.type )
|
|
52
|
+
) {
|
|
53
|
+
return post.permissions?.update;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// In the case of templates, we can only rename custom templates.
|
|
57
|
+
if ( isTemplate( post ) ) {
|
|
58
|
+
return (
|
|
59
|
+
isTemplateRemovable( post ) &&
|
|
60
|
+
post.is_custom &&
|
|
61
|
+
post.permissions?.update
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if ( isTemplatePart( post ) ) {
|
|
66
|
+
return (
|
|
67
|
+
post.source === TEMPLATE_ORIGINS.custom &&
|
|
68
|
+
! post?.has_theme_file &&
|
|
69
|
+
post.permissions?.update
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return post.type === PATTERN_TYPES.user && post.permissions?.update;
|
|
74
|
+
},
|
|
75
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
76
|
+
const [ item ] = items;
|
|
77
|
+
const [ title, setTitle ] = useState( () => getItemTitle( item ) );
|
|
78
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
79
|
+
useDispatch( coreStore );
|
|
80
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
81
|
+
useDispatch( noticesStore );
|
|
82
|
+
|
|
83
|
+
async function onRename( event: React.FormEvent ) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
try {
|
|
86
|
+
await editEntityRecord( 'postType', item.type, item.id, {
|
|
87
|
+
title,
|
|
88
|
+
} );
|
|
89
|
+
// Update state before saving rerenders the list.
|
|
90
|
+
setTitle( '' );
|
|
91
|
+
closeModal?.();
|
|
92
|
+
// Persist edited entity.
|
|
93
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
94
|
+
throwOnError: true,
|
|
95
|
+
} );
|
|
96
|
+
createSuccessNotice( __( 'Name updated' ), {
|
|
97
|
+
type: 'snackbar',
|
|
98
|
+
} );
|
|
99
|
+
onActionPerformed?.( items );
|
|
100
|
+
} catch ( error ) {
|
|
101
|
+
const typedError = error as CoreDataError;
|
|
102
|
+
const errorMessage =
|
|
103
|
+
typedError.message && typedError.code !== 'unknown_error'
|
|
104
|
+
? typedError.message
|
|
105
|
+
: __( 'An error occurred while updating the name' );
|
|
106
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<form onSubmit={ onRename }>
|
|
112
|
+
<VStack spacing="5">
|
|
113
|
+
<TextControl
|
|
114
|
+
__nextHasNoMarginBottom
|
|
115
|
+
__next40pxDefaultSize
|
|
116
|
+
label={ __( 'Name' ) }
|
|
117
|
+
value={ title }
|
|
118
|
+
onChange={ setTitle }
|
|
119
|
+
required
|
|
120
|
+
/>
|
|
121
|
+
<HStack justify="right">
|
|
122
|
+
<Button
|
|
123
|
+
__next40pxDefaultSize
|
|
124
|
+
variant="tertiary"
|
|
125
|
+
onClick={ () => {
|
|
126
|
+
closeModal?.();
|
|
127
|
+
} }
|
|
128
|
+
>
|
|
129
|
+
{ __( 'Cancel' ) }
|
|
130
|
+
</Button>
|
|
131
|
+
<Button
|
|
132
|
+
__next40pxDefaultSize
|
|
133
|
+
variant="primary"
|
|
134
|
+
type="submit"
|
|
135
|
+
>
|
|
136
|
+
{ __( 'Save' ) }
|
|
137
|
+
</Button>
|
|
138
|
+
</HStack>
|
|
139
|
+
</VStack>
|
|
140
|
+
</form>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default renamePost;
|
|
@@ -17,8 +17,8 @@ import type { Action, RenderModalProps } from '@wordpress/dataviews';
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
|
-
import type { CoreDataError, BasePost } from '
|
|
21
|
-
import { orderField } from '
|
|
20
|
+
import type { CoreDataError, BasePost } from '../types';
|
|
21
|
+
import { orderField } from '../fields';
|
|
22
22
|
|
|
23
23
|
const fields = [ orderField ];
|
|
24
24
|
const formOrderAction = {
|