@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
@@ -1,17 +1,17 @@
|
|
1
|
-
import {
|
1
|
+
import { CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
3
|
-
import { useStrapiApp,
|
4
|
-
import { stringify } from "qs";
|
5
|
-
import { useIntl } from "react-intl";
|
6
|
-
import { useNavigate, useParams, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
3
|
+
import { useStrapiApp, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useQueryParams, useTracking, useForm, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
|
7
4
|
import * as React from "react";
|
8
5
|
import { lazy } from "react";
|
9
6
|
import { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
|
7
|
+
import { useIntl } from "react-intl";
|
8
|
+
import { useParams, Navigate, useNavigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
10
9
|
import { styled } from "styled-components";
|
11
10
|
import * as yup from "yup";
|
12
11
|
import { ValidationError } from "yup";
|
13
12
|
import pipe from "lodash/fp/pipe";
|
14
13
|
import { intervalToDuration, isPast } from "date-fns";
|
14
|
+
import { stringify } from "qs";
|
15
15
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
16
16
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
17
17
|
const v = glob[path];
|
@@ -49,42 +49,6 @@ const useInjectionZone = (area) => {
|
|
49
49
|
const [page, position] = area.split(".");
|
50
50
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
51
51
|
};
|
52
|
-
const HistoryAction = ({ model, document }) => {
|
53
|
-
const { formatMessage } = useIntl();
|
54
|
-
const [{ query }] = useQueryParams();
|
55
|
-
const navigate = useNavigate();
|
56
|
-
const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
|
57
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
58
|
-
return null;
|
59
|
-
}
|
60
|
-
return {
|
61
|
-
icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
|
62
|
-
label: formatMessage({
|
63
|
-
id: "content-manager.history.document-action",
|
64
|
-
defaultMessage: "Content History"
|
65
|
-
}),
|
66
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
67
|
-
disabled: (
|
68
|
-
/**
|
69
|
-
* The user is creating a new document.
|
70
|
-
* It hasn't been saved yet, so there's no history to go to
|
71
|
-
*/
|
72
|
-
!document || /**
|
73
|
-
* The document has been created but the current dimension has never been saved.
|
74
|
-
* For example, the user is creating a new locale in an existing document,
|
75
|
-
* so there's no history for the document in that locale
|
76
|
-
*/
|
77
|
-
!document.id || /**
|
78
|
-
* History is only available for content types created by the user.
|
79
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
80
|
-
* which start with `admin::` or `plugin::`
|
81
|
-
*/
|
82
|
-
!model.startsWith("api::")
|
83
|
-
),
|
84
|
-
position: "header"
|
85
|
-
};
|
86
|
-
};
|
87
|
-
HistoryAction.type = "history";
|
88
52
|
const ID = "id";
|
89
53
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
90
54
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -600,11 +564,11 @@ const createAttributeSchema = (attribute) => {
|
|
600
564
|
}
|
601
565
|
};
|
602
566
|
const addRequiredValidation = (attribute) => (schema) => {
|
567
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
568
|
+
return schema.min(1, translatedErrors.required);
|
569
|
+
}
|
603
570
|
if (attribute.required && attribute.type !== "relation") {
|
604
|
-
return schema.required(
|
605
|
-
id: translatedErrors.required.id,
|
606
|
-
defaultMessage: "This field is required."
|
607
|
-
});
|
571
|
+
return schema.required(translatedErrors.required);
|
608
572
|
}
|
609
573
|
return schema?.nullable ? schema.nullable() : (
|
610
574
|
// In some cases '.nullable' will not be available on the schema.
|
@@ -638,6 +602,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
638
602
|
const addMinValidation = (attribute) => (schema) => {
|
639
603
|
if ("min" in attribute) {
|
640
604
|
const min = toInteger(attribute.min);
|
605
|
+
if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
|
606
|
+
if (!attribute.required && "test" in schema && min) {
|
607
|
+
return schema.test(
|
608
|
+
"custom-min",
|
609
|
+
{
|
610
|
+
...translatedErrors.min,
|
611
|
+
values: {
|
612
|
+
min: attribute.min
|
613
|
+
}
|
614
|
+
},
|
615
|
+
(value) => {
|
616
|
+
if (!value) {
|
617
|
+
return true;
|
618
|
+
}
|
619
|
+
if (Array.isArray(value) && value.length === 0) {
|
620
|
+
return true;
|
621
|
+
}
|
622
|
+
return value.length >= min;
|
623
|
+
}
|
624
|
+
);
|
625
|
+
}
|
626
|
+
}
|
641
627
|
if ("min" in schema && min) {
|
642
628
|
return schema.min(min, {
|
643
629
|
...translatedErrors.min,
|
@@ -1269,7 +1255,7 @@ const useDocumentActions = () => {
|
|
1269
1255
|
};
|
1270
1256
|
};
|
1271
1257
|
const ProtectedHistoryPage = lazy(
|
1272
|
-
() => import("./History-
|
1258
|
+
() => import("./History-CBNGU7a-.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1273
1259
|
);
|
1274
1260
|
const routes$1 = [
|
1275
1261
|
{
|
@@ -1282,31 +1268,31 @@ const routes$1 = [
|
|
1282
1268
|
}
|
1283
1269
|
];
|
1284
1270
|
const ProtectedEditViewPage = lazy(
|
1285
|
-
() => import("./EditViewPage-
|
1271
|
+
() => import("./EditViewPage-DlLEyUL6.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1286
1272
|
);
|
1287
1273
|
const ProtectedListViewPage = lazy(
|
1288
|
-
() => import("./ListViewPage-
|
1274
|
+
() => import("./ListViewPage-DecLrYV6.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1289
1275
|
);
|
1290
1276
|
const ProtectedListConfiguration = lazy(
|
1291
|
-
() => import("./ListConfigurationPage-
|
1277
|
+
() => import("./ListConfigurationPage-5dr4qpue.mjs").then((mod) => ({
|
1292
1278
|
default: mod.ProtectedListConfiguration
|
1293
1279
|
}))
|
1294
1280
|
);
|
1295
1281
|
const ProtectedEditConfigurationPage = lazy(
|
1296
|
-
() => import("./EditConfigurationPage-
|
1282
|
+
() => import("./EditConfigurationPage-ZO0vOO8q.mjs").then((mod) => ({
|
1297
1283
|
default: mod.ProtectedEditConfigurationPage
|
1298
1284
|
}))
|
1299
1285
|
);
|
1300
1286
|
const ProtectedComponentConfigurationPage = lazy(
|
1301
|
-
() => import("./ComponentConfigurationPage-
|
1287
|
+
() => import("./ComponentConfigurationPage-B1bIXVuX.mjs").then((mod) => ({
|
1302
1288
|
default: mod.ProtectedComponentConfigurationPage
|
1303
1289
|
}))
|
1304
1290
|
);
|
1305
1291
|
const NoPermissions = lazy(
|
1306
|
-
() => import("./NoPermissionsPage-
|
1292
|
+
() => import("./NoPermissionsPage-CM5UD8ee.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1307
1293
|
);
|
1308
1294
|
const NoContentType = lazy(
|
1309
|
-
() => import("./NoContentTypePage-
|
1295
|
+
() => import("./NoContentTypePage-CiIcfYsd.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1310
1296
|
);
|
1311
1297
|
const CollectionTypePages = () => {
|
1312
1298
|
const { collectionType } = useParams();
|
@@ -1433,7 +1419,7 @@ const DocumentActionButton = (action) => {
|
|
1433
1419
|
DocumentActionConfirmDialog,
|
1434
1420
|
{
|
1435
1421
|
...action.dialog,
|
1436
|
-
variant: action.variant,
|
1422
|
+
variant: action.dialog?.variant ?? action.variant,
|
1437
1423
|
isOpen: dialogId === action.id,
|
1438
1424
|
onClose: handleClose
|
1439
1425
|
}
|
@@ -1662,6 +1648,12 @@ const PublishAction$1 = ({
|
|
1662
1648
|
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1663
1649
|
);
|
1664
1650
|
const { publish } = useDocumentActions();
|
1651
|
+
const [
|
1652
|
+
countDraftRelations,
|
1653
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
1654
|
+
] = useLazyGetDraftRelationCountQuery();
|
1655
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
|
1656
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
|
1665
1657
|
const [{ query, rawQuery }] = useQueryParams();
|
1666
1658
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1667
1659
|
const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1670,10 +1662,101 @@ const PublishAction$1 = ({
|
|
1670
1662
|
const validate = useForm("PublishAction", (state) => state.validate);
|
1671
1663
|
const setErrors = useForm("PublishAction", (state) => state.setErrors);
|
1672
1664
|
const formValues = useForm("PublishAction", ({ values }) => values);
|
1665
|
+
React.useEffect(() => {
|
1666
|
+
if (isErrorDraftRelations) {
|
1667
|
+
toggleNotification({
|
1668
|
+
type: "danger",
|
1669
|
+
message: formatMessage({
|
1670
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
1671
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
1672
|
+
})
|
1673
|
+
});
|
1674
|
+
}
|
1675
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
1676
|
+
React.useEffect(() => {
|
1677
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
1678
|
+
const extractDraftRelations = (data) => {
|
1679
|
+
const relations = data.connect || [];
|
1680
|
+
relations.forEach((relation) => {
|
1681
|
+
if (relation.status === "draft") {
|
1682
|
+
localDraftRelations.add(relation.id);
|
1683
|
+
}
|
1684
|
+
});
|
1685
|
+
};
|
1686
|
+
const traverseAndExtract = (data) => {
|
1687
|
+
Object.entries(data).forEach(([key, value]) => {
|
1688
|
+
if (key === "connect" && Array.isArray(value)) {
|
1689
|
+
extractDraftRelations({ connect: value });
|
1690
|
+
} else if (typeof value === "object" && value !== null) {
|
1691
|
+
traverseAndExtract(value);
|
1692
|
+
}
|
1693
|
+
});
|
1694
|
+
};
|
1695
|
+
if (!documentId || modified) {
|
1696
|
+
traverseAndExtract(formValues);
|
1697
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
1698
|
+
}
|
1699
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1700
|
+
React.useEffect(() => {
|
1701
|
+
if (documentId) {
|
1702
|
+
const fetchDraftRelationsCount = async () => {
|
1703
|
+
const { data, error } = await countDraftRelations({
|
1704
|
+
collectionType,
|
1705
|
+
model,
|
1706
|
+
documentId,
|
1707
|
+
params
|
1708
|
+
});
|
1709
|
+
if (error) {
|
1710
|
+
throw error;
|
1711
|
+
}
|
1712
|
+
if (data) {
|
1713
|
+
setServerCountOfDraftRelations(data.data);
|
1714
|
+
}
|
1715
|
+
};
|
1716
|
+
fetchDraftRelationsCount();
|
1717
|
+
}
|
1718
|
+
}, [documentId, countDraftRelations, collectionType, model, params]);
|
1673
1719
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1674
1720
|
if (!schema?.options?.draftAndPublish) {
|
1675
1721
|
return null;
|
1676
1722
|
}
|
1723
|
+
const performPublish = async () => {
|
1724
|
+
setSubmitting(true);
|
1725
|
+
try {
|
1726
|
+
const { errors } = await validate();
|
1727
|
+
if (errors) {
|
1728
|
+
toggleNotification({
|
1729
|
+
type: "danger",
|
1730
|
+
message: formatMessage({
|
1731
|
+
id: "content-manager.validation.error",
|
1732
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1733
|
+
})
|
1734
|
+
});
|
1735
|
+
return;
|
1736
|
+
}
|
1737
|
+
const res = await publish(
|
1738
|
+
{
|
1739
|
+
collectionType,
|
1740
|
+
model,
|
1741
|
+
documentId,
|
1742
|
+
params
|
1743
|
+
},
|
1744
|
+
formValues
|
1745
|
+
);
|
1746
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1747
|
+
navigate({
|
1748
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1749
|
+
search: rawQuery
|
1750
|
+
});
|
1751
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1752
|
+
setErrors(formatValidationErrors(res.error));
|
1753
|
+
}
|
1754
|
+
} finally {
|
1755
|
+
setSubmitting(false);
|
1756
|
+
}
|
1757
|
+
};
|
1758
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1759
|
+
const hasDraftRelations = totalDraftRelations > 0;
|
1677
1760
|
return {
|
1678
1761
|
/**
|
1679
1762
|
* Disabled when:
|
@@ -1686,46 +1769,38 @@ const PublishAction$1 = ({
|
|
1686
1769
|
* - the user doesn't have the permission to create a new document
|
1687
1770
|
* - the user doesn't have the permission to update the document
|
1688
1771
|
*/
|
1689
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
|
1772
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
|
1690
1773
|
label: formatMessage({
|
1691
1774
|
id: "app.utils.publish",
|
1692
1775
|
defaultMessage: "Publish"
|
1693
1776
|
}),
|
1694
1777
|
onClick: async () => {
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
formValues
|
1716
|
-
);
|
1717
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1718
|
-
navigate({
|
1719
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1720
|
-
search: rawQuery
|
1721
|
-
});
|
1722
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1723
|
-
setErrors(formatValidationErrors(res.error));
|
1778
|
+
if (hasDraftRelations) {
|
1779
|
+
return;
|
1780
|
+
}
|
1781
|
+
await performPublish();
|
1782
|
+
},
|
1783
|
+
dialog: hasDraftRelations ? {
|
1784
|
+
type: "dialog",
|
1785
|
+
variant: "danger",
|
1786
|
+
footer: null,
|
1787
|
+
title: formatMessage({
|
1788
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
1789
|
+
defaultMessage: "Confirmation"
|
1790
|
+
}),
|
1791
|
+
content: formatMessage(
|
1792
|
+
{
|
1793
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
1794
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
1795
|
+
},
|
1796
|
+
{
|
1797
|
+
count: totalDraftRelations
|
1724
1798
|
}
|
1725
|
-
|
1726
|
-
|
1799
|
+
),
|
1800
|
+
onConfirm: async () => {
|
1801
|
+
await performPublish();
|
1727
1802
|
}
|
1728
|
-
}
|
1803
|
+
} : void 0
|
1729
1804
|
};
|
1730
1805
|
};
|
1731
1806
|
PublishAction$1.type = "publish";
|
@@ -2076,23 +2151,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2076
2151
|
id: "content-manager.containers.edit.title.new",
|
2077
2152
|
defaultMessage: "Create an entry"
|
2078
2153
|
}) : documentTitle;
|
2079
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2154
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2080
2155
|
/* @__PURE__ */ jsx(BackButton, {}),
|
2081
|
-
/* @__PURE__ */ jsxs(
|
2082
|
-
|
2083
|
-
{
|
2084
|
-
|
2085
|
-
|
2086
|
-
paddingTop: 1,
|
2087
|
-
gap: "80px",
|
2088
|
-
alignItems: "flex-start",
|
2089
|
-
children: [
|
2090
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2091
|
-
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2092
|
-
]
|
2093
|
-
}
|
2094
|
-
),
|
2095
|
-
status ? /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2156
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2157
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2158
|
+
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2159
|
+
] }),
|
2160
|
+
status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2096
2161
|
] });
|
2097
2162
|
};
|
2098
2163
|
const HeaderToolbar = () => {
|
@@ -2783,7 +2848,7 @@ const ConfirmBulkActionDialog = ({
|
|
2783
2848
|
endAction
|
2784
2849
|
}) => {
|
2785
2850
|
const { formatMessage } = useIntl();
|
2786
|
-
return /* @__PURE__ */ jsx(Dialog.Root, {
|
2851
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2787
2852
|
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
|
2788
2853
|
id: "app.components.ConfirmDialog.title",
|
2789
2854
|
defaultMessage: "Confirmation"
|
@@ -3574,8 +3639,7 @@ class ContentManagerPlugin {
|
|
3574
3639
|
documentActions = [
|
3575
3640
|
...DEFAULT_ACTIONS,
|
3576
3641
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3577
|
-
...DEFAULT_HEADER_ACTIONS
|
3578
|
-
HistoryAction
|
3642
|
+
...DEFAULT_HEADER_ACTIONS
|
3579
3643
|
];
|
3580
3644
|
editViewSidePanels = [ActionsPanel];
|
3581
3645
|
headerActions = [];
|
@@ -3664,6 +3728,52 @@ const getPrintableType = (value) => {
|
|
3664
3728
|
}
|
3665
3729
|
return nativeType;
|
3666
3730
|
};
|
3731
|
+
const HistoryAction = ({ model, document }) => {
|
3732
|
+
const { formatMessage } = useIntl();
|
3733
|
+
const [{ query }] = useQueryParams();
|
3734
|
+
const navigate = useNavigate();
|
3735
|
+
const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
|
3736
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3737
|
+
return null;
|
3738
|
+
}
|
3739
|
+
return {
|
3740
|
+
icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
|
3741
|
+
label: formatMessage({
|
3742
|
+
id: "content-manager.history.document-action",
|
3743
|
+
defaultMessage: "Content History"
|
3744
|
+
}),
|
3745
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3746
|
+
disabled: (
|
3747
|
+
/**
|
3748
|
+
* The user is creating a new document.
|
3749
|
+
* It hasn't been saved yet, so there's no history to go to
|
3750
|
+
*/
|
3751
|
+
!document || /**
|
3752
|
+
* The document has been created but the current dimension has never been saved.
|
3753
|
+
* For example, the user is creating a new locale in an existing document,
|
3754
|
+
* so there's no history for the document in that locale
|
3755
|
+
*/
|
3756
|
+
!document.id || /**
|
3757
|
+
* History is only available for content types created by the user.
|
3758
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3759
|
+
* which start with `admin::` or `plugin::`
|
3760
|
+
*/
|
3761
|
+
!model.startsWith("api::")
|
3762
|
+
),
|
3763
|
+
position: "header"
|
3764
|
+
};
|
3765
|
+
};
|
3766
|
+
HistoryAction.type = "history";
|
3767
|
+
const historyAdmin = {
|
3768
|
+
bootstrap(app) {
|
3769
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3770
|
+
addDocumentAction((actions2) => {
|
3771
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3772
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3773
|
+
return actions2;
|
3774
|
+
});
|
3775
|
+
}
|
3776
|
+
};
|
3667
3777
|
const initialState = {
|
3668
3778
|
collectionTypeLinks: [],
|
3669
3779
|
components: [],
|
@@ -3719,7 +3829,7 @@ const index = {
|
|
3719
3829
|
app.router.addRoute({
|
3720
3830
|
path: "content-manager/*",
|
3721
3831
|
lazy: async () => {
|
3722
|
-
const { Layout } = await import("./layout-
|
3832
|
+
const { Layout } = await import("./layout-DPaHUusj.mjs");
|
3723
3833
|
return {
|
3724
3834
|
Component: Layout
|
3725
3835
|
};
|
@@ -3728,10 +3838,15 @@ const index = {
|
|
3728
3838
|
});
|
3729
3839
|
app.registerPlugin(cm.config);
|
3730
3840
|
},
|
3841
|
+
bootstrap(app) {
|
3842
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3843
|
+
historyAdmin.bootstrap(app);
|
3844
|
+
}
|
3845
|
+
},
|
3731
3846
|
async registerTrads({ locales }) {
|
3732
3847
|
const importedTrads = await Promise.all(
|
3733
3848
|
locales.map((locale) => {
|
3734
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-
|
3849
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-BrCTWlZv.mjs"), "./translations/es.json": () => import("./es-CeXiYflN.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-CD9VFbPM.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-CtsUxOvk.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3735
3850
|
return {
|
3736
3851
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3737
3852
|
locale
|
@@ -3790,4 +3905,4 @@ export {
|
|
3790
3905
|
useUpdateContentTypeConfigurationMutation as y,
|
3791
3906
|
extractContentTypeComponents as z
|
3792
3907
|
};
|
3793
|
-
//# sourceMappingURL=index-
|
3908
|
+
//# sourceMappingURL=index-BSn97i8U.mjs.map
|