@strapi/content-manager 0.0.0-experimental.3c73a4c6f6073abdf1608121a200c3d4d87b1aa8 → 0.0.0-experimental.3d5794391d4c2d9eddf7bd162c02f4bb836eb7a6
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-BZIaEffq.js → ComponentConfigurationPage-Cjr64OS0.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js.map → ComponentConfigurationPage-Cjr64OS0.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs → ComponentConfigurationPage-DKuCF_uX.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs.map → ComponentConfigurationPage-DKuCF_uX.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js → EditConfigurationPage-BeikGxvq.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js.map → EditConfigurationPage-BeikGxvq.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs → EditConfigurationPage-CyqSP6ru.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs.map → EditConfigurationPage-CyqSP6ru.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CzuJgWWp.mjs → EditViewPage-PrPHZN_9.mjs} +102 -51
- package/dist/_chunks/EditViewPage-PrPHZN_9.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-CU7724gt.js → EditViewPage-pyqEgLgP.js} +100 -49
- package/dist/_chunks/EditViewPage-pyqEgLgP.js.map +1 -0
- package/dist/_chunks/{Field-QtUSh5mU.mjs → Field-DuAYQka5.mjs} +600 -228
- package/dist/_chunks/Field-DuAYQka5.mjs.map +1 -0
- package/dist/_chunks/{Field-Dh1yZyqy.js → Field-fKtb7rWK.js} +602 -230
- package/dist/_chunks/Field-fKtb7rWK.js.map +1 -0
- package/dist/_chunks/{Form-BOR8NOe1.js → Form-BPXw-S-J.js} +52 -34
- package/dist/_chunks/Form-BPXw-S-J.js.map +1 -0
- package/dist/_chunks/{Form-COLpvlnv.mjs → Form-Dxh71ckp.mjs} +54 -36
- package/dist/_chunks/Form-Dxh71ckp.mjs.map +1 -0
- package/dist/_chunks/{History-CW2akQ6h.js → History-BGGn9JGY.js} +171 -126
- package/dist/_chunks/History-BGGn9JGY.js.map +1 -0
- package/dist/_chunks/{History-Bu53Yfw-.mjs → History-CGblSVMc.mjs} +172 -127
- package/dist/_chunks/History-CGblSVMc.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-jzdhEk_u.js → ListConfigurationPage-D3Avyi4t.js} +58 -47
- package/dist/_chunks/ListConfigurationPage-D3Avyi4t.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-TqrmwjPN.mjs → ListConfigurationPage-TIM0JveM.mjs} +59 -49
- package/dist/_chunks/ListConfigurationPage-TIM0JveM.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BO_mOXIl.mjs → ListViewPage-C975eW-t.mjs} +128 -105
- package/dist/_chunks/ListViewPage-C975eW-t.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-B3bMOrMv.js → ListViewPage-DtAHWFMV.js} +130 -107
- package/dist/_chunks/ListViewPage-DtAHWFMV.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js → NoContentTypePage-BFjWZX0i.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D77xsNHj.js.map → NoContentTypePage-BFjWZX0i.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs → NoContentTypePage-SgNTVGjF.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs.map → NoContentTypePage-SgNTVGjF.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs → NoPermissionsPage-D4XYRoPf.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs.map → NoPermissionsPage-D4XYRoPf.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js → NoPermissionsPage-j7oulOpl.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js.map → NoPermissionsPage-j7oulOpl.js.map} +1 -1
- package/dist/_chunks/Preview-Bx1WfmKJ.js +256 -0
- package/dist/_chunks/Preview-Bx1WfmKJ.js.map +1 -0
- package/dist/_chunks/Preview-Cy6fuAnd.mjs +237 -0
- package/dist/_chunks/Preview-Cy6fuAnd.mjs.map +1 -0
- package/dist/_chunks/{Relations-B6fb2POW.js → Relations-CXQqwRXC.js} +72 -36
- package/dist/_chunks/Relations-CXQqwRXC.js.map +1 -0
- package/dist/_chunks/{Relations-CJ4qdkRo.mjs → Relations-DUrYWw0N.mjs} +73 -37
- package/dist/_chunks/Relations-DUrYWw0N.mjs.map +1 -0
- package/dist/_chunks/{en-9GwRW_ku.mjs → en-69jRDM9j.mjs} +31 -17
- package/dist/_chunks/{en-9GwRW_ku.mjs.map → en-69jRDM9j.mjs.map} +1 -1
- package/dist/_chunks/{en-DZXjRiWA.js → en-DAgtrRoa.js} +31 -17
- package/dist/_chunks/{en-DZXjRiWA.js.map → en-DAgtrRoa.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-Dahjdw4h.mjs → index-Ta--2bRa.mjs} +1107 -883
- package/dist/_chunks/index-Ta--2bRa.mjs.map +1 -0
- package/dist/_chunks/{index-DcUu-_72.js → index-_j7lH3CO.js} +1099 -874
- package/dist/_chunks/index-_j7lH3CO.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-jcY4dyUG.js → layout-BDwU2I_y.js} +25 -12
- package/dist/_chunks/layout-BDwU2I_y.js.map +1 -0
- package/dist/_chunks/{layout-omucV6TV.mjs → layout-C8H4oKDo.mjs} +27 -14
- package/dist/_chunks/layout-C8H4oKDo.mjs.map +1 -0
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-DGzD7ORa.js → relations-CPfMNzM6.js} +6 -7
- package/dist/_chunks/relations-CPfMNzM6.js.map +1 -0
- package/dist/_chunks/{relations-CN0-aw6p.mjs → relations-Ch70q86O.mjs} +6 -7
- package/dist/_chunks/relations-Ch70q86O.mjs.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -3
- package/dist/admin/src/exports.d.ts +1 -1
- 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/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- 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/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- 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/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -17
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +551 -263
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +552 -264
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +4 -4
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +15 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +30 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +18 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +14 -14
- 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
- package/dist/_chunks/relations-CN0-aw6p.mjs.map +0 -1
- package/dist/_chunks/relations-DGzD7ORa.js.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -2,15 +2,16 @@
|
|
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");
|
10
|
-
const
|
7
|
+
const mapValues = require("lodash/fp/mapValues");
|
8
|
+
const reactIntl = require("react-intl");
|
9
|
+
const reactRouterDom = require("react-router-dom");
|
11
10
|
const yup = require("yup");
|
12
11
|
const pipe = require("lodash/fp/pipe");
|
13
12
|
const dateFns = require("date-fns");
|
13
|
+
const styledComponents = require("styled-components");
|
14
|
+
const qs = require("qs");
|
14
15
|
const toolkit = require("@reduxjs/toolkit");
|
15
16
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
17
|
function _interopNamespace(e) {
|
@@ -32,6 +33,7 @@ function _interopNamespace(e) {
|
|
32
33
|
return Object.freeze(n);
|
33
34
|
}
|
34
35
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
36
|
+
const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
|
35
37
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
36
38
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
37
39
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -70,42 +72,6 @@ const useInjectionZone = (area) => {
|
|
70
72
|
const [page, position] = area.split(".");
|
71
73
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
72
74
|
};
|
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
75
|
const ID = "id";
|
110
76
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
111
77
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -157,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
157
123
|
if (!slug) {
|
158
124
|
throw new Error("Cannot find the slug param in the URL");
|
159
125
|
}
|
126
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
160
127
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
161
128
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
162
129
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -167,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
167
134
|
return { ...acc, [action]: [permission] };
|
168
135
|
}, {});
|
169
136
|
}, [slug, userPermissions]);
|
170
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
137
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
138
|
+
contentTypePermissions,
|
139
|
+
permissions ?? void 0,
|
140
|
+
// TODO: useRBAC context should be typed and built differently
|
141
|
+
// We are passing raw query as context to the hook so that it can
|
142
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
143
|
+
rawQuery
|
144
|
+
);
|
171
145
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
172
146
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
173
147
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -215,10 +189,12 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
215
189
|
"Document",
|
216
190
|
"InitialData",
|
217
191
|
"HistoryVersion",
|
218
|
-
"Relations"
|
192
|
+
"Relations",
|
193
|
+
"UidAvailability"
|
219
194
|
]
|
220
195
|
});
|
221
196
|
const documentApi = contentManagerApi.injectEndpoints({
|
197
|
+
overrideExisting: true,
|
222
198
|
endpoints: (builder) => ({
|
223
199
|
autoCloneDocument: builder.mutation({
|
224
200
|
query: ({ model, sourceId, query }) => ({
|
@@ -228,7 +204,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
228
204
|
params: query
|
229
205
|
}
|
230
206
|
}),
|
231
|
-
invalidatesTags: (_result,
|
207
|
+
invalidatesTags: (_result, error, { model }) => {
|
208
|
+
if (error) {
|
209
|
+
return [];
|
210
|
+
}
|
211
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
212
|
+
}
|
232
213
|
}),
|
233
214
|
cloneDocument: builder.mutation({
|
234
215
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -239,7 +220,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
239
220
|
params
|
240
221
|
}
|
241
222
|
}),
|
242
|
-
invalidatesTags: (_result, _error, { model }) => [
|
223
|
+
invalidatesTags: (_result, _error, { model }) => [
|
224
|
+
{ type: "Document", id: `${model}_LIST` },
|
225
|
+
{ type: "UidAvailability", id: model }
|
226
|
+
]
|
243
227
|
}),
|
244
228
|
/**
|
245
229
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -256,7 +240,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
256
240
|
}),
|
257
241
|
invalidatesTags: (result, _error, { model }) => [
|
258
242
|
{ type: "Document", id: `${model}_LIST` },
|
259
|
-
"Relations"
|
243
|
+
"Relations",
|
244
|
+
{ type: "UidAvailability", id: model }
|
260
245
|
]
|
261
246
|
}),
|
262
247
|
deleteDocument: builder.mutation({
|
@@ -297,7 +282,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
297
282
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
298
283
|
},
|
299
284
|
{ type: "Document", id: `${model}_LIST` },
|
300
|
-
"Relations"
|
285
|
+
"Relations",
|
286
|
+
{ type: "UidAvailability", id: model }
|
301
287
|
];
|
302
288
|
}
|
303
289
|
}),
|
@@ -315,6 +301,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
315
301
|
}),
|
316
302
|
providesTags: (result, _error, arg) => {
|
317
303
|
return [
|
304
|
+
{ type: "Document", id: `ALL_LIST` },
|
318
305
|
{ type: "Document", id: `${arg.model}_LIST` },
|
319
306
|
...result?.results.map(({ documentId }) => ({
|
320
307
|
type: "Document",
|
@@ -353,6 +340,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
353
340
|
{
|
354
341
|
type: "Document",
|
355
342
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
343
|
+
},
|
344
|
+
// Make it easy to invalidate all individual documents queries for a model
|
345
|
+
{
|
346
|
+
type: "Document",
|
347
|
+
id: `${model}_ALL_ITEMS`
|
356
348
|
}
|
357
349
|
];
|
358
350
|
}
|
@@ -416,8 +408,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
416
408
|
type: "Document",
|
417
409
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
418
410
|
},
|
419
|
-
"Relations"
|
411
|
+
"Relations",
|
412
|
+
{ type: "UidAvailability", id: model }
|
420
413
|
];
|
414
|
+
},
|
415
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
416
|
+
const patchResult = dispatch(
|
417
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
418
|
+
Object.assign(draft.data, data);
|
419
|
+
})
|
420
|
+
);
|
421
|
+
try {
|
422
|
+
await queryFulfilled;
|
423
|
+
} catch {
|
424
|
+
patchResult.undo();
|
425
|
+
}
|
421
426
|
}
|
422
427
|
}),
|
423
428
|
unpublishDocument: builder.mutation({
|
@@ -487,20 +492,39 @@ const buildValidParams = (query) => {
|
|
487
492
|
const isBaseQueryError = (error) => {
|
488
493
|
return error.name !== void 0;
|
489
494
|
};
|
490
|
-
const
|
495
|
+
const arrayValidator = (attribute, options) => ({
|
496
|
+
message: strapiAdmin.translatedErrors.required,
|
497
|
+
test(value) {
|
498
|
+
if (options.status === "draft") {
|
499
|
+
return true;
|
500
|
+
}
|
501
|
+
if (!attribute.required) {
|
502
|
+
return true;
|
503
|
+
}
|
504
|
+
if (!value) {
|
505
|
+
return false;
|
506
|
+
}
|
507
|
+
if (Array.isArray(value) && value.length === 0) {
|
508
|
+
return false;
|
509
|
+
}
|
510
|
+
return true;
|
511
|
+
}
|
512
|
+
});
|
513
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
491
514
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
492
515
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
493
516
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
494
517
|
return acc;
|
495
518
|
}
|
496
519
|
const validations = [
|
520
|
+
addNullableValidation,
|
497
521
|
addRequiredValidation,
|
498
522
|
addMinLengthValidation,
|
499
523
|
addMaxLengthValidation,
|
500
524
|
addMinValidation,
|
501
525
|
addMaxValidation,
|
502
526
|
addRegexValidation
|
503
|
-
].map((fn) => fn(attribute));
|
527
|
+
].map((fn) => fn(attribute, options));
|
504
528
|
const transformSchema = pipe__default.default(...validations);
|
505
529
|
switch (attribute.type) {
|
506
530
|
case "component": {
|
@@ -510,12 +534,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
510
534
|
...acc,
|
511
535
|
[name]: transformSchema(
|
512
536
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
513
|
-
)
|
537
|
+
).test(arrayValidator(attribute, options))
|
514
538
|
};
|
515
539
|
} else {
|
516
540
|
return {
|
517
541
|
...acc,
|
518
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
542
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
519
543
|
};
|
520
544
|
}
|
521
545
|
}
|
@@ -537,7 +561,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
537
561
|
}
|
538
562
|
)
|
539
563
|
)
|
540
|
-
)
|
564
|
+
).test(arrayValidator(attribute, options))
|
541
565
|
};
|
542
566
|
case "relation":
|
543
567
|
return {
|
@@ -549,7 +573,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
549
573
|
} else if (Array.isArray(value)) {
|
550
574
|
return yup__namespace.array().of(
|
551
575
|
yup__namespace.object().shape({
|
552
|
-
id: yup__namespace.
|
576
|
+
id: yup__namespace.number().required()
|
553
577
|
})
|
554
578
|
);
|
555
579
|
} else if (typeof value === "object") {
|
@@ -601,6 +625,14 @@ const createAttributeSchema = (attribute) => {
|
|
601
625
|
if (!value || typeof value === "string" && value.length === 0) {
|
602
626
|
return true;
|
603
627
|
}
|
628
|
+
if (typeof value === "object") {
|
629
|
+
try {
|
630
|
+
JSON.stringify(value);
|
631
|
+
return true;
|
632
|
+
} catch (err) {
|
633
|
+
return false;
|
634
|
+
}
|
635
|
+
}
|
604
636
|
try {
|
605
637
|
JSON.parse(value);
|
606
638
|
return true;
|
@@ -619,13 +651,7 @@ const createAttributeSchema = (attribute) => {
|
|
619
651
|
return yup__namespace.mixed();
|
620
652
|
}
|
621
653
|
};
|
622
|
-
const
|
623
|
-
if (attribute.required) {
|
624
|
-
return schema.required({
|
625
|
-
id: strapiAdmin.translatedErrors.required.id,
|
626
|
-
defaultMessage: "This field is required."
|
627
|
-
});
|
628
|
-
}
|
654
|
+
const nullableSchema = (schema) => {
|
629
655
|
return schema?.nullable ? schema.nullable() : (
|
630
656
|
// In some cases '.nullable' will not be available on the schema.
|
631
657
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -633,7 +659,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
633
659
|
schema
|
634
660
|
);
|
635
661
|
};
|
636
|
-
const
|
662
|
+
const addNullableValidation = () => (schema) => {
|
663
|
+
return nullableSchema(schema);
|
664
|
+
};
|
665
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
666
|
+
if (options.status === "draft" || !attribute.required) {
|
667
|
+
return schema;
|
668
|
+
}
|
669
|
+
if (attribute.required && "required" in schema) {
|
670
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
671
|
+
}
|
672
|
+
return schema;
|
673
|
+
};
|
674
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
675
|
+
if (options.status === "draft") {
|
676
|
+
return schema;
|
677
|
+
}
|
637
678
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
638
679
|
return schema.min(attribute.minLength, {
|
639
680
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -655,10 +696,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
655
696
|
}
|
656
697
|
return schema;
|
657
698
|
};
|
658
|
-
const addMinValidation = (attribute) => (schema) => {
|
659
|
-
if ("
|
699
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
700
|
+
if (options.status === "draft") {
|
701
|
+
return schema;
|
702
|
+
}
|
703
|
+
if ("min" in attribute && "min" in schema) {
|
660
704
|
const min = toInteger(attribute.min);
|
661
|
-
if (
|
705
|
+
if (min) {
|
662
706
|
return schema.min(min, {
|
663
707
|
...strapiAdmin.translatedErrors.min,
|
664
708
|
values: {
|
@@ -776,16 +820,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
776
820
|
}, {});
|
777
821
|
return componentsByKey;
|
778
822
|
};
|
779
|
-
const
|
823
|
+
const HOOKS = {
|
824
|
+
/**
|
825
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
826
|
+
* @constant
|
827
|
+
* @type {string}
|
828
|
+
*/
|
829
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
830
|
+
/**
|
831
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
832
|
+
* @constant
|
833
|
+
* @type {string}
|
834
|
+
*/
|
835
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
836
|
+
/**
|
837
|
+
* Hook that allows to mutate the CM's edit view layout
|
838
|
+
* @constant
|
839
|
+
* @type {string}
|
840
|
+
*/
|
841
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
842
|
+
/**
|
843
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
844
|
+
* @constant
|
845
|
+
* @type {string}
|
846
|
+
*/
|
847
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
848
|
+
};
|
849
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
850
|
+
endpoints: (builder) => ({
|
851
|
+
getContentTypeConfiguration: builder.query({
|
852
|
+
query: (uid) => ({
|
853
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
854
|
+
method: "GET"
|
855
|
+
}),
|
856
|
+
transformResponse: (response) => response.data,
|
857
|
+
providesTags: (_result, _error, uid) => [
|
858
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
859
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
860
|
+
]
|
861
|
+
}),
|
862
|
+
getAllContentTypeSettings: builder.query({
|
863
|
+
query: () => "/content-manager/content-types-settings",
|
864
|
+
transformResponse: (response) => response.data,
|
865
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
866
|
+
}),
|
867
|
+
updateContentTypeConfiguration: builder.mutation({
|
868
|
+
query: ({ uid, ...body }) => ({
|
869
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
870
|
+
method: "PUT",
|
871
|
+
data: body
|
872
|
+
}),
|
873
|
+
transformResponse: (response) => response.data,
|
874
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
875
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
876
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
877
|
+
// Is this necessary?
|
878
|
+
{ type: "InitialData" }
|
879
|
+
]
|
880
|
+
})
|
881
|
+
})
|
882
|
+
});
|
883
|
+
const {
|
884
|
+
useGetContentTypeConfigurationQuery,
|
885
|
+
useGetAllContentTypeSettingsQuery,
|
886
|
+
useUpdateContentTypeConfigurationMutation
|
887
|
+
} = contentTypesApi;
|
888
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
889
|
+
const { type } = attribute;
|
890
|
+
if (type === "relation") {
|
891
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
892
|
+
}
|
893
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
894
|
+
};
|
895
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
896
|
+
if (!mainFieldName) {
|
897
|
+
return void 0;
|
898
|
+
}
|
899
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
900
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
901
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
902
|
+
);
|
903
|
+
return {
|
904
|
+
name: mainFieldName,
|
905
|
+
type: mainFieldType ?? "string"
|
906
|
+
};
|
907
|
+
};
|
908
|
+
const DEFAULT_SETTINGS = {
|
909
|
+
bulkable: false,
|
910
|
+
filterable: false,
|
911
|
+
searchable: false,
|
912
|
+
pagination: false,
|
913
|
+
defaultSortBy: "",
|
914
|
+
defaultSortOrder: "asc",
|
915
|
+
mainField: "id",
|
916
|
+
pageSize: 10
|
917
|
+
};
|
918
|
+
const useDocumentLayout = (model) => {
|
919
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
920
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
921
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
780
922
|
const { toggleNotification } = strapiAdmin.useNotification();
|
781
923
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
924
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
782
925
|
const {
|
783
|
-
|
784
|
-
isLoading:
|
785
|
-
|
786
|
-
|
787
|
-
} =
|
788
|
-
const
|
926
|
+
data,
|
927
|
+
isLoading: isLoadingConfigs,
|
928
|
+
error,
|
929
|
+
isFetching: isFetchingConfigs
|
930
|
+
} = useGetContentTypeConfigurationQuery(model);
|
931
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
789
932
|
React__namespace.useEffect(() => {
|
790
933
|
if (error) {
|
791
934
|
toggleNotification({
|
@@ -793,68 +936,322 @@ const useDocument = (args, opts) => {
|
|
793
936
|
message: formatAPIError(error)
|
794
937
|
});
|
795
938
|
}
|
796
|
-
}, [
|
797
|
-
const
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
(document) => {
|
805
|
-
if (!validationSchema) {
|
806
|
-
throw new Error(
|
807
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
808
|
-
);
|
809
|
-
}
|
810
|
-
try {
|
811
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
812
|
-
return null;
|
813
|
-
} catch (error2) {
|
814
|
-
if (error2 instanceof yup.ValidationError) {
|
815
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
816
|
-
}
|
817
|
-
throw error2;
|
818
|
-
}
|
939
|
+
}, [error, formatAPIError, toggleNotification]);
|
940
|
+
const editLayout = React__namespace.useMemo(
|
941
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
942
|
+
layout: [],
|
943
|
+
components: {},
|
944
|
+
metadatas: {},
|
945
|
+
options: {},
|
946
|
+
settings: DEFAULT_SETTINGS
|
819
947
|
},
|
820
|
-
[
|
948
|
+
[data, isLoading, schemas, schema, components]
|
949
|
+
);
|
950
|
+
const listLayout = React__namespace.useMemo(() => {
|
951
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
952
|
+
layout: [],
|
953
|
+
metadatas: {},
|
954
|
+
options: {},
|
955
|
+
settings: DEFAULT_SETTINGS
|
956
|
+
};
|
957
|
+
}, [data, isLoading, schemas, schema, components]);
|
958
|
+
const { layout: edit } = React__namespace.useMemo(
|
959
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
960
|
+
layout: editLayout,
|
961
|
+
query
|
962
|
+
}),
|
963
|
+
[editLayout, query, runHookWaterfall]
|
821
964
|
);
|
822
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
823
965
|
return {
|
824
|
-
|
825
|
-
document: data?.data,
|
826
|
-
meta: data?.meta,
|
966
|
+
error,
|
827
967
|
isLoading,
|
828
|
-
|
829
|
-
|
968
|
+
edit,
|
969
|
+
list: listLayout
|
830
970
|
};
|
831
971
|
};
|
832
|
-
const
|
833
|
-
const {
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
972
|
+
const useDocLayout = () => {
|
973
|
+
const { model } = useDoc();
|
974
|
+
return useDocumentLayout(model);
|
975
|
+
};
|
976
|
+
const formatEditLayout = (data, {
|
977
|
+
schemas,
|
978
|
+
schema,
|
979
|
+
components
|
980
|
+
}) => {
|
981
|
+
let currentPanelIndex = 0;
|
982
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
983
|
+
data.contentType.layouts.edit,
|
984
|
+
schema?.attributes,
|
985
|
+
data.contentType.metadatas,
|
986
|
+
{ configurations: data.components, schemas: components },
|
987
|
+
schemas
|
988
|
+
).reduce((panels, row) => {
|
989
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
990
|
+
panels.push([row]);
|
991
|
+
currentPanelIndex += 2;
|
992
|
+
} else {
|
993
|
+
if (!panels[currentPanelIndex]) {
|
994
|
+
panels.push([row]);
|
995
|
+
} else {
|
996
|
+
panels[currentPanelIndex].push(row);
|
997
|
+
}
|
998
|
+
}
|
999
|
+
return panels;
|
1000
|
+
}, []);
|
1001
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1002
|
+
(acc, [uid, configuration]) => {
|
1003
|
+
acc[uid] = {
|
1004
|
+
layout: convertEditLayoutToFieldLayouts(
|
1005
|
+
configuration.layouts.edit,
|
1006
|
+
components[uid].attributes,
|
1007
|
+
configuration.metadatas,
|
1008
|
+
{ configurations: data.components, schemas: components }
|
1009
|
+
),
|
1010
|
+
settings: {
|
1011
|
+
...configuration.settings,
|
1012
|
+
icon: components[uid].info.icon,
|
1013
|
+
displayName: components[uid].info.displayName
|
1014
|
+
}
|
1015
|
+
};
|
1016
|
+
return acc;
|
1017
|
+
},
|
1018
|
+
{}
|
1019
|
+
);
|
1020
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1021
|
+
(acc, [attribute, metadata]) => {
|
1022
|
+
return {
|
1023
|
+
...acc,
|
1024
|
+
[attribute]: metadata.edit
|
1025
|
+
};
|
1026
|
+
},
|
1027
|
+
{}
|
1028
|
+
);
|
1029
|
+
return {
|
1030
|
+
layout: panelledEditAttributes,
|
1031
|
+
components: componentEditAttributes,
|
1032
|
+
metadatas: editMetadatas,
|
1033
|
+
settings: {
|
1034
|
+
...data.contentType.settings,
|
1035
|
+
displayName: schema?.info.displayName
|
1036
|
+
},
|
1037
|
+
options: {
|
1038
|
+
...schema?.options,
|
1039
|
+
...schema?.pluginOptions,
|
1040
|
+
...data.contentType.options
|
1041
|
+
}
|
1042
|
+
};
|
1043
|
+
};
|
1044
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1045
|
+
return rows.map(
|
1046
|
+
(row) => row.map((field) => {
|
1047
|
+
const attribute = attributes[field.name];
|
1048
|
+
if (!attribute) {
|
1049
|
+
return null;
|
1050
|
+
}
|
1051
|
+
const { edit: metadata } = metadatas[field.name];
|
1052
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1053
|
+
return {
|
1054
|
+
attribute,
|
1055
|
+
disabled: !metadata.editable,
|
1056
|
+
hint: metadata.description,
|
1057
|
+
label: metadata.label ?? "",
|
1058
|
+
name: field.name,
|
1059
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1060
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1061
|
+
schemas,
|
1062
|
+
components: components?.schemas ?? {}
|
1063
|
+
}),
|
1064
|
+
placeholder: metadata.placeholder ?? "",
|
1065
|
+
required: attribute.required ?? false,
|
1066
|
+
size: field.size,
|
1067
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1068
|
+
visible: metadata.visible ?? true,
|
1069
|
+
type: attribute.type
|
1070
|
+
};
|
1071
|
+
}).filter((field) => field !== null)
|
1072
|
+
);
|
1073
|
+
};
|
1074
|
+
const formatListLayout = (data, {
|
1075
|
+
schemas,
|
1076
|
+
schema,
|
1077
|
+
components
|
1078
|
+
}) => {
|
1079
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1080
|
+
(acc, [attribute, metadata]) => {
|
1081
|
+
return {
|
1082
|
+
...acc,
|
1083
|
+
[attribute]: metadata.list
|
1084
|
+
};
|
1085
|
+
},
|
1086
|
+
{}
|
1087
|
+
);
|
1088
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1089
|
+
data.contentType.layouts.list,
|
1090
|
+
schema?.attributes,
|
1091
|
+
listMetadatas,
|
1092
|
+
{ configurations: data.components, schemas: components },
|
1093
|
+
schemas
|
1094
|
+
);
|
1095
|
+
return {
|
1096
|
+
layout: listAttributes,
|
1097
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1098
|
+
metadatas: listMetadatas,
|
1099
|
+
options: {
|
1100
|
+
...schema?.options,
|
1101
|
+
...schema?.pluginOptions,
|
1102
|
+
...data.contentType.options
|
1103
|
+
}
|
1104
|
+
};
|
1105
|
+
};
|
1106
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1107
|
+
return columns.map((name) => {
|
1108
|
+
const attribute = attributes[name];
|
1109
|
+
if (!attribute) {
|
1110
|
+
return null;
|
1111
|
+
}
|
1112
|
+
const metadata = metadatas[name];
|
1113
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1114
|
+
return {
|
1115
|
+
attribute,
|
1116
|
+
label: metadata.label ?? "",
|
1117
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1118
|
+
schemas,
|
1119
|
+
components: components?.schemas ?? {}
|
1120
|
+
}),
|
1121
|
+
name,
|
1122
|
+
searchable: metadata.searchable ?? true,
|
1123
|
+
sortable: metadata.sortable ?? true
|
1124
|
+
};
|
1125
|
+
}).filter((field) => field !== null);
|
1126
|
+
};
|
1127
|
+
const useDocument = (args, opts) => {
|
1128
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1129
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1130
|
+
const {
|
1131
|
+
currentData: data,
|
1132
|
+
isLoading: isLoadingDocument,
|
1133
|
+
isFetching: isFetchingDocument,
|
1134
|
+
error
|
1135
|
+
} = useGetDocumentQuery(args, {
|
1136
|
+
...opts,
|
1137
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1138
|
+
});
|
1139
|
+
const {
|
1140
|
+
components,
|
1141
|
+
schema,
|
1142
|
+
schemas,
|
1143
|
+
isLoading: isLoadingSchema
|
1144
|
+
} = useContentTypeSchema(args.model);
|
1145
|
+
React__namespace.useEffect(() => {
|
1146
|
+
if (error) {
|
1147
|
+
toggleNotification({
|
1148
|
+
type: "danger",
|
1149
|
+
message: formatAPIError(error)
|
1150
|
+
});
|
1151
|
+
}
|
1152
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1153
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1154
|
+
if (!schema) {
|
1155
|
+
return null;
|
1156
|
+
}
|
1157
|
+
return createYupSchema(schema.attributes, components);
|
1158
|
+
}, [schema, components]);
|
1159
|
+
const validate = React__namespace.useCallback(
|
1160
|
+
(document) => {
|
1161
|
+
if (!validationSchema) {
|
1162
|
+
throw new Error(
|
1163
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1164
|
+
);
|
1165
|
+
}
|
1166
|
+
try {
|
1167
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1168
|
+
return null;
|
1169
|
+
} catch (error2) {
|
1170
|
+
if (error2 instanceof yup.ValidationError) {
|
1171
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1172
|
+
}
|
1173
|
+
throw error2;
|
1174
|
+
}
|
1175
|
+
},
|
1176
|
+
[validationSchema]
|
1177
|
+
);
|
1178
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1179
|
+
const hasError = !!error;
|
1180
|
+
return {
|
1181
|
+
components,
|
1182
|
+
document: data?.data,
|
1183
|
+
meta: data?.meta,
|
1184
|
+
isLoading,
|
1185
|
+
hasError,
|
1186
|
+
schema,
|
1187
|
+
schemas,
|
1188
|
+
validate
|
1189
|
+
};
|
1190
|
+
};
|
1191
|
+
const useDoc = () => {
|
1192
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1193
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1194
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1195
|
+
if (!collectionType) {
|
1196
|
+
throw new Error("Could not find collectionType in url params");
|
1197
|
+
}
|
1198
|
+
if (!slug) {
|
840
1199
|
throw new Error("Could not find model in url params");
|
841
1200
|
}
|
1201
|
+
const document = useDocument(
|
1202
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1203
|
+
{
|
1204
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1205
|
+
}
|
1206
|
+
);
|
1207
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
842
1208
|
return {
|
843
1209
|
collectionType,
|
844
1210
|
model: slug,
|
845
|
-
id:
|
846
|
-
...
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
1211
|
+
id: returnId,
|
1212
|
+
...document
|
1213
|
+
};
|
1214
|
+
};
|
1215
|
+
const useContentManagerContext = () => {
|
1216
|
+
const {
|
1217
|
+
collectionType,
|
1218
|
+
model,
|
1219
|
+
id,
|
1220
|
+
components,
|
1221
|
+
isLoading: isLoadingDoc,
|
1222
|
+
schema,
|
1223
|
+
schemas
|
1224
|
+
} = useDoc();
|
1225
|
+
const layout = useDocumentLayout(model);
|
1226
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1227
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1228
|
+
const slug = model;
|
1229
|
+
const isCreatingEntry = id === "create";
|
1230
|
+
useContentTypeSchema();
|
1231
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1232
|
+
const error = layout.error;
|
1233
|
+
return {
|
1234
|
+
error,
|
1235
|
+
isLoading,
|
1236
|
+
// Base metadata
|
1237
|
+
model,
|
1238
|
+
collectionType,
|
1239
|
+
id,
|
1240
|
+
slug,
|
1241
|
+
isCreatingEntry,
|
1242
|
+
isSingleType,
|
1243
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1244
|
+
// All schema infos
|
1245
|
+
components,
|
1246
|
+
contentType: schema,
|
1247
|
+
contentTypes: schemas,
|
1248
|
+
// Form state
|
1249
|
+
form,
|
1250
|
+
// layout infos
|
1251
|
+
layout
|
852
1252
|
};
|
853
1253
|
};
|
854
1254
|
const prefixPluginTranslations = (trad, pluginId) => {
|
855
|
-
if (!pluginId) {
|
856
|
-
throw new TypeError("pluginId can't be empty");
|
857
|
-
}
|
858
1255
|
return Object.keys(trad).reduce((acc, current) => {
|
859
1256
|
acc[`${pluginId}.${current}`] = trad[current];
|
860
1257
|
return acc;
|
@@ -870,6 +1267,8 @@ const useDocumentActions = () => {
|
|
870
1267
|
const { formatMessage } = reactIntl.useIntl();
|
871
1268
|
const { trackUsage } = strapiAdmin.useTracking();
|
872
1269
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1270
|
+
const navigate = reactRouterDom.useNavigate();
|
1271
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
873
1272
|
const [deleteDocument] = useDeleteDocumentMutation();
|
874
1273
|
const _delete = React__namespace.useCallback(
|
875
1274
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1184,6 +1583,7 @@ const useDocumentActions = () => {
|
|
1184
1583
|
defaultMessage: "Saved document"
|
1185
1584
|
})
|
1186
1585
|
});
|
1586
|
+
setCurrentStep("contentManager.success");
|
1187
1587
|
return res.data;
|
1188
1588
|
} catch (err) {
|
1189
1589
|
toggleNotification({
|
@@ -1205,7 +1605,6 @@ const useDocumentActions = () => {
|
|
1205
1605
|
sourceId
|
1206
1606
|
});
|
1207
1607
|
if ("error" in res) {
|
1208
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1209
1608
|
return { error: res.error };
|
1210
1609
|
}
|
1211
1610
|
toggleNotification({
|
@@ -1224,7 +1623,7 @@ const useDocumentActions = () => {
|
|
1224
1623
|
throw err;
|
1225
1624
|
}
|
1226
1625
|
},
|
1227
|
-
[autoCloneDocument,
|
1626
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1228
1627
|
);
|
1229
1628
|
const [cloneDocument] = useCloneDocumentMutation();
|
1230
1629
|
const clone = React__namespace.useCallback(
|
@@ -1250,6 +1649,7 @@ const useDocumentActions = () => {
|
|
1250
1649
|
defaultMessage: "Cloned document"
|
1251
1650
|
})
|
1252
1651
|
});
|
1652
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1253
1653
|
return res.data;
|
1254
1654
|
} catch (err) {
|
1255
1655
|
toggleNotification({
|
@@ -1260,7 +1660,7 @@ const useDocumentActions = () => {
|
|
1260
1660
|
throw err;
|
1261
1661
|
}
|
1262
1662
|
},
|
1263
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1663
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1264
1664
|
);
|
1265
1665
|
const [getDoc] = useLazyGetDocumentQuery();
|
1266
1666
|
const getDocument = React__namespace.useCallback(
|
@@ -1285,10 +1685,10 @@ const useDocumentActions = () => {
|
|
1285
1685
|
update
|
1286
1686
|
};
|
1287
1687
|
};
|
1288
|
-
const ProtectedHistoryPage =
|
1289
|
-
() => Promise.resolve().then(() => require("./History-
|
1688
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1689
|
+
() => Promise.resolve().then(() => require("./History-BGGn9JGY.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1290
1690
|
);
|
1291
|
-
const routes$
|
1691
|
+
const routes$2 = [
|
1292
1692
|
{
|
1293
1693
|
path: ":collectionType/:slug/:id/history",
|
1294
1694
|
Component: ProtectedHistoryPage
|
@@ -1298,32 +1698,45 @@ const routes$1 = [
|
|
1298
1698
|
Component: ProtectedHistoryPage
|
1299
1699
|
}
|
1300
1700
|
];
|
1701
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1702
|
+
() => Promise.resolve().then(() => require("./Preview-Bx1WfmKJ.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1703
|
+
);
|
1704
|
+
const routes$1 = [
|
1705
|
+
{
|
1706
|
+
path: ":collectionType/:slug/:id/preview",
|
1707
|
+
Component: ProtectedPreviewPage
|
1708
|
+
},
|
1709
|
+
{
|
1710
|
+
path: ":collectionType/:slug/preview",
|
1711
|
+
Component: ProtectedPreviewPage
|
1712
|
+
}
|
1713
|
+
];
|
1301
1714
|
const ProtectedEditViewPage = React.lazy(
|
1302
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1715
|
+
() => Promise.resolve().then(() => require("./EditViewPage-pyqEgLgP.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1303
1716
|
);
|
1304
1717
|
const ProtectedListViewPage = React.lazy(
|
1305
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1718
|
+
() => Promise.resolve().then(() => require("./ListViewPage-DtAHWFMV.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1306
1719
|
);
|
1307
1720
|
const ProtectedListConfiguration = React.lazy(
|
1308
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1721
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-D3Avyi4t.js")).then((mod) => ({
|
1309
1722
|
default: mod.ProtectedListConfiguration
|
1310
1723
|
}))
|
1311
1724
|
);
|
1312
1725
|
const ProtectedEditConfigurationPage = React.lazy(
|
1313
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1726
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BeikGxvq.js")).then((mod) => ({
|
1314
1727
|
default: mod.ProtectedEditConfigurationPage
|
1315
1728
|
}))
|
1316
1729
|
);
|
1317
1730
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1318
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1731
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-Cjr64OS0.js")).then((mod) => ({
|
1319
1732
|
default: mod.ProtectedComponentConfigurationPage
|
1320
1733
|
}))
|
1321
1734
|
);
|
1322
1735
|
const NoPermissions = React.lazy(
|
1323
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1736
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-j7oulOpl.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1324
1737
|
);
|
1325
1738
|
const NoContentType = React.lazy(
|
1326
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1739
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-BFjWZX0i.js")).then((mod) => ({ default: mod.NoContentType }))
|
1327
1740
|
);
|
1328
1741
|
const CollectionTypePages = () => {
|
1329
1742
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1335,7 +1748,7 @@ const CollectionTypePages = () => {
|
|
1335
1748
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1336
1749
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1337
1750
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1338
|
-
const LIST_PATH = `/content-manager
|
1751
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1339
1752
|
const routes = [
|
1340
1753
|
{
|
1341
1754
|
path: LIST_RELATIVE_PATH,
|
@@ -1369,6 +1782,7 @@ const routes = [
|
|
1369
1782
|
path: "no-content-types",
|
1370
1783
|
Component: NoContentType
|
1371
1784
|
},
|
1785
|
+
...routes$2,
|
1372
1786
|
...routes$1
|
1373
1787
|
];
|
1374
1788
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1437,12 +1851,14 @@ const DocumentActionButton = (action) => {
|
|
1437
1851
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1438
1852
|
designSystem.Button,
|
1439
1853
|
{
|
1440
|
-
flex:
|
1854
|
+
flex: "auto",
|
1441
1855
|
startIcon: action.icon,
|
1442
1856
|
disabled: action.disabled,
|
1443
1857
|
onClick: handleClick(action),
|
1444
1858
|
justifyContent: "center",
|
1445
1859
|
variant: action.variant || "default",
|
1860
|
+
paddingTop: "7px",
|
1861
|
+
paddingBottom: "7px",
|
1446
1862
|
children: action.label
|
1447
1863
|
}
|
1448
1864
|
),
|
@@ -1450,7 +1866,7 @@ const DocumentActionButton = (action) => {
|
|
1450
1866
|
DocumentActionConfirmDialog,
|
1451
1867
|
{
|
1452
1868
|
...action.dialog,
|
1453
|
-
variant: action.variant,
|
1869
|
+
variant: action.dialog?.variant ?? action.variant,
|
1454
1870
|
isOpen: dialogId === action.id,
|
1455
1871
|
onClose: handleClose
|
1456
1872
|
}
|
@@ -1507,9 +1923,9 @@ const DocumentActionsMenu = ({
|
|
1507
1923
|
disabled: isDisabled,
|
1508
1924
|
size: "S",
|
1509
1925
|
endIcon: null,
|
1510
|
-
paddingTop: "
|
1511
|
-
paddingLeft: "
|
1512
|
-
paddingRight: "
|
1926
|
+
paddingTop: "4px",
|
1927
|
+
paddingLeft: "7px",
|
1928
|
+
paddingRight: "7px",
|
1513
1929
|
variant,
|
1514
1930
|
children: [
|
1515
1931
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1520,7 +1936,7 @@ const DocumentActionsMenu = ({
|
|
1520
1936
|
]
|
1521
1937
|
}
|
1522
1938
|
),
|
1523
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1939
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1524
1940
|
actions2.map((action) => {
|
1525
1941
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1526
1942
|
designSystem.Menu.Item,
|
@@ -1528,28 +1944,25 @@ const DocumentActionsMenu = ({
|
|
1528
1944
|
disabled: action.disabled,
|
1529
1945
|
onSelect: handleClick(action),
|
1530
1946
|
display: "block",
|
1531
|
-
children: /* @__PURE__ */ jsxRuntime.
|
1532
|
-
|
1533
|
-
|
1534
|
-
action.
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
}
|
1551
|
-
)
|
1552
|
-
] })
|
1947
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1948
|
+
designSystem.Flex,
|
1949
|
+
{
|
1950
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1951
|
+
gap: 2,
|
1952
|
+
tag: "span",
|
1953
|
+
children: [
|
1954
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1955
|
+
designSystem.Flex,
|
1956
|
+
{
|
1957
|
+
tag: "span",
|
1958
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1959
|
+
children: action.icon
|
1960
|
+
}
|
1961
|
+
),
|
1962
|
+
action.label
|
1963
|
+
]
|
1964
|
+
}
|
1965
|
+
) })
|
1553
1966
|
},
|
1554
1967
|
action.id
|
1555
1968
|
);
|
@@ -1591,10 +2004,22 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1591
2004
|
return "primary600";
|
1592
2005
|
}
|
1593
2006
|
};
|
1594
|
-
const
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
2007
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
2008
|
+
switch (variant) {
|
2009
|
+
case "danger":
|
2010
|
+
return "danger600";
|
2011
|
+
case "secondary":
|
2012
|
+
return "neutral500";
|
2013
|
+
case "success":
|
2014
|
+
return "success600";
|
2015
|
+
default:
|
2016
|
+
return "primary600";
|
2017
|
+
}
|
2018
|
+
};
|
2019
|
+
const DocumentActionConfirmDialog = ({
|
2020
|
+
onClose,
|
2021
|
+
onCancel,
|
2022
|
+
onConfirm,
|
1598
2023
|
title,
|
1599
2024
|
content,
|
1600
2025
|
isOpen,
|
@@ -1613,22 +2038,20 @@ const DocumentActionConfirmDialog = ({
|
|
1613
2038
|
}
|
1614
2039
|
onClose();
|
1615
2040
|
};
|
1616
|
-
return /* @__PURE__ */ jsxRuntime.
|
1617
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1618
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1619
|
-
|
1620
|
-
{
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
)
|
1631
|
-
] });
|
2041
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2042
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2043
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
2044
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2045
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
2046
|
+
id: "app.components.Button.cancel",
|
2047
|
+
defaultMessage: "Cancel"
|
2048
|
+
}) }) }),
|
2049
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
2050
|
+
id: "app.components.Button.confirm",
|
2051
|
+
defaultMessage: "Confirm"
|
2052
|
+
}) })
|
2053
|
+
] })
|
2054
|
+
] }) });
|
1632
2055
|
};
|
1633
2056
|
const DocumentActionModal = ({
|
1634
2057
|
isOpen,
|
@@ -1638,34 +2061,29 @@ const DocumentActionModal = ({
|
|
1638
2061
|
content: Content,
|
1639
2062
|
onModalClose
|
1640
2063
|
}) => {
|
1641
|
-
const id = React__namespace.useId();
|
1642
|
-
if (!isOpen) {
|
1643
|
-
return null;
|
1644
|
-
}
|
1645
2064
|
const handleClose = () => {
|
1646
2065
|
if (onClose) {
|
1647
2066
|
onClose();
|
1648
2067
|
}
|
1649
2068
|
onModalClose();
|
1650
2069
|
};
|
1651
|
-
return /* @__PURE__ */ jsxRuntime.
|
1652
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1653
|
-
|
1654
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
] });
|
2070
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
2071
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
2072
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
2073
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
2074
|
+
] }) });
|
2075
|
+
};
|
2076
|
+
const transformData = (data) => {
|
2077
|
+
if (Array.isArray(data)) {
|
2078
|
+
return data.map(transformData);
|
2079
|
+
}
|
2080
|
+
if (typeof data === "object" && data !== null) {
|
2081
|
+
if ("apiData" in data) {
|
2082
|
+
return data.apiData;
|
2083
|
+
}
|
2084
|
+
return mapValues__default.default(transformData)(data);
|
2085
|
+
}
|
2086
|
+
return data;
|
1669
2087
|
};
|
1670
2088
|
const PublishAction$1 = ({
|
1671
2089
|
activeTab,
|
@@ -1679,13 +2097,17 @@ const PublishAction$1 = ({
|
|
1679
2097
|
const navigate = reactRouterDom.useNavigate();
|
1680
2098
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1681
2099
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2100
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1682
2101
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
1683
2102
|
const { formatMessage } = reactIntl.useIntl();
|
1684
|
-
const { canPublish
|
1685
|
-
"PublishAction",
|
1686
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1687
|
-
);
|
2103
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1688
2104
|
const { publish } = useDocumentActions();
|
2105
|
+
const [
|
2106
|
+
countDraftRelations,
|
2107
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
2108
|
+
] = useLazyGetDraftRelationCountQuery();
|
2109
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
2110
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1689
2111
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1690
2112
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1691
2113
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1694,10 +2116,105 @@ const PublishAction$1 = ({
|
|
1694
2116
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1695
2117
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1696
2118
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
2119
|
+
React__namespace.useEffect(() => {
|
2120
|
+
if (isErrorDraftRelations) {
|
2121
|
+
toggleNotification({
|
2122
|
+
type: "danger",
|
2123
|
+
message: formatMessage({
|
2124
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
2125
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
2126
|
+
})
|
2127
|
+
});
|
2128
|
+
}
|
2129
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
2130
|
+
React__namespace.useEffect(() => {
|
2131
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
2132
|
+
const extractDraftRelations = (data) => {
|
2133
|
+
const relations = data.connect || [];
|
2134
|
+
relations.forEach((relation) => {
|
2135
|
+
if (relation.status === "draft") {
|
2136
|
+
localDraftRelations.add(relation.id);
|
2137
|
+
}
|
2138
|
+
});
|
2139
|
+
};
|
2140
|
+
const traverseAndExtract = (data) => {
|
2141
|
+
Object.entries(data).forEach(([key, value]) => {
|
2142
|
+
if (key === "connect" && Array.isArray(value)) {
|
2143
|
+
extractDraftRelations({ connect: value });
|
2144
|
+
} else if (typeof value === "object" && value !== null) {
|
2145
|
+
traverseAndExtract(value);
|
2146
|
+
}
|
2147
|
+
});
|
2148
|
+
};
|
2149
|
+
if (!documentId || modified) {
|
2150
|
+
traverseAndExtract(formValues);
|
2151
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
2152
|
+
}
|
2153
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
2154
|
+
React__namespace.useEffect(() => {
|
2155
|
+
if (!document || !document.documentId || isListView) {
|
2156
|
+
return;
|
2157
|
+
}
|
2158
|
+
const fetchDraftRelationsCount = async () => {
|
2159
|
+
const { data, error } = await countDraftRelations({
|
2160
|
+
collectionType,
|
2161
|
+
model,
|
2162
|
+
documentId,
|
2163
|
+
params
|
2164
|
+
});
|
2165
|
+
if (error) {
|
2166
|
+
throw error;
|
2167
|
+
}
|
2168
|
+
if (data) {
|
2169
|
+
setServerCountOfDraftRelations(data.data);
|
2170
|
+
}
|
2171
|
+
};
|
2172
|
+
fetchDraftRelationsCount();
|
2173
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1697
2174
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1698
2175
|
if (!schema?.options?.draftAndPublish) {
|
1699
2176
|
return null;
|
1700
2177
|
}
|
2178
|
+
const performPublish = async () => {
|
2179
|
+
setSubmitting(true);
|
2180
|
+
try {
|
2181
|
+
const { errors } = await validate(true, {
|
2182
|
+
status: "published"
|
2183
|
+
});
|
2184
|
+
if (errors) {
|
2185
|
+
toggleNotification({
|
2186
|
+
type: "danger",
|
2187
|
+
message: formatMessage({
|
2188
|
+
id: "content-manager.validation.error",
|
2189
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2190
|
+
})
|
2191
|
+
});
|
2192
|
+
return;
|
2193
|
+
}
|
2194
|
+
const res = await publish(
|
2195
|
+
{
|
2196
|
+
collectionType,
|
2197
|
+
model,
|
2198
|
+
documentId,
|
2199
|
+
params
|
2200
|
+
},
|
2201
|
+
transformData(formValues)
|
2202
|
+
);
|
2203
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2204
|
+
navigate({
|
2205
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2206
|
+
search: rawQuery
|
2207
|
+
});
|
2208
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2209
|
+
setErrors(formatValidationErrors(res.error));
|
2210
|
+
}
|
2211
|
+
} finally {
|
2212
|
+
setSubmitting(false);
|
2213
|
+
}
|
2214
|
+
};
|
2215
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
2216
|
+
const enableDraftRelationsCount = false;
|
2217
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1701
2218
|
return {
|
1702
2219
|
/**
|
1703
2220
|
* Disabled when:
|
@@ -1707,49 +2224,36 @@ const PublishAction$1 = ({
|
|
1707
2224
|
* - the document is already published & not modified
|
1708
2225
|
* - the document is being created & not modified
|
1709
2226
|
* - the user doesn't have the permission to publish
|
1710
|
-
* - the user doesn't have the permission to create a new document
|
1711
|
-
* - the user doesn't have the permission to update the document
|
1712
2227
|
*/
|
1713
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2228
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1714
2229
|
label: formatMessage({
|
1715
2230
|
id: "app.utils.publish",
|
1716
2231
|
defaultMessage: "Publish"
|
1717
2232
|
}),
|
1718
2233
|
onClick: async () => {
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
documentId,
|
1737
|
-
params
|
1738
|
-
},
|
1739
|
-
formValues
|
1740
|
-
);
|
1741
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1742
|
-
navigate({
|
1743
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1744
|
-
search: rawQuery
|
1745
|
-
});
|
1746
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1747
|
-
setErrors(formatValidationErrors(res.error));
|
2234
|
+
await performPublish();
|
2235
|
+
},
|
2236
|
+
dialog: hasDraftRelations ? {
|
2237
|
+
type: "dialog",
|
2238
|
+
variant: "danger",
|
2239
|
+
footer: null,
|
2240
|
+
title: formatMessage({
|
2241
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
2242
|
+
defaultMessage: "Confirmation"
|
2243
|
+
}),
|
2244
|
+
content: formatMessage(
|
2245
|
+
{
|
2246
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2247
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
2248
|
+
},
|
2249
|
+
{
|
2250
|
+
count: totalDraftRelations
|
1748
2251
|
}
|
1749
|
-
|
1750
|
-
|
2252
|
+
),
|
2253
|
+
onConfirm: async () => {
|
2254
|
+
await performPublish();
|
1751
2255
|
}
|
1752
|
-
}
|
2256
|
+
} : void 0
|
1753
2257
|
};
|
1754
2258
|
};
|
1755
2259
|
PublishAction$1.type = "publish";
|
@@ -1765,10 +2269,6 @@ const UpdateAction = ({
|
|
1765
2269
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1766
2270
|
const isCloning = cloneMatch !== null;
|
1767
2271
|
const { formatMessage } = reactIntl.useIntl();
|
1768
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1769
|
-
canCreate: canCreate2,
|
1770
|
-
canUpdate: canUpdate2
|
1771
|
-
}));
|
1772
2272
|
const { create, update, clone } = useDocumentActions();
|
1773
2273
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1774
2274
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1785,10 +2285,8 @@ const UpdateAction = ({
|
|
1785
2285
|
* - the form is submitting
|
1786
2286
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1787
2287
|
* - the active tab is the published tab
|
1788
|
-
* - the user doesn't have the permission to create a new document
|
1789
|
-
* - the user doesn't have the permission to update the document
|
1790
2288
|
*/
|
1791
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
2289
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1792
2290
|
label: formatMessage({
|
1793
2291
|
id: "content-manager.containers.Edit.save",
|
1794
2292
|
defaultMessage: "Save"
|
@@ -1796,7 +2294,9 @@ const UpdateAction = ({
|
|
1796
2294
|
onClick: async () => {
|
1797
2295
|
setSubmitting(true);
|
1798
2296
|
try {
|
1799
|
-
const { errors } = await validate(
|
2297
|
+
const { errors } = await validate(true, {
|
2298
|
+
status: "draft"
|
2299
|
+
});
|
1800
2300
|
if (errors) {
|
1801
2301
|
toggleNotification({
|
1802
2302
|
type: "danger",
|
@@ -1814,13 +2314,16 @@ const UpdateAction = ({
|
|
1814
2314
|
documentId: cloneMatch.params.origin,
|
1815
2315
|
params
|
1816
2316
|
},
|
1817
|
-
document
|
2317
|
+
transformData(document)
|
1818
2318
|
);
|
1819
2319
|
if ("data" in res) {
|
1820
|
-
navigate(
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
2320
|
+
navigate(
|
2321
|
+
{
|
2322
|
+
pathname: `../${res.data.documentId}`,
|
2323
|
+
search: rawQuery
|
2324
|
+
},
|
2325
|
+
{ relative: "path" }
|
2326
|
+
);
|
1824
2327
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1825
2328
|
setErrors(formatValidationErrors(res.error));
|
1826
2329
|
}
|
@@ -1832,7 +2335,7 @@ const UpdateAction = ({
|
|
1832
2335
|
documentId,
|
1833
2336
|
params
|
1834
2337
|
},
|
1835
|
-
document
|
2338
|
+
transformData(document)
|
1836
2339
|
);
|
1837
2340
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1838
2341
|
setErrors(formatValidationErrors(res.error));
|
@@ -1845,13 +2348,16 @@ const UpdateAction = ({
|
|
1845
2348
|
model,
|
1846
2349
|
params
|
1847
2350
|
},
|
1848
|
-
document
|
2351
|
+
transformData(document)
|
1849
2352
|
);
|
1850
2353
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1851
|
-
navigate(
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
2354
|
+
navigate(
|
2355
|
+
{
|
2356
|
+
pathname: `../${res.data.documentId}`,
|
2357
|
+
search: rawQuery
|
2358
|
+
},
|
2359
|
+
{ replace: true, relative: "path" }
|
2360
|
+
);
|
1855
2361
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1856
2362
|
setErrors(formatValidationErrors(res.error));
|
1857
2363
|
}
|
@@ -1883,10 +2389,8 @@ const UnpublishAction$1 = ({
|
|
1883
2389
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1884
2390
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1885
2391
|
const isDocumentModified = document?.status === "modified";
|
1886
|
-
const handleChange = (
|
1887
|
-
|
1888
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1889
|
-
}
|
2392
|
+
const handleChange = (value) => {
|
2393
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1890
2394
|
};
|
1891
2395
|
if (!schema?.options?.draftAndPublish) {
|
1892
2396
|
return null;
|
@@ -1897,7 +2401,7 @@ const UnpublishAction$1 = ({
|
|
1897
2401
|
id: "app.utils.unpublish",
|
1898
2402
|
defaultMessage: "Unpublish"
|
1899
2403
|
}),
|
1900
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2404
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1901
2405
|
onClick: async () => {
|
1902
2406
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1903
2407
|
if (!documentId) {
|
@@ -1936,40 +2440,24 @@ const UnpublishAction$1 = ({
|
|
1936
2440
|
}) })
|
1937
2441
|
] }),
|
1938
2442
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1939
|
-
designSystem.
|
2443
|
+
designSystem.Radio.Group,
|
1940
2444
|
{
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
2445
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2446
|
+
name: "discard-options",
|
2447
|
+
"aria-label": formatMessage({
|
2448
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2449
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2450
|
+
}),
|
2451
|
+
onValueChange: handleChange,
|
1947
2452
|
children: [
|
1948
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1957
|
-
defaultMessage: "Keep draft"
|
1958
|
-
})
|
1959
|
-
}
|
1960
|
-
),
|
1961
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1962
|
-
designSystem.Radio,
|
1963
|
-
{
|
1964
|
-
checked: !shouldKeepDraft,
|
1965
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1966
|
-
name: "discard-options",
|
1967
|
-
children: formatMessage({
|
1968
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1969
|
-
defaultMessage: "Replace draft"
|
1970
|
-
})
|
1971
|
-
}
|
1972
|
-
)
|
2453
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2454
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2455
|
+
defaultMessage: "Keep draft"
|
2456
|
+
}) }),
|
2457
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2458
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2459
|
+
defaultMessage: "Replace draft"
|
2460
|
+
}) })
|
1973
2461
|
]
|
1974
2462
|
}
|
1975
2463
|
)
|
@@ -2025,7 +2513,7 @@ const DiscardAction = ({
|
|
2025
2513
|
id: "content-manager.actions.discard.label",
|
2026
2514
|
defaultMessage: "Discard changes"
|
2027
2515
|
}),
|
2028
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2516
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2029
2517
|
position: ["panel", "table-row"],
|
2030
2518
|
variant: "danger",
|
2031
2519
|
dialog: {
|
@@ -2053,11 +2541,6 @@ const DiscardAction = ({
|
|
2053
2541
|
};
|
2054
2542
|
};
|
2055
2543
|
DiscardAction.type = "discard";
|
2056
|
-
const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
2057
|
-
path {
|
2058
|
-
fill: currentColor;
|
2059
|
-
}
|
2060
|
-
`;
|
2061
2544
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2062
2545
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2063
2546
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2070,7 +2553,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2070
2553
|
});
|
2071
2554
|
const unit = intervals.find((intervalUnit) => {
|
2072
2555
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2073
|
-
});
|
2556
|
+
}) ?? "seconds";
|
2074
2557
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2075
2558
|
const customInterval = customIntervals.find(
|
2076
2559
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2104,9 +2587,13 @@ const getDisplayName = ({
|
|
2104
2587
|
return email ?? "";
|
2105
2588
|
};
|
2106
2589
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2107
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2108
|
-
const statusVariant = status === "draft" ? "
|
2109
|
-
|
2590
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2591
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2592
|
+
const { formatMessage } = reactIntl.useIntl();
|
2593
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2594
|
+
id: `content-manager.containers.List.${status}`,
|
2595
|
+
defaultMessage: capitalise(status)
|
2596
|
+
}) }) });
|
2110
2597
|
};
|
2111
2598
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2112
2599
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2115,23 +2602,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2115
2602
|
id: "content-manager.containers.edit.title.new",
|
2116
2603
|
defaultMessage: "Create an entry"
|
2117
2604
|
}) : documentTitle;
|
2118
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2605
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2119
2606
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2120
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2121
|
-
designSystem.
|
2122
|
-
{
|
2123
|
-
|
2124
|
-
|
2125
|
-
paddingTop: 1,
|
2126
|
-
gap: "80px",
|
2127
|
-
alignItems: "flex-start",
|
2128
|
-
children: [
|
2129
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2130
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2131
|
-
]
|
2132
|
-
}
|
2133
|
-
),
|
2134
|
-
status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2607
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2608
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2609
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2610
|
+
] }),
|
2611
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2135
2612
|
] });
|
2136
2613
|
};
|
2137
2614
|
const HeaderToolbar = () => {
|
@@ -2214,12 +2691,12 @@ const Information = ({ activeTab }) => {
|
|
2214
2691
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2215
2692
|
label: formatMessage({
|
2216
2693
|
id: "content-manager.containers.edit.information.last-published.label",
|
2217
|
-
defaultMessage: "
|
2694
|
+
defaultMessage: "Published"
|
2218
2695
|
}),
|
2219
2696
|
value: formatMessage(
|
2220
2697
|
{
|
2221
2698
|
id: "content-manager.containers.edit.information.last-published.value",
|
2222
|
-
defaultMessage: `
|
2699
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2223
2700
|
},
|
2224
2701
|
{
|
2225
2702
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2232,12 +2709,12 @@ const Information = ({ activeTab }) => {
|
|
2232
2709
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2233
2710
|
label: formatMessage({
|
2234
2711
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2235
|
-
defaultMessage: "
|
2712
|
+
defaultMessage: "Updated"
|
2236
2713
|
}),
|
2237
2714
|
value: formatMessage(
|
2238
2715
|
{
|
2239
2716
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2240
|
-
defaultMessage: `
|
2717
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2241
2718
|
},
|
2242
2719
|
{
|
2243
2720
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2255,12 +2732,12 @@ const Information = ({ activeTab }) => {
|
|
2255
2732
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2256
2733
|
label: formatMessage({
|
2257
2734
|
id: "content-manager.containers.edit.information.document.label",
|
2258
|
-
defaultMessage: "
|
2735
|
+
defaultMessage: "Created"
|
2259
2736
|
}),
|
2260
2737
|
value: formatMessage(
|
2261
2738
|
{
|
2262
2739
|
id: "content-manager.containers.edit.information.document.value",
|
2263
|
-
defaultMessage: `
|
2740
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2264
2741
|
},
|
2265
2742
|
{
|
2266
2743
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2298,25 +2775,77 @@ const Information = ({ activeTab }) => {
|
|
2298
2775
|
);
|
2299
2776
|
};
|
2300
2777
|
const HeaderActions = ({ actions: actions2 }) => {
|
2301
|
-
|
2302
|
-
|
2778
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2779
|
+
const handleClick = (action) => async (e) => {
|
2780
|
+
if (!("options" in action)) {
|
2781
|
+
const { onClick = () => false, dialog, id } = action;
|
2782
|
+
const muteDialog = await onClick(e);
|
2783
|
+
if (dialog && !muteDialog) {
|
2784
|
+
e.preventDefault();
|
2785
|
+
setDialogId(id);
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
};
|
2789
|
+
const handleClose = () => {
|
2790
|
+
setDialogId(null);
|
2791
|
+
};
|
2792
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2793
|
+
if (action.options) {
|
2303
2794
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2304
2795
|
designSystem.SingleSelect,
|
2305
2796
|
{
|
2306
2797
|
size: "S",
|
2307
|
-
disabled: action.disabled,
|
2308
|
-
"aria-label": action.label,
|
2309
2798
|
onChange: action.onSelect,
|
2310
|
-
|
2799
|
+
"aria-label": action.label,
|
2800
|
+
...action,
|
2311
2801
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2312
2802
|
},
|
2313
2803
|
action.id
|
2314
2804
|
);
|
2315
2805
|
} else {
|
2316
|
-
|
2806
|
+
if (action.type === "icon") {
|
2807
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2808
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2809
|
+
designSystem.IconButton,
|
2810
|
+
{
|
2811
|
+
disabled: action.disabled,
|
2812
|
+
label: action.label,
|
2813
|
+
size: "S",
|
2814
|
+
onClick: handleClick(action),
|
2815
|
+
children: action.icon
|
2816
|
+
}
|
2817
|
+
),
|
2818
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2819
|
+
HeaderActionDialog,
|
2820
|
+
{
|
2821
|
+
...action.dialog,
|
2822
|
+
isOpen: dialogId === action.id,
|
2823
|
+
onClose: handleClose
|
2824
|
+
}
|
2825
|
+
) : null
|
2826
|
+
] }, action.id);
|
2827
|
+
}
|
2317
2828
|
}
|
2318
2829
|
}) });
|
2319
2830
|
};
|
2831
|
+
const HeaderActionDialog = ({
|
2832
|
+
onClose,
|
2833
|
+
onCancel,
|
2834
|
+
title,
|
2835
|
+
content: Content,
|
2836
|
+
isOpen
|
2837
|
+
}) => {
|
2838
|
+
const handleClose = async () => {
|
2839
|
+
if (onCancel) {
|
2840
|
+
await onCancel();
|
2841
|
+
}
|
2842
|
+
onClose();
|
2843
|
+
};
|
2844
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2845
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2846
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2847
|
+
] }) });
|
2848
|
+
};
|
2320
2849
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2321
2850
|
const navigate = reactRouterDom.useNavigate();
|
2322
2851
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2357,12 +2886,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2357
2886
|
const { delete: deleteAction } = useDocumentActions();
|
2358
2887
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2359
2888
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2889
|
+
const isLocalized = document?.locale != null;
|
2360
2890
|
return {
|
2361
2891
|
disabled: !canDelete || !document,
|
2362
|
-
label: formatMessage(
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2892
|
+
label: formatMessage(
|
2893
|
+
{
|
2894
|
+
id: "content-manager.actions.delete.label",
|
2895
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2896
|
+
},
|
2897
|
+
{ isLocalized }
|
2898
|
+
),
|
2366
2899
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2367
2900
|
dialog: {
|
2368
2901
|
type: "dialog",
|
@@ -2452,7 +2985,7 @@ const ActionsPanel = () => {
|
|
2452
2985
|
return {
|
2453
2986
|
title: formatMessage({
|
2454
2987
|
id: "content-manager.containers.edit.panels.default.title",
|
2455
|
-
defaultMessage: "
|
2988
|
+
defaultMessage: "Entry"
|
2456
2989
|
}),
|
2457
2990
|
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2458
2991
|
};
|
@@ -2487,334 +3020,32 @@ const ActionsPanelContent = () => {
|
|
2487
3020
|
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2488
3021
|
] });
|
2489
3022
|
};
|
2490
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2491
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2492
|
-
designSystem.Flex,
|
2493
|
-
{
|
2494
|
-
ref,
|
2495
|
-
tag: "aside",
|
2496
|
-
"aria-labelledby": "additional-information",
|
2497
|
-
background: "neutral0",
|
2498
|
-
borderColor: "neutral150",
|
2499
|
-
hasRadius: true,
|
2500
|
-
paddingBottom: 4,
|
2501
|
-
paddingLeft: 4,
|
2502
|
-
paddingRight: 4,
|
2503
|
-
paddingTop: 4,
|
2504
|
-
shadow: "tableShadow",
|
2505
|
-
gap: 3,
|
2506
|
-
direction: "column",
|
2507
|
-
justifyContent: "stretch",
|
2508
|
-
alignItems: "flex-start",
|
2509
|
-
children: [
|
2510
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2511
|
-
children
|
2512
|
-
]
|
2513
|
-
}
|
2514
|
-
);
|
2515
|
-
});
|
2516
|
-
const HOOKS = {
|
2517
|
-
/**
|
2518
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2519
|
-
* @constant
|
2520
|
-
* @type {string}
|
2521
|
-
*/
|
2522
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2523
|
-
/**
|
2524
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2525
|
-
* @constant
|
2526
|
-
* @type {string}
|
2527
|
-
*/
|
2528
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2529
|
-
/**
|
2530
|
-
* Hook that allows to mutate the CM's edit view layout
|
2531
|
-
* @constant
|
2532
|
-
* @type {string}
|
2533
|
-
*/
|
2534
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2535
|
-
/**
|
2536
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2537
|
-
* @constant
|
2538
|
-
* @type {string}
|
2539
|
-
*/
|
2540
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2541
|
-
};
|
2542
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2543
|
-
endpoints: (builder) => ({
|
2544
|
-
getContentTypeConfiguration: builder.query({
|
2545
|
-
query: (uid) => ({
|
2546
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2547
|
-
method: "GET"
|
2548
|
-
}),
|
2549
|
-
transformResponse: (response) => response.data,
|
2550
|
-
providesTags: (_result, _error, uid) => [
|
2551
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2552
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2553
|
-
]
|
2554
|
-
}),
|
2555
|
-
getAllContentTypeSettings: builder.query({
|
2556
|
-
query: () => "/content-manager/content-types-settings",
|
2557
|
-
transformResponse: (response) => response.data,
|
2558
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2559
|
-
}),
|
2560
|
-
updateContentTypeConfiguration: builder.mutation({
|
2561
|
-
query: ({ uid, ...body }) => ({
|
2562
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2563
|
-
method: "PUT",
|
2564
|
-
data: body
|
2565
|
-
}),
|
2566
|
-
transformResponse: (response) => response.data,
|
2567
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2568
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2569
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2570
|
-
// Is this necessary?
|
2571
|
-
{ type: "InitialData" }
|
2572
|
-
]
|
2573
|
-
})
|
2574
|
-
})
|
2575
|
-
});
|
2576
|
-
const {
|
2577
|
-
useGetContentTypeConfigurationQuery,
|
2578
|
-
useGetAllContentTypeSettingsQuery,
|
2579
|
-
useUpdateContentTypeConfigurationMutation
|
2580
|
-
} = contentTypesApi;
|
2581
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2582
|
-
const { type } = attribute;
|
2583
|
-
if (type === "relation") {
|
2584
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2585
|
-
}
|
2586
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2587
|
-
};
|
2588
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2589
|
-
if (!mainFieldName) {
|
2590
|
-
return void 0;
|
2591
|
-
}
|
2592
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2593
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2594
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2595
|
-
);
|
2596
|
-
return {
|
2597
|
-
name: mainFieldName,
|
2598
|
-
type: mainFieldType ?? "string"
|
2599
|
-
};
|
2600
|
-
};
|
2601
|
-
const DEFAULT_SETTINGS = {
|
2602
|
-
bulkable: false,
|
2603
|
-
filterable: false,
|
2604
|
-
searchable: false,
|
2605
|
-
pagination: false,
|
2606
|
-
defaultSortBy: "",
|
2607
|
-
defaultSortOrder: "asc",
|
2608
|
-
mainField: "id",
|
2609
|
-
pageSize: 10
|
2610
|
-
};
|
2611
|
-
const useDocumentLayout = (model) => {
|
2612
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2613
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2614
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2615
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2616
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2617
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2618
|
-
const {
|
2619
|
-
data,
|
2620
|
-
isLoading: isLoadingConfigs,
|
2621
|
-
error,
|
2622
|
-
isFetching: isFetchingConfigs
|
2623
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2624
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2625
|
-
React__namespace.useEffect(() => {
|
2626
|
-
if (error) {
|
2627
|
-
toggleNotification({
|
2628
|
-
type: "danger",
|
2629
|
-
message: formatAPIError(error)
|
2630
|
-
});
|
2631
|
-
}
|
2632
|
-
}, [error, formatAPIError, toggleNotification]);
|
2633
|
-
const editLayout = React__namespace.useMemo(
|
2634
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2635
|
-
layout: [],
|
2636
|
-
components: {},
|
2637
|
-
metadatas: {},
|
2638
|
-
options: {},
|
2639
|
-
settings: DEFAULT_SETTINGS
|
2640
|
-
},
|
2641
|
-
[data, isLoading, schemas, schema, components]
|
2642
|
-
);
|
2643
|
-
const listLayout = React__namespace.useMemo(() => {
|
2644
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2645
|
-
layout: [],
|
2646
|
-
metadatas: {},
|
2647
|
-
options: {},
|
2648
|
-
settings: DEFAULT_SETTINGS
|
2649
|
-
};
|
2650
|
-
}, [data, isLoading, schemas, schema, components]);
|
2651
|
-
const { layout: edit } = React__namespace.useMemo(
|
2652
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2653
|
-
layout: editLayout,
|
2654
|
-
query
|
2655
|
-
}),
|
2656
|
-
[editLayout, query, runHookWaterfall]
|
2657
|
-
);
|
2658
|
-
return {
|
2659
|
-
error,
|
2660
|
-
isLoading,
|
2661
|
-
edit,
|
2662
|
-
list: listLayout
|
2663
|
-
};
|
2664
|
-
};
|
2665
|
-
const useDocLayout = () => {
|
2666
|
-
const { model } = useDoc();
|
2667
|
-
return useDocumentLayout(model);
|
2668
|
-
};
|
2669
|
-
const formatEditLayout = (data, {
|
2670
|
-
schemas,
|
2671
|
-
schema,
|
2672
|
-
components
|
2673
|
-
}) => {
|
2674
|
-
let currentPanelIndex = 0;
|
2675
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2676
|
-
data.contentType.layouts.edit,
|
2677
|
-
schema?.attributes,
|
2678
|
-
data.contentType.metadatas,
|
2679
|
-
{ configurations: data.components, schemas: components },
|
2680
|
-
schemas
|
2681
|
-
).reduce((panels, row) => {
|
2682
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2683
|
-
panels.push([row]);
|
2684
|
-
currentPanelIndex += 2;
|
2685
|
-
} else {
|
2686
|
-
if (!panels[currentPanelIndex]) {
|
2687
|
-
panels.push([]);
|
2688
|
-
}
|
2689
|
-
panels[currentPanelIndex].push(row);
|
2690
|
-
}
|
2691
|
-
return panels;
|
2692
|
-
}, []);
|
2693
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2694
|
-
(acc, [uid, configuration]) => {
|
2695
|
-
acc[uid] = {
|
2696
|
-
layout: convertEditLayoutToFieldLayouts(
|
2697
|
-
configuration.layouts.edit,
|
2698
|
-
components[uid].attributes,
|
2699
|
-
configuration.metadatas
|
2700
|
-
),
|
2701
|
-
settings: {
|
2702
|
-
...configuration.settings,
|
2703
|
-
icon: components[uid].info.icon,
|
2704
|
-
displayName: components[uid].info.displayName
|
2705
|
-
}
|
2706
|
-
};
|
2707
|
-
return acc;
|
2708
|
-
},
|
2709
|
-
{}
|
2710
|
-
);
|
2711
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2712
|
-
(acc, [attribute, metadata]) => {
|
2713
|
-
return {
|
2714
|
-
...acc,
|
2715
|
-
[attribute]: metadata.edit
|
2716
|
-
};
|
2717
|
-
},
|
2718
|
-
{}
|
2719
|
-
);
|
2720
|
-
return {
|
2721
|
-
layout: panelledEditAttributes,
|
2722
|
-
components: componentEditAttributes,
|
2723
|
-
metadatas: editMetadatas,
|
2724
|
-
settings: {
|
2725
|
-
...data.contentType.settings,
|
2726
|
-
displayName: schema?.info.displayName
|
2727
|
-
},
|
2728
|
-
options: {
|
2729
|
-
...schema?.options,
|
2730
|
-
...schema?.pluginOptions,
|
2731
|
-
...data.contentType.options
|
2732
|
-
}
|
2733
|
-
};
|
2734
|
-
};
|
2735
|
-
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2736
|
-
return rows.map(
|
2737
|
-
(row) => row.map((field) => {
|
2738
|
-
const attribute = attributes[field.name];
|
2739
|
-
if (!attribute) {
|
2740
|
-
return null;
|
2741
|
-
}
|
2742
|
-
const { edit: metadata } = metadatas[field.name];
|
2743
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2744
|
-
return {
|
2745
|
-
attribute,
|
2746
|
-
disabled: !metadata.editable,
|
2747
|
-
hint: metadata.description,
|
2748
|
-
label: metadata.label ?? "",
|
2749
|
-
name: field.name,
|
2750
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2751
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2752
|
-
schemas,
|
2753
|
-
components: components?.schemas ?? {}
|
2754
|
-
}),
|
2755
|
-
placeholder: metadata.placeholder ?? "",
|
2756
|
-
required: attribute.required ?? false,
|
2757
|
-
size: field.size,
|
2758
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2759
|
-
visible: metadata.visible ?? true,
|
2760
|
-
type: attribute.type
|
2761
|
-
};
|
2762
|
-
}).filter((field) => field !== null)
|
2763
|
-
);
|
2764
|
-
};
|
2765
|
-
const formatListLayout = (data, {
|
2766
|
-
schemas,
|
2767
|
-
schema,
|
2768
|
-
components
|
2769
|
-
}) => {
|
2770
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2771
|
-
(acc, [attribute, metadata]) => {
|
2772
|
-
return {
|
2773
|
-
...acc,
|
2774
|
-
[attribute]: metadata.list
|
2775
|
-
};
|
2776
|
-
},
|
2777
|
-
{}
|
2778
|
-
);
|
2779
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2780
|
-
data.contentType.layouts.list,
|
2781
|
-
schema?.attributes,
|
2782
|
-
listMetadatas,
|
2783
|
-
{ configurations: data.components, schemas: components },
|
2784
|
-
schemas
|
2785
|
-
);
|
2786
|
-
return {
|
2787
|
-
layout: listAttributes,
|
2788
|
-
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2789
|
-
metadatas: listMetadatas,
|
2790
|
-
options: {
|
2791
|
-
...schema?.options,
|
2792
|
-
...schema?.pluginOptions,
|
2793
|
-
...data.contentType.options
|
2794
|
-
}
|
2795
|
-
};
|
2796
|
-
};
|
2797
|
-
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2798
|
-
return columns.map((name) => {
|
2799
|
-
const attribute = attributes[name];
|
2800
|
-
if (!attribute) {
|
2801
|
-
return null;
|
3023
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3024
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3025
|
+
designSystem.Flex,
|
3026
|
+
{
|
3027
|
+
ref,
|
3028
|
+
tag: "aside",
|
3029
|
+
"aria-labelledby": "additional-information",
|
3030
|
+
background: "neutral0",
|
3031
|
+
borderColor: "neutral150",
|
3032
|
+
hasRadius: true,
|
3033
|
+
paddingBottom: 4,
|
3034
|
+
paddingLeft: 4,
|
3035
|
+
paddingRight: 4,
|
3036
|
+
paddingTop: 4,
|
3037
|
+
shadow: "tableShadow",
|
3038
|
+
gap: 3,
|
3039
|
+
direction: "column",
|
3040
|
+
justifyContent: "stretch",
|
3041
|
+
alignItems: "flex-start",
|
3042
|
+
children: [
|
3043
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3044
|
+
children
|
3045
|
+
]
|
2802
3046
|
}
|
2803
|
-
|
2804
|
-
|
2805
|
-
return {
|
2806
|
-
attribute,
|
2807
|
-
label: metadata.label ?? "",
|
2808
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2809
|
-
schemas,
|
2810
|
-
components: components?.schemas ?? {}
|
2811
|
-
}),
|
2812
|
-
name,
|
2813
|
-
searchable: metadata.searchable ?? true,
|
2814
|
-
sortable: metadata.sortable ?? true
|
2815
|
-
};
|
2816
|
-
}).filter((field) => field !== null);
|
2817
|
-
};
|
3047
|
+
);
|
3048
|
+
});
|
2818
3049
|
const ConfirmBulkActionDialog = ({
|
2819
3050
|
onToggleDialog,
|
2820
3051
|
isOpen = false,
|
@@ -2822,30 +3053,23 @@ const ConfirmBulkActionDialog = ({
|
|
2822
3053
|
endAction
|
2823
3054
|
}) => {
|
2824
3055
|
const { formatMessage } = reactIntl.useIntl();
|
2825
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2826
|
-
designSystem.Dialog,
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
}) }),
|
2843
|
-
endAction
|
2844
|
-
}
|
2845
|
-
)
|
2846
|
-
]
|
2847
|
-
}
|
2848
|
-
);
|
3056
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
3057
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
3058
|
+
id: "app.components.ConfirmDialog.title",
|
3059
|
+
defaultMessage: "Confirmation"
|
3060
|
+
}) }),
|
3061
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3062
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3063
|
+
dialogBody
|
3064
|
+
] }) }),
|
3065
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
3066
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
3067
|
+
id: "app.components.Button.cancel",
|
3068
|
+
defaultMessage: "Cancel"
|
3069
|
+
}) }) }),
|
3070
|
+
endAction
|
3071
|
+
] })
|
3072
|
+
] }) });
|
2849
3073
|
};
|
2850
3074
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2851
3075
|
const ConfirmDialogPublishAll = ({
|
@@ -2860,6 +3084,7 @@ const ConfirmDialogPublishAll = ({
|
|
2860
3084
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2861
3085
|
const { model, schema } = useDoc();
|
2862
3086
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3087
|
+
const enableDraftRelationsCount = false;
|
2863
3088
|
const {
|
2864
3089
|
data: countDraftRelations = 0,
|
2865
3090
|
isLoading,
|
@@ -2871,7 +3096,7 @@ const ConfirmDialogPublishAll = ({
|
|
2871
3096
|
locale: query?.plugins?.i18n?.locale
|
2872
3097
|
},
|
2873
3098
|
{
|
2874
|
-
skip:
|
3099
|
+
skip: !enableDraftRelationsCount
|
2875
3100
|
}
|
2876
3101
|
);
|
2877
3102
|
React__namespace.useEffect(() => {
|
@@ -2950,7 +3175,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2950
3175
|
)
|
2951
3176
|
);
|
2952
3177
|
} else {
|
2953
|
-
messages.push(
|
3178
|
+
messages.push(
|
3179
|
+
...formatErrorMessages(
|
3180
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3181
|
+
value,
|
3182
|
+
currentKey,
|
3183
|
+
formatMessage
|
3184
|
+
)
|
3185
|
+
);
|
2954
3186
|
}
|
2955
3187
|
} else {
|
2956
3188
|
messages.push(
|
@@ -3049,7 +3281,7 @@ const SelectedEntriesTableContent = ({
|
|
3049
3281
|
status: row.status
|
3050
3282
|
}
|
3051
3283
|
) }),
|
3052
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3284
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3053
3285
|
designSystem.IconButton,
|
3054
3286
|
{
|
3055
3287
|
tag: reactRouterDom.Link,
|
@@ -3058,23 +3290,16 @@ const SelectedEntriesTableContent = ({
|
|
3058
3290
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3059
3291
|
},
|
3060
3292
|
state: { from: pathname },
|
3061
|
-
label: formatMessage(
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
{
|
3066
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3067
|
-
defaultMessage: "item line {number}"
|
3068
|
-
},
|
3069
|
-
{ number: index2 + 1 }
|
3070
|
-
)
|
3071
|
-
}
|
3072
|
-
),
|
3293
|
+
label: formatMessage({
|
3294
|
+
id: "content-manager.bulk-publish.edit",
|
3295
|
+
defaultMessage: "Edit"
|
3296
|
+
}),
|
3073
3297
|
target: "_blank",
|
3074
3298
|
marginLeft: "auto",
|
3075
|
-
|
3299
|
+
variant: "ghost",
|
3300
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3076
3301
|
}
|
3077
|
-
) })
|
3302
|
+
) }) })
|
3078
3303
|
] }, row.id)) })
|
3079
3304
|
] });
|
3080
3305
|
};
|
@@ -3111,7 +3336,13 @@ const SelectedEntriesModalContent = ({
|
|
3111
3336
|
);
|
3112
3337
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3113
3338
|
if (data.length > 0 && schema) {
|
3114
|
-
const validate = createYupSchema(
|
3339
|
+
const validate = createYupSchema(
|
3340
|
+
schema.attributes,
|
3341
|
+
components,
|
3342
|
+
// Since this is the "Publish" action, the validation
|
3343
|
+
// schema must enforce the rules for published entities
|
3344
|
+
{ status: "published" }
|
3345
|
+
);
|
3115
3346
|
const validationErrors2 = {};
|
3116
3347
|
const rows2 = data.map((entry) => {
|
3117
3348
|
try {
|
@@ -3187,7 +3418,7 @@ const SelectedEntriesModalContent = ({
|
|
3187
3418
|
);
|
3188
3419
|
};
|
3189
3420
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3190
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3421
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3191
3422
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3192
3423
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3193
3424
|
SelectedEntriesTableContent,
|
@@ -3199,27 +3430,24 @@ const SelectedEntriesModalContent = ({
|
|
3199
3430
|
}
|
3200
3431
|
) })
|
3201
3432
|
] }),
|
3202
|
-
/* @__PURE__ */ jsxRuntime.
|
3203
|
-
designSystem.
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
}) }),
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
] })
|
3221
|
-
}
|
3222
|
-
),
|
3433
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3434
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3435
|
+
id: "app.components.Button.cancel",
|
3436
|
+
defaultMessage: "Cancel"
|
3437
|
+
}) }),
|
3438
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3439
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3440
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3441
|
+
designSystem.Button,
|
3442
|
+
{
|
3443
|
+
onClick: toggleDialog,
|
3444
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3445
|
+
loading: isSubmittingForm,
|
3446
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3447
|
+
}
|
3448
|
+
)
|
3449
|
+
] })
|
3450
|
+
] }),
|
3223
3451
|
/* @__PURE__ */ jsxRuntime.jsx(
|
3224
3452
|
ConfirmDialogPublishAll,
|
3225
3453
|
{
|
@@ -3284,143 +3512,10 @@ const BulkActionsRenderer = () => {
|
|
3284
3512
|
documents: selectedRows
|
3285
3513
|
},
|
3286
3514
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3287
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
3515
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3288
3516
|
}
|
3289
3517
|
) });
|
3290
3518
|
};
|
3291
|
-
const BulkActionAction = (action) => {
|
3292
|
-
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3293
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
3294
|
-
const handleClick = (action2) => (e) => {
|
3295
|
-
const { onClick, dialog, id } = action2;
|
3296
|
-
if (onClick) {
|
3297
|
-
onClick(e);
|
3298
|
-
}
|
3299
|
-
if (dialog) {
|
3300
|
-
switch (dialog.type) {
|
3301
|
-
case "notification":
|
3302
|
-
toggleNotification({
|
3303
|
-
title: dialog.title,
|
3304
|
-
message: dialog.content,
|
3305
|
-
type: dialog.status,
|
3306
|
-
timeout: dialog.timeout,
|
3307
|
-
onClose: dialog.onClose
|
3308
|
-
});
|
3309
|
-
break;
|
3310
|
-
case "dialog":
|
3311
|
-
case "modal": {
|
3312
|
-
e.preventDefault();
|
3313
|
-
setDialogId(id);
|
3314
|
-
}
|
3315
|
-
}
|
3316
|
-
}
|
3317
|
-
};
|
3318
|
-
const handleClose = () => {
|
3319
|
-
setDialogId(null);
|
3320
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3321
|
-
action.dialog.onClose();
|
3322
|
-
}
|
3323
|
-
};
|
3324
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3325
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3326
|
-
designSystem.Button,
|
3327
|
-
{
|
3328
|
-
disabled: action.disabled,
|
3329
|
-
startIcon: action.icon,
|
3330
|
-
variant: action.variant,
|
3331
|
-
onClick: handleClick(action),
|
3332
|
-
children: action.label
|
3333
|
-
}
|
3334
|
-
),
|
3335
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3336
|
-
BulkActionConfirmDialog,
|
3337
|
-
{
|
3338
|
-
...action.dialog,
|
3339
|
-
variant: action.variant,
|
3340
|
-
isOpen: dialogId === action.id,
|
3341
|
-
onClose: handleClose
|
3342
|
-
}
|
3343
|
-
) : null,
|
3344
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3345
|
-
BulkActionModal,
|
3346
|
-
{
|
3347
|
-
...action.dialog,
|
3348
|
-
onModalClose: handleClose,
|
3349
|
-
isOpen: dialogId === action.id
|
3350
|
-
}
|
3351
|
-
) : null
|
3352
|
-
] });
|
3353
|
-
};
|
3354
|
-
const BulkActionConfirmDialog = ({
|
3355
|
-
onClose,
|
3356
|
-
onCancel,
|
3357
|
-
onConfirm,
|
3358
|
-
title,
|
3359
|
-
content,
|
3360
|
-
confirmButton,
|
3361
|
-
isOpen,
|
3362
|
-
variant = "secondary"
|
3363
|
-
}) => {
|
3364
|
-
const { formatMessage } = reactIntl.useIntl();
|
3365
|
-
const handleClose = async () => {
|
3366
|
-
if (onCancel) {
|
3367
|
-
await onCancel();
|
3368
|
-
}
|
3369
|
-
onClose();
|
3370
|
-
};
|
3371
|
-
const handleConfirm = async () => {
|
3372
|
-
if (onConfirm) {
|
3373
|
-
await onConfirm();
|
3374
|
-
}
|
3375
|
-
onClose();
|
3376
|
-
};
|
3377
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
|
3378
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
|
3379
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3380
|
-
designSystem.DialogFooter,
|
3381
|
-
{
|
3382
|
-
startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3383
|
-
id: "app.components.Button.cancel",
|
3384
|
-
defaultMessage: "Cancel"
|
3385
|
-
}) }),
|
3386
|
-
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
3387
|
-
designSystem.Button,
|
3388
|
-
{
|
3389
|
-
onClick: handleConfirm,
|
3390
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3391
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
3392
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3393
|
-
id: "app.components.Button.confirm",
|
3394
|
-
defaultMessage: "Confirm"
|
3395
|
-
})
|
3396
|
-
}
|
3397
|
-
)
|
3398
|
-
}
|
3399
|
-
)
|
3400
|
-
] });
|
3401
|
-
};
|
3402
|
-
const BulkActionModal = ({
|
3403
|
-
isOpen,
|
3404
|
-
title,
|
3405
|
-
onClose,
|
3406
|
-
content: Content,
|
3407
|
-
onModalClose
|
3408
|
-
}) => {
|
3409
|
-
const id = React__namespace.useId();
|
3410
|
-
if (!isOpen) {
|
3411
|
-
return null;
|
3412
|
-
}
|
3413
|
-
const handleClose = () => {
|
3414
|
-
if (onClose) {
|
3415
|
-
onClose();
|
3416
|
-
}
|
3417
|
-
onModalClose();
|
3418
|
-
};
|
3419
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3420
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3421
|
-
/* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
|
3422
|
-
] });
|
3423
|
-
};
|
3424
3519
|
const DeleteAction = ({ documents, model }) => {
|
3425
3520
|
const { formatMessage } = reactIntl.useIntl();
|
3426
3521
|
const { schema: contentType } = useDoc();
|
@@ -3453,6 +3548,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3453
3548
|
defaultMessage: "Confirmation"
|
3454
3549
|
}),
|
3455
3550
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3551
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3456
3552
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3457
3553
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3458
3554
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3502,6 +3598,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3502
3598
|
defaultMessage: "Confirmation"
|
3503
3599
|
}),
|
3504
3600
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3601
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3505
3602
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3506
3603
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3507
3604
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3595,7 +3692,7 @@ const TableActions = ({ document }) => {
|
|
3595
3692
|
strapiAdmin.DescriptionComponentRenderer,
|
3596
3693
|
{
|
3597
3694
|
props,
|
3598
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3695
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3599
3696
|
children: (actions2) => {
|
3600
3697
|
const tableRowActions = actions2.filter((action) => {
|
3601
3698
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3706,7 +3803,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3706
3803
|
}),
|
3707
3804
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3708
3805
|
footer: ({ onClose }) => {
|
3709
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3806
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3710
3807
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3711
3808
|
id: "cancel",
|
3712
3809
|
defaultMessage: "Cancel"
|
@@ -3747,8 +3844,7 @@ class ContentManagerPlugin {
|
|
3747
3844
|
documentActions = [
|
3748
3845
|
...DEFAULT_ACTIONS,
|
3749
3846
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3750
|
-
...DEFAULT_HEADER_ACTIONS
|
3751
|
-
HistoryAction
|
3847
|
+
...DEFAULT_HEADER_ACTIONS
|
3752
3848
|
];
|
3753
3849
|
editViewSidePanels = [ActionsPanel];
|
3754
3850
|
headerActions = [];
|
@@ -3837,6 +3933,52 @@ const getPrintableType = (value) => {
|
|
3837
3933
|
}
|
3838
3934
|
return nativeType;
|
3839
3935
|
};
|
3936
|
+
const HistoryAction = ({ model, document }) => {
|
3937
|
+
const { formatMessage } = reactIntl.useIntl();
|
3938
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3939
|
+
const navigate = reactRouterDom.useNavigate();
|
3940
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3941
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3942
|
+
return null;
|
3943
|
+
}
|
3944
|
+
return {
|
3945
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3946
|
+
label: formatMessage({
|
3947
|
+
id: "content-manager.history.document-action",
|
3948
|
+
defaultMessage: "Content History"
|
3949
|
+
}),
|
3950
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3951
|
+
disabled: (
|
3952
|
+
/**
|
3953
|
+
* The user is creating a new document.
|
3954
|
+
* It hasn't been saved yet, so there's no history to go to
|
3955
|
+
*/
|
3956
|
+
!document || /**
|
3957
|
+
* The document has been created but the current dimension has never been saved.
|
3958
|
+
* For example, the user is creating a new locale in an existing document,
|
3959
|
+
* so there's no history for the document in that locale
|
3960
|
+
*/
|
3961
|
+
!document.id || /**
|
3962
|
+
* History is only available for content types created by the user.
|
3963
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3964
|
+
* which start with `admin::` or `plugin::`
|
3965
|
+
*/
|
3966
|
+
!model.startsWith("api::")
|
3967
|
+
),
|
3968
|
+
position: "header"
|
3969
|
+
};
|
3970
|
+
};
|
3971
|
+
HistoryAction.type = "history";
|
3972
|
+
const historyAdmin = {
|
3973
|
+
bootstrap(app) {
|
3974
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3975
|
+
addDocumentAction((actions2) => {
|
3976
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3977
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3978
|
+
return actions2;
|
3979
|
+
});
|
3980
|
+
}
|
3981
|
+
};
|
3840
3982
|
const initialState = {
|
3841
3983
|
collectionTypeLinks: [],
|
3842
3984
|
components: [],
|
@@ -3873,6 +4015,70 @@ const { setInitialData } = actions;
|
|
3873
4015
|
const reducer = toolkit.combineReducers({
|
3874
4016
|
app: reducer$1
|
3875
4017
|
});
|
4018
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4019
|
+
endpoints: (builder) => ({
|
4020
|
+
getPreviewUrl: builder.query({
|
4021
|
+
query({ query, params }) {
|
4022
|
+
return {
|
4023
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4024
|
+
method: "GET",
|
4025
|
+
config: {
|
4026
|
+
params: query
|
4027
|
+
}
|
4028
|
+
};
|
4029
|
+
}
|
4030
|
+
})
|
4031
|
+
})
|
4032
|
+
});
|
4033
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4034
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4035
|
+
const { formatMessage } = reactIntl.useIntl();
|
4036
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4037
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4038
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4039
|
+
params: {
|
4040
|
+
contentType: model
|
4041
|
+
},
|
4042
|
+
query: {
|
4043
|
+
documentId,
|
4044
|
+
locale: document?.locale,
|
4045
|
+
status: document?.status
|
4046
|
+
}
|
4047
|
+
});
|
4048
|
+
if (!data?.data?.url || error) {
|
4049
|
+
return null;
|
4050
|
+
}
|
4051
|
+
const handleClick = () => {
|
4052
|
+
trackUsage("willOpenPreview");
|
4053
|
+
};
|
4054
|
+
return {
|
4055
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4056
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4057
|
+
designSystem.Button,
|
4058
|
+
{
|
4059
|
+
variant: "tertiary",
|
4060
|
+
tag: reactRouterDom.Link,
|
4061
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4062
|
+
onClick: handleClick,
|
4063
|
+
flex: "auto",
|
4064
|
+
children: formatMessage({
|
4065
|
+
id: "content-manager.preview.panel.button",
|
4066
|
+
defaultMessage: "Open preview"
|
4067
|
+
})
|
4068
|
+
}
|
4069
|
+
) })
|
4070
|
+
};
|
4071
|
+
};
|
4072
|
+
const FEATURE_ID = "preview";
|
4073
|
+
const previewAdmin = {
|
4074
|
+
bootstrap(app) {
|
4075
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4076
|
+
return;
|
4077
|
+
}
|
4078
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4079
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4080
|
+
}
|
4081
|
+
};
|
3876
4082
|
const index = {
|
3877
4083
|
register(app) {
|
3878
4084
|
const cm = new ContentManagerPlugin();
|
@@ -3887,15 +4093,32 @@ const index = {
|
|
3887
4093
|
defaultMessage: "Content Manager"
|
3888
4094
|
},
|
3889
4095
|
permissions: [],
|
3890
|
-
Component: () => Promise.resolve().then(() => require("./layout-jcY4dyUG.js")).then((mod) => ({ default: mod.Layout })),
|
3891
4096
|
position: 1
|
3892
4097
|
});
|
4098
|
+
app.router.addRoute({
|
4099
|
+
path: "content-manager/*",
|
4100
|
+
lazy: async () => {
|
4101
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-BDwU2I_y.js"));
|
4102
|
+
return {
|
4103
|
+
Component: Layout
|
4104
|
+
};
|
4105
|
+
},
|
4106
|
+
children: routes
|
4107
|
+
});
|
3893
4108
|
app.registerPlugin(cm.config);
|
3894
4109
|
},
|
4110
|
+
bootstrap(app) {
|
4111
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
4112
|
+
historyAdmin.bootstrap(app);
|
4113
|
+
}
|
4114
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4115
|
+
previewAdmin.bootstrap(app);
|
4116
|
+
}
|
4117
|
+
},
|
3895
4118
|
async registerTrads({ locales }) {
|
3896
4119
|
const importedTrads = await Promise.all(
|
3897
4120
|
locales.map((locale) => {
|
3898
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
4121
|
+
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-DAgtrRoa.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B2Kyv8Z9.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-7sfIbjxE.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3899
4122
|
return {
|
3900
4123
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3901
4124
|
locale
|
@@ -3913,6 +4136,7 @@ const index = {
|
|
3913
4136
|
};
|
3914
4137
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3915
4138
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4139
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3916
4140
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3917
4141
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3918
4142
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3939,8 +4163,8 @@ exports.getDisplayName = getDisplayName;
|
|
3939
4163
|
exports.getMainField = getMainField;
|
3940
4164
|
exports.getTranslation = getTranslation;
|
3941
4165
|
exports.index = index;
|
3942
|
-
exports.routes = routes;
|
3943
4166
|
exports.setInitialData = setInitialData;
|
4167
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3944
4168
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3945
4169
|
exports.useDoc = useDoc;
|
3946
4170
|
exports.useDocLayout = useDocLayout;
|
@@ -3952,5 +4176,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3952
4176
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3953
4177
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3954
4178
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4179
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3955
4180
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3956
|
-
//# sourceMappingURL=index-
|
4181
|
+
//# sourceMappingURL=index-_j7lH3CO.js.map
|