@strapi/content-manager 0.0.0-experimental.4ddd402c7194d1a969a797313bf007c93148d59a → 0.0.0-experimental.545ccead2ee1717bbc7ab950455dbb0ddb9924a3
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/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs → ComponentConfigurationPage-B1bIXVuX.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs.map → ComponentConfigurationPage-B1bIXVuX.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js → ComponentConfigurationPage-Bqgx7Mes.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js.map → ComponentConfigurationPage-Bqgx7Mes.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js → EditConfigurationPage-BFEwvdMW.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js.map → EditConfigurationPage-BFEwvdMW.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs → EditConfigurationPage-ZO0vOO8q.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs.map → EditConfigurationPage-ZO0vOO8q.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CU7724gt.js → EditViewPage-DA95Ha6J.js} +45 -45
- package/dist/_chunks/EditViewPage-DA95Ha6J.js.map +1 -0
- package/dist/_chunks/{EditViewPage-CzuJgWWp.mjs → EditViewPage-DlLEyUL6.mjs} +46 -46
- package/dist/_chunks/EditViewPage-DlLEyUL6.mjs.map +1 -0
- package/dist/_chunks/{Field-Dh1yZyqy.js → Field-CnK8dO8N.js} +416 -136
- package/dist/_chunks/Field-CnK8dO8N.js.map +1 -0
- package/dist/_chunks/{Field-QtUSh5mU.mjs → Field-Dq7bDnuh.mjs} +417 -137
- package/dist/_chunks/Field-Dq7bDnuh.mjs.map +1 -0
- package/dist/_chunks/{Form-COLpvlnv.mjs → Form-B_JE0dbz.mjs} +27 -28
- package/dist/_chunks/Form-B_JE0dbz.mjs.map +1 -0
- package/dist/_chunks/{Form-BOR8NOe1.js → Form-BpiR4piS.js} +25 -26
- package/dist/_chunks/Form-BpiR4piS.js.map +1 -0
- package/dist/_chunks/{History-Bu53Yfw-.mjs → History-CBNGU7a-.mjs} +124 -30
- package/dist/_chunks/History-CBNGU7a-.mjs.map +1 -0
- package/dist/_chunks/{History-CW2akQ6h.js → History-DdIstl8b.js} +123 -29
- package/dist/_chunks/History-DdIstl8b.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-TqrmwjPN.mjs → ListConfigurationPage-5dr4qpue.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-jzdhEk_u.js → ListConfigurationPage-DkKRparB.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BO_mOXIl.mjs → ListViewPage-DecLrYV6.mjs} +60 -68
- package/dist/_chunks/ListViewPage-DecLrYV6.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-B3bMOrMv.js → ListViewPage-wE0lXqoD.js} +59 -67
- package/dist/_chunks/ListViewPage-wE0lXqoD.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs → NoContentTypePage-CiIcfYsd.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs.map → NoContentTypePage-CiIcfYsd.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js → NoContentTypePage-DEKR6tf9.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js.map → NoContentTypePage-DEKR6tf9.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs → NoPermissionsPage-CM5UD8ee.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs.map → NoPermissionsPage-CM5UD8ee.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js → NoPermissionsPage-DmNfF2Bb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js.map → NoPermissionsPage-DmNfF2Bb.js.map} +1 -1
- package/dist/_chunks/{Relations-CJ4qdkRo.mjs → Relations-Dqz0C1fz.mjs} +3 -3
- package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +1 -0
- package/dist/_chunks/{Relations-B6fb2POW.js → Relations-L0xYRoSQ.js} +3 -3
- package/dist/_chunks/Relations-L0xYRoSQ.js.map +1 -0
- package/dist/_chunks/{en-9GwRW_ku.mjs → en-BrCTWlZv.mjs} +7 -4
- package/dist/_chunks/{en-9GwRW_ku.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-DZXjRiWA.js → en-uOUIxfcQ.js} +7 -4
- package/dist/_chunks/{en-DZXjRiWA.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-Dahjdw4h.mjs → index-BSn97i8U.mjs} +355 -384
- package/dist/_chunks/index-BSn97i8U.mjs.map +1 -0
- package/dist/_chunks/{index-DcUu-_72.js → index-DyvUPg1a.js} +340 -369
- package/dist/_chunks/index-DyvUPg1a.js.map +1 -0
- package/dist/_chunks/{layout-omucV6TV.mjs → layout-DPaHUusj.mjs} +8 -8
- package/dist/_chunks/layout-DPaHUusj.mjs.map +1 -0
- package/dist/_chunks/{layout-jcY4dyUG.js → layout-TPqF2oJ5.js} +7 -7
- package/dist/_chunks/layout-TPqF2oJ5.js.map +1 -0
- package/dist/_chunks/{relations-DGzD7ORa.js → relations-BWYS9gkn.js} +2 -2
- package/dist/_chunks/{relations-DGzD7ORa.js.map → relations-BWYS9gkn.js.map} +1 -1
- package/dist/_chunks/{relations-CN0-aw6p.mjs → relations-Ck7-ecDT.mjs} +2 -2
- package/dist/_chunks/{relations-CN0-aw6p.mjs.map → relations-Ck7-ecDT.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/server/index.js +11 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +11 -6
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CU7724gt.js.map +0 -1
- package/dist/_chunks/EditViewPage-CzuJgWWp.mjs.map +0 -1
- package/dist/_chunks/Field-Dh1yZyqy.js.map +0 -1
- package/dist/_chunks/Field-QtUSh5mU.mjs.map +0 -1
- package/dist/_chunks/Form-BOR8NOe1.js.map +0 -1
- package/dist/_chunks/Form-COLpvlnv.mjs.map +0 -1
- package/dist/_chunks/History-Bu53Yfw-.mjs.map +0 -1
- package/dist/_chunks/History-CW2akQ6h.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-TqrmwjPN.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-jzdhEk_u.js.map +0 -1
- package/dist/_chunks/ListViewPage-B3bMOrMv.js.map +0 -1
- package/dist/_chunks/ListViewPage-BO_mOXIl.mjs.map +0 -1
- package/dist/_chunks/Relations-B6fb2POW.js.map +0 -1
- package/dist/_chunks/Relations-CJ4qdkRo.mjs.map +0 -1
- package/dist/_chunks/index-Dahjdw4h.mjs.map +0 -1
- package/dist/_chunks/index-DcUu-_72.js.map +0 -1
- package/dist/_chunks/layout-jcY4dyUG.js.map +0 -1
- package/dist/_chunks/layout-omucV6TV.mjs.map +0 -1
@@ -2,15 +2,15 @@
|
|
2
2
|
const Icons = require("@strapi/icons");
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
|
-
const qs = require("qs");
|
6
|
-
const reactIntl = require("react-intl");
|
7
|
-
const reactRouterDom = require("react-router-dom");
|
8
5
|
const React = require("react");
|
9
6
|
const designSystem = require("@strapi/design-system");
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const reactRouterDom = require("react-router-dom");
|
10
9
|
const styledComponents = require("styled-components");
|
11
10
|
const yup = require("yup");
|
12
11
|
const pipe = require("lodash/fp/pipe");
|
13
12
|
const dateFns = require("date-fns");
|
13
|
+
const qs = require("qs");
|
14
14
|
const toolkit = require("@reduxjs/toolkit");
|
15
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
16
|
function _interopNamespace(e) {
|
@@ -70,42 +70,6 @@ const useInjectionZone = (area) => {
|
|
70
70
|
const [page, position] = area.split(".");
|
71
71
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
72
72
|
};
|
73
|
-
const HistoryAction = ({ model, document }) => {
|
74
|
-
const { formatMessage } = reactIntl.useIntl();
|
75
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
76
|
-
const navigate = reactRouterDom.useNavigate();
|
77
|
-
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
78
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
return {
|
82
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
83
|
-
label: formatMessage({
|
84
|
-
id: "content-manager.history.document-action",
|
85
|
-
defaultMessage: "Content History"
|
86
|
-
}),
|
87
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
88
|
-
disabled: (
|
89
|
-
/**
|
90
|
-
* The user is creating a new document.
|
91
|
-
* It hasn't been saved yet, so there's no history to go to
|
92
|
-
*/
|
93
|
-
!document || /**
|
94
|
-
* The document has been created but the current dimension has never been saved.
|
95
|
-
* For example, the user is creating a new locale in an existing document,
|
96
|
-
* so there's no history for the document in that locale
|
97
|
-
*/
|
98
|
-
!document.id || /**
|
99
|
-
* History is only available for content types created by the user.
|
100
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
101
|
-
* which start with `admin::` or `plugin::`
|
102
|
-
*/
|
103
|
-
!model.startsWith("api::")
|
104
|
-
),
|
105
|
-
position: "header"
|
106
|
-
};
|
107
|
-
};
|
108
|
-
HistoryAction.type = "history";
|
109
73
|
const ID = "id";
|
110
74
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
111
75
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -219,6 +183,7 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
219
183
|
]
|
220
184
|
});
|
221
185
|
const documentApi = contentManagerApi.injectEndpoints({
|
186
|
+
overrideExisting: true,
|
222
187
|
endpoints: (builder) => ({
|
223
188
|
autoCloneDocument: builder.mutation({
|
224
189
|
query: ({ model, sourceId, query }) => ({
|
@@ -620,11 +585,11 @@ const createAttributeSchema = (attribute) => {
|
|
620
585
|
}
|
621
586
|
};
|
622
587
|
const addRequiredValidation = (attribute) => (schema) => {
|
623
|
-
if (attribute.required) {
|
624
|
-
return schema.required
|
625
|
-
|
626
|
-
|
627
|
-
|
588
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
589
|
+
return schema.min(1, strapiAdmin.translatedErrors.required);
|
590
|
+
}
|
591
|
+
if (attribute.required && attribute.type !== "relation") {
|
592
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
628
593
|
}
|
629
594
|
return schema?.nullable ? schema.nullable() : (
|
630
595
|
// In some cases '.nullable' will not be available on the schema.
|
@@ -658,6 +623,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
658
623
|
const addMinValidation = (attribute) => (schema) => {
|
659
624
|
if ("min" in attribute) {
|
660
625
|
const min = toInteger(attribute.min);
|
626
|
+
if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
|
627
|
+
if (!attribute.required && "test" in schema && min) {
|
628
|
+
return schema.test(
|
629
|
+
"custom-min",
|
630
|
+
{
|
631
|
+
...strapiAdmin.translatedErrors.min,
|
632
|
+
values: {
|
633
|
+
min: attribute.min
|
634
|
+
}
|
635
|
+
},
|
636
|
+
(value) => {
|
637
|
+
if (!value) {
|
638
|
+
return true;
|
639
|
+
}
|
640
|
+
if (Array.isArray(value) && value.length === 0) {
|
641
|
+
return true;
|
642
|
+
}
|
643
|
+
return value.length >= min;
|
644
|
+
}
|
645
|
+
);
|
646
|
+
}
|
647
|
+
}
|
661
648
|
if ("min" in schema && min) {
|
662
649
|
return schema.min(min, {
|
663
650
|
...strapiAdmin.translatedErrors.min,
|
@@ -784,7 +771,10 @@ const useDocument = (args, opts) => {
|
|
784
771
|
isLoading: isLoadingDocument,
|
785
772
|
isFetching: isFetchingDocument,
|
786
773
|
error
|
787
|
-
} = useGetDocumentQuery(args,
|
774
|
+
} = useGetDocumentQuery(args, {
|
775
|
+
...opts,
|
776
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
777
|
+
});
|
788
778
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
789
779
|
React__namespace.useEffect(() => {
|
790
780
|
if (error) {
|
@@ -1286,7 +1276,7 @@ const useDocumentActions = () => {
|
|
1286
1276
|
};
|
1287
1277
|
};
|
1288
1278
|
const ProtectedHistoryPage = React.lazy(
|
1289
|
-
() => Promise.resolve().then(() => require("./History-
|
1279
|
+
() => Promise.resolve().then(() => require("./History-DdIstl8b.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1290
1280
|
);
|
1291
1281
|
const routes$1 = [
|
1292
1282
|
{
|
@@ -1299,31 +1289,31 @@ const routes$1 = [
|
|
1299
1289
|
}
|
1300
1290
|
];
|
1301
1291
|
const ProtectedEditViewPage = React.lazy(
|
1302
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1292
|
+
() => Promise.resolve().then(() => require("./EditViewPage-DA95Ha6J.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1303
1293
|
);
|
1304
1294
|
const ProtectedListViewPage = React.lazy(
|
1305
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1295
|
+
() => Promise.resolve().then(() => require("./ListViewPage-wE0lXqoD.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1306
1296
|
);
|
1307
1297
|
const ProtectedListConfiguration = React.lazy(
|
1308
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1298
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-DkKRparB.js")).then((mod) => ({
|
1309
1299
|
default: mod.ProtectedListConfiguration
|
1310
1300
|
}))
|
1311
1301
|
);
|
1312
1302
|
const ProtectedEditConfigurationPage = React.lazy(
|
1313
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1303
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BFEwvdMW.js")).then((mod) => ({
|
1314
1304
|
default: mod.ProtectedEditConfigurationPage
|
1315
1305
|
}))
|
1316
1306
|
);
|
1317
1307
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1318
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1308
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-Bqgx7Mes.js")).then((mod) => ({
|
1319
1309
|
default: mod.ProtectedComponentConfigurationPage
|
1320
1310
|
}))
|
1321
1311
|
);
|
1322
1312
|
const NoPermissions = React.lazy(
|
1323
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1313
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-DmNfF2Bb.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1324
1314
|
);
|
1325
1315
|
const NoContentType = React.lazy(
|
1326
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1316
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-DEKR6tf9.js")).then((mod) => ({ default: mod.NoContentType }))
|
1327
1317
|
);
|
1328
1318
|
const CollectionTypePages = () => {
|
1329
1319
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1450,7 +1440,7 @@ const DocumentActionButton = (action) => {
|
|
1450
1440
|
DocumentActionConfirmDialog,
|
1451
1441
|
{
|
1452
1442
|
...action.dialog,
|
1453
|
-
variant: action.variant,
|
1443
|
+
variant: action.dialog?.variant ?? action.variant,
|
1454
1444
|
isOpen: dialogId === action.id,
|
1455
1445
|
onClose: handleClose
|
1456
1446
|
}
|
@@ -1530,7 +1520,7 @@ const DocumentActionsMenu = ({
|
|
1530
1520
|
display: "block",
|
1531
1521
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1532
1522
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
|
1533
|
-
action.icon,
|
1523
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
|
1534
1524
|
action.label
|
1535
1525
|
] }),
|
1536
1526
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -1591,6 +1581,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1591
1581
|
return "primary600";
|
1592
1582
|
}
|
1593
1583
|
};
|
1584
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1585
|
+
switch (variant) {
|
1586
|
+
case "danger":
|
1587
|
+
return "danger600";
|
1588
|
+
case "secondary":
|
1589
|
+
return "neutral500";
|
1590
|
+
case "success":
|
1591
|
+
return "success600";
|
1592
|
+
default:
|
1593
|
+
return "primary600";
|
1594
|
+
}
|
1595
|
+
};
|
1594
1596
|
const DocumentActionConfirmDialog = ({
|
1595
1597
|
onClose,
|
1596
1598
|
onCancel,
|
@@ -1613,22 +1615,20 @@ const DocumentActionConfirmDialog = ({
|
|
1613
1615
|
}
|
1614
1616
|
onClose();
|
1615
1617
|
};
|
1616
|
-
return /* @__PURE__ */ jsxRuntime.
|
1617
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1618
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1619
|
-
|
1620
|
-
{
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
)
|
1631
|
-
] });
|
1618
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
1619
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1620
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1621
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1622
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
1623
|
+
id: "app.components.Button.cancel",
|
1624
|
+
defaultMessage: "Cancel"
|
1625
|
+
}) }) }),
|
1626
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1627
|
+
id: "app.components.Button.confirm",
|
1628
|
+
defaultMessage: "Confirm"
|
1629
|
+
}) })
|
1630
|
+
] })
|
1631
|
+
] }) });
|
1632
1632
|
};
|
1633
1633
|
const DocumentActionModal = ({
|
1634
1634
|
isOpen,
|
@@ -1638,34 +1638,17 @@ const DocumentActionModal = ({
|
|
1638
1638
|
content: Content,
|
1639
1639
|
onModalClose
|
1640
1640
|
}) => {
|
1641
|
-
const id = React__namespace.useId();
|
1642
|
-
if (!isOpen) {
|
1643
|
-
return null;
|
1644
|
-
}
|
1645
1641
|
const handleClose = () => {
|
1646
1642
|
if (onClose) {
|
1647
1643
|
onClose();
|
1648
1644
|
}
|
1649
1645
|
onModalClose();
|
1650
1646
|
};
|
1651
|
-
return /* @__PURE__ */ jsxRuntime.
|
1652
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1653
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1654
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1655
|
-
|
1656
|
-
{
|
1657
|
-
paddingTop: 4,
|
1658
|
-
paddingBottom: 4,
|
1659
|
-
paddingLeft: 5,
|
1660
|
-
paddingRight: 5,
|
1661
|
-
borderWidth: "1px 0 0 0",
|
1662
|
-
borderStyle: "solid",
|
1663
|
-
borderColor: "neutral150",
|
1664
|
-
background: "neutral100",
|
1665
|
-
children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1666
|
-
}
|
1667
|
-
)
|
1668
|
-
] });
|
1647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
1649
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content }),
|
1650
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer })
|
1651
|
+
] }) });
|
1669
1652
|
};
|
1670
1653
|
const PublishAction$1 = ({
|
1671
1654
|
activeTab,
|
@@ -1686,6 +1669,12 @@ const PublishAction$1 = ({
|
|
1686
1669
|
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1687
1670
|
);
|
1688
1671
|
const { publish } = useDocumentActions();
|
1672
|
+
const [
|
1673
|
+
countDraftRelations,
|
1674
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
1675
|
+
] = useLazyGetDraftRelationCountQuery();
|
1676
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
1677
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1689
1678
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1690
1679
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1691
1680
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1694,10 +1683,101 @@ const PublishAction$1 = ({
|
|
1694
1683
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1695
1684
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1696
1685
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
1686
|
+
React__namespace.useEffect(() => {
|
1687
|
+
if (isErrorDraftRelations) {
|
1688
|
+
toggleNotification({
|
1689
|
+
type: "danger",
|
1690
|
+
message: formatMessage({
|
1691
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
1692
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
1693
|
+
})
|
1694
|
+
});
|
1695
|
+
}
|
1696
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
1697
|
+
React__namespace.useEffect(() => {
|
1698
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
1699
|
+
const extractDraftRelations = (data) => {
|
1700
|
+
const relations = data.connect || [];
|
1701
|
+
relations.forEach((relation) => {
|
1702
|
+
if (relation.status === "draft") {
|
1703
|
+
localDraftRelations.add(relation.id);
|
1704
|
+
}
|
1705
|
+
});
|
1706
|
+
};
|
1707
|
+
const traverseAndExtract = (data) => {
|
1708
|
+
Object.entries(data).forEach(([key, value]) => {
|
1709
|
+
if (key === "connect" && Array.isArray(value)) {
|
1710
|
+
extractDraftRelations({ connect: value });
|
1711
|
+
} else if (typeof value === "object" && value !== null) {
|
1712
|
+
traverseAndExtract(value);
|
1713
|
+
}
|
1714
|
+
});
|
1715
|
+
};
|
1716
|
+
if (!documentId || modified) {
|
1717
|
+
traverseAndExtract(formValues);
|
1718
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
1719
|
+
}
|
1720
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1721
|
+
React__namespace.useEffect(() => {
|
1722
|
+
if (documentId) {
|
1723
|
+
const fetchDraftRelationsCount = async () => {
|
1724
|
+
const { data, error } = await countDraftRelations({
|
1725
|
+
collectionType,
|
1726
|
+
model,
|
1727
|
+
documentId,
|
1728
|
+
params
|
1729
|
+
});
|
1730
|
+
if (error) {
|
1731
|
+
throw error;
|
1732
|
+
}
|
1733
|
+
if (data) {
|
1734
|
+
setServerCountOfDraftRelations(data.data);
|
1735
|
+
}
|
1736
|
+
};
|
1737
|
+
fetchDraftRelationsCount();
|
1738
|
+
}
|
1739
|
+
}, [documentId, countDraftRelations, collectionType, model, params]);
|
1697
1740
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1698
1741
|
if (!schema?.options?.draftAndPublish) {
|
1699
1742
|
return null;
|
1700
1743
|
}
|
1744
|
+
const performPublish = async () => {
|
1745
|
+
setSubmitting(true);
|
1746
|
+
try {
|
1747
|
+
const { errors } = await validate();
|
1748
|
+
if (errors) {
|
1749
|
+
toggleNotification({
|
1750
|
+
type: "danger",
|
1751
|
+
message: formatMessage({
|
1752
|
+
id: "content-manager.validation.error",
|
1753
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1754
|
+
})
|
1755
|
+
});
|
1756
|
+
return;
|
1757
|
+
}
|
1758
|
+
const res = await publish(
|
1759
|
+
{
|
1760
|
+
collectionType,
|
1761
|
+
model,
|
1762
|
+
documentId,
|
1763
|
+
params
|
1764
|
+
},
|
1765
|
+
formValues
|
1766
|
+
);
|
1767
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1768
|
+
navigate({
|
1769
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1770
|
+
search: rawQuery
|
1771
|
+
});
|
1772
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1773
|
+
setErrors(formatValidationErrors(res.error));
|
1774
|
+
}
|
1775
|
+
} finally {
|
1776
|
+
setSubmitting(false);
|
1777
|
+
}
|
1778
|
+
};
|
1779
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1780
|
+
const hasDraftRelations = totalDraftRelations > 0;
|
1701
1781
|
return {
|
1702
1782
|
/**
|
1703
1783
|
* Disabled when:
|
@@ -1710,46 +1790,38 @@ const PublishAction$1 = ({
|
|
1710
1790
|
* - the user doesn't have the permission to create a new document
|
1711
1791
|
* - the user doesn't have the permission to update the document
|
1712
1792
|
*/
|
1713
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
|
1793
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
|
1714
1794
|
label: formatMessage({
|
1715
1795
|
id: "app.utils.publish",
|
1716
1796
|
defaultMessage: "Publish"
|
1717
1797
|
}),
|
1718
1798
|
onClick: async () => {
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
formValues
|
1740
|
-
);
|
1741
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1742
|
-
navigate({
|
1743
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1744
|
-
search: rawQuery
|
1745
|
-
});
|
1746
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1747
|
-
setErrors(formatValidationErrors(res.error));
|
1799
|
+
if (hasDraftRelations) {
|
1800
|
+
return;
|
1801
|
+
}
|
1802
|
+
await performPublish();
|
1803
|
+
},
|
1804
|
+
dialog: hasDraftRelations ? {
|
1805
|
+
type: "dialog",
|
1806
|
+
variant: "danger",
|
1807
|
+
footer: null,
|
1808
|
+
title: formatMessage({
|
1809
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
1810
|
+
defaultMessage: "Confirmation"
|
1811
|
+
}),
|
1812
|
+
content: formatMessage(
|
1813
|
+
{
|
1814
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
1815
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
1816
|
+
},
|
1817
|
+
{
|
1818
|
+
count: totalDraftRelations
|
1748
1819
|
}
|
1749
|
-
|
1750
|
-
|
1820
|
+
),
|
1821
|
+
onConfirm: async () => {
|
1822
|
+
await performPublish();
|
1751
1823
|
}
|
1752
|
-
}
|
1824
|
+
} : void 0
|
1753
1825
|
};
|
1754
1826
|
};
|
1755
1827
|
PublishAction$1.type = "publish";
|
@@ -1848,10 +1920,13 @@ const UpdateAction = ({
|
|
1848
1920
|
document
|
1849
1921
|
);
|
1850
1922
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1851
|
-
navigate(
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1923
|
+
navigate(
|
1924
|
+
{
|
1925
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1926
|
+
search: rawQuery
|
1927
|
+
},
|
1928
|
+
{ replace: true }
|
1929
|
+
);
|
1855
1930
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1856
1931
|
setErrors(formatValidationErrors(res.error));
|
1857
1932
|
}
|
@@ -1883,10 +1958,8 @@ const UnpublishAction$1 = ({
|
|
1883
1958
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1884
1959
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1885
1960
|
const isDocumentModified = document?.status === "modified";
|
1886
|
-
const handleChange = (
|
1887
|
-
|
1888
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1889
|
-
}
|
1961
|
+
const handleChange = (value) => {
|
1962
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1890
1963
|
};
|
1891
1964
|
if (!schema?.options?.draftAndPublish) {
|
1892
1965
|
return null;
|
@@ -1936,40 +2009,24 @@ const UnpublishAction$1 = ({
|
|
1936
2009
|
}) })
|
1937
2010
|
] }),
|
1938
2011
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1939
|
-
designSystem.
|
2012
|
+
designSystem.Radio.Group,
|
1940
2013
|
{
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
2014
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2015
|
+
name: "discard-options",
|
2016
|
+
"aria-label": formatMessage({
|
2017
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2018
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2019
|
+
}),
|
2020
|
+
onValueChange: handleChange,
|
1947
2021
|
children: [
|
1948
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1957
|
-
defaultMessage: "Keep draft"
|
1958
|
-
})
|
1959
|
-
}
|
1960
|
-
),
|
1961
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1962
|
-
designSystem.Radio,
|
1963
|
-
{
|
1964
|
-
checked: !shouldKeepDraft,
|
1965
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1966
|
-
name: "discard-options",
|
1967
|
-
children: formatMessage({
|
1968
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1969
|
-
defaultMessage: "Replace draft"
|
1970
|
-
})
|
1971
|
-
}
|
1972
|
-
)
|
2022
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2023
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2024
|
+
defaultMessage: "Keep draft"
|
2025
|
+
}) }),
|
2026
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2027
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2028
|
+
defaultMessage: "Replace draft"
|
2029
|
+
}) })
|
1973
2030
|
]
|
1974
2031
|
}
|
1975
2032
|
)
|
@@ -2115,23 +2172,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2115
2172
|
id: "content-manager.containers.edit.title.new",
|
2116
2173
|
defaultMessage: "Create an entry"
|
2117
2174
|
}) : documentTitle;
|
2118
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2175
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2119
2176
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2120
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2121
|
-
designSystem.
|
2122
|
-
{
|
2123
|
-
|
2124
|
-
|
2125
|
-
paddingTop: 1,
|
2126
|
-
gap: "80px",
|
2127
|
-
alignItems: "flex-start",
|
2128
|
-
children: [
|
2129
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2130
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2131
|
-
]
|
2132
|
-
}
|
2133
|
-
),
|
2134
|
-
status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2177
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2178
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2179
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2180
|
+
] }),
|
2181
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2135
2182
|
] });
|
2136
2183
|
};
|
2137
2184
|
const HeaderToolbar = () => {
|
@@ -2822,30 +2869,23 @@ const ConfirmBulkActionDialog = ({
|
|
2822
2869
|
endAction
|
2823
2870
|
}) => {
|
2824
2871
|
const { formatMessage } = reactIntl.useIntl();
|
2825
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2826
|
-
designSystem.Dialog,
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
}) }),
|
2843
|
-
endAction
|
2844
|
-
}
|
2845
|
-
)
|
2846
|
-
]
|
2847
|
-
}
|
2848
|
-
);
|
2872
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2873
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2874
|
+
id: "app.components.ConfirmDialog.title",
|
2875
|
+
defaultMessage: "Confirmation"
|
2876
|
+
}) }),
|
2877
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2878
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2879
|
+
dialogBody
|
2880
|
+
] }) }),
|
2881
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2882
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2883
|
+
id: "app.components.Button.cancel",
|
2884
|
+
defaultMessage: "Cancel"
|
2885
|
+
}) }) }),
|
2886
|
+
endAction
|
2887
|
+
] })
|
2888
|
+
] }) });
|
2849
2889
|
};
|
2850
2890
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2851
2891
|
const ConfirmDialogPublishAll = ({
|
@@ -2950,7 +2990,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2950
2990
|
)
|
2951
2991
|
);
|
2952
2992
|
} else {
|
2953
|
-
messages.push(
|
2993
|
+
messages.push(
|
2994
|
+
...formatErrorMessages(
|
2995
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
2996
|
+
value,
|
2997
|
+
currentKey,
|
2998
|
+
formatMessage
|
2999
|
+
)
|
3000
|
+
);
|
2954
3001
|
}
|
2955
3002
|
} else {
|
2956
3003
|
messages.push(
|
@@ -3187,7 +3234,7 @@ const SelectedEntriesModalContent = ({
|
|
3187
3234
|
);
|
3188
3235
|
};
|
3189
3236
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3190
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3237
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3191
3238
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3192
3239
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3193
3240
|
SelectedEntriesTableContent,
|
@@ -3199,27 +3246,24 @@ const SelectedEntriesModalContent = ({
|
|
3199
3246
|
}
|
3200
3247
|
) })
|
3201
3248
|
] }),
|
3202
|
-
/* @__PURE__ */ jsxRuntime.
|
3203
|
-
designSystem.
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
}) }),
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
] })
|
3221
|
-
}
|
3222
|
-
),
|
3249
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3250
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3251
|
+
id: "app.components.Button.cancel",
|
3252
|
+
defaultMessage: "Cancel"
|
3253
|
+
}) }),
|
3254
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3255
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3256
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3257
|
+
designSystem.Button,
|
3258
|
+
{
|
3259
|
+
onClick: toggleDialog,
|
3260
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3261
|
+
loading: isSubmittingForm,
|
3262
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3263
|
+
}
|
3264
|
+
)
|
3265
|
+
] })
|
3266
|
+
] }),
|
3223
3267
|
/* @__PURE__ */ jsxRuntime.jsx(
|
3224
3268
|
ConfirmDialogPublishAll,
|
3225
3269
|
{
|
@@ -3284,143 +3328,10 @@ const BulkActionsRenderer = () => {
|
|
3284
3328
|
documents: selectedRows
|
3285
3329
|
},
|
3286
3330
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3287
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
3331
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3288
3332
|
}
|
3289
3333
|
) });
|
3290
3334
|
};
|
3291
|
-
const BulkActionAction = (action) => {
|
3292
|
-
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3293
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
3294
|
-
const handleClick = (action2) => (e) => {
|
3295
|
-
const { onClick, dialog, id } = action2;
|
3296
|
-
if (onClick) {
|
3297
|
-
onClick(e);
|
3298
|
-
}
|
3299
|
-
if (dialog) {
|
3300
|
-
switch (dialog.type) {
|
3301
|
-
case "notification":
|
3302
|
-
toggleNotification({
|
3303
|
-
title: dialog.title,
|
3304
|
-
message: dialog.content,
|
3305
|
-
type: dialog.status,
|
3306
|
-
timeout: dialog.timeout,
|
3307
|
-
onClose: dialog.onClose
|
3308
|
-
});
|
3309
|
-
break;
|
3310
|
-
case "dialog":
|
3311
|
-
case "modal": {
|
3312
|
-
e.preventDefault();
|
3313
|
-
setDialogId(id);
|
3314
|
-
}
|
3315
|
-
}
|
3316
|
-
}
|
3317
|
-
};
|
3318
|
-
const handleClose = () => {
|
3319
|
-
setDialogId(null);
|
3320
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3321
|
-
action.dialog.onClose();
|
3322
|
-
}
|
3323
|
-
};
|
3324
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3325
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3326
|
-
designSystem.Button,
|
3327
|
-
{
|
3328
|
-
disabled: action.disabled,
|
3329
|
-
startIcon: action.icon,
|
3330
|
-
variant: action.variant,
|
3331
|
-
onClick: handleClick(action),
|
3332
|
-
children: action.label
|
3333
|
-
}
|
3334
|
-
),
|
3335
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3336
|
-
BulkActionConfirmDialog,
|
3337
|
-
{
|
3338
|
-
...action.dialog,
|
3339
|
-
variant: action.variant,
|
3340
|
-
isOpen: dialogId === action.id,
|
3341
|
-
onClose: handleClose
|
3342
|
-
}
|
3343
|
-
) : null,
|
3344
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3345
|
-
BulkActionModal,
|
3346
|
-
{
|
3347
|
-
...action.dialog,
|
3348
|
-
onModalClose: handleClose,
|
3349
|
-
isOpen: dialogId === action.id
|
3350
|
-
}
|
3351
|
-
) : null
|
3352
|
-
] });
|
3353
|
-
};
|
3354
|
-
const BulkActionConfirmDialog = ({
|
3355
|
-
onClose,
|
3356
|
-
onCancel,
|
3357
|
-
onConfirm,
|
3358
|
-
title,
|
3359
|
-
content,
|
3360
|
-
confirmButton,
|
3361
|
-
isOpen,
|
3362
|
-
variant = "secondary"
|
3363
|
-
}) => {
|
3364
|
-
const { formatMessage } = reactIntl.useIntl();
|
3365
|
-
const handleClose = async () => {
|
3366
|
-
if (onCancel) {
|
3367
|
-
await onCancel();
|
3368
|
-
}
|
3369
|
-
onClose();
|
3370
|
-
};
|
3371
|
-
const handleConfirm = async () => {
|
3372
|
-
if (onConfirm) {
|
3373
|
-
await onConfirm();
|
3374
|
-
}
|
3375
|
-
onClose();
|
3376
|
-
};
|
3377
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
|
3378
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
|
3379
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3380
|
-
designSystem.DialogFooter,
|
3381
|
-
{
|
3382
|
-
startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3383
|
-
id: "app.components.Button.cancel",
|
3384
|
-
defaultMessage: "Cancel"
|
3385
|
-
}) }),
|
3386
|
-
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
3387
|
-
designSystem.Button,
|
3388
|
-
{
|
3389
|
-
onClick: handleConfirm,
|
3390
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3391
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
3392
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3393
|
-
id: "app.components.Button.confirm",
|
3394
|
-
defaultMessage: "Confirm"
|
3395
|
-
})
|
3396
|
-
}
|
3397
|
-
)
|
3398
|
-
}
|
3399
|
-
)
|
3400
|
-
] });
|
3401
|
-
};
|
3402
|
-
const BulkActionModal = ({
|
3403
|
-
isOpen,
|
3404
|
-
title,
|
3405
|
-
onClose,
|
3406
|
-
content: Content,
|
3407
|
-
onModalClose
|
3408
|
-
}) => {
|
3409
|
-
const id = React__namespace.useId();
|
3410
|
-
if (!isOpen) {
|
3411
|
-
return null;
|
3412
|
-
}
|
3413
|
-
const handleClose = () => {
|
3414
|
-
if (onClose) {
|
3415
|
-
onClose();
|
3416
|
-
}
|
3417
|
-
onModalClose();
|
3418
|
-
};
|
3419
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3420
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3421
|
-
/* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
|
3422
|
-
] });
|
3423
|
-
};
|
3424
3335
|
const DeleteAction = ({ documents, model }) => {
|
3425
3336
|
const { formatMessage } = reactIntl.useIntl();
|
3426
3337
|
const { schema: contentType } = useDoc();
|
@@ -3453,6 +3364,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3453
3364
|
defaultMessage: "Confirmation"
|
3454
3365
|
}),
|
3455
3366
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3367
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3456
3368
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3457
3369
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3458
3370
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3502,6 +3414,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3502
3414
|
defaultMessage: "Confirmation"
|
3503
3415
|
}),
|
3504
3416
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3417
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3505
3418
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3506
3419
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3507
3420
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3747,8 +3660,7 @@ class ContentManagerPlugin {
|
|
3747
3660
|
documentActions = [
|
3748
3661
|
...DEFAULT_ACTIONS,
|
3749
3662
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3750
|
-
...DEFAULT_HEADER_ACTIONS
|
3751
|
-
HistoryAction
|
3663
|
+
...DEFAULT_HEADER_ACTIONS
|
3752
3664
|
];
|
3753
3665
|
editViewSidePanels = [ActionsPanel];
|
3754
3666
|
headerActions = [];
|
@@ -3837,6 +3749,52 @@ const getPrintableType = (value) => {
|
|
3837
3749
|
}
|
3838
3750
|
return nativeType;
|
3839
3751
|
};
|
3752
|
+
const HistoryAction = ({ model, document }) => {
|
3753
|
+
const { formatMessage } = reactIntl.useIntl();
|
3754
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3755
|
+
const navigate = reactRouterDom.useNavigate();
|
3756
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3757
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3758
|
+
return null;
|
3759
|
+
}
|
3760
|
+
return {
|
3761
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3762
|
+
label: formatMessage({
|
3763
|
+
id: "content-manager.history.document-action",
|
3764
|
+
defaultMessage: "Content History"
|
3765
|
+
}),
|
3766
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3767
|
+
disabled: (
|
3768
|
+
/**
|
3769
|
+
* The user is creating a new document.
|
3770
|
+
* It hasn't been saved yet, so there's no history to go to
|
3771
|
+
*/
|
3772
|
+
!document || /**
|
3773
|
+
* The document has been created but the current dimension has never been saved.
|
3774
|
+
* For example, the user is creating a new locale in an existing document,
|
3775
|
+
* so there's no history for the document in that locale
|
3776
|
+
*/
|
3777
|
+
!document.id || /**
|
3778
|
+
* History is only available for content types created by the user.
|
3779
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3780
|
+
* which start with `admin::` or `plugin::`
|
3781
|
+
*/
|
3782
|
+
!model.startsWith("api::")
|
3783
|
+
),
|
3784
|
+
position: "header"
|
3785
|
+
};
|
3786
|
+
};
|
3787
|
+
HistoryAction.type = "history";
|
3788
|
+
const historyAdmin = {
|
3789
|
+
bootstrap(app) {
|
3790
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3791
|
+
addDocumentAction((actions2) => {
|
3792
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3793
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3794
|
+
return actions2;
|
3795
|
+
});
|
3796
|
+
}
|
3797
|
+
};
|
3840
3798
|
const initialState = {
|
3841
3799
|
collectionTypeLinks: [],
|
3842
3800
|
components: [],
|
@@ -3887,15 +3845,29 @@ const index = {
|
|
3887
3845
|
defaultMessage: "Content Manager"
|
3888
3846
|
},
|
3889
3847
|
permissions: [],
|
3890
|
-
Component: () => Promise.resolve().then(() => require("./layout-jcY4dyUG.js")).then((mod) => ({ default: mod.Layout })),
|
3891
3848
|
position: 1
|
3892
3849
|
});
|
3850
|
+
app.router.addRoute({
|
3851
|
+
path: "content-manager/*",
|
3852
|
+
lazy: async () => {
|
3853
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-TPqF2oJ5.js"));
|
3854
|
+
return {
|
3855
|
+
Component: Layout
|
3856
|
+
};
|
3857
|
+
},
|
3858
|
+
children: routes
|
3859
|
+
});
|
3893
3860
|
app.registerPlugin(cm.config);
|
3894
3861
|
},
|
3862
|
+
bootstrap(app) {
|
3863
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3864
|
+
historyAdmin.bootstrap(app);
|
3865
|
+
}
|
3866
|
+
},
|
3895
3867
|
async registerTrads({ locales }) {
|
3896
3868
|
const importedTrads = await Promise.all(
|
3897
3869
|
locales.map((locale) => {
|
3898
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
3870
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-uOUIxfcQ.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3899
3871
|
return {
|
3900
3872
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3901
3873
|
locale
|
@@ -3939,7 +3911,6 @@ exports.getDisplayName = getDisplayName;
|
|
3939
3911
|
exports.getMainField = getMainField;
|
3940
3912
|
exports.getTranslation = getTranslation;
|
3941
3913
|
exports.index = index;
|
3942
|
-
exports.routes = routes;
|
3943
3914
|
exports.setInitialData = setInitialData;
|
3944
3915
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3945
3916
|
exports.useDoc = useDoc;
|
@@ -3953,4 +3924,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3953
3924
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3954
3925
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3955
3926
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3956
|
-
//# sourceMappingURL=index-
|
3927
|
+
//# sourceMappingURL=index-DyvUPg1a.js.map
|