@wordpress/fields 0.25.5 → 0.25.7
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/build/actions/duplicate-post.js +2 -6
- package/build/actions/duplicate-post.js.map +2 -2
- package/build/actions/rename-post.js +4 -3
- package/build/actions/rename-post.js.map +2 -2
- package/build/actions/reset-post.js +15 -6
- package/build/actions/reset-post.js.map +2 -2
- package/build/actions/trash-post.js +1 -4
- package/build/actions/trash-post.js.map +2 -2
- package/build-module/actions/duplicate-post.js +2 -6
- package/build-module/actions/duplicate-post.js.map +2 -2
- package/build-module/actions/rename-post.js +10 -4
- package/build-module/actions/rename-post.js.map +2 -2
- package/build-module/actions/reset-post.js +16 -7
- package/build-module/actions/reset-post.js.map +2 -2
- package/build-module/actions/trash-post.js +2 -5
- package/build-module/actions/trash-post.js.map +2 -2
- package/build-types/actions/duplicate-post.d.ts.map +1 -1
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts +2 -2
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/actions/trash-post.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/actions/duplicate-post.tsx +2 -11
- package/src/actions/rename-post.tsx +16 -7
- package/src/actions/reset-post.tsx +30 -15
- package/src/actions/trash-post.tsx +2 -7
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -11,17 +11,14 @@ import {
|
|
|
11
11
|
__experimentalHStack as HStack,
|
|
12
12
|
__experimentalVStack as VStack
|
|
13
13
|
} from "@wordpress/components";
|
|
14
|
-
import { getItemTitle } from "./utils";
|
|
14
|
+
import { getItemTitle, isTemplateOrTemplatePart } from "./utils";
|
|
15
15
|
const trashPost = {
|
|
16
16
|
id: "move-to-trash",
|
|
17
17
|
label: __("Trash"),
|
|
18
18
|
isPrimary: true,
|
|
19
19
|
icon: trash,
|
|
20
20
|
isEligible(item) {
|
|
21
|
-
if (item
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (item.type === "wp_template" && typeof item.id === "string") {
|
|
21
|
+
if (isTemplateOrTemplatePart(item) || item.type === "wp_block") {
|
|
25
22
|
return false;
|
|
26
23
|
}
|
|
27
24
|
return !!item.status && !["auto-draft", "trash"].includes(item.status) && item.permissions?.delete;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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: __( 'Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( item
|
|
5
|
-
"mappings": "
|
|
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, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( '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\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": "AAiDI,cAmBA,YAnBA;AA9CJ,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,SAAS,UAAU;AACpC,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AACzB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AAMP,SAAS,cAAc,gCAAgC;AAGvD,MAAM,YAA2C;AAAA,EAChD,IAAI;AAAA,EACJ,OAAO,GAAI,OAAQ;AAAA,EACnB,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAY,MAAO;AAClB,QAAK,yBAA0B,IAAK,KAAK,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,IAAI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YAEpB,aAAI,SAAS,MAAO;AAAA;AAAA,QACvB;AAAA,SACD;AAAA,OACD;AAAA,EAEF;AACD;AAKA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-post.d.ts","sourceRoot":"","sources":["../../src/actions/duplicate-post.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAGxD,UAAU,gBAAgB,CAAE,IAAI;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;CAC9C;AAED,UAAU,MAAM,CAAE,IAAI;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,OAAO,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,IAAI,CAAE,KAAM,GAAG,CAAC,OAAO,CAAC;CAChE;AAED,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"duplicate-post.d.ts","sourceRoot":"","sources":["../../src/actions/duplicate-post.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAGxD,UAAU,gBAAgB,CAAE,IAAI;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;CAC9C;AAED,UAAU,MAAM,CAAE,IAAI;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,OAAO,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,IAAI,CAAE,KAAM,GAAG,CAAC,OAAO,CAAC;CAChE;AAED,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,QAAQ,CAgJpC,CAAC;AAEF;;GAEG;AACH,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-post.d.ts","sourceRoot":"","sources":["../../src/actions/rename-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rename-post.d.ts","sourceRoot":"","sources":["../../src/actions/rename-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAcnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKnE,QAAA,MAAM,UAAU,EAAE,MAAM,CAAE,mBAAmB,CA0G5C,CAAC;AAEF;;GAEG;AACH,eAAe,UAAU,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Action } from '@wordpress/dataviews';
|
|
2
|
-
import type { TemplatePart } from '../types';
|
|
3
|
-
declare const resetPostAction: Action<TemplatePart>;
|
|
2
|
+
import type { Template, TemplatePart } from '../types';
|
|
3
|
+
declare const resetPostAction: Action<Template | TemplatePart>;
|
|
4
4
|
/**
|
|
5
5
|
* Reset action for Template and TemplatePart.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,KAAK,EAAiB,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAwJtE,QAAA,MAAM,eAAe,EAAE,MAAM,CAAE,QAAQ,GAAG,YAAY,CAoHrD,CAAC;AAEF;;GAEG;AACH,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trash-post.d.ts","sourceRoot":"","sources":["../../src/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,
|
|
1
|
+
{"version":3,"file":"trash-post.d.ts","sourceRoot":"","sources":["../../src/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,CA6K3C,CAAC;AAEF;;GAEG;AACH,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.7",
|
|
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",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"@wordpress/api-fetch": "^7.33.1",
|
|
43
43
|
"@wordpress/base-styles": "^6.9.1",
|
|
44
44
|
"@wordpress/blob": "^4.33.1",
|
|
45
|
-
"@wordpress/block-editor": "^15.6.
|
|
45
|
+
"@wordpress/block-editor": "^15.6.5",
|
|
46
46
|
"@wordpress/blocks": "^15.6.1",
|
|
47
|
-
"@wordpress/components": "^30.6.
|
|
47
|
+
"@wordpress/components": "^30.6.3",
|
|
48
48
|
"@wordpress/compose": "^7.33.1",
|
|
49
|
-
"@wordpress/core-data": "^7.33.
|
|
49
|
+
"@wordpress/core-data": "^7.33.5",
|
|
50
50
|
"@wordpress/data": "^10.33.1",
|
|
51
|
-
"@wordpress/dataviews": "^10.1.
|
|
51
|
+
"@wordpress/dataviews": "^10.1.4",
|
|
52
52
|
"@wordpress/date": "^5.33.1",
|
|
53
53
|
"@wordpress/element": "^6.33.1",
|
|
54
54
|
"@wordpress/hooks": "^4.33.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@wordpress/icons": "^11.0.1",
|
|
58
58
|
"@wordpress/media-utils": "^5.33.1",
|
|
59
59
|
"@wordpress/notices": "^5.33.1",
|
|
60
|
-
"@wordpress/patterns": "^2.33.
|
|
60
|
+
"@wordpress/patterns": "^2.33.5",
|
|
61
61
|
"@wordpress/primitives": "^4.33.1",
|
|
62
62
|
"@wordpress/private-apis": "^1.33.1",
|
|
63
63
|
"@wordpress/router": "^1.33.1",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "36643498e343222da980e5ae235d2f8630ad6b4f"
|
|
78
78
|
}
|
|
@@ -62,12 +62,10 @@ const duplicatePost: Action< BasePost > = {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const isTemplate = item.type === 'wp_template';
|
|
66
|
-
|
|
67
65
|
const newItemObject = {
|
|
68
|
-
status:
|
|
66
|
+
status: 'draft',
|
|
69
67
|
title: item.title,
|
|
70
|
-
slug:
|
|
68
|
+
slug: item.title || __( 'No title' ),
|
|
71
69
|
comment_status: item.comment_status,
|
|
72
70
|
content:
|
|
73
71
|
typeof item.content === 'string'
|
|
@@ -145,13 +143,6 @@ const duplicatePost: Action< BasePost > = {
|
|
|
145
143
|
return (
|
|
146
144
|
<form onSubmit={ createPage }>
|
|
147
145
|
<VStack spacing={ 3 }>
|
|
148
|
-
{ typeof item.id === 'string' && (
|
|
149
|
-
<div>
|
|
150
|
-
{ __(
|
|
151
|
-
'You are about to duplicate a bundled template. Changes will not be live until you activate the new template.'
|
|
152
|
-
) }
|
|
153
|
-
</div>
|
|
154
|
-
) }
|
|
155
146
|
<InputControl
|
|
156
147
|
__next40pxDefaultSize
|
|
157
148
|
label={ __( 'Title' ) }
|
|
@@ -21,7 +21,12 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { unlock } from '../lock-unlock';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
getItemTitle,
|
|
26
|
+
isTemplateRemovable,
|
|
27
|
+
isTemplate,
|
|
28
|
+
isTemplatePart,
|
|
29
|
+
} from './utils';
|
|
25
30
|
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
26
31
|
|
|
27
32
|
// Patterns.
|
|
@@ -35,15 +40,10 @@ const renamePost: Action< PostWithPermissions > = {
|
|
|
35
40
|
if ( post.status === 'trash' ) {
|
|
36
41
|
return false;
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
// Non-database template cannot be edited.
|
|
40
|
-
if ( post.type === 'wp_template' && typeof post.id === 'string' ) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
43
|
// Templates, template parts and patterns have special checks for renaming.
|
|
45
44
|
if (
|
|
46
45
|
! [
|
|
46
|
+
'wp_template',
|
|
47
47
|
'wp_template_part',
|
|
48
48
|
...Object.values( PATTERN_TYPES ),
|
|
49
49
|
].includes( post.type )
|
|
@@ -51,6 +51,15 @@ const renamePost: Action< PostWithPermissions > = {
|
|
|
51
51
|
return post.permissions?.update;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// In the case of templates, we can only rename custom templates.
|
|
55
|
+
if ( isTemplate( post ) ) {
|
|
56
|
+
return (
|
|
57
|
+
isTemplateRemovable( post ) &&
|
|
58
|
+
post.is_custom &&
|
|
59
|
+
post.permissions?.update
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
if ( isTemplatePart( post ) ) {
|
|
55
64
|
return (
|
|
56
65
|
post.source === 'custom' &&
|
|
@@ -22,10 +22,12 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
-
import { getItemTitle } from './utils';
|
|
26
|
-
import type { CoreDataError, TemplatePart } from '../types';
|
|
25
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
26
|
+
import type { CoreDataError, Template, TemplatePart } from '../types';
|
|
27
27
|
|
|
28
|
-
const isTemplateRevertable = (
|
|
28
|
+
const isTemplateRevertable = (
|
|
29
|
+
templateOrTemplatePart: Template | TemplatePart
|
|
30
|
+
) => {
|
|
29
31
|
if ( ! templateOrTemplatePart ) {
|
|
30
32
|
return false;
|
|
31
33
|
}
|
|
@@ -46,7 +48,7 @@ const isTemplateRevertable = ( templateOrTemplatePart: TemplatePart ) => {
|
|
|
46
48
|
* reverting the template. Default true.
|
|
47
49
|
*/
|
|
48
50
|
const revertTemplate = async (
|
|
49
|
-
template: TemplatePart,
|
|
51
|
+
template: TemplatePart | Template,
|
|
50
52
|
{ allowUndo = true } = {}
|
|
51
53
|
) => {
|
|
52
54
|
const noticeId = 'edit-site-template-reverted';
|
|
@@ -173,14 +175,15 @@ const revertTemplate = async (
|
|
|
173
175
|
}
|
|
174
176
|
};
|
|
175
177
|
|
|
176
|
-
const resetPostAction: Action< TemplatePart > = {
|
|
178
|
+
const resetPostAction: Action< Template | TemplatePart > = {
|
|
177
179
|
id: 'reset-post',
|
|
178
180
|
label: __( 'Reset' ),
|
|
179
181
|
isEligible: ( item ) => {
|
|
180
182
|
return (
|
|
181
|
-
item
|
|
183
|
+
isTemplateOrTemplatePart( item ) &&
|
|
182
184
|
item?.source === 'custom' &&
|
|
183
|
-
item?.
|
|
185
|
+
( Boolean( item.type === 'wp_template' && item?.plugin ) ||
|
|
186
|
+
item?.has_theme_file )
|
|
184
187
|
);
|
|
185
188
|
},
|
|
186
189
|
icon: backup,
|
|
@@ -223,14 +226,26 @@ const resetPostAction: Action< TemplatePart > = {
|
|
|
223
226
|
}
|
|
224
227
|
);
|
|
225
228
|
} catch ( error ) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
let fallbackErrorMessage;
|
|
230
|
+
if ( items[ 0 ].type === 'wp_template' ) {
|
|
231
|
+
fallbackErrorMessage =
|
|
232
|
+
items.length === 1
|
|
233
|
+
? __(
|
|
234
|
+
'An error occurred while reverting the template.'
|
|
235
|
+
)
|
|
236
|
+
: __(
|
|
237
|
+
'An error occurred while reverting the templates.'
|
|
238
|
+
);
|
|
239
|
+
} else {
|
|
240
|
+
fallbackErrorMessage =
|
|
241
|
+
items.length === 1
|
|
242
|
+
? __(
|
|
243
|
+
'An error occurred while reverting the template part.'
|
|
244
|
+
)
|
|
245
|
+
: __(
|
|
246
|
+
'An error occurred while reverting the template parts.'
|
|
247
|
+
);
|
|
248
|
+
}
|
|
234
249
|
|
|
235
250
|
const typedError = error as CoreDataError;
|
|
236
251
|
const errorMessage =
|
|
@@ -18,7 +18,7 @@ import type { Action } from '@wordpress/dataviews';
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
|
-
import { getItemTitle } from './utils';
|
|
21
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
22
22
|
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
23
23
|
|
|
24
24
|
const trashPost: Action< PostWithPermissions > = {
|
|
@@ -27,12 +27,7 @@ const trashPost: Action< PostWithPermissions > = {
|
|
|
27
27
|
isPrimary: true,
|
|
28
28
|
icon: trash,
|
|
29
29
|
isEligible( item ) {
|
|
30
|
-
if ( item
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Non-database template cannot be trashed.
|
|
35
|
-
if ( item.type === 'wp_template' && typeof item.id === 'string' ) {
|
|
30
|
+
if ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {
|
|
36
31
|
return false;
|
|
37
32
|
}
|
|
38
33
|
|