@wordpress/editor 14.8.6 → 14.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js +15 -18
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-tools/index.js +1 -6
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +22 -17
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +8 -9
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/use-post-content-blocks.js +34 -0
- package/build/components/provider/use-post-content-blocks.js.map +1 -0
- package/build/components/resizable-editor/resize-handle.js +4 -0
- package/build/components/resizable-editor/resize-handle.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +1 -1
- package/build/components/zoom-out-toggle/index.js.map +1 -1
- package/build/dataviews/store/private-actions.js +2 -7
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/store/actions.js +20 -5
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +14 -18
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -6
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +22 -17
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +8 -9
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/use-post-content-blocks.js +27 -0
- package/build-module/components/provider/use-post-content-blocks.js.map +1 -0
- package/build-module/components/resizable-editor/resize-handle.js +4 -0
- package/build-module/components/resizable-editor/resize-handle.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +1 -1
- package/build-module/components/zoom-out-toggle/index.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +4 -8
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/store/actions.js +18 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -1
- package/build-style/style.css +10 -1
- package/build-types/components/document-tools/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/use-post-content-blocks.d.ts +2 -0
- package/build-types/components/provider/use-post-content-blocks.d.ts.map +1 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +1 -13
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +2 -2
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/block-settings-menu/content-only-settings-menu.js +19 -19
- package/src/components/document-tools/index.js +1 -4
- package/src/components/header/index.js +30 -14
- package/src/components/inserter-sidebar/index.js +8 -11
- package/src/components/provider/disable-non-page-content-blocks.js +20 -34
- package/src/components/provider/use-post-content-blocks.js +42 -0
- package/src/components/resizable-editor/resize-handle.js +5 -0
- package/src/components/zoom-out-toggle/index.js +1 -1
- package/src/dataviews/store/private-actions.ts +7 -7
- package/src/store/actions.js +23 -6
- package/src/store/private-selectors.js +2 -2
- package/src/store/test/actions.js +76 -0
- package/src/store/test/reducer.js +0 -22
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataviews/actions/delete-post.js +0 -98
- package/build/dataviews/actions/delete-post.js.map +0 -1
- package/build/dataviews/actions/rename-post.js +0 -125
- package/build/dataviews/actions/rename-post.js.map +0 -1
- package/build/dataviews/actions/reset-post.js +0 -113
- package/build/dataviews/actions/reset-post.js.map +0 -1
- package/build/dataviews/actions/restore-post.js +0 -112
- package/build/dataviews/actions/restore-post.js.map +0 -1
- package/build/dataviews/actions/trash-post.js +0 -144
- package/build/dataviews/actions/trash-post.js.map +0 -1
- package/build/dataviews/fields/index.js +0 -32
- package/build/dataviews/fields/index.js.map +0 -1
- package/build-module/dataviews/actions/delete-post.js +0 -89
- package/build-module/dataviews/actions/delete-post.js.map +0 -1
- package/build-module/dataviews/actions/rename-post.js +0 -118
- package/build-module/dataviews/actions/rename-post.js.map +0 -1
- package/build-module/dataviews/actions/reset-post.js +0 -106
- package/build-module/dataviews/actions/reset-post.js.map +0 -1
- package/build-module/dataviews/actions/restore-post.js +0 -104
- package/build-module/dataviews/actions/restore-post.js.map +0 -1
- package/build-module/dataviews/actions/trash-post.js +0 -137
- package/build-module/dataviews/actions/trash-post.js.map +0 -1
- package/build-module/dataviews/fields/index.js +0 -26
- package/build-module/dataviews/fields/index.js.map +0 -1
- package/build-types/dataviews/actions/delete-post.d.ts +0 -5
- package/build-types/dataviews/actions/delete-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/rename-post.d.ts +0 -5
- package/build-types/dataviews/actions/rename-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/reset-post.d.ts +0 -5
- package/build-types/dataviews/actions/reset-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/restore-post.d.ts +0 -5
- package/build-types/dataviews/actions/restore-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/trash-post.d.ts +0 -5
- package/build-types/dataviews/actions/trash-post.d.ts.map +0 -1
- package/build-types/dataviews/fields/index.d.ts +0 -8
- package/build-types/dataviews/fields/index.d.ts.map +0 -1
- package/src/dataviews/actions/delete-post.tsx +0 -109
- package/src/dataviews/actions/rename-post.tsx +0 -146
- package/src/dataviews/actions/reset-post.tsx +0 -147
- package/src/dataviews/actions/restore-post.tsx +0 -134
- package/src/dataviews/actions/trash-post.tsx +0 -198
- package/src/dataviews/fields/index.ts +0 -26
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { backup } from '@wordpress/icons';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
12
|
-
const restorePost = {
|
|
13
|
-
id: 'restore',
|
|
14
|
-
label: __('Restore'),
|
|
15
|
-
isPrimary: true,
|
|
16
|
-
icon: backup,
|
|
17
|
-
supportsBulk: true,
|
|
18
|
-
isEligible(item) {
|
|
19
|
-
return !isTemplateOrTemplatePart(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
|
|
20
|
-
},
|
|
21
|
-
async callback(posts, {
|
|
22
|
-
registry,
|
|
23
|
-
onActionPerformed
|
|
24
|
-
}) {
|
|
25
|
-
const {
|
|
26
|
-
createSuccessNotice,
|
|
27
|
-
createErrorNotice
|
|
28
|
-
} = registry.dispatch(noticesStore);
|
|
29
|
-
const {
|
|
30
|
-
editEntityRecord,
|
|
31
|
-
saveEditedEntityRecord
|
|
32
|
-
} = registry.dispatch(coreStore);
|
|
33
|
-
await Promise.allSettled(posts.map(post => {
|
|
34
|
-
return editEntityRecord('postType', post.type, post.id, {
|
|
35
|
-
status: 'draft'
|
|
36
|
-
});
|
|
37
|
-
}));
|
|
38
|
-
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
39
|
-
return saveEditedEntityRecord('postType', post.type, post.id, {
|
|
40
|
-
throwOnError: true
|
|
41
|
-
});
|
|
42
|
-
}));
|
|
43
|
-
if (promiseResult.every(({
|
|
44
|
-
status
|
|
45
|
-
}) => status === 'fulfilled')) {
|
|
46
|
-
let successMessage;
|
|
47
|
-
if (posts.length === 1) {
|
|
48
|
-
successMessage = sprintf( /* translators: The number of posts. */
|
|
49
|
-
__('"%s" has been restored.'), getItemTitle(posts[0]));
|
|
50
|
-
} else if (posts[0].type === 'page') {
|
|
51
|
-
successMessage = sprintf( /* translators: The number of posts. */
|
|
52
|
-
__('%d pages have been restored.'), posts.length);
|
|
53
|
-
} else {
|
|
54
|
-
successMessage = sprintf( /* translators: The number of posts. */
|
|
55
|
-
__('%d posts have been restored.'), posts.length);
|
|
56
|
-
}
|
|
57
|
-
createSuccessNotice(successMessage, {
|
|
58
|
-
type: 'snackbar',
|
|
59
|
-
id: 'restore-post-action'
|
|
60
|
-
});
|
|
61
|
-
if (onActionPerformed) {
|
|
62
|
-
onActionPerformed(posts);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
// If there was at lease one failure.
|
|
66
|
-
let errorMessage;
|
|
67
|
-
// If we were trying to move a single post to the trash.
|
|
68
|
-
if (promiseResult.length === 1) {
|
|
69
|
-
const typedError = promiseResult[0];
|
|
70
|
-
if (typedError.reason?.message) {
|
|
71
|
-
errorMessage = typedError.reason.message;
|
|
72
|
-
} else {
|
|
73
|
-
errorMessage = __('An error occurred while restoring the post.');
|
|
74
|
-
}
|
|
75
|
-
// If we were trying to move multiple posts to the trash
|
|
76
|
-
} else {
|
|
77
|
-
const errorMessages = new Set();
|
|
78
|
-
const failedPromises = promiseResult.filter(({
|
|
79
|
-
status
|
|
80
|
-
}) => status === 'rejected');
|
|
81
|
-
for (const failedPromise of failedPromises) {
|
|
82
|
-
const typedError = failedPromise;
|
|
83
|
-
if (typedError.reason?.message) {
|
|
84
|
-
errorMessages.add(typedError.reason.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (errorMessages.size === 0) {
|
|
88
|
-
errorMessage = __('An error occurred while restoring the posts.');
|
|
89
|
-
} else if (errorMessages.size === 1) {
|
|
90
|
-
errorMessage = sprintf( /* translators: %s: an error message */
|
|
91
|
-
__('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
|
|
92
|
-
} else {
|
|
93
|
-
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
94
|
-
__('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
createErrorNotice(errorMessage, {
|
|
98
|
-
type: 'snackbar'
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
export default restorePost;
|
|
104
|
-
//# sourceMappingURL=restore-post.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["backup","store","coreStore","__","sprintf","noticesStore","getItemTitle","isTemplateOrTemplatePart","restorePost","id","label","isPrimary","icon","supportsBulk","isEligible","item","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","editEntityRecord","saveEditedEntityRecord","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/dataviews/actions/restore-post.tsx"],"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: 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: 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: 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();\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\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AAC,MAAM;UACNH,YAAY,GAAGnC,EAAE,CAChB,6CACD,CAAC;QACF;QACA;MACD,CAAC,MAAM;QACN,MAAMuC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAAC;QAC/B,MAAMC,cAAc,GAAGX,aAAa,CAACY,MAAM,CAC1C,CAAE;UAAE5B;QAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;QACD,KAAM,MAAM6B,aAAa,IAAIF,cAAc,EAAG;UAC7C,MAAML,UAAU,GAAGO,aAElB;UACD,IAAKP,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;YACjCC,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAGnC,EAAE,CAChB,8CACD,CAAC;QACF,CAAC,MAAM,IAAKuC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGuC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CACD,oDACD,CAAC,EACD,CAAE,GAAGuC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACAxB,iBAAiB,CAAEa,YAAY,EAAE;QAChCtB,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAED,eAAeR,WAAW","ignoreList":[]}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { trash } from '@wordpress/icons';
|
|
5
|
-
import { useDispatch } from '@wordpress/data';
|
|
6
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
import { __, _n, sprintf, _x } from '@wordpress/i18n';
|
|
8
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
import { Button, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
const trashPost = {
|
|
18
|
-
id: 'move-to-trash',
|
|
19
|
-
label: __('Move to trash'),
|
|
20
|
-
isPrimary: true,
|
|
21
|
-
icon: trash,
|
|
22
|
-
isEligible(item) {
|
|
23
|
-
if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
|
|
27
|
-
},
|
|
28
|
-
supportsBulk: true,
|
|
29
|
-
hideModalHeader: true,
|
|
30
|
-
RenderModal: ({
|
|
31
|
-
items,
|
|
32
|
-
closeModal,
|
|
33
|
-
onActionPerformed
|
|
34
|
-
}) => {
|
|
35
|
-
const [isBusy, setIsBusy] = useState(false);
|
|
36
|
-
const {
|
|
37
|
-
createSuccessNotice,
|
|
38
|
-
createErrorNotice
|
|
39
|
-
} = useDispatch(noticesStore);
|
|
40
|
-
const {
|
|
41
|
-
deleteEntityRecord
|
|
42
|
-
} = useDispatch(coreStore);
|
|
43
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
44
|
-
spacing: "5",
|
|
45
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
46
|
-
children: items.length === 1 ? sprintf(
|
|
47
|
-
// translators: %s: The item's title.
|
|
48
|
-
__('Are you sure you want to move "%s" to the trash?'), getItemTitle(items[0])) : sprintf(
|
|
49
|
-
// translators: %d: The number of items (2 or more).
|
|
50
|
-
_n('Are you sure you want to move %d item to the trash ?', 'Are you sure you want to move %d items to the trash ?', items.length), items.length)
|
|
51
|
-
}), /*#__PURE__*/_jsxs(HStack, {
|
|
52
|
-
justify: "right",
|
|
53
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
54
|
-
__next40pxDefaultSize: true,
|
|
55
|
-
variant: "tertiary",
|
|
56
|
-
onClick: closeModal,
|
|
57
|
-
disabled: isBusy,
|
|
58
|
-
accessibleWhenDisabled: true,
|
|
59
|
-
children: __('Cancel')
|
|
60
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
61
|
-
__next40pxDefaultSize: true,
|
|
62
|
-
variant: "primary",
|
|
63
|
-
onClick: async () => {
|
|
64
|
-
setIsBusy(true);
|
|
65
|
-
const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
|
|
66
|
-
throwOnError: true
|
|
67
|
-
})));
|
|
68
|
-
// If all the promises were fulfilled with success.
|
|
69
|
-
if (promiseResult.every(({
|
|
70
|
-
status
|
|
71
|
-
}) => status === 'fulfilled')) {
|
|
72
|
-
let successMessage;
|
|
73
|
-
if (promiseResult.length === 1) {
|
|
74
|
-
successMessage = sprintf( /* translators: The item's title. */
|
|
75
|
-
__('"%s" moved to the trash.'), getItemTitle(items[0]));
|
|
76
|
-
} else {
|
|
77
|
-
successMessage = sprintf( /* translators: The number of items. */
|
|
78
|
-
_n('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
|
|
79
|
-
}
|
|
80
|
-
createSuccessNotice(successMessage, {
|
|
81
|
-
type: 'snackbar',
|
|
82
|
-
id: 'move-to-trash-action'
|
|
83
|
-
});
|
|
84
|
-
} else {
|
|
85
|
-
// If there was at least one failure.
|
|
86
|
-
let errorMessage;
|
|
87
|
-
// If we were trying to delete a single item.
|
|
88
|
-
if (promiseResult.length === 1) {
|
|
89
|
-
const typedError = promiseResult[0];
|
|
90
|
-
if (typedError.reason?.message) {
|
|
91
|
-
errorMessage = typedError.reason.message;
|
|
92
|
-
} else {
|
|
93
|
-
errorMessage = __('An error occurred while moving the item to the trash.');
|
|
94
|
-
}
|
|
95
|
-
// If we were trying to delete multiple items.
|
|
96
|
-
} else {
|
|
97
|
-
const errorMessages = new Set();
|
|
98
|
-
const failedPromises = promiseResult.filter(({
|
|
99
|
-
status
|
|
100
|
-
}) => status === 'rejected');
|
|
101
|
-
for (const failedPromise of failedPromises) {
|
|
102
|
-
const typedError = failedPromise;
|
|
103
|
-
if (typedError.reason?.message) {
|
|
104
|
-
errorMessages.add(typedError.reason.message);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (errorMessages.size === 0) {
|
|
108
|
-
errorMessage = __('An error occurred while moving the items to the trash.');
|
|
109
|
-
} else if (errorMessages.size === 1) {
|
|
110
|
-
errorMessage = sprintf( /* translators: %s: an error message */
|
|
111
|
-
__('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
|
|
112
|
-
} else {
|
|
113
|
-
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
114
|
-
__('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
createErrorNotice(errorMessage, {
|
|
118
|
-
type: 'snackbar'
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
if (onActionPerformed) {
|
|
122
|
-
onActionPerformed(items);
|
|
123
|
-
}
|
|
124
|
-
setIsBusy(false);
|
|
125
|
-
closeModal?.();
|
|
126
|
-
},
|
|
127
|
-
isBusy: isBusy,
|
|
128
|
-
disabled: isBusy,
|
|
129
|
-
accessibleWhenDisabled: true,
|
|
130
|
-
children: _x('Trash', 'verb')
|
|
131
|
-
})]
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
export default trashPost;
|
|
137
|
-
//# sourceMappingURL=trash-post.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["trash","useDispatch","store","coreStore","__","_n","sprintf","_x","noticesStore","useState","Button","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","getItemTitle","isTemplateOrTemplatePart","jsx","_jsx","jsxs","_jsxs","trashPost","id","label","isPrimary","icon","isEligible","item","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","createSuccessNotice","createErrorNotice","deleteEntityRecord","spacing","children","length","justify","__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"],"sources":["@wordpress/editor/src/dataviews/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, isTemplateOrTemplatePart } 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 ( isTemplateOrTemplatePart( item ) || 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\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: 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: 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'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s 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();\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</VSt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ChBR,UAAU,CAACC,MAAM,CAACC,OACnB,CAAC;kBACF;gBACD;gBACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;kBAC/BV,YAAY,GAAG3D,EAAE,CAChB,wDACD,CAAC;gBACF,CAAC,MAAM,IAAK+D,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;kBACtCV,YAAY,GAAGzD,OAAO,EACrB;kBACAF,EAAE,CACD,0DACD,CAAC,EACD,CAAE,GAAG+D,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;gBACF,CAAC,MAAM;kBACNJ,YAAY,GAAGzD,OAAO,EACrB;kBACAF,EAAE,CACD,8DACD,CAAC,EACD,CAAE,GAAG+D,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACA9B,iBAAiB,CAAEmB,YAAY,EAAE;gBAChCjC,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKU,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBY,QAAQ,EAAGZ,MAAQ;UACnBa,sBAAsB;UAAAP,QAAA,EAEpBxC,EAAE,CAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAED,eAAegB,SAAS","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { getItemTitle } from '../actions/utils';
|
|
11
|
-
export const titleField = {
|
|
12
|
-
type: 'text',
|
|
13
|
-
id: 'title',
|
|
14
|
-
label: __('Title'),
|
|
15
|
-
placeholder: __('No title'),
|
|
16
|
-
getValue: ({
|
|
17
|
-
item
|
|
18
|
-
}) => getItemTitle(item)
|
|
19
|
-
};
|
|
20
|
-
export const orderField = {
|
|
21
|
-
type: 'integer',
|
|
22
|
-
id: 'menu_order',
|
|
23
|
-
label: __('Order'),
|
|
24
|
-
description: __('Determines the order of pages.')
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","getItemTitle","titleField","type","id","label","placeholder","getValue","item","orderField","description"],"sources":["@wordpress/editor/src/dataviews/fields/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\nimport { getItemTitle } from '../actions/utils';\n\nexport const titleField: Field< BasePost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n};\n\nexport const orderField: Field< BasePost > = {\n\ttype: 'integer',\n\tid: 'menu_order',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAGpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,OAAO,MAAMC,UAA6B,GAAG;EAC5CC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAEL,EAAE,CAAE,OAAQ,CAAC;EACpBM,WAAW,EAAEN,EAAE,CAAE,UAAW,CAAC;EAC7BO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMP,YAAY,CAAEO,IAAK;AAC9C,CAAC;AAED,OAAO,MAAMC,UAA6B,GAAG;EAC5CN,IAAI,EAAE,SAAS;EACfC,EAAE,EAAE,YAAY;EAChBC,KAAK,EAAEL,EAAE,CAAE,OAAQ,CAAC;EACpBU,WAAW,EAAEV,EAAE,CAAE,gCAAiC;AACnD,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/delete-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAcnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOrC,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAE,IAAI,CAsEnC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rename-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/rename-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAkBnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKnE,QAAA,MAAM,UAAU,EAAE,MAAM,CAAE,mBAAmB,CAyG5C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/reset-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASnD,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,UAAU,CAAC;AAGpD,QAAA,MAAM,SAAS,EAAE,MAAM,CAAE,IAAI,CAqH5B,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"restore-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/restore-post.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEnE,QAAA,MAAM,WAAW,EAAE,MAAM,CAAE,mBAAmB,CAoH7C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trash-post.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/trash-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEnE,QAAA,MAAM,SAAS,EAAE,MAAM,CAAE,mBAAmB,CA4K3C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Field } from '@wordpress/dataviews';
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import type { BasePost } from '../types';
|
|
6
|
-
export declare const titleField: Field<BasePost>;
|
|
7
|
-
export declare const orderField: Field<BasePost>;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataviews/fields/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,eAAO,MAAM,UAAU,EAAE,KAAK,CAAE,QAAQ,CAMvC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAE,QAAQ,CAKvC,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { trash } from '@wordpress/icons';
|
|
5
|
-
import { useDispatch } from '@wordpress/data';
|
|
6
|
-
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
7
|
-
import { useState } from '@wordpress/element';
|
|
8
|
-
import {
|
|
9
|
-
Button,
|
|
10
|
-
__experimentalText as Text,
|
|
11
|
-
__experimentalHStack as HStack,
|
|
12
|
-
__experimentalVStack as VStack,
|
|
13
|
-
} from '@wordpress/components';
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
16
|
-
import type { Action } from '@wordpress/dataviews';
|
|
17
|
-
import type { StoreDescriptor } from '@wordpress/data';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
import {
|
|
23
|
-
isTemplateRemovable,
|
|
24
|
-
getItemTitle,
|
|
25
|
-
isTemplateOrTemplatePart,
|
|
26
|
-
} from './utils';
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
import { store as editorStore } from '../../store';
|
|
29
|
-
import { unlock } from '../../lock-unlock';
|
|
30
|
-
import type { Post } from '../types';
|
|
31
|
-
|
|
32
|
-
const { PATTERN_TYPES } = unlock( patternsPrivateApis );
|
|
33
|
-
|
|
34
|
-
// This action is used for templates, patterns and template parts.
|
|
35
|
-
// Every other post type uses the similar `trashPostAction` which
|
|
36
|
-
// moves the post to trash.
|
|
37
|
-
const deletePostAction: Action< Post > = {
|
|
38
|
-
id: 'delete-post',
|
|
39
|
-
label: __( 'Delete' ),
|
|
40
|
-
isPrimary: true,
|
|
41
|
-
icon: trash,
|
|
42
|
-
isEligible( post ) {
|
|
43
|
-
if ( isTemplateOrTemplatePart( post ) ) {
|
|
44
|
-
return isTemplateRemovable( post );
|
|
45
|
-
}
|
|
46
|
-
// We can only remove user patterns.
|
|
47
|
-
return post.type === PATTERN_TYPES.user;
|
|
48
|
-
},
|
|
49
|
-
supportsBulk: true,
|
|
50
|
-
hideModalHeader: true,
|
|
51
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
52
|
-
const [ isBusy, setIsBusy ] = useState( false );
|
|
53
|
-
const { removeTemplates } = unlock(
|
|
54
|
-
useDispatch( editorStore as StoreDescriptor )
|
|
55
|
-
);
|
|
56
|
-
return (
|
|
57
|
-
<VStack spacing="5">
|
|
58
|
-
<Text>
|
|
59
|
-
{ items.length > 1
|
|
60
|
-
? sprintf(
|
|
61
|
-
// translators: %d: number of items to delete.
|
|
62
|
-
_n(
|
|
63
|
-
'Delete %d item?',
|
|
64
|
-
'Delete %d items?',
|
|
65
|
-
items.length
|
|
66
|
-
),
|
|
67
|
-
items.length
|
|
68
|
-
)
|
|
69
|
-
: sprintf(
|
|
70
|
-
// translators: %s: The template or template part's titles
|
|
71
|
-
__( 'Delete "%s"?' ),
|
|
72
|
-
getItemTitle( items[ 0 ] )
|
|
73
|
-
) }
|
|
74
|
-
</Text>
|
|
75
|
-
<HStack justify="right">
|
|
76
|
-
<Button
|
|
77
|
-
variant="tertiary"
|
|
78
|
-
onClick={ closeModal }
|
|
79
|
-
disabled={ isBusy }
|
|
80
|
-
accessibleWhenDisabled
|
|
81
|
-
__next40pxDefaultSize
|
|
82
|
-
>
|
|
83
|
-
{ __( 'Cancel' ) }
|
|
84
|
-
</Button>
|
|
85
|
-
<Button
|
|
86
|
-
variant="primary"
|
|
87
|
-
onClick={ async () => {
|
|
88
|
-
setIsBusy( true );
|
|
89
|
-
await removeTemplates( items, {
|
|
90
|
-
allowUndo: false,
|
|
91
|
-
} );
|
|
92
|
-
onActionPerformed?.( items );
|
|
93
|
-
setIsBusy( false );
|
|
94
|
-
closeModal?.();
|
|
95
|
-
} }
|
|
96
|
-
isBusy={ isBusy }
|
|
97
|
-
disabled={ isBusy }
|
|
98
|
-
accessibleWhenDisabled
|
|
99
|
-
__next40pxDefaultSize
|
|
100
|
-
>
|
|
101
|
-
{ __( 'Delete' ) }
|
|
102
|
-
</Button>
|
|
103
|
-
</HStack>
|
|
104
|
-
</VStack>
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default deletePostAction;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useDispatch } from '@wordpress/data';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { 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
|
-
import {
|
|
23
|
-
TEMPLATE_ORIGINS,
|
|
24
|
-
TEMPLATE_PART_POST_TYPE,
|
|
25
|
-
TEMPLATE_POST_TYPE,
|
|
26
|
-
} from '../../store/constants';
|
|
27
|
-
import { unlock } from '../../lock-unlock';
|
|
28
|
-
import {
|
|
29
|
-
getItemTitle,
|
|
30
|
-
isTemplateRemovable,
|
|
31
|
-
isTemplate,
|
|
32
|
-
isTemplatePart,
|
|
33
|
-
} from './utils';
|
|
34
|
-
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
35
|
-
|
|
36
|
-
// Patterns.
|
|
37
|
-
const { PATTERN_TYPES } = unlock( patternsPrivateApis );
|
|
38
|
-
|
|
39
|
-
const renamePost: Action< PostWithPermissions > = {
|
|
40
|
-
id: 'rename-post',
|
|
41
|
-
label: __( 'Rename' ),
|
|
42
|
-
isEligible( post ) {
|
|
43
|
-
if ( post.status === 'trash' ) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
// Templates, template parts and patterns have special checks for renaming.
|
|
47
|
-
if (
|
|
48
|
-
! [
|
|
49
|
-
TEMPLATE_POST_TYPE,
|
|
50
|
-
TEMPLATE_PART_POST_TYPE,
|
|
51
|
-
...Object.values( PATTERN_TYPES ),
|
|
52
|
-
].includes( post.type )
|
|
53
|
-
) {
|
|
54
|
-
return post.permissions?.update;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// In the case of templates, we can only rename custom templates.
|
|
58
|
-
if ( isTemplate( post ) ) {
|
|
59
|
-
return (
|
|
60
|
-
isTemplateRemovable( post ) &&
|
|
61
|
-
post.is_custom &&
|
|
62
|
-
post.permissions?.update
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ( isTemplatePart( post ) ) {
|
|
67
|
-
return (
|
|
68
|
-
post.source === TEMPLATE_ORIGINS.custom &&
|
|
69
|
-
! post?.has_theme_file &&
|
|
70
|
-
post.permissions?.update
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return post.type === PATTERN_TYPES.user && post.permissions?.update;
|
|
75
|
-
},
|
|
76
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
77
|
-
const [ item ] = items;
|
|
78
|
-
const [ title, setTitle ] = useState( () => getItemTitle( item ) );
|
|
79
|
-
const { editEntityRecord, saveEditedEntityRecord } =
|
|
80
|
-
useDispatch( coreStore );
|
|
81
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
82
|
-
useDispatch( noticesStore );
|
|
83
|
-
|
|
84
|
-
async function onRename( event: React.FormEvent ) {
|
|
85
|
-
event.preventDefault();
|
|
86
|
-
try {
|
|
87
|
-
await editEntityRecord( 'postType', item.type, item.id, {
|
|
88
|
-
title,
|
|
89
|
-
} );
|
|
90
|
-
// Update state before saving rerenders the list.
|
|
91
|
-
setTitle( '' );
|
|
92
|
-
closeModal?.();
|
|
93
|
-
// Persist edited entity.
|
|
94
|
-
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
95
|
-
throwOnError: true,
|
|
96
|
-
} );
|
|
97
|
-
createSuccessNotice( __( 'Name updated' ), {
|
|
98
|
-
type: 'snackbar',
|
|
99
|
-
} );
|
|
100
|
-
onActionPerformed?.( items );
|
|
101
|
-
} catch ( error ) {
|
|
102
|
-
const typedError = error as CoreDataError;
|
|
103
|
-
const errorMessage =
|
|
104
|
-
typedError.message && typedError.code !== 'unknown_error'
|
|
105
|
-
? typedError.message
|
|
106
|
-
: __( 'An error occurred while updating the name' );
|
|
107
|
-
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<form onSubmit={ onRename }>
|
|
113
|
-
<VStack spacing="5">
|
|
114
|
-
<TextControl
|
|
115
|
-
__nextHasNoMarginBottom
|
|
116
|
-
__next40pxDefaultSize
|
|
117
|
-
label={ __( 'Name' ) }
|
|
118
|
-
value={ title }
|
|
119
|
-
onChange={ setTitle }
|
|
120
|
-
required
|
|
121
|
-
/>
|
|
122
|
-
<HStack justify="right">
|
|
123
|
-
<Button
|
|
124
|
-
__next40pxDefaultSize
|
|
125
|
-
variant="tertiary"
|
|
126
|
-
onClick={ () => {
|
|
127
|
-
closeModal?.();
|
|
128
|
-
} }
|
|
129
|
-
>
|
|
130
|
-
{ __( 'Cancel' ) }
|
|
131
|
-
</Button>
|
|
132
|
-
<Button
|
|
133
|
-
__next40pxDefaultSize
|
|
134
|
-
variant="primary"
|
|
135
|
-
type="submit"
|
|
136
|
-
>
|
|
137
|
-
{ __( 'Save' ) }
|
|
138
|
-
</Button>
|
|
139
|
-
</HStack>
|
|
140
|
-
</VStack>
|
|
141
|
-
</form>
|
|
142
|
-
);
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export default renamePost;
|