@strapi/content-manager 5.0.0-beta.9 → 5.0.0-rc.1
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-y_7iLdmB.js → ComponentConfigurationPage-D8RyVgJC.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js.map → ComponentConfigurationPage-D8RyVgJC.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs → ComponentConfigurationPage-DLuACgva.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs.map → ComponentConfigurationPage-DLuACgva.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs → EditConfigurationPage-CuCAsHWR.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs.map → EditConfigurationPage-CuCAsHWR.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js → EditConfigurationPage-fOm5AebB.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js.map → EditConfigurationPage-fOm5AebB.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DWb0DE7R.mjs → EditViewPage-BqDlT9w0.mjs} +46 -46
- package/dist/_chunks/EditViewPage-BqDlT9w0.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-CTTDHKkQ.js → EditViewPage-Or0fpTwh.js} +45 -45
- package/dist/_chunks/EditViewPage-Or0fpTwh.js.map +1 -0
- package/dist/_chunks/{Field-C5Z1Ivdv.js → Field-Bix2HU_O.js} +421 -141
- package/dist/_chunks/Field-Bix2HU_O.js.map +1 -0
- package/dist/_chunks/{Field-DnStdvQw.mjs → Field-OfBJ6x59.mjs} +422 -142
- package/dist/_chunks/Field-OfBJ6x59.mjs.map +1 -0
- package/dist/_chunks/{Form-B81OtW-k.js → Form-Bv5ABnqE.js} +25 -26
- package/dist/_chunks/Form-Bv5ABnqE.js.map +1 -0
- package/dist/_chunks/{Form-DqGgE55Q.mjs → Form-DyMXqj_v.mjs} +27 -28
- package/dist/_chunks/Form-DyMXqj_v.mjs.map +1 -0
- package/dist/_chunks/{History-4NbOq2dX.js → History-fnln26gA.js} +51 -28
- package/dist/_chunks/History-fnln26gA.js.map +1 -0
- package/dist/_chunks/{History-DS6-HCYX.mjs → History-rvLnluF0.mjs} +52 -29
- package/dist/_chunks/History-rvLnluF0.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CpfstlYY.js → ListConfigurationPage-BtCBP_L_.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-BtCBP_L_.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DQJJltko.mjs → ListConfigurationPage-DdKfJRdq.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-DdKfJRdq.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-nQrOQuVo.mjs → ListViewPage-B8cPO1bK.mjs} +60 -68
- package/dist/_chunks/ListViewPage-B8cPO1bK.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CA3I75m5.js → ListViewPage-CGZWD2qn.js} +59 -67
- package/dist/_chunks/ListViewPage-CGZWD2qn.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs → NoContentTypePage-CVqYTeML.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs.map → NoContentTypePage-CVqYTeML.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js → NoContentTypePage-oJxX0WCQ.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js.map → NoContentTypePage-oJxX0WCQ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js → NoPermissionsPage-BB11jqM_.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js.map → NoPermissionsPage-BB11jqM_.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs → NoPermissionsPage-mlXqh8p6.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs.map → NoPermissionsPage-mlXqh8p6.mjs.map} +1 -1
- package/dist/_chunks/{Relations-DG2jnOcr.js → Relations-6xIumgbN.js} +3 -3
- package/dist/_chunks/Relations-6xIumgbN.js.map +1 -0
- package/dist/_chunks/{Relations-BDRl99Ux.mjs → Relations-DWscdjKO.mjs} +3 -3
- package/dist/_chunks/Relations-DWscdjKO.mjs.map +1 -0
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-BrCTWlZv.mjs} +5 -4
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-fbKQxLGn.js → en-uOUIxfcQ.js} +5 -4
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-BZoNZMXL.js → index-BzUwgKUj.js} +347 -373
- package/dist/_chunks/index-BzUwgKUj.js.map +1 -0
- package/dist/_chunks/{index-Drt2DN7v.mjs → index-JSJrqmB9.mjs} +362 -388
- package/dist/_chunks/index-JSJrqmB9.mjs.map +1 -0
- package/dist/_chunks/{layout-BzAbmoO6.mjs → layout-Dewoec1b.mjs} +8 -8
- package/dist/_chunks/layout-Dewoec1b.mjs.map +1 -0
- package/dist/_chunks/{layout-DEYBqgF1.js → layout-U4xJd8Oi.js} +7 -7
- package/dist/_chunks/layout-U4xJd8Oi.js.map +1 -0
- package/dist/_chunks/{relations-D0eZ4VWw.js → relations-BifGhhuo.js} +2 -2
- package/dist/_chunks/{relations-D0eZ4VWw.js.map → relations-BifGhhuo.js.map} +1 -1
- package/dist/_chunks/{relations-D26zVRdi.mjs → relations-DMxeUp5V.mjs} +2 -2
- package/dist/_chunks/{relations-D26zVRdi.mjs.map → relations-DMxeUp5V.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- 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 +15 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +15 -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/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CTTDHKkQ.js.map +0 -1
- package/dist/_chunks/EditViewPage-DWb0DE7R.mjs.map +0 -1
- package/dist/_chunks/Field-C5Z1Ivdv.js.map +0 -1
- package/dist/_chunks/Field-DnStdvQw.mjs.map +0 -1
- package/dist/_chunks/Form-B81OtW-k.js.map +0 -1
- package/dist/_chunks/Form-DqGgE55Q.mjs.map +0 -1
- package/dist/_chunks/History-4NbOq2dX.js.map +0 -1
- package/dist/_chunks/History-DS6-HCYX.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CpfstlYY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DQJJltko.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-CA3I75m5.js.map +0 -1
- package/dist/_chunks/ListViewPage-nQrOQuVo.mjs.map +0 -1
- package/dist/_chunks/Relations-BDRl99Ux.mjs.map +0 -1
- package/dist/_chunks/Relations-DG2jnOcr.js.map +0 -1
- package/dist/_chunks/index-BZoNZMXL.js.map +0 -1
- package/dist/_chunks/index-Drt2DN7v.mjs.map +0 -1
- package/dist/_chunks/layout-BzAbmoO6.mjs.map +0 -1
- package/dist/_chunks/layout-DEYBqgF1.js.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-fnln26gA.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-Or0fpTwh.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-CGZWD2qn.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-BtCBP_L_.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-fOm5AebB.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-D8RyVgJC.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-BB11jqM_.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-oJxX0WCQ.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";
|
@@ -1817,10 +1889,13 @@ const UpdateAction = ({
|
|
1817
1889
|
document
|
1818
1890
|
);
|
1819
1891
|
if ("data" in res) {
|
1820
|
-
navigate(
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1892
|
+
navigate(
|
1893
|
+
{
|
1894
|
+
pathname: `../${res.data.documentId}`,
|
1895
|
+
search: rawQuery
|
1896
|
+
},
|
1897
|
+
{ relative: "path" }
|
1898
|
+
);
|
1824
1899
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1825
1900
|
setErrors(formatValidationErrors(res.error));
|
1826
1901
|
}
|
@@ -1848,10 +1923,13 @@ const UpdateAction = ({
|
|
1848
1923
|
document
|
1849
1924
|
);
|
1850
1925
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1851
|
-
navigate(
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1926
|
+
navigate(
|
1927
|
+
{
|
1928
|
+
pathname: `../${res.data.documentId}`,
|
1929
|
+
search: rawQuery
|
1930
|
+
},
|
1931
|
+
{ replace: true, relative: "path" }
|
1932
|
+
);
|
1855
1933
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1856
1934
|
setErrors(formatValidationErrors(res.error));
|
1857
1935
|
}
|
@@ -1883,10 +1961,8 @@ const UnpublishAction$1 = ({
|
|
1883
1961
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1884
1962
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1885
1963
|
const isDocumentModified = document?.status === "modified";
|
1886
|
-
const handleChange = (
|
1887
|
-
|
1888
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1889
|
-
}
|
1964
|
+
const handleChange = (value) => {
|
1965
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1890
1966
|
};
|
1891
1967
|
if (!schema?.options?.draftAndPublish) {
|
1892
1968
|
return null;
|
@@ -1936,40 +2012,24 @@ const UnpublishAction$1 = ({
|
|
1936
2012
|
}) })
|
1937
2013
|
] }),
|
1938
2014
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1939
|
-
designSystem.
|
2015
|
+
designSystem.Radio.Group,
|
1940
2016
|
{
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
2017
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2018
|
+
name: "discard-options",
|
2019
|
+
"aria-label": formatMessage({
|
2020
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2021
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2022
|
+
}),
|
2023
|
+
onValueChange: handleChange,
|
1947
2024
|
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
|
-
)
|
2025
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2026
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2027
|
+
defaultMessage: "Keep draft"
|
2028
|
+
}) }),
|
2029
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2030
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2031
|
+
defaultMessage: "Replace draft"
|
2032
|
+
}) })
|
1973
2033
|
]
|
1974
2034
|
}
|
1975
2035
|
)
|
@@ -2115,23 +2175,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2115
2175
|
id: "content-manager.containers.edit.title.new",
|
2116
2176
|
defaultMessage: "Create an entry"
|
2117
2177
|
}) : documentTitle;
|
2118
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2178
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2119
2179
|
/* @__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
|
2180
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2181
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2182
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2183
|
+
] }),
|
2184
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2135
2185
|
] });
|
2136
2186
|
};
|
2137
2187
|
const HeaderToolbar = () => {
|
@@ -2822,30 +2872,23 @@ const ConfirmBulkActionDialog = ({
|
|
2822
2872
|
endAction
|
2823
2873
|
}) => {
|
2824
2874
|
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
|
-
);
|
2875
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2876
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2877
|
+
id: "app.components.ConfirmDialog.title",
|
2878
|
+
defaultMessage: "Confirmation"
|
2879
|
+
}) }),
|
2880
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2881
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2882
|
+
dialogBody
|
2883
|
+
] }) }),
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2885
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2886
|
+
id: "app.components.Button.cancel",
|
2887
|
+
defaultMessage: "Cancel"
|
2888
|
+
}) }) }),
|
2889
|
+
endAction
|
2890
|
+
] })
|
2891
|
+
] }) });
|
2849
2892
|
};
|
2850
2893
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2851
2894
|
const ConfirmDialogPublishAll = ({
|
@@ -2950,7 +2993,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2950
2993
|
)
|
2951
2994
|
);
|
2952
2995
|
} else {
|
2953
|
-
messages.push(
|
2996
|
+
messages.push(
|
2997
|
+
...formatErrorMessages(
|
2998
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
2999
|
+
value,
|
3000
|
+
currentKey,
|
3001
|
+
formatMessage
|
3002
|
+
)
|
3003
|
+
);
|
2954
3004
|
}
|
2955
3005
|
} else {
|
2956
3006
|
messages.push(
|
@@ -3187,7 +3237,7 @@ const SelectedEntriesModalContent = ({
|
|
3187
3237
|
);
|
3188
3238
|
};
|
3189
3239
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3190
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3240
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3191
3241
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3192
3242
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3193
3243
|
SelectedEntriesTableContent,
|
@@ -3199,27 +3249,24 @@ const SelectedEntriesModalContent = ({
|
|
3199
3249
|
}
|
3200
3250
|
) })
|
3201
3251
|
] }),
|
3202
|
-
/* @__PURE__ */ jsxRuntime.
|
3203
|
-
designSystem.
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
}) }),
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
] })
|
3221
|
-
}
|
3222
|
-
),
|
3252
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3253
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3254
|
+
id: "app.components.Button.cancel",
|
3255
|
+
defaultMessage: "Cancel"
|
3256
|
+
}) }),
|
3257
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3258
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3259
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3260
|
+
designSystem.Button,
|
3261
|
+
{
|
3262
|
+
onClick: toggleDialog,
|
3263
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3264
|
+
loading: isSubmittingForm,
|
3265
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3266
|
+
}
|
3267
|
+
)
|
3268
|
+
] })
|
3269
|
+
] }),
|
3223
3270
|
/* @__PURE__ */ jsxRuntime.jsx(
|
3224
3271
|
ConfirmDialogPublishAll,
|
3225
3272
|
{
|
@@ -3284,143 +3331,10 @@ const BulkActionsRenderer = () => {
|
|
3284
3331
|
documents: selectedRows
|
3285
3332
|
},
|
3286
3333
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3287
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
3334
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3288
3335
|
}
|
3289
3336
|
) });
|
3290
3337
|
};
|
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
3338
|
const DeleteAction = ({ documents, model }) => {
|
3425
3339
|
const { formatMessage } = reactIntl.useIntl();
|
3426
3340
|
const { schema: contentType } = useDoc();
|
@@ -3453,6 +3367,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3453
3367
|
defaultMessage: "Confirmation"
|
3454
3368
|
}),
|
3455
3369
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3370
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3456
3371
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3457
3372
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3458
3373
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3502,6 +3417,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3502
3417
|
defaultMessage: "Confirmation"
|
3503
3418
|
}),
|
3504
3419
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3420
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3505
3421
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3506
3422
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3507
3423
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3747,8 +3663,7 @@ class ContentManagerPlugin {
|
|
3747
3663
|
documentActions = [
|
3748
3664
|
...DEFAULT_ACTIONS,
|
3749
3665
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3750
|
-
...DEFAULT_HEADER_ACTIONS
|
3751
|
-
HistoryAction
|
3666
|
+
...DEFAULT_HEADER_ACTIONS
|
3752
3667
|
];
|
3753
3668
|
editViewSidePanels = [ActionsPanel];
|
3754
3669
|
headerActions = [];
|
@@ -3837,6 +3752,52 @@ const getPrintableType = (value) => {
|
|
3837
3752
|
}
|
3838
3753
|
return nativeType;
|
3839
3754
|
};
|
3755
|
+
const HistoryAction = ({ model, document }) => {
|
3756
|
+
const { formatMessage } = reactIntl.useIntl();
|
3757
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3758
|
+
const navigate = reactRouterDom.useNavigate();
|
3759
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3760
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3761
|
+
return null;
|
3762
|
+
}
|
3763
|
+
return {
|
3764
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3765
|
+
label: formatMessage({
|
3766
|
+
id: "content-manager.history.document-action",
|
3767
|
+
defaultMessage: "Content History"
|
3768
|
+
}),
|
3769
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3770
|
+
disabled: (
|
3771
|
+
/**
|
3772
|
+
* The user is creating a new document.
|
3773
|
+
* It hasn't been saved yet, so there's no history to go to
|
3774
|
+
*/
|
3775
|
+
!document || /**
|
3776
|
+
* The document has been created but the current dimension has never been saved.
|
3777
|
+
* For example, the user is creating a new locale in an existing document,
|
3778
|
+
* so there's no history for the document in that locale
|
3779
|
+
*/
|
3780
|
+
!document.id || /**
|
3781
|
+
* History is only available for content types created by the user.
|
3782
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3783
|
+
* which start with `admin::` or `plugin::`
|
3784
|
+
*/
|
3785
|
+
!model.startsWith("api::")
|
3786
|
+
),
|
3787
|
+
position: "header"
|
3788
|
+
};
|
3789
|
+
};
|
3790
|
+
HistoryAction.type = "history";
|
3791
|
+
const historyAdmin = {
|
3792
|
+
bootstrap(app) {
|
3793
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3794
|
+
addDocumentAction((actions2) => {
|
3795
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3796
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3797
|
+
return actions2;
|
3798
|
+
});
|
3799
|
+
}
|
3800
|
+
};
|
3840
3801
|
const initialState = {
|
3841
3802
|
collectionTypeLinks: [],
|
3842
3803
|
components: [],
|
@@ -3887,15 +3848,29 @@ const index = {
|
|
3887
3848
|
defaultMessage: "Content Manager"
|
3888
3849
|
},
|
3889
3850
|
permissions: [],
|
3890
|
-
Component: () => Promise.resolve().then(() => require("./layout-DEYBqgF1.js")).then((mod) => ({ default: mod.Layout })),
|
3891
3851
|
position: 1
|
3892
3852
|
});
|
3853
|
+
app.router.addRoute({
|
3854
|
+
path: "content-manager/*",
|
3855
|
+
lazy: async () => {
|
3856
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-U4xJd8Oi.js"));
|
3857
|
+
return {
|
3858
|
+
Component: Layout
|
3859
|
+
};
|
3860
|
+
},
|
3861
|
+
children: routes
|
3862
|
+
});
|
3893
3863
|
app.registerPlugin(cm.config);
|
3894
3864
|
},
|
3865
|
+
bootstrap(app) {
|
3866
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3867
|
+
historyAdmin.bootstrap(app);
|
3868
|
+
}
|
3869
|
+
},
|
3895
3870
|
async registerTrads({ locales }) {
|
3896
3871
|
const importedTrads = await Promise.all(
|
3897
3872
|
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-
|
3873
|
+
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
3874
|
return {
|
3900
3875
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3901
3876
|
locale
|
@@ -3939,7 +3914,6 @@ exports.getDisplayName = getDisplayName;
|
|
3939
3914
|
exports.getMainField = getMainField;
|
3940
3915
|
exports.getTranslation = getTranslation;
|
3941
3916
|
exports.index = index;
|
3942
|
-
exports.routes = routes;
|
3943
3917
|
exports.setInitialData = setInitialData;
|
3944
3918
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3945
3919
|
exports.useDoc = useDoc;
|
@@ -3953,4 +3927,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3953
3927
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3954
3928
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3955
3929
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3956
|
-
//# sourceMappingURL=index-
|
3930
|
+
//# sourceMappingURL=index-BzUwgKUj.js.map
|