@strapi/content-manager 0.0.0-experimental.745741d19e90275ca6f7c928ca19f9bb0fd9d933 → 0.0.0-experimental.779667bd163026468f566293decf331a0246fff9
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/dist/_chunks/{ComponentConfigurationPage-DHNM3YBz.mjs → ComponentConfigurationPage-B1bIXVuX.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DHNM3YBz.mjs.map → ComponentConfigurationPage-B1bIXVuX.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BvHtG7uH.js → ComponentConfigurationPage-Bqgx7Mes.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BvHtG7uH.js.map → ComponentConfigurationPage-Bqgx7Mes.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DOmfCEMo.js → EditConfigurationPage-BFEwvdMW.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-DOmfCEMo.js.map → EditConfigurationPage-BFEwvdMW.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Cp6HAEzN.mjs → EditConfigurationPage-ZO0vOO8q.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-Cp6HAEzN.mjs.map → EditConfigurationPage-ZO0vOO8q.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-BqNpC6hO.js → EditViewPage-DA95Ha6J.js} +3 -3
- package/dist/_chunks/{EditViewPage-BqNpC6hO.js.map → EditViewPage-DA95Ha6J.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BtkEx339.mjs → EditViewPage-DlLEyUL6.mjs} +3 -3
- package/dist/_chunks/{EditViewPage-BtkEx339.mjs.map → EditViewPage-DlLEyUL6.mjs.map} +1 -1
- package/dist/_chunks/{Field-lsPFnAmH.js → Field-CnK8dO8N.js} +74 -49
- package/dist/_chunks/Field-CnK8dO8N.js.map +1 -0
- package/dist/_chunks/{Field-R5NbffTB.mjs → Field-Dq7bDnuh.mjs} +74 -49
- package/dist/_chunks/Field-Dq7bDnuh.mjs.map +1 -0
- package/dist/_chunks/{Form-BHmXSfyy.mjs → Form-B_JE0dbz.mjs} +2 -2
- package/dist/_chunks/{Form-BHmXSfyy.mjs.map → Form-B_JE0dbz.mjs.map} +1 -1
- package/dist/_chunks/{Form-CcGboku8.js → Form-BpiR4piS.js} +2 -2
- package/dist/_chunks/{Form-CcGboku8.js.map → Form-BpiR4piS.js.map} +1 -1
- package/dist/_chunks/{History-ByUPL3T3.mjs → History-CBNGU7a-.mjs} +11 -11
- package/dist/_chunks/History-CBNGU7a-.mjs.map +1 -0
- package/dist/_chunks/{History-Bsud8jwh.js → History-DdIstl8b.js} +11 -11
- package/dist/_chunks/History-DdIstl8b.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Bm5HACXf.mjs → ListConfigurationPage-5dr4qpue.mjs} +8 -6
- package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DiT463qx.js → ListConfigurationPage-DkKRparB.js} +8 -6
- package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +1 -0
- package/dist/_chunks/{ListViewPage-JSyNAAYu.mjs → ListViewPage-DecLrYV6.mjs} +3 -3
- package/dist/_chunks/{ListViewPage-JSyNAAYu.mjs.map → ListViewPage-DecLrYV6.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-CsrC9L_d.js → ListViewPage-wE0lXqoD.js} +3 -3
- package/dist/_chunks/{ListViewPage-CsrC9L_d.js.map → ListViewPage-wE0lXqoD.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CsrQUpBE.mjs → NoContentTypePage-CiIcfYsd.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CsrQUpBE.mjs.map → NoContentTypePage-CiIcfYsd.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Bsvng4II.js → NoContentTypePage-DEKR6tf9.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-Bsvng4II.js.map → NoContentTypePage-DEKR6tf9.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DNmf_pj0.mjs → NoPermissionsPage-CM5UD8ee.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DNmf_pj0.mjs.map → NoPermissionsPage-CM5UD8ee.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CdHNJtEf.js → NoPermissionsPage-DmNfF2Bb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CdHNJtEf.js.map → NoPermissionsPage-DmNfF2Bb.js.map} +1 -1
- package/dist/_chunks/{Relations-u8-37jK0.mjs → Relations-Dqz0C1fz.mjs} +3 -3
- package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +1 -0
- package/dist/_chunks/{Relations-CghaPv2D.js → Relations-L0xYRoSQ.js} +3 -3
- package/dist/_chunks/Relations-L0xYRoSQ.js.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-CaE6NG4a.mjs → index-BSn97i8U.mjs} +224 -109
- package/dist/_chunks/index-BSn97i8U.mjs.map +1 -0
- package/dist/_chunks/{index-BOZx6IMg.js → index-DyvUPg1a.js} +222 -107
- package/dist/_chunks/index-DyvUPg1a.js.map +1 -0
- package/dist/_chunks/{layout-Bx7svTbY.mjs → layout-DPaHUusj.mjs} +4 -4
- package/dist/_chunks/layout-DPaHUusj.mjs.map +1 -0
- package/dist/_chunks/{layout-Ciz224q5.js → layout-TPqF2oJ5.js} +4 -4
- package/dist/_chunks/layout-TPqF2oJ5.js.map +1 -0
- package/dist/_chunks/{relations-CP8sB2YZ.js → relations-BWYS9gkn.js} +2 -2
- package/dist/_chunks/{relations-CP8sB2YZ.js.map → relations-BWYS9gkn.js.map} +1 -1
- package/dist/_chunks/{relations-Cxc1cEv3.mjs → relations-Ck7-ecDT.mjs} +2 -2
- package/dist/_chunks/{relations-Cxc1cEv3.mjs.map → relations-Ck7-ecDT.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +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 +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/package.json +6 -6
- package/dist/_chunks/Field-R5NbffTB.mjs.map +0 -1
- package/dist/_chunks/Field-lsPFnAmH.js.map +0 -1
- package/dist/_chunks/History-Bsud8jwh.js.map +0 -1
- package/dist/_chunks/History-ByUPL3T3.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Bm5HACXf.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DiT463qx.js.map +0 -1
- package/dist/_chunks/Relations-CghaPv2D.js.map +0 -1
- package/dist/_chunks/Relations-u8-37jK0.mjs.map +0 -1
- package/dist/_chunks/index-BOZx6IMg.js.map +0 -1
- package/dist/_chunks/index-CaE6NG4a.mjs.map +0 -1
- package/dist/_chunks/layout-Bx7svTbY.mjs.map +0 -1
- package/dist/_chunks/layout-Ciz224q5.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";
|
@@ -621,11 +585,11 @@ const createAttributeSchema = (attribute) => {
|
|
621
585
|
}
|
622
586
|
};
|
623
587
|
const addRequiredValidation = (attribute) => (schema) => {
|
588
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
589
|
+
return schema.min(1, strapiAdmin.translatedErrors.required);
|
590
|
+
}
|
624
591
|
if (attribute.required && attribute.type !== "relation") {
|
625
|
-
return schema.required(
|
626
|
-
id: strapiAdmin.translatedErrors.required.id,
|
627
|
-
defaultMessage: "This field is required."
|
628
|
-
});
|
592
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
629
593
|
}
|
630
594
|
return schema?.nullable ? schema.nullable() : (
|
631
595
|
// In some cases '.nullable' will not be available on the schema.
|
@@ -659,6 +623,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
659
623
|
const addMinValidation = (attribute) => (schema) => {
|
660
624
|
if ("min" in attribute) {
|
661
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
|
+
}
|
662
648
|
if ("min" in schema && min) {
|
663
649
|
return schema.min(min, {
|
664
650
|
...strapiAdmin.translatedErrors.min,
|
@@ -1290,7 +1276,7 @@ const useDocumentActions = () => {
|
|
1290
1276
|
};
|
1291
1277
|
};
|
1292
1278
|
const ProtectedHistoryPage = React.lazy(
|
1293
|
-
() => Promise.resolve().then(() => require("./History-
|
1279
|
+
() => Promise.resolve().then(() => require("./History-DdIstl8b.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1294
1280
|
);
|
1295
1281
|
const routes$1 = [
|
1296
1282
|
{
|
@@ -1303,31 +1289,31 @@ const routes$1 = [
|
|
1303
1289
|
}
|
1304
1290
|
];
|
1305
1291
|
const ProtectedEditViewPage = React.lazy(
|
1306
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1292
|
+
() => Promise.resolve().then(() => require("./EditViewPage-DA95Ha6J.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1307
1293
|
);
|
1308
1294
|
const ProtectedListViewPage = React.lazy(
|
1309
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1295
|
+
() => Promise.resolve().then(() => require("./ListViewPage-wE0lXqoD.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1310
1296
|
);
|
1311
1297
|
const ProtectedListConfiguration = React.lazy(
|
1312
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1298
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-DkKRparB.js")).then((mod) => ({
|
1313
1299
|
default: mod.ProtectedListConfiguration
|
1314
1300
|
}))
|
1315
1301
|
);
|
1316
1302
|
const ProtectedEditConfigurationPage = React.lazy(
|
1317
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1303
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BFEwvdMW.js")).then((mod) => ({
|
1318
1304
|
default: mod.ProtectedEditConfigurationPage
|
1319
1305
|
}))
|
1320
1306
|
);
|
1321
1307
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1322
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1308
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-Bqgx7Mes.js")).then((mod) => ({
|
1323
1309
|
default: mod.ProtectedComponentConfigurationPage
|
1324
1310
|
}))
|
1325
1311
|
);
|
1326
1312
|
const NoPermissions = React.lazy(
|
1327
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1313
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-DmNfF2Bb.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1328
1314
|
);
|
1329
1315
|
const NoContentType = React.lazy(
|
1330
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1316
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-DEKR6tf9.js")).then((mod) => ({ default: mod.NoContentType }))
|
1331
1317
|
);
|
1332
1318
|
const CollectionTypePages = () => {
|
1333
1319
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1454,7 +1440,7 @@ const DocumentActionButton = (action) => {
|
|
1454
1440
|
DocumentActionConfirmDialog,
|
1455
1441
|
{
|
1456
1442
|
...action.dialog,
|
1457
|
-
variant: action.variant,
|
1443
|
+
variant: action.dialog?.variant ?? action.variant,
|
1458
1444
|
isOpen: dialogId === action.id,
|
1459
1445
|
onClose: handleClose
|
1460
1446
|
}
|
@@ -1683,6 +1669,12 @@ const PublishAction$1 = ({
|
|
1683
1669
|
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1684
1670
|
);
|
1685
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);
|
1686
1678
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1687
1679
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1688
1680
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1691,10 +1683,101 @@ const PublishAction$1 = ({
|
|
1691
1683
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1692
1684
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1693
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]);
|
1694
1740
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1695
1741
|
if (!schema?.options?.draftAndPublish) {
|
1696
1742
|
return null;
|
1697
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;
|
1698
1781
|
return {
|
1699
1782
|
/**
|
1700
1783
|
* Disabled when:
|
@@ -1707,46 +1790,38 @@ const PublishAction$1 = ({
|
|
1707
1790
|
* - the user doesn't have the permission to create a new document
|
1708
1791
|
* - the user doesn't have the permission to update the document
|
1709
1792
|
*/
|
1710
|
-
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),
|
1711
1794
|
label: formatMessage({
|
1712
1795
|
id: "app.utils.publish",
|
1713
1796
|
defaultMessage: "Publish"
|
1714
1797
|
}),
|
1715
1798
|
onClick: async () => {
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
formValues
|
1737
|
-
);
|
1738
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1739
|
-
navigate({
|
1740
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1741
|
-
search: rawQuery
|
1742
|
-
});
|
1743
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1744
|
-
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
|
1745
1819
|
}
|
1746
|
-
|
1747
|
-
|
1820
|
+
),
|
1821
|
+
onConfirm: async () => {
|
1822
|
+
await performPublish();
|
1748
1823
|
}
|
1749
|
-
}
|
1824
|
+
} : void 0
|
1750
1825
|
};
|
1751
1826
|
};
|
1752
1827
|
PublishAction$1.type = "publish";
|
@@ -2097,23 +2172,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2097
2172
|
id: "content-manager.containers.edit.title.new",
|
2098
2173
|
defaultMessage: "Create an entry"
|
2099
2174
|
}) : documentTitle;
|
2100
|
-
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: [
|
2101
2176
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2102
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2103
|
-
designSystem.
|
2104
|
-
{
|
2105
|
-
|
2106
|
-
|
2107
|
-
paddingTop: 1,
|
2108
|
-
gap: "80px",
|
2109
|
-
alignItems: "flex-start",
|
2110
|
-
children: [
|
2111
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2112
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2113
|
-
]
|
2114
|
-
}
|
2115
|
-
),
|
2116
|
-
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
|
2117
2182
|
] });
|
2118
2183
|
};
|
2119
2184
|
const HeaderToolbar = () => {
|
@@ -2804,7 +2869,7 @@ const ConfirmBulkActionDialog = ({
|
|
2804
2869
|
endAction
|
2805
2870
|
}) => {
|
2806
2871
|
const { formatMessage } = reactIntl.useIntl();
|
2807
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, {
|
2872
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2808
2873
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2809
2874
|
id: "app.components.ConfirmDialog.title",
|
2810
2875
|
defaultMessage: "Confirmation"
|
@@ -3595,8 +3660,7 @@ class ContentManagerPlugin {
|
|
3595
3660
|
documentActions = [
|
3596
3661
|
...DEFAULT_ACTIONS,
|
3597
3662
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3598
|
-
...DEFAULT_HEADER_ACTIONS
|
3599
|
-
HistoryAction
|
3663
|
+
...DEFAULT_HEADER_ACTIONS
|
3600
3664
|
];
|
3601
3665
|
editViewSidePanels = [ActionsPanel];
|
3602
3666
|
headerActions = [];
|
@@ -3685,6 +3749,52 @@ const getPrintableType = (value) => {
|
|
3685
3749
|
}
|
3686
3750
|
return nativeType;
|
3687
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
|
+
};
|
3688
3798
|
const initialState = {
|
3689
3799
|
collectionTypeLinks: [],
|
3690
3800
|
components: [],
|
@@ -3740,7 +3850,7 @@ const index = {
|
|
3740
3850
|
app.router.addRoute({
|
3741
3851
|
path: "content-manager/*",
|
3742
3852
|
lazy: async () => {
|
3743
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
3853
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-TPqF2oJ5.js"));
|
3744
3854
|
return {
|
3745
3855
|
Component: Layout
|
3746
3856
|
};
|
@@ -3749,10 +3859,15 @@ const index = {
|
|
3749
3859
|
});
|
3750
3860
|
app.registerPlugin(cm.config);
|
3751
3861
|
},
|
3862
|
+
bootstrap(app) {
|
3863
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3864
|
+
historyAdmin.bootstrap(app);
|
3865
|
+
}
|
3866
|
+
},
|
3752
3867
|
async registerTrads({ locales }) {
|
3753
3868
|
const importedTrads = await Promise.all(
|
3754
3869
|
locales.map((locale) => {
|
3755
|
-
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 }) => {
|
3756
3871
|
return {
|
3757
3872
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3758
3873
|
locale
|
@@ -3809,4 +3924,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3809
3924
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3810
3925
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3811
3926
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3812
|
-
//# sourceMappingURL=index-
|
3927
|
+
//# sourceMappingURL=index-DyvUPg1a.js.map
|