@strapi/content-manager 0.0.0-experimental.4ddd402c7194d1a969a797313bf007c93148d59a → 0.0.0-experimental.545ccead2ee1717bbc7ab950455dbb0ddb9924a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs → ComponentConfigurationPage-B1bIXVuX.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs.map → ComponentConfigurationPage-B1bIXVuX.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js → ComponentConfigurationPage-Bqgx7Mes.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js.map → ComponentConfigurationPage-Bqgx7Mes.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js → EditConfigurationPage-BFEwvdMW.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js.map → EditConfigurationPage-BFEwvdMW.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs → EditConfigurationPage-ZO0vOO8q.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs.map → EditConfigurationPage-ZO0vOO8q.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CU7724gt.js → EditViewPage-DA95Ha6J.js} +45 -45
- package/dist/_chunks/EditViewPage-DA95Ha6J.js.map +1 -0
- package/dist/_chunks/{EditViewPage-CzuJgWWp.mjs → EditViewPage-DlLEyUL6.mjs} +46 -46
- package/dist/_chunks/EditViewPage-DlLEyUL6.mjs.map +1 -0
- package/dist/_chunks/{Field-Dh1yZyqy.js → Field-CnK8dO8N.js} +416 -136
- package/dist/_chunks/Field-CnK8dO8N.js.map +1 -0
- package/dist/_chunks/{Field-QtUSh5mU.mjs → Field-Dq7bDnuh.mjs} +417 -137
- package/dist/_chunks/Field-Dq7bDnuh.mjs.map +1 -0
- package/dist/_chunks/{Form-COLpvlnv.mjs → Form-B_JE0dbz.mjs} +27 -28
- package/dist/_chunks/Form-B_JE0dbz.mjs.map +1 -0
- package/dist/_chunks/{Form-BOR8NOe1.js → Form-BpiR4piS.js} +25 -26
- package/dist/_chunks/Form-BpiR4piS.js.map +1 -0
- package/dist/_chunks/{History-Bu53Yfw-.mjs → History-CBNGU7a-.mjs} +124 -30
- package/dist/_chunks/History-CBNGU7a-.mjs.map +1 -0
- package/dist/_chunks/{History-CW2akQ6h.js → History-DdIstl8b.js} +123 -29
- package/dist/_chunks/History-DdIstl8b.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-TqrmwjPN.mjs → ListConfigurationPage-5dr4qpue.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-jzdhEk_u.js → ListConfigurationPage-DkKRparB.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BO_mOXIl.mjs → ListViewPage-DecLrYV6.mjs} +60 -68
- package/dist/_chunks/ListViewPage-DecLrYV6.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-B3bMOrMv.js → ListViewPage-wE0lXqoD.js} +59 -67
- package/dist/_chunks/ListViewPage-wE0lXqoD.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs → NoContentTypePage-CiIcfYsd.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs.map → NoContentTypePage-CiIcfYsd.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js → NoContentTypePage-DEKR6tf9.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js.map → NoContentTypePage-DEKR6tf9.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs → NoPermissionsPage-CM5UD8ee.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs.map → NoPermissionsPage-CM5UD8ee.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js → NoPermissionsPage-DmNfF2Bb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js.map → NoPermissionsPage-DmNfF2Bb.js.map} +1 -1
- package/dist/_chunks/{Relations-CJ4qdkRo.mjs → Relations-Dqz0C1fz.mjs} +3 -3
- package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +1 -0
- package/dist/_chunks/{Relations-B6fb2POW.js → Relations-L0xYRoSQ.js} +3 -3
- package/dist/_chunks/Relations-L0xYRoSQ.js.map +1 -0
- package/dist/_chunks/{en-9GwRW_ku.mjs → en-BrCTWlZv.mjs} +7 -4
- package/dist/_chunks/{en-9GwRW_ku.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-DZXjRiWA.js → en-uOUIxfcQ.js} +7 -4
- package/dist/_chunks/{en-DZXjRiWA.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-Dahjdw4h.mjs → index-BSn97i8U.mjs} +355 -384
- package/dist/_chunks/index-BSn97i8U.mjs.map +1 -0
- package/dist/_chunks/{index-DcUu-_72.js → index-DyvUPg1a.js} +340 -369
- package/dist/_chunks/index-DyvUPg1a.js.map +1 -0
- package/dist/_chunks/{layout-omucV6TV.mjs → layout-DPaHUusj.mjs} +8 -8
- package/dist/_chunks/layout-DPaHUusj.mjs.map +1 -0
- package/dist/_chunks/{layout-jcY4dyUG.js → layout-TPqF2oJ5.js} +7 -7
- package/dist/_chunks/layout-TPqF2oJ5.js.map +1 -0
- package/dist/_chunks/{relations-DGzD7ORa.js → relations-BWYS9gkn.js} +2 -2
- package/dist/_chunks/{relations-DGzD7ORa.js.map → relations-BWYS9gkn.js.map} +1 -1
- package/dist/_chunks/{relations-CN0-aw6p.mjs → relations-Ck7-ecDT.mjs} +2 -2
- package/dist/_chunks/{relations-CN0-aw6p.mjs.map → relations-Ck7-ecDT.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/server/index.js +11 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +11 -6
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CU7724gt.js.map +0 -1
- package/dist/_chunks/EditViewPage-CzuJgWWp.mjs.map +0 -1
- package/dist/_chunks/Field-Dh1yZyqy.js.map +0 -1
- package/dist/_chunks/Field-QtUSh5mU.mjs.map +0 -1
- package/dist/_chunks/Form-BOR8NOe1.js.map +0 -1
- package/dist/_chunks/Form-COLpvlnv.mjs.map +0 -1
- package/dist/_chunks/History-Bu53Yfw-.mjs.map +0 -1
- package/dist/_chunks/History-CW2akQ6h.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-TqrmwjPN.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-jzdhEk_u.js.map +0 -1
- package/dist/_chunks/ListViewPage-B3bMOrMv.js.map +0 -1
- package/dist/_chunks/ListViewPage-BO_mOXIl.mjs.map +0 -1
- package/dist/_chunks/Relations-B6fb2POW.js.map +0 -1
- package/dist/_chunks/Relations-CJ4qdkRo.mjs.map +0 -1
- package/dist/_chunks/index-Dahjdw4h.mjs.map +0 -1
- package/dist/_chunks/index-DcUu-_72.js.map +0 -1
- package/dist/_chunks/layout-jcY4dyUG.js.map +0 -1
- package/dist/_chunks/layout-omucV6TV.mjs.map +0 -1
@@ -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
|
-
import { Menu, VisuallyHidden, Flex, Typography, Dialog,
|
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";
|
@@ -198,6 +162,7 @@ const contentManagerApi = adminApi.enhanceEndpoints({
|
|
198
162
|
]
|
199
163
|
});
|
200
164
|
const documentApi = contentManagerApi.injectEndpoints({
|
165
|
+
overrideExisting: true,
|
201
166
|
endpoints: (builder) => ({
|
202
167
|
autoCloneDocument: builder.mutation({
|
203
168
|
query: ({ model, sourceId, query }) => ({
|
@@ -599,11 +564,11 @@ const createAttributeSchema = (attribute) => {
|
|
599
564
|
}
|
600
565
|
};
|
601
566
|
const addRequiredValidation = (attribute) => (schema) => {
|
602
|
-
if (attribute.required) {
|
603
|
-
return schema.required
|
604
|
-
|
605
|
-
|
606
|
-
|
567
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
568
|
+
return schema.min(1, translatedErrors.required);
|
569
|
+
}
|
570
|
+
if (attribute.required && attribute.type !== "relation") {
|
571
|
+
return schema.required(translatedErrors.required);
|
607
572
|
}
|
608
573
|
return schema?.nullable ? schema.nullable() : (
|
609
574
|
// In some cases '.nullable' will not be available on the schema.
|
@@ -637,6 +602,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
637
602
|
const addMinValidation = (attribute) => (schema) => {
|
638
603
|
if ("min" in attribute) {
|
639
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
|
+
}
|
640
627
|
if ("min" in schema && min) {
|
641
628
|
return schema.min(min, {
|
642
629
|
...translatedErrors.min,
|
@@ -763,7 +750,10 @@ const useDocument = (args, opts) => {
|
|
763
750
|
isLoading: isLoadingDocument,
|
764
751
|
isFetching: isFetchingDocument,
|
765
752
|
error
|
766
|
-
} = useGetDocumentQuery(args,
|
753
|
+
} = useGetDocumentQuery(args, {
|
754
|
+
...opts,
|
755
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
756
|
+
});
|
767
757
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
768
758
|
React.useEffect(() => {
|
769
759
|
if (error) {
|
@@ -1265,7 +1255,7 @@ const useDocumentActions = () => {
|
|
1265
1255
|
};
|
1266
1256
|
};
|
1267
1257
|
const ProtectedHistoryPage = lazy(
|
1268
|
-
() => import("./History-
|
1258
|
+
() => import("./History-CBNGU7a-.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1269
1259
|
);
|
1270
1260
|
const routes$1 = [
|
1271
1261
|
{
|
@@ -1278,31 +1268,31 @@ const routes$1 = [
|
|
1278
1268
|
}
|
1279
1269
|
];
|
1280
1270
|
const ProtectedEditViewPage = lazy(
|
1281
|
-
() => import("./EditViewPage-
|
1271
|
+
() => import("./EditViewPage-DlLEyUL6.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1282
1272
|
);
|
1283
1273
|
const ProtectedListViewPage = lazy(
|
1284
|
-
() => import("./ListViewPage-
|
1274
|
+
() => import("./ListViewPage-DecLrYV6.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1285
1275
|
);
|
1286
1276
|
const ProtectedListConfiguration = lazy(
|
1287
|
-
() => import("./ListConfigurationPage-
|
1277
|
+
() => import("./ListConfigurationPage-5dr4qpue.mjs").then((mod) => ({
|
1288
1278
|
default: mod.ProtectedListConfiguration
|
1289
1279
|
}))
|
1290
1280
|
);
|
1291
1281
|
const ProtectedEditConfigurationPage = lazy(
|
1292
|
-
() => import("./EditConfigurationPage-
|
1282
|
+
() => import("./EditConfigurationPage-ZO0vOO8q.mjs").then((mod) => ({
|
1293
1283
|
default: mod.ProtectedEditConfigurationPage
|
1294
1284
|
}))
|
1295
1285
|
);
|
1296
1286
|
const ProtectedComponentConfigurationPage = lazy(
|
1297
|
-
() => import("./ComponentConfigurationPage-
|
1287
|
+
() => import("./ComponentConfigurationPage-B1bIXVuX.mjs").then((mod) => ({
|
1298
1288
|
default: mod.ProtectedComponentConfigurationPage
|
1299
1289
|
}))
|
1300
1290
|
);
|
1301
1291
|
const NoPermissions = lazy(
|
1302
|
-
() => import("./NoPermissionsPage-
|
1292
|
+
() => import("./NoPermissionsPage-CM5UD8ee.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1303
1293
|
);
|
1304
1294
|
const NoContentType = lazy(
|
1305
|
-
() => import("./NoContentTypePage-
|
1295
|
+
() => import("./NoContentTypePage-CiIcfYsd.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1306
1296
|
);
|
1307
1297
|
const CollectionTypePages = () => {
|
1308
1298
|
const { collectionType } = useParams();
|
@@ -1429,7 +1419,7 @@ const DocumentActionButton = (action) => {
|
|
1429
1419
|
DocumentActionConfirmDialog,
|
1430
1420
|
{
|
1431
1421
|
...action.dialog,
|
1432
|
-
variant: action.variant,
|
1422
|
+
variant: action.dialog?.variant ?? action.variant,
|
1433
1423
|
isOpen: dialogId === action.id,
|
1434
1424
|
onClose: handleClose
|
1435
1425
|
}
|
@@ -1509,7 +1499,7 @@ const DocumentActionsMenu = ({
|
|
1509
1499
|
display: "block",
|
1510
1500
|
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
|
1511
1501
|
/* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
|
1512
|
-
action.icon,
|
1502
|
+
/* @__PURE__ */ jsx(Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
|
1513
1503
|
action.label
|
1514
1504
|
] }),
|
1515
1505
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
|
@@ -1570,6 +1560,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1570
1560
|
return "primary600";
|
1571
1561
|
}
|
1572
1562
|
};
|
1563
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1564
|
+
switch (variant) {
|
1565
|
+
case "danger":
|
1566
|
+
return "danger600";
|
1567
|
+
case "secondary":
|
1568
|
+
return "neutral500";
|
1569
|
+
case "success":
|
1570
|
+
return "success600";
|
1571
|
+
default:
|
1572
|
+
return "primary600";
|
1573
|
+
}
|
1574
|
+
};
|
1573
1575
|
const DocumentActionConfirmDialog = ({
|
1574
1576
|
onClose,
|
1575
1577
|
onCancel,
|
@@ -1592,22 +1594,20 @@ const DocumentActionConfirmDialog = ({
|
|
1592
1594
|
}
|
1593
1595
|
onClose();
|
1594
1596
|
};
|
1595
|
-
return /* @__PURE__ */
|
1596
|
-
/* @__PURE__ */ jsx(
|
1597
|
-
/* @__PURE__ */ jsx(
|
1598
|
-
|
1599
|
-
{
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
)
|
1610
|
-
] });
|
1597
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
1598
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
1599
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
1600
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
1601
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
1602
|
+
id: "app.components.Button.cancel",
|
1603
|
+
defaultMessage: "Cancel"
|
1604
|
+
}) }) }),
|
1605
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1606
|
+
id: "app.components.Button.confirm",
|
1607
|
+
defaultMessage: "Confirm"
|
1608
|
+
}) })
|
1609
|
+
] })
|
1610
|
+
] }) });
|
1611
1611
|
};
|
1612
1612
|
const DocumentActionModal = ({
|
1613
1613
|
isOpen,
|
@@ -1617,34 +1617,17 @@ const DocumentActionModal = ({
|
|
1617
1617
|
content: Content,
|
1618
1618
|
onModalClose
|
1619
1619
|
}) => {
|
1620
|
-
const id = React.useId();
|
1621
|
-
if (!isOpen) {
|
1622
|
-
return null;
|
1623
|
-
}
|
1624
1620
|
const handleClose = () => {
|
1625
1621
|
if (onClose) {
|
1626
1622
|
onClose();
|
1627
1623
|
}
|
1628
1624
|
onModalClose();
|
1629
1625
|
};
|
1630
|
-
return /* @__PURE__ */
|
1631
|
-
/* @__PURE__ */ jsx(
|
1632
|
-
/* @__PURE__ */ jsx(
|
1633
|
-
/* @__PURE__ */ jsx(
|
1634
|
-
|
1635
|
-
{
|
1636
|
-
paddingTop: 4,
|
1637
|
-
paddingBottom: 4,
|
1638
|
-
paddingLeft: 5,
|
1639
|
-
paddingRight: 5,
|
1640
|
-
borderWidth: "1px 0 0 0",
|
1641
|
-
borderStyle: "solid",
|
1642
|
-
borderColor: "neutral150",
|
1643
|
-
background: "neutral100",
|
1644
|
-
children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
1645
|
-
}
|
1646
|
-
)
|
1647
|
-
] });
|
1626
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
|
1627
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
|
1628
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content }),
|
1629
|
+
/* @__PURE__ */ jsx(Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer })
|
1630
|
+
] }) });
|
1648
1631
|
};
|
1649
1632
|
const PublishAction$1 = ({
|
1650
1633
|
activeTab,
|
@@ -1665,6 +1648,12 @@ const PublishAction$1 = ({
|
|
1665
1648
|
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1666
1649
|
);
|
1667
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);
|
1668
1657
|
const [{ query, rawQuery }] = useQueryParams();
|
1669
1658
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1670
1659
|
const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1673,10 +1662,101 @@ const PublishAction$1 = ({
|
|
1673
1662
|
const validate = useForm("PublishAction", (state) => state.validate);
|
1674
1663
|
const setErrors = useForm("PublishAction", (state) => state.setErrors);
|
1675
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]);
|
1676
1719
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1677
1720
|
if (!schema?.options?.draftAndPublish) {
|
1678
1721
|
return null;
|
1679
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;
|
1680
1760
|
return {
|
1681
1761
|
/**
|
1682
1762
|
* Disabled when:
|
@@ -1689,46 +1769,38 @@ const PublishAction$1 = ({
|
|
1689
1769
|
* - the user doesn't have the permission to create a new document
|
1690
1770
|
* - the user doesn't have the permission to update the document
|
1691
1771
|
*/
|
1692
|
-
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),
|
1693
1773
|
label: formatMessage({
|
1694
1774
|
id: "app.utils.publish",
|
1695
1775
|
defaultMessage: "Publish"
|
1696
1776
|
}),
|
1697
1777
|
onClick: async () => {
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
formValues
|
1719
|
-
);
|
1720
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1721
|
-
navigate({
|
1722
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1723
|
-
search: rawQuery
|
1724
|
-
});
|
1725
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1726
|
-
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
|
1727
1798
|
}
|
1728
|
-
|
1729
|
-
|
1799
|
+
),
|
1800
|
+
onConfirm: async () => {
|
1801
|
+
await performPublish();
|
1730
1802
|
}
|
1731
|
-
}
|
1803
|
+
} : void 0
|
1732
1804
|
};
|
1733
1805
|
};
|
1734
1806
|
PublishAction$1.type = "publish";
|
@@ -1827,10 +1899,13 @@ const UpdateAction = ({
|
|
1827
1899
|
document
|
1828
1900
|
);
|
1829
1901
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1830
|
-
navigate(
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1902
|
+
navigate(
|
1903
|
+
{
|
1904
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1905
|
+
search: rawQuery
|
1906
|
+
},
|
1907
|
+
{ replace: true }
|
1908
|
+
);
|
1834
1909
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1835
1910
|
setErrors(formatValidationErrors(res.error));
|
1836
1911
|
}
|
@@ -1862,10 +1937,8 @@ const UnpublishAction$1 = ({
|
|
1862
1937
|
const { toggleNotification } = useNotification();
|
1863
1938
|
const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
|
1864
1939
|
const isDocumentModified = document?.status === "modified";
|
1865
|
-
const handleChange = (
|
1866
|
-
|
1867
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1868
|
-
}
|
1940
|
+
const handleChange = (value) => {
|
1941
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1869
1942
|
};
|
1870
1943
|
if (!schema?.options?.draftAndPublish) {
|
1871
1944
|
return null;
|
@@ -1915,40 +1988,24 @@ const UnpublishAction$1 = ({
|
|
1915
1988
|
}) })
|
1916
1989
|
] }),
|
1917
1990
|
/* @__PURE__ */ jsxs(
|
1918
|
-
|
1991
|
+
Radio.Group,
|
1919
1992
|
{
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1993
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
1994
|
+
name: "discard-options",
|
1995
|
+
"aria-label": formatMessage({
|
1996
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
1997
|
+
defaultMessage: "Choose an option to unpublish the document."
|
1998
|
+
}),
|
1999
|
+
onValueChange: handleChange,
|
1926
2000
|
children: [
|
1927
|
-
/* @__PURE__ */ jsx(
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1936
|
-
defaultMessage: "Keep draft"
|
1937
|
-
})
|
1938
|
-
}
|
1939
|
-
),
|
1940
|
-
/* @__PURE__ */ jsx(
|
1941
|
-
Radio,
|
1942
|
-
{
|
1943
|
-
checked: !shouldKeepDraft,
|
1944
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1945
|
-
name: "discard-options",
|
1946
|
-
children: formatMessage({
|
1947
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1948
|
-
defaultMessage: "Replace draft"
|
1949
|
-
})
|
1950
|
-
}
|
1951
|
-
)
|
2001
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2002
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2003
|
+
defaultMessage: "Keep draft"
|
2004
|
+
}) }),
|
2005
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2006
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2007
|
+
defaultMessage: "Replace draft"
|
2008
|
+
}) })
|
1952
2009
|
]
|
1953
2010
|
}
|
1954
2011
|
)
|
@@ -2094,23 +2151,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2094
2151
|
id: "content-manager.containers.edit.title.new",
|
2095
2152
|
defaultMessage: "Create an entry"
|
2096
2153
|
}) : documentTitle;
|
2097
|
-
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: [
|
2098
2155
|
/* @__PURE__ */ jsx(BackButton, {}),
|
2099
|
-
/* @__PURE__ */ jsxs(
|
2100
|
-
|
2101
|
-
{
|
2102
|
-
|
2103
|
-
|
2104
|
-
paddingTop: 1,
|
2105
|
-
gap: "80px",
|
2106
|
-
alignItems: "flex-start",
|
2107
|
-
children: [
|
2108
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2109
|
-
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2110
|
-
]
|
2111
|
-
}
|
2112
|
-
),
|
2113
|
-
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
|
2114
2161
|
] });
|
2115
2162
|
};
|
2116
2163
|
const HeaderToolbar = () => {
|
@@ -2801,30 +2848,23 @@ const ConfirmBulkActionDialog = ({
|
|
2801
2848
|
endAction
|
2802
2849
|
}) => {
|
2803
2850
|
const { formatMessage } = useIntl();
|
2804
|
-
return /* @__PURE__ */ jsxs(
|
2805
|
-
Dialog,
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
}) }),
|
2822
|
-
endAction
|
2823
|
-
}
|
2824
|
-
)
|
2825
|
-
]
|
2826
|
-
}
|
2827
|
-
);
|
2851
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2852
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
|
2853
|
+
id: "app.components.ConfirmDialog.title",
|
2854
|
+
defaultMessage: "Confirmation"
|
2855
|
+
}) }),
|
2856
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2857
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2858
|
+
dialogBody
|
2859
|
+
] }) }),
|
2860
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
2861
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2862
|
+
id: "app.components.Button.cancel",
|
2863
|
+
defaultMessage: "Cancel"
|
2864
|
+
}) }) }),
|
2865
|
+
endAction
|
2866
|
+
] })
|
2867
|
+
] }) });
|
2828
2868
|
};
|
2829
2869
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
2830
2870
|
const ConfirmDialogPublishAll = ({
|
@@ -2929,7 +2969,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2929
2969
|
)
|
2930
2970
|
);
|
2931
2971
|
} else {
|
2932
|
-
messages.push(
|
2972
|
+
messages.push(
|
2973
|
+
...formatErrorMessages(
|
2974
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
2975
|
+
value,
|
2976
|
+
currentKey,
|
2977
|
+
formatMessage
|
2978
|
+
)
|
2979
|
+
);
|
2933
2980
|
}
|
2934
2981
|
} else {
|
2935
2982
|
messages.push(
|
@@ -3166,7 +3213,7 @@ const SelectedEntriesModalContent = ({
|
|
3166
3213
|
);
|
3167
3214
|
};
|
3168
3215
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3169
|
-
/* @__PURE__ */ jsxs(
|
3216
|
+
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
3170
3217
|
/* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
|
3171
3218
|
/* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
|
3172
3219
|
SelectedEntriesTableContent,
|
@@ -3178,27 +3225,24 @@ const SelectedEntriesModalContent = ({
|
|
3178
3225
|
}
|
3179
3226
|
) })
|
3180
3227
|
] }),
|
3181
|
-
/* @__PURE__ */
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
}) }),
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3191
|
-
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
] })
|
3200
|
-
}
|
3201
|
-
),
|
3228
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3229
|
+
/* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3230
|
+
id: "app.components.Button.cancel",
|
3231
|
+
defaultMessage: "Cancel"
|
3232
|
+
}) }),
|
3233
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3234
|
+
/* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3235
|
+
/* @__PURE__ */ jsx(
|
3236
|
+
Button,
|
3237
|
+
{
|
3238
|
+
onClick: toggleDialog,
|
3239
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3240
|
+
loading: isSubmittingForm,
|
3241
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3242
|
+
}
|
3243
|
+
)
|
3244
|
+
] })
|
3245
|
+
] }),
|
3202
3246
|
/* @__PURE__ */ jsx(
|
3203
3247
|
ConfirmDialogPublishAll,
|
3204
3248
|
{
|
@@ -3263,143 +3307,10 @@ const BulkActionsRenderer = () => {
|
|
3263
3307
|
documents: selectedRows
|
3264
3308
|
},
|
3265
3309
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3266
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(
|
3310
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
|
3267
3311
|
}
|
3268
3312
|
) });
|
3269
3313
|
};
|
3270
|
-
const BulkActionAction = (action) => {
|
3271
|
-
const [dialogId, setDialogId] = React.useState(null);
|
3272
|
-
const { toggleNotification } = useNotification();
|
3273
|
-
const handleClick = (action2) => (e) => {
|
3274
|
-
const { onClick, dialog, id } = action2;
|
3275
|
-
if (onClick) {
|
3276
|
-
onClick(e);
|
3277
|
-
}
|
3278
|
-
if (dialog) {
|
3279
|
-
switch (dialog.type) {
|
3280
|
-
case "notification":
|
3281
|
-
toggleNotification({
|
3282
|
-
title: dialog.title,
|
3283
|
-
message: dialog.content,
|
3284
|
-
type: dialog.status,
|
3285
|
-
timeout: dialog.timeout,
|
3286
|
-
onClose: dialog.onClose
|
3287
|
-
});
|
3288
|
-
break;
|
3289
|
-
case "dialog":
|
3290
|
-
case "modal": {
|
3291
|
-
e.preventDefault();
|
3292
|
-
setDialogId(id);
|
3293
|
-
}
|
3294
|
-
}
|
3295
|
-
}
|
3296
|
-
};
|
3297
|
-
const handleClose = () => {
|
3298
|
-
setDialogId(null);
|
3299
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3300
|
-
action.dialog.onClose();
|
3301
|
-
}
|
3302
|
-
};
|
3303
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3304
|
-
/* @__PURE__ */ jsx(
|
3305
|
-
Button,
|
3306
|
-
{
|
3307
|
-
disabled: action.disabled,
|
3308
|
-
startIcon: action.icon,
|
3309
|
-
variant: action.variant,
|
3310
|
-
onClick: handleClick(action),
|
3311
|
-
children: action.label
|
3312
|
-
}
|
3313
|
-
),
|
3314
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
|
3315
|
-
BulkActionConfirmDialog,
|
3316
|
-
{
|
3317
|
-
...action.dialog,
|
3318
|
-
variant: action.variant,
|
3319
|
-
isOpen: dialogId === action.id,
|
3320
|
-
onClose: handleClose
|
3321
|
-
}
|
3322
|
-
) : null,
|
3323
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
|
3324
|
-
BulkActionModal,
|
3325
|
-
{
|
3326
|
-
...action.dialog,
|
3327
|
-
onModalClose: handleClose,
|
3328
|
-
isOpen: dialogId === action.id
|
3329
|
-
}
|
3330
|
-
) : null
|
3331
|
-
] });
|
3332
|
-
};
|
3333
|
-
const BulkActionConfirmDialog = ({
|
3334
|
-
onClose,
|
3335
|
-
onCancel,
|
3336
|
-
onConfirm,
|
3337
|
-
title,
|
3338
|
-
content,
|
3339
|
-
confirmButton,
|
3340
|
-
isOpen,
|
3341
|
-
variant = "secondary"
|
3342
|
-
}) => {
|
3343
|
-
const { formatMessage } = useIntl();
|
3344
|
-
const handleClose = async () => {
|
3345
|
-
if (onCancel) {
|
3346
|
-
await onCancel();
|
3347
|
-
}
|
3348
|
-
onClose();
|
3349
|
-
};
|
3350
|
-
const handleConfirm = async () => {
|
3351
|
-
if (onConfirm) {
|
3352
|
-
await onConfirm();
|
3353
|
-
}
|
3354
|
-
onClose();
|
3355
|
-
};
|
3356
|
-
return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
|
3357
|
-
/* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: content }),
|
3358
|
-
/* @__PURE__ */ jsx(
|
3359
|
-
DialogFooter,
|
3360
|
-
{
|
3361
|
-
startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3362
|
-
id: "app.components.Button.cancel",
|
3363
|
-
defaultMessage: "Cancel"
|
3364
|
-
}) }),
|
3365
|
-
endAction: /* @__PURE__ */ jsx(
|
3366
|
-
Button,
|
3367
|
-
{
|
3368
|
-
onClick: handleConfirm,
|
3369
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3370
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsx(Trash, {}) : /* @__PURE__ */ jsx(Check, {}),
|
3371
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3372
|
-
id: "app.components.Button.confirm",
|
3373
|
-
defaultMessage: "Confirm"
|
3374
|
-
})
|
3375
|
-
}
|
3376
|
-
)
|
3377
|
-
}
|
3378
|
-
)
|
3379
|
-
] });
|
3380
|
-
};
|
3381
|
-
const BulkActionModal = ({
|
3382
|
-
isOpen,
|
3383
|
-
title,
|
3384
|
-
onClose,
|
3385
|
-
content: Content,
|
3386
|
-
onModalClose
|
3387
|
-
}) => {
|
3388
|
-
const id = React.useId();
|
3389
|
-
if (!isOpen) {
|
3390
|
-
return null;
|
3391
|
-
}
|
3392
|
-
const handleClose = () => {
|
3393
|
-
if (onClose) {
|
3394
|
-
onClose();
|
3395
|
-
}
|
3396
|
-
onModalClose();
|
3397
|
-
};
|
3398
|
-
return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3399
|
-
/* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3400
|
-
/* @__PURE__ */ jsx(Content, { onClose: handleClose })
|
3401
|
-
] });
|
3402
|
-
};
|
3403
3314
|
const DeleteAction = ({ documents, model }) => {
|
3404
3315
|
const { formatMessage } = useIntl();
|
3405
3316
|
const { schema: contentType } = useDoc();
|
@@ -3432,6 +3343,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3432
3343
|
defaultMessage: "Confirmation"
|
3433
3344
|
}),
|
3434
3345
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3346
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3435
3347
|
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3436
3348
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3437
3349
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3481,6 +3393,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3481
3393
|
defaultMessage: "Confirmation"
|
3482
3394
|
}),
|
3483
3395
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3396
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3484
3397
|
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3485
3398
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3486
3399
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3726,8 +3639,7 @@ class ContentManagerPlugin {
|
|
3726
3639
|
documentActions = [
|
3727
3640
|
...DEFAULT_ACTIONS,
|
3728
3641
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3729
|
-
...DEFAULT_HEADER_ACTIONS
|
3730
|
-
HistoryAction
|
3642
|
+
...DEFAULT_HEADER_ACTIONS
|
3731
3643
|
];
|
3732
3644
|
editViewSidePanels = [ActionsPanel];
|
3733
3645
|
headerActions = [];
|
@@ -3816,6 +3728,52 @@ const getPrintableType = (value) => {
|
|
3816
3728
|
}
|
3817
3729
|
return nativeType;
|
3818
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
|
+
};
|
3819
3777
|
const initialState = {
|
3820
3778
|
collectionTypeLinks: [],
|
3821
3779
|
components: [],
|
@@ -3866,15 +3824,29 @@ const index = {
|
|
3866
3824
|
defaultMessage: "Content Manager"
|
3867
3825
|
},
|
3868
3826
|
permissions: [],
|
3869
|
-
Component: () => import("./layout-omucV6TV.mjs").then((mod) => ({ default: mod.Layout })),
|
3870
3827
|
position: 1
|
3871
3828
|
});
|
3829
|
+
app.router.addRoute({
|
3830
|
+
path: "content-manager/*",
|
3831
|
+
lazy: async () => {
|
3832
|
+
const { Layout } = await import("./layout-DPaHUusj.mjs");
|
3833
|
+
return {
|
3834
|
+
Component: Layout
|
3835
|
+
};
|
3836
|
+
},
|
3837
|
+
children: routes
|
3838
|
+
});
|
3872
3839
|
app.registerPlugin(cm.config);
|
3873
3840
|
},
|
3841
|
+
bootstrap(app) {
|
3842
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3843
|
+
historyAdmin.bootstrap(app);
|
3844
|
+
}
|
3845
|
+
},
|
3874
3846
|
async registerTrads({ locales }) {
|
3875
3847
|
const importedTrads = await Promise.all(
|
3876
3848
|
locales.map((locale) => {
|
3877
|
-
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 }) => {
|
3878
3850
|
return {
|
3879
3851
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3880
3852
|
locale
|
@@ -3895,14 +3867,13 @@ export {
|
|
3895
3867
|
BulkActionsRenderer as B,
|
3896
3868
|
COLLECTION_TYPES as C,
|
3897
3869
|
DocumentStatus as D,
|
3898
|
-
|
3899
|
-
|
3900
|
-
|
3870
|
+
DEFAULT_SETTINGS as E,
|
3871
|
+
convertEditLayoutToFieldLayouts as F,
|
3872
|
+
useDocument as G,
|
3901
3873
|
HOOKS as H,
|
3902
3874
|
InjectionZone as I,
|
3903
|
-
|
3904
|
-
|
3905
|
-
useDocumentActions as L,
|
3875
|
+
index as J,
|
3876
|
+
useDocumentActions as K,
|
3906
3877
|
Panels as P,
|
3907
3878
|
RelativeTime as R,
|
3908
3879
|
SINGLE_TYPES as S,
|
@@ -3924,14 +3895,14 @@ export {
|
|
3924
3895
|
useGetContentTypeConfigurationQuery as o,
|
3925
3896
|
CREATOR_FIELDS as p,
|
3926
3897
|
getMainField as q,
|
3927
|
-
|
3898
|
+
getDisplayName as r,
|
3928
3899
|
setInitialData as s,
|
3929
|
-
|
3900
|
+
checkIfAttributeIsDisplayable as t,
|
3930
3901
|
useContentTypeSchema as u,
|
3931
|
-
|
3932
|
-
|
3933
|
-
|
3934
|
-
|
3935
|
-
|
3902
|
+
useGetAllDocumentsQuery as v,
|
3903
|
+
convertListLayoutToFieldLayouts as w,
|
3904
|
+
capitalise as x,
|
3905
|
+
useUpdateContentTypeConfigurationMutation as y,
|
3906
|
+
extractContentTypeComponents as z
|
3936
3907
|
};
|
3937
|
-
//# sourceMappingURL=index-
|
3908
|
+
//# sourceMappingURL=index-BSn97i8U.mjs.map
|