@strapi/content-manager 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.f0a0bc26f5ef0693aaea2a616bc6b816cfee54b6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-BAgyHiMm.mjs → ComponentConfigurationPage-DhWA-JzT.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BAgyHiMm.mjs.map → ComponentConfigurationPage-DhWA-JzT.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-5ukroXAh.js → ComponentConfigurationPage-UduDBv3m.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-5ukroXAh.js.map → ComponentConfigurationPage-UduDBv3m.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DmoXawIh.mjs → EditConfigurationPage-5tmx_7Hp.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DmoXawIh.mjs.map → EditConfigurationPage-5tmx_7Hp.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Xp7lun0f.js → EditConfigurationPage-Cp9UzUfs.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-Xp7lun0f.js.map → EditConfigurationPage-Cp9UzUfs.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BLsjc5F-.mjs → EditViewPage-BKoISUOu.mjs} +63 -12
- package/dist/_chunks/EditViewPage-BKoISUOu.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-C-ukDOB7.js → EditViewPage-C7l2Emuj.js} +62 -11
- package/dist/_chunks/EditViewPage-C7l2Emuj.js.map +1 -0
- package/dist/_chunks/{Field-Bfph5SOd.js → Field-BPSJpDfE.js} +211 -120
- package/dist/_chunks/Field-BPSJpDfE.js.map +1 -0
- package/dist/_chunks/{Field-Cs7duwWd.mjs → Field-BZxzYf1x.mjs} +210 -119
- package/dist/_chunks/Field-BZxzYf1x.mjs.map +1 -0
- package/dist/_chunks/{Form-Dg_GS5TQ.mjs → Form-8qyOU6YG.mjs} +36 -17
- package/dist/_chunks/Form-8qyOU6YG.mjs.map +1 -0
- package/dist/_chunks/{Form-CPYqIWDG.js → Form-DLkqDd2G.js} +36 -17
- package/dist/_chunks/Form-DLkqDd2G.js.map +1 -0
- package/dist/_chunks/{History-DNQkXANT.js → History-DYMicybF.js} +41 -98
- package/dist/_chunks/History-DYMicybF.js.map +1 -0
- package/dist/_chunks/{History-wrnHqf09.mjs → History-N_kRb1Yr.mjs} +43 -100
- package/dist/_chunks/History-N_kRb1Yr.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DScmJVkW.mjs → ListConfigurationPage-BM3qVxug.mjs} +18 -7
- package/dist/_chunks/ListConfigurationPage-BM3qVxug.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CUQxfpjT.js → ListConfigurationPage-rUF9iGWq.js} +17 -6
- package/dist/_chunks/ListConfigurationPage-rUF9iGWq.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BsLiH2-2.js → ListViewPage-BSLzd7cZ.js} +108 -76
- package/dist/_chunks/ListViewPage-BSLzd7cZ.js.map +1 -0
- package/dist/_chunks/{ListViewPage-C4IvrMgY.mjs → ListViewPage-CWilGbZb.mjs} +106 -74
- package/dist/_chunks/ListViewPage-CWilGbZb.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-BZ-PnGAf.js → NoContentTypePage-CQccVhIX.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BZ-PnGAf.js.map → NoContentTypePage-CQccVhIX.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Djg8nPlj.mjs → NoContentTypePage-VWYlePwI.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Djg8nPlj.mjs.map → NoContentTypePage-VWYlePwI.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-_lUqjGW3.js → NoPermissionsPage-Af32Gg2m.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-_lUqjGW3.js.map → NoPermissionsPage-Af32Gg2m.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DSP7R-hv.mjs → NoPermissionsPage-CS2tCmfr.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DSP7R-hv.mjs.map → NoPermissionsPage-CS2tCmfr.mjs.map} +1 -1
- package/dist/_chunks/Preview-D4KzuJFL.js +291 -0
- package/dist/_chunks/Preview-D4KzuJFL.js.map +1 -0
- package/dist/_chunks/Preview-kPkuZbBJ.mjs +272 -0
- package/dist/_chunks/Preview-kPkuZbBJ.mjs.map +1 -0
- package/dist/_chunks/{Relations-BZr8tL0R.mjs → Relations-5k27Rh54.mjs} +73 -37
- package/dist/_chunks/Relations-5k27Rh54.mjs.map +1 -0
- package/dist/_chunks/{Relations-CtELXYIK.js → Relations-D_Ki5aVM.js} +72 -36
- package/dist/_chunks/Relations-D_Ki5aVM.js.map +1 -0
- package/dist/_chunks/{en-uOUIxfcQ.js → en-BK8Xyl5I.js} +28 -15
- package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-BrCTWlZv.mjs → en-Dtk_ot79.mjs} +28 -15
- package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-Dtk_ot79.mjs.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-c_5DdJi-.mjs → index-BLPa8Dq-.mjs} +1201 -924
- package/dist/_chunks/index-BLPa8Dq-.mjs.map +1 -0
- package/dist/_chunks/{index-OerGjbAN.js → index-DwOsF7wF.js} +1182 -904
- package/dist/_chunks/index-DwOsF7wF.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-oPBiO7RY.mjs → layout-2Si0j0jO.mjs} +22 -9
- package/dist/_chunks/layout-2Si0j0jO.mjs.map +1 -0
- package/dist/_chunks/{layout-Ci7qHlFb.js → layout-CN2bFL9V.js} +21 -8
- package/dist/_chunks/layout-CN2bFL9V.js.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-COBpStiF.js → relations-B0E0XUY7.js} +6 -7
- package/dist/_chunks/relations-B0E0XUY7.js.map +1 -0
- package/dist/_chunks/{relations-BIdWFjdq.mjs → relations-CAxDjUJF.mjs} +6 -7
- package/dist/_chunks/relations-CAxDjUJF.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 +5 -4
- package/dist/admin/src/exports.d.ts +1 -1
- 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/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- 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 +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- 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 -20
- 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 +560 -235
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +561 -236
- 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/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.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 +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -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 +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- 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/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-BLsjc5F-.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-C-ukDOB7.js.map +0 -1
- package/dist/_chunks/Field-Bfph5SOd.js.map +0 -1
- package/dist/_chunks/Field-Cs7duwWd.mjs.map +0 -1
- package/dist/_chunks/Form-CPYqIWDG.js.map +0 -1
- package/dist/_chunks/Form-Dg_GS5TQ.mjs.map +0 -1
- package/dist/_chunks/History-DNQkXANT.js.map +0 -1
- package/dist/_chunks/History-wrnHqf09.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CUQxfpjT.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DScmJVkW.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BsLiH2-2.js.map +0 -1
- package/dist/_chunks/ListViewPage-C4IvrMgY.mjs.map +0 -1
- package/dist/_chunks/Relations-BZr8tL0R.mjs.map +0 -1
- package/dist/_chunks/Relations-CtELXYIK.js.map +0 -1
- package/dist/_chunks/index-OerGjbAN.js.map +0 -1
- package/dist/_chunks/index-c_5DdJi-.mjs.map +0 -1
- package/dist/_chunks/layout-Ci7qHlFb.js.map +0 -1
- package/dist/_chunks/layout-oPBiO7RY.mjs.map +0 -1
- package/dist/_chunks/relations-BIdWFjdq.mjs.map +0 -1
- package/dist/_chunks/relations-COBpStiF.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
@@ -4,13 +4,14 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
5
|
const React = require("react");
|
6
6
|
const designSystem = require("@strapi/design-system");
|
7
|
+
const mapValues = require("lodash/fp/mapValues");
|
7
8
|
const reactIntl = require("react-intl");
|
8
9
|
const reactRouterDom = require("react-router-dom");
|
9
10
|
const styledComponents = require("styled-components");
|
10
11
|
const yup = require("yup");
|
12
|
+
const qs = require("qs");
|
11
13
|
const pipe = require("lodash/fp/pipe");
|
12
14
|
const dateFns = require("date-fns");
|
13
|
-
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) => {
|
@@ -121,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
121
123
|
if (!slug) {
|
122
124
|
throw new Error("Cannot find the slug param in the URL");
|
123
125
|
}
|
126
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
124
127
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
125
128
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
126
129
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -131,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
131
134
|
return { ...acc, [action]: [permission] };
|
132
135
|
}, {});
|
133
136
|
}, [slug, userPermissions]);
|
134
|
-
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
|
+
);
|
135
145
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
136
146
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
137
147
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -179,7 +189,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
179
189
|
"Document",
|
180
190
|
"InitialData",
|
181
191
|
"HistoryVersion",
|
182
|
-
"Relations"
|
192
|
+
"Relations",
|
193
|
+
"UidAvailability"
|
183
194
|
]
|
184
195
|
});
|
185
196
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -209,7 +220,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
209
220
|
params
|
210
221
|
}
|
211
222
|
}),
|
212
|
-
invalidatesTags: (_result, _error, { model }) => [
|
223
|
+
invalidatesTags: (_result, _error, { model }) => [
|
224
|
+
{ type: "Document", id: `${model}_LIST` },
|
225
|
+
{ type: "UidAvailability", id: model }
|
226
|
+
]
|
213
227
|
}),
|
214
228
|
/**
|
215
229
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -226,7 +240,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
226
240
|
}),
|
227
241
|
invalidatesTags: (result, _error, { model }) => [
|
228
242
|
{ type: "Document", id: `${model}_LIST` },
|
229
|
-
"Relations"
|
243
|
+
"Relations",
|
244
|
+
{ type: "UidAvailability", id: model }
|
230
245
|
]
|
231
246
|
}),
|
232
247
|
deleteDocument: builder.mutation({
|
@@ -267,7 +282,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
267
282
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
268
283
|
},
|
269
284
|
{ type: "Document", id: `${model}_LIST` },
|
270
|
-
"Relations"
|
285
|
+
"Relations",
|
286
|
+
{ type: "UidAvailability", id: model }
|
271
287
|
];
|
272
288
|
}
|
273
289
|
}),
|
@@ -280,11 +296,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
280
296
|
url: `/content-manager/collection-types/${model}`,
|
281
297
|
method: "GET",
|
282
298
|
config: {
|
283
|
-
params
|
299
|
+
params: qs.stringify(params, { encode: true })
|
284
300
|
}
|
285
301
|
}),
|
286
302
|
providesTags: (result, _error, arg) => {
|
287
303
|
return [
|
304
|
+
{ type: "Document", id: `ALL_LIST` },
|
288
305
|
{ type: "Document", id: `${arg.model}_LIST` },
|
289
306
|
...result?.results.map(({ documentId }) => ({
|
290
307
|
type: "Document",
|
@@ -323,6 +340,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
323
340
|
{
|
324
341
|
type: "Document",
|
325
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`
|
326
348
|
}
|
327
349
|
];
|
328
350
|
}
|
@@ -386,7 +408,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
386
408
|
type: "Document",
|
387
409
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
388
410
|
},
|
389
|
-
"Relations"
|
411
|
+
"Relations",
|
412
|
+
{ type: "UidAvailability", id: model }
|
390
413
|
];
|
391
414
|
},
|
392
415
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -461,28 +484,44 @@ const buildValidParams = (query) => {
|
|
461
484
|
{}
|
462
485
|
)
|
463
486
|
};
|
464
|
-
if ("_q" in validQueryParams) {
|
465
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
466
|
-
}
|
467
487
|
return validQueryParams;
|
468
488
|
};
|
469
489
|
const isBaseQueryError = (error) => {
|
470
490
|
return error.name !== void 0;
|
471
491
|
};
|
472
|
-
const
|
492
|
+
const arrayValidator = (attribute, options) => ({
|
493
|
+
message: strapiAdmin.translatedErrors.required,
|
494
|
+
test(value) {
|
495
|
+
if (options.status === "draft") {
|
496
|
+
return true;
|
497
|
+
}
|
498
|
+
if (!attribute.required) {
|
499
|
+
return true;
|
500
|
+
}
|
501
|
+
if (!value) {
|
502
|
+
return false;
|
503
|
+
}
|
504
|
+
if (Array.isArray(value) && value.length === 0) {
|
505
|
+
return false;
|
506
|
+
}
|
507
|
+
return true;
|
508
|
+
}
|
509
|
+
});
|
510
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
473
511
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
474
512
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
475
513
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
476
514
|
return acc;
|
477
515
|
}
|
478
516
|
const validations = [
|
517
|
+
addNullableValidation,
|
479
518
|
addRequiredValidation,
|
480
519
|
addMinLengthValidation,
|
481
520
|
addMaxLengthValidation,
|
482
521
|
addMinValidation,
|
483
522
|
addMaxValidation,
|
484
523
|
addRegexValidation
|
485
|
-
].map((fn) => fn(attribute));
|
524
|
+
].map((fn) => fn(attribute, options));
|
486
525
|
const transformSchema = pipe__default.default(...validations);
|
487
526
|
switch (attribute.type) {
|
488
527
|
case "component": {
|
@@ -492,12 +531,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
492
531
|
...acc,
|
493
532
|
[name]: transformSchema(
|
494
533
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
495
|
-
)
|
534
|
+
).test(arrayValidator(attribute, options))
|
496
535
|
};
|
497
536
|
} else {
|
498
537
|
return {
|
499
538
|
...acc,
|
500
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
539
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
501
540
|
};
|
502
541
|
}
|
503
542
|
}
|
@@ -519,7 +558,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
519
558
|
}
|
520
559
|
)
|
521
560
|
)
|
522
|
-
)
|
561
|
+
).test(arrayValidator(attribute, options))
|
523
562
|
};
|
524
563
|
case "relation":
|
525
564
|
return {
|
@@ -531,7 +570,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
531
570
|
} else if (Array.isArray(value)) {
|
532
571
|
return yup__namespace.array().of(
|
533
572
|
yup__namespace.object().shape({
|
534
|
-
id: yup__namespace.
|
573
|
+
id: yup__namespace.number().required()
|
535
574
|
})
|
536
575
|
);
|
537
576
|
} else if (typeof value === "object") {
|
@@ -583,6 +622,14 @@ const createAttributeSchema = (attribute) => {
|
|
583
622
|
if (!value || typeof value === "string" && value.length === 0) {
|
584
623
|
return true;
|
585
624
|
}
|
625
|
+
if (typeof value === "object") {
|
626
|
+
try {
|
627
|
+
JSON.stringify(value);
|
628
|
+
return true;
|
629
|
+
} catch (err) {
|
630
|
+
return false;
|
631
|
+
}
|
632
|
+
}
|
586
633
|
try {
|
587
634
|
JSON.parse(value);
|
588
635
|
return true;
|
@@ -601,13 +648,7 @@ const createAttributeSchema = (attribute) => {
|
|
601
648
|
return yup__namespace.mixed();
|
602
649
|
}
|
603
650
|
};
|
604
|
-
const
|
605
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
606
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
607
|
-
}
|
608
|
-
if (attribute.required && attribute.type !== "relation") {
|
609
|
-
return schema.required(strapiAdmin.translatedErrors.required);
|
610
|
-
}
|
651
|
+
const nullableSchema = (schema) => {
|
611
652
|
return schema?.nullable ? schema.nullable() : (
|
612
653
|
// In some cases '.nullable' will not be available on the schema.
|
613
654
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -615,7 +656,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
615
656
|
schema
|
616
657
|
);
|
617
658
|
};
|
618
|
-
const
|
659
|
+
const addNullableValidation = () => (schema) => {
|
660
|
+
return nullableSchema(schema);
|
661
|
+
};
|
662
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
663
|
+
if (options.status === "draft" || !attribute.required) {
|
664
|
+
return schema;
|
665
|
+
}
|
666
|
+
if (attribute.required && "required" in schema) {
|
667
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
668
|
+
}
|
669
|
+
return schema;
|
670
|
+
};
|
671
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
672
|
+
if (options.status === "draft") {
|
673
|
+
return schema;
|
674
|
+
}
|
619
675
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
620
676
|
return schema.min(attribute.minLength, {
|
621
677
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -637,32 +693,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
637
693
|
}
|
638
694
|
return schema;
|
639
695
|
};
|
640
|
-
const addMinValidation = (attribute) => (schema) => {
|
641
|
-
if ("
|
696
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
697
|
+
if (options.status === "draft") {
|
698
|
+
return schema;
|
699
|
+
}
|
700
|
+
if ("min" in attribute && "min" in schema) {
|
642
701
|
const min = toInteger(attribute.min);
|
643
|
-
if (
|
644
|
-
if (!attribute.required && "test" in schema && min) {
|
645
|
-
return schema.test(
|
646
|
-
"custom-min",
|
647
|
-
{
|
648
|
-
...strapiAdmin.translatedErrors.min,
|
649
|
-
values: {
|
650
|
-
min: attribute.min
|
651
|
-
}
|
652
|
-
},
|
653
|
-
(value) => {
|
654
|
-
if (!value) {
|
655
|
-
return true;
|
656
|
-
}
|
657
|
-
if (Array.isArray(value) && value.length === 0) {
|
658
|
-
return true;
|
659
|
-
}
|
660
|
-
return value.length >= min;
|
661
|
-
}
|
662
|
-
);
|
663
|
-
}
|
664
|
-
}
|
665
|
-
if ("min" in schema && min) {
|
702
|
+
if (min) {
|
666
703
|
return schema.min(min, {
|
667
704
|
...strapiAdmin.translatedErrors.min,
|
668
705
|
values: {
|
@@ -780,19 +817,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
780
817
|
}, {});
|
781
818
|
return componentsByKey;
|
782
819
|
};
|
783
|
-
const
|
820
|
+
const HOOKS = {
|
821
|
+
/**
|
822
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
823
|
+
* @constant
|
824
|
+
* @type {string}
|
825
|
+
*/
|
826
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
827
|
+
/**
|
828
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
829
|
+
* @constant
|
830
|
+
* @type {string}
|
831
|
+
*/
|
832
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
833
|
+
/**
|
834
|
+
* Hook that allows to mutate the CM's edit view layout
|
835
|
+
* @constant
|
836
|
+
* @type {string}
|
837
|
+
*/
|
838
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
839
|
+
/**
|
840
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
841
|
+
* @constant
|
842
|
+
* @type {string}
|
843
|
+
*/
|
844
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
845
|
+
};
|
846
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
847
|
+
endpoints: (builder) => ({
|
848
|
+
getContentTypeConfiguration: builder.query({
|
849
|
+
query: (uid) => ({
|
850
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
851
|
+
method: "GET"
|
852
|
+
}),
|
853
|
+
transformResponse: (response) => response.data,
|
854
|
+
providesTags: (_result, _error, uid) => [
|
855
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
856
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
857
|
+
]
|
858
|
+
}),
|
859
|
+
getAllContentTypeSettings: builder.query({
|
860
|
+
query: () => "/content-manager/content-types-settings",
|
861
|
+
transformResponse: (response) => response.data,
|
862
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
863
|
+
}),
|
864
|
+
updateContentTypeConfiguration: builder.mutation({
|
865
|
+
query: ({ uid, ...body }) => ({
|
866
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
867
|
+
method: "PUT",
|
868
|
+
data: body
|
869
|
+
}),
|
870
|
+
transformResponse: (response) => response.data,
|
871
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
872
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
873
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
874
|
+
// Is this necessary?
|
875
|
+
{ type: "InitialData" }
|
876
|
+
]
|
877
|
+
})
|
878
|
+
})
|
879
|
+
});
|
880
|
+
const {
|
881
|
+
useGetContentTypeConfigurationQuery,
|
882
|
+
useGetAllContentTypeSettingsQuery,
|
883
|
+
useUpdateContentTypeConfigurationMutation
|
884
|
+
} = contentTypesApi;
|
885
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
886
|
+
const { type } = attribute;
|
887
|
+
if (type === "relation") {
|
888
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
889
|
+
}
|
890
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
891
|
+
};
|
892
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
893
|
+
if (!mainFieldName) {
|
894
|
+
return void 0;
|
895
|
+
}
|
896
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
897
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
898
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
899
|
+
);
|
900
|
+
return {
|
901
|
+
name: mainFieldName,
|
902
|
+
type: mainFieldType ?? "string"
|
903
|
+
};
|
904
|
+
};
|
905
|
+
const DEFAULT_SETTINGS = {
|
906
|
+
bulkable: false,
|
907
|
+
filterable: false,
|
908
|
+
searchable: false,
|
909
|
+
pagination: false,
|
910
|
+
defaultSortBy: "",
|
911
|
+
defaultSortOrder: "asc",
|
912
|
+
mainField: "id",
|
913
|
+
pageSize: 10
|
914
|
+
};
|
915
|
+
const useDocumentLayout = (model) => {
|
916
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
917
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
918
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
784
919
|
const { toggleNotification } = strapiAdmin.useNotification();
|
785
920
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
921
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
786
922
|
const {
|
787
|
-
|
788
|
-
isLoading:
|
789
|
-
|
790
|
-
|
791
|
-
} =
|
792
|
-
|
793
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
794
|
-
});
|
795
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
923
|
+
data,
|
924
|
+
isLoading: isLoadingConfigs,
|
925
|
+
error,
|
926
|
+
isFetching: isFetchingConfigs
|
927
|
+
} = useGetContentTypeConfigurationQuery(model);
|
928
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
796
929
|
React__namespace.useEffect(() => {
|
797
930
|
if (error) {
|
798
931
|
toggleNotification({
|
@@ -800,362 +933,438 @@ const useDocument = (args, opts) => {
|
|
800
933
|
message: formatAPIError(error)
|
801
934
|
});
|
802
935
|
}
|
803
|
-
}, [
|
804
|
-
const
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
(document) => {
|
812
|
-
if (!validationSchema) {
|
813
|
-
throw new Error(
|
814
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
815
|
-
);
|
816
|
-
}
|
817
|
-
try {
|
818
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
819
|
-
return null;
|
820
|
-
} catch (error2) {
|
821
|
-
if (error2 instanceof yup.ValidationError) {
|
822
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
823
|
-
}
|
824
|
-
throw error2;
|
825
|
-
}
|
936
|
+
}, [error, formatAPIError, toggleNotification]);
|
937
|
+
const editLayout = React__namespace.useMemo(
|
938
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
939
|
+
layout: [],
|
940
|
+
components: {},
|
941
|
+
metadatas: {},
|
942
|
+
options: {},
|
943
|
+
settings: DEFAULT_SETTINGS
|
826
944
|
},
|
827
|
-
[
|
945
|
+
[data, isLoading, schemas, schema, components]
|
946
|
+
);
|
947
|
+
const listLayout = React__namespace.useMemo(() => {
|
948
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
949
|
+
layout: [],
|
950
|
+
metadatas: {},
|
951
|
+
options: {},
|
952
|
+
settings: DEFAULT_SETTINGS
|
953
|
+
};
|
954
|
+
}, [data, isLoading, schemas, schema, components]);
|
955
|
+
const { layout: edit } = React__namespace.useMemo(
|
956
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
957
|
+
layout: editLayout,
|
958
|
+
query
|
959
|
+
}),
|
960
|
+
[editLayout, query, runHookWaterfall]
|
828
961
|
);
|
829
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
830
962
|
return {
|
831
|
-
|
832
|
-
document: data?.data,
|
833
|
-
meta: data?.meta,
|
963
|
+
error,
|
834
964
|
isLoading,
|
835
|
-
|
836
|
-
|
837
|
-
};
|
838
|
-
};
|
839
|
-
const useDoc = () => {
|
840
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
841
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
842
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
843
|
-
if (!collectionType) {
|
844
|
-
throw new Error("Could not find collectionType in url params");
|
845
|
-
}
|
846
|
-
if (!slug) {
|
847
|
-
throw new Error("Could not find model in url params");
|
848
|
-
}
|
849
|
-
return {
|
850
|
-
collectionType,
|
851
|
-
model: slug,
|
852
|
-
id: origin || id === "create" ? void 0 : id,
|
853
|
-
...useDocument(
|
854
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
855
|
-
{
|
856
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
857
|
-
}
|
858
|
-
)
|
965
|
+
edit,
|
966
|
+
list: listLayout
|
859
967
|
};
|
860
968
|
};
|
861
|
-
const
|
862
|
-
|
863
|
-
|
864
|
-
}
|
865
|
-
return Object.keys(trad).reduce((acc, current) => {
|
866
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
867
|
-
return acc;
|
868
|
-
}, {});
|
869
|
-
};
|
870
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
871
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
872
|
-
id: "notification.error",
|
873
|
-
defaultMessage: "An error occurred, please try again"
|
969
|
+
const useDocLayout = () => {
|
970
|
+
const { model } = useDoc();
|
971
|
+
return useDocumentLayout(model);
|
874
972
|
};
|
875
|
-
const
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
const
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
return { error: res.error };
|
897
|
-
}
|
898
|
-
toggleNotification({
|
899
|
-
type: "success",
|
900
|
-
message: formatMessage({
|
901
|
-
id: getTranslation("success.record.delete"),
|
902
|
-
defaultMessage: "Deleted document"
|
903
|
-
})
|
904
|
-
});
|
905
|
-
trackUsage("didDeleteEntry", trackerProperty);
|
906
|
-
return res.data;
|
907
|
-
} catch (err) {
|
908
|
-
toggleNotification({
|
909
|
-
type: "danger",
|
910
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
911
|
-
});
|
912
|
-
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
913
|
-
throw err;
|
973
|
+
const formatEditLayout = (data, {
|
974
|
+
schemas,
|
975
|
+
schema,
|
976
|
+
components
|
977
|
+
}) => {
|
978
|
+
let currentPanelIndex = 0;
|
979
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
980
|
+
data.contentType.layouts.edit,
|
981
|
+
schema?.attributes,
|
982
|
+
data.contentType.metadatas,
|
983
|
+
{ configurations: data.components, schemas: components },
|
984
|
+
schemas
|
985
|
+
).reduce((panels, row) => {
|
986
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
987
|
+
panels.push([row]);
|
988
|
+
currentPanelIndex += 2;
|
989
|
+
} else {
|
990
|
+
if (!panels[currentPanelIndex]) {
|
991
|
+
panels.push([row]);
|
992
|
+
} else {
|
993
|
+
panels[currentPanelIndex].push(row);
|
914
994
|
}
|
915
|
-
}
|
916
|
-
|
917
|
-
);
|
918
|
-
const
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
message: formatAPIError(res.error)
|
932
|
-
});
|
933
|
-
return { error: res.error };
|
995
|
+
}
|
996
|
+
return panels;
|
997
|
+
}, []);
|
998
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
999
|
+
(acc, [uid, configuration]) => {
|
1000
|
+
acc[uid] = {
|
1001
|
+
layout: convertEditLayoutToFieldLayouts(
|
1002
|
+
configuration.layouts.edit,
|
1003
|
+
components[uid].attributes,
|
1004
|
+
configuration.metadatas,
|
1005
|
+
{ configurations: data.components, schemas: components }
|
1006
|
+
),
|
1007
|
+
settings: {
|
1008
|
+
...configuration.settings,
|
1009
|
+
icon: components[uid].info.icon,
|
1010
|
+
displayName: components[uid].info.displayName
|
934
1011
|
}
|
935
|
-
|
936
|
-
|
937
|
-
title: formatMessage({
|
938
|
-
id: getTranslation("success.records.delete"),
|
939
|
-
defaultMessage: "Successfully deleted."
|
940
|
-
}),
|
941
|
-
message: ""
|
942
|
-
});
|
943
|
-
trackUsage("didBulkDeleteEntries");
|
944
|
-
return res.data;
|
945
|
-
} catch (err) {
|
946
|
-
toggleNotification({
|
947
|
-
type: "danger",
|
948
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
949
|
-
});
|
950
|
-
trackUsage("didNotBulkDeleteEntries");
|
951
|
-
throw err;
|
952
|
-
}
|
1012
|
+
};
|
1013
|
+
return acc;
|
953
1014
|
},
|
954
|
-
|
1015
|
+
{}
|
955
1016
|
);
|
956
|
-
const
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
model,
|
963
|
-
documentId,
|
964
|
-
params
|
965
|
-
});
|
966
|
-
if ("error" in res) {
|
967
|
-
toggleNotification({
|
968
|
-
type: "danger",
|
969
|
-
message: formatAPIError(res.error)
|
970
|
-
});
|
971
|
-
return { error: res.error };
|
972
|
-
}
|
973
|
-
toggleNotification({
|
974
|
-
type: "success",
|
975
|
-
message: formatMessage({
|
976
|
-
id: "content-manager.success.record.discard",
|
977
|
-
defaultMessage: "Changes discarded"
|
978
|
-
})
|
979
|
-
});
|
980
|
-
return res.data;
|
981
|
-
} catch (err) {
|
982
|
-
toggleNotification({
|
983
|
-
type: "danger",
|
984
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
985
|
-
});
|
986
|
-
throw err;
|
987
|
-
}
|
1017
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1018
|
+
(acc, [attribute, metadata]) => {
|
1019
|
+
return {
|
1020
|
+
...acc,
|
1021
|
+
[attribute]: metadata.edit
|
1022
|
+
};
|
988
1023
|
},
|
989
|
-
|
1024
|
+
{}
|
990
1025
|
);
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
model,
|
999
|
-
documentId,
|
1000
|
-
data,
|
1001
|
-
params
|
1002
|
-
});
|
1003
|
-
if ("error" in res) {
|
1004
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1005
|
-
return { error: res.error };
|
1006
|
-
}
|
1007
|
-
trackUsage("didPublishEntry");
|
1008
|
-
toggleNotification({
|
1009
|
-
type: "success",
|
1010
|
-
message: formatMessage({
|
1011
|
-
id: getTranslation("success.record.publish"),
|
1012
|
-
defaultMessage: "Published document"
|
1013
|
-
})
|
1014
|
-
});
|
1015
|
-
return res.data;
|
1016
|
-
} catch (err) {
|
1017
|
-
toggleNotification({
|
1018
|
-
type: "danger",
|
1019
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1020
|
-
});
|
1021
|
-
throw err;
|
1022
|
-
}
|
1026
|
+
return {
|
1027
|
+
layout: panelledEditAttributes,
|
1028
|
+
components: componentEditAttributes,
|
1029
|
+
metadatas: editMetadatas,
|
1030
|
+
settings: {
|
1031
|
+
...data.contentType.settings,
|
1032
|
+
displayName: schema?.info.displayName
|
1023
1033
|
},
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
return { error: res.error };
|
1038
|
-
}
|
1039
|
-
toggleNotification({
|
1040
|
-
type: "success",
|
1041
|
-
message: formatMessage({
|
1042
|
-
id: getTranslation("success.record.publish"),
|
1043
|
-
defaultMessage: "Published document"
|
1044
|
-
})
|
1045
|
-
});
|
1046
|
-
return res.data;
|
1047
|
-
} catch (err) {
|
1048
|
-
toggleNotification({
|
1049
|
-
type: "danger",
|
1050
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1051
|
-
});
|
1052
|
-
throw err;
|
1034
|
+
options: {
|
1035
|
+
...schema?.options,
|
1036
|
+
...schema?.pluginOptions,
|
1037
|
+
...data.contentType.options
|
1038
|
+
}
|
1039
|
+
};
|
1040
|
+
};
|
1041
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1042
|
+
return rows.map(
|
1043
|
+
(row) => row.map((field) => {
|
1044
|
+
const attribute = attributes[field.name];
|
1045
|
+
if (!attribute) {
|
1046
|
+
return null;
|
1053
1047
|
}
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1048
|
+
const { edit: metadata } = metadatas[field.name];
|
1049
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1050
|
+
return {
|
1051
|
+
attribute,
|
1052
|
+
disabled: !metadata.editable,
|
1053
|
+
hint: metadata.description,
|
1054
|
+
label: metadata.label ?? "",
|
1055
|
+
name: field.name,
|
1056
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1057
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1058
|
+
schemas,
|
1059
|
+
components: components?.schemas ?? {}
|
1060
|
+
}),
|
1061
|
+
placeholder: metadata.placeholder ?? "",
|
1062
|
+
required: attribute.required ?? false,
|
1063
|
+
size: field.size,
|
1064
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1065
|
+
visible: metadata.visible ?? true,
|
1066
|
+
type: attribute.type
|
1067
|
+
};
|
1068
|
+
}).filter((field) => field !== null)
|
1062
1069
|
);
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1070
|
+
};
|
1071
|
+
const formatListLayout = (data, {
|
1072
|
+
schemas,
|
1073
|
+
schema,
|
1074
|
+
components
|
1075
|
+
}) => {
|
1076
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1077
|
+
(acc, [attribute, metadata]) => {
|
1078
|
+
return {
|
1079
|
+
...acc,
|
1080
|
+
[attribute]: metadata.list
|
1081
|
+
};
|
1082
|
+
},
|
1083
|
+
{}
|
1084
|
+
);
|
1085
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1086
|
+
data.contentType.layouts.list,
|
1087
|
+
schema?.attributes,
|
1088
|
+
listMetadatas,
|
1089
|
+
{ configurations: data.components, schemas: components },
|
1090
|
+
schemas
|
1091
|
+
);
|
1092
|
+
return {
|
1093
|
+
layout: listAttributes,
|
1094
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1095
|
+
metadatas: listMetadatas,
|
1096
|
+
options: {
|
1097
|
+
...schema?.options,
|
1098
|
+
...schema?.pluginOptions,
|
1099
|
+
...data.contentType.options
|
1100
|
+
}
|
1101
|
+
};
|
1102
|
+
};
|
1103
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1104
|
+
return columns.map((name) => {
|
1105
|
+
const attribute = attributes[name];
|
1106
|
+
if (!attribute) {
|
1107
|
+
return null;
|
1108
|
+
}
|
1109
|
+
const metadata = metadatas[name];
|
1110
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1111
|
+
return {
|
1112
|
+
attribute,
|
1113
|
+
label: metadata.label ?? "",
|
1114
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1115
|
+
schemas,
|
1116
|
+
components: components?.schemas ?? {}
|
1117
|
+
}),
|
1118
|
+
name,
|
1119
|
+
searchable: metadata.searchable ?? true,
|
1120
|
+
sortable: metadata.sortable ?? true
|
1121
|
+
};
|
1122
|
+
}).filter((field) => field !== null);
|
1123
|
+
};
|
1124
|
+
const useDocument = (args, opts) => {
|
1125
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1126
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1127
|
+
const {
|
1128
|
+
currentData: data,
|
1129
|
+
isLoading: isLoadingDocument,
|
1130
|
+
isFetching: isFetchingDocument,
|
1131
|
+
error
|
1132
|
+
} = useGetDocumentQuery(args, {
|
1133
|
+
...opts,
|
1134
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1135
|
+
});
|
1136
|
+
const {
|
1137
|
+
components,
|
1138
|
+
schema,
|
1139
|
+
schemas,
|
1140
|
+
isLoading: isLoadingSchema
|
1141
|
+
} = useContentTypeSchema(args.model);
|
1142
|
+
React__namespace.useEffect(() => {
|
1143
|
+
if (error) {
|
1144
|
+
toggleNotification({
|
1145
|
+
type: "danger",
|
1146
|
+
message: formatAPIError(error)
|
1147
|
+
});
|
1148
|
+
}
|
1149
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1150
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1151
|
+
if (!schema) {
|
1152
|
+
return null;
|
1153
|
+
}
|
1154
|
+
return createYupSchema(schema.attributes, components);
|
1155
|
+
}, [schema, components]);
|
1156
|
+
const validate = React__namespace.useCallback(
|
1157
|
+
(document) => {
|
1158
|
+
if (!validationSchema) {
|
1159
|
+
throw new Error(
|
1160
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1161
|
+
);
|
1162
|
+
}
|
1066
1163
|
try {
|
1067
|
-
|
1068
|
-
|
1164
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1165
|
+
return null;
|
1166
|
+
} catch (error2) {
|
1167
|
+
if (error2 instanceof yup.ValidationError) {
|
1168
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1169
|
+
}
|
1170
|
+
throw error2;
|
1171
|
+
}
|
1172
|
+
},
|
1173
|
+
[validationSchema]
|
1174
|
+
);
|
1175
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1176
|
+
const hasError = !!error;
|
1177
|
+
return {
|
1178
|
+
components,
|
1179
|
+
document: data?.data,
|
1180
|
+
meta: data?.meta,
|
1181
|
+
isLoading,
|
1182
|
+
hasError,
|
1183
|
+
schema,
|
1184
|
+
schemas,
|
1185
|
+
validate
|
1186
|
+
};
|
1187
|
+
};
|
1188
|
+
const useDoc = () => {
|
1189
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1190
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1191
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1192
|
+
if (!collectionType) {
|
1193
|
+
throw new Error("Could not find collectionType in url params");
|
1194
|
+
}
|
1195
|
+
if (!slug) {
|
1196
|
+
throw new Error("Could not find model in url params");
|
1197
|
+
}
|
1198
|
+
const document = useDocument(
|
1199
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1200
|
+
{
|
1201
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1202
|
+
}
|
1203
|
+
);
|
1204
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1205
|
+
return {
|
1206
|
+
collectionType,
|
1207
|
+
model: slug,
|
1208
|
+
id: returnId,
|
1209
|
+
...document
|
1210
|
+
};
|
1211
|
+
};
|
1212
|
+
const useContentManagerContext = () => {
|
1213
|
+
const {
|
1214
|
+
collectionType,
|
1215
|
+
model,
|
1216
|
+
id,
|
1217
|
+
components,
|
1218
|
+
isLoading: isLoadingDoc,
|
1219
|
+
schema,
|
1220
|
+
schemas
|
1221
|
+
} = useDoc();
|
1222
|
+
const layout = useDocumentLayout(model);
|
1223
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1224
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1225
|
+
const slug = model;
|
1226
|
+
const isCreatingEntry = id === "create";
|
1227
|
+
useContentTypeSchema();
|
1228
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1229
|
+
const error = layout.error;
|
1230
|
+
return {
|
1231
|
+
error,
|
1232
|
+
isLoading,
|
1233
|
+
// Base metadata
|
1234
|
+
model,
|
1235
|
+
collectionType,
|
1236
|
+
id,
|
1237
|
+
slug,
|
1238
|
+
isCreatingEntry,
|
1239
|
+
isSingleType,
|
1240
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1241
|
+
// All schema infos
|
1242
|
+
components,
|
1243
|
+
contentType: schema,
|
1244
|
+
contentTypes: schemas,
|
1245
|
+
// Form state
|
1246
|
+
form,
|
1247
|
+
// layout infos
|
1248
|
+
layout
|
1249
|
+
};
|
1250
|
+
};
|
1251
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1252
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1253
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1254
|
+
return acc;
|
1255
|
+
}, {});
|
1256
|
+
};
|
1257
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1258
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1259
|
+
id: "notification.error",
|
1260
|
+
defaultMessage: "An error occurred, please try again"
|
1261
|
+
};
|
1262
|
+
const useDocumentActions = () => {
|
1263
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1264
|
+
const { formatMessage } = reactIntl.useIntl();
|
1265
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
1266
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1267
|
+
const navigate = reactRouterDom.useNavigate();
|
1268
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1269
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1270
|
+
const _delete = React__namespace.useCallback(
|
1271
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1272
|
+
try {
|
1273
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1274
|
+
const res = await deleteDocument({
|
1069
1275
|
collectionType,
|
1070
1276
|
model,
|
1071
1277
|
documentId,
|
1072
|
-
data,
|
1073
1278
|
params
|
1074
1279
|
});
|
1075
1280
|
if ("error" in res) {
|
1076
|
-
toggleNotification({
|
1077
|
-
|
1281
|
+
toggleNotification({
|
1282
|
+
type: "danger",
|
1283
|
+
message: formatAPIError(res.error)
|
1284
|
+
});
|
1078
1285
|
return { error: res.error };
|
1079
1286
|
}
|
1080
|
-
trackUsage("didEditEntry", trackerProperty);
|
1081
1287
|
toggleNotification({
|
1082
1288
|
type: "success",
|
1083
1289
|
message: formatMessage({
|
1084
|
-
id: getTranslation("success.record.
|
1085
|
-
defaultMessage: "
|
1290
|
+
id: getTranslation("success.record.delete"),
|
1291
|
+
defaultMessage: "Deleted document"
|
1086
1292
|
})
|
1087
1293
|
});
|
1294
|
+
trackUsage("didDeleteEntry", trackerProperty);
|
1088
1295
|
return res.data;
|
1089
1296
|
} catch (err) {
|
1090
|
-
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1091
1297
|
toggleNotification({
|
1092
1298
|
type: "danger",
|
1093
1299
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1094
1300
|
});
|
1301
|
+
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
1095
1302
|
throw err;
|
1096
1303
|
}
|
1097
1304
|
},
|
1098
|
-
[trackUsage,
|
1305
|
+
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
1099
1306
|
);
|
1100
|
-
const [
|
1101
|
-
const
|
1102
|
-
async ({
|
1307
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
1308
|
+
const deleteMany = React__namespace.useCallback(
|
1309
|
+
async ({ model, documentIds, params }) => {
|
1103
1310
|
try {
|
1104
|
-
trackUsage("
|
1105
|
-
const res = await
|
1106
|
-
collectionType,
|
1311
|
+
trackUsage("willBulkDeleteEntries");
|
1312
|
+
const res = await deleteManyDocuments({
|
1107
1313
|
model,
|
1108
|
-
|
1109
|
-
params
|
1110
|
-
data: {
|
1111
|
-
discardDraft
|
1112
|
-
}
|
1314
|
+
documentIds,
|
1315
|
+
params
|
1113
1316
|
});
|
1114
1317
|
if ("error" in res) {
|
1115
|
-
toggleNotification({
|
1318
|
+
toggleNotification({
|
1319
|
+
type: "danger",
|
1320
|
+
message: formatAPIError(res.error)
|
1321
|
+
});
|
1116
1322
|
return { error: res.error };
|
1117
1323
|
}
|
1118
|
-
trackUsage("didUnpublishEntry");
|
1119
1324
|
toggleNotification({
|
1120
1325
|
type: "success",
|
1121
|
-
|
1122
|
-
id: getTranslation("success.
|
1123
|
-
defaultMessage: "
|
1124
|
-
})
|
1326
|
+
title: formatMessage({
|
1327
|
+
id: getTranslation("success.records.delete"),
|
1328
|
+
defaultMessage: "Successfully deleted."
|
1329
|
+
}),
|
1330
|
+
message: ""
|
1125
1331
|
});
|
1332
|
+
trackUsage("didBulkDeleteEntries");
|
1126
1333
|
return res.data;
|
1127
1334
|
} catch (err) {
|
1128
1335
|
toggleNotification({
|
1129
1336
|
type: "danger",
|
1130
1337
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1131
1338
|
});
|
1339
|
+
trackUsage("didNotBulkDeleteEntries");
|
1132
1340
|
throw err;
|
1133
1341
|
}
|
1134
1342
|
},
|
1135
|
-
[trackUsage,
|
1343
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1136
1344
|
);
|
1137
|
-
const [
|
1138
|
-
const
|
1139
|
-
async ({ model,
|
1345
|
+
const [discardDocument] = useDiscardDocumentMutation();
|
1346
|
+
const discard = React__namespace.useCallback(
|
1347
|
+
async ({ collectionType, model, documentId, params }) => {
|
1140
1348
|
try {
|
1141
|
-
|
1142
|
-
|
1349
|
+
const res = await discardDocument({
|
1350
|
+
collectionType,
|
1143
1351
|
model,
|
1144
|
-
|
1352
|
+
documentId,
|
1145
1353
|
params
|
1146
1354
|
});
|
1147
1355
|
if ("error" in res) {
|
1148
|
-
toggleNotification({
|
1356
|
+
toggleNotification({
|
1357
|
+
type: "danger",
|
1358
|
+
message: formatAPIError(res.error)
|
1359
|
+
});
|
1149
1360
|
return { error: res.error };
|
1150
1361
|
}
|
1151
|
-
trackUsage("didBulkUnpublishEntries");
|
1152
1362
|
toggleNotification({
|
1153
1363
|
type: "success",
|
1154
|
-
|
1155
|
-
id:
|
1156
|
-
defaultMessage: "
|
1157
|
-
})
|
1158
|
-
message: ""
|
1364
|
+
message: formatMessage({
|
1365
|
+
id: "content-manager.success.record.discard",
|
1366
|
+
defaultMessage: "Changes discarded"
|
1367
|
+
})
|
1159
1368
|
});
|
1160
1369
|
return res.data;
|
1161
1370
|
} catch (err) {
|
@@ -1163,14 +1372,194 @@ const useDocumentActions = () => {
|
|
1163
1372
|
type: "danger",
|
1164
1373
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1165
1374
|
});
|
1166
|
-
trackUsage("didNotBulkUnpublishEntries");
|
1167
1375
|
throw err;
|
1168
1376
|
}
|
1169
1377
|
},
|
1170
|
-
[
|
1378
|
+
[discardDocument, formatAPIError, formatMessage, toggleNotification]
|
1171
1379
|
);
|
1172
|
-
const [
|
1173
|
-
const
|
1380
|
+
const [publishDocument] = usePublishDocumentMutation();
|
1381
|
+
const publish = React__namespace.useCallback(
|
1382
|
+
async ({ collectionType, model, documentId, params }, data) => {
|
1383
|
+
try {
|
1384
|
+
trackUsage("willPublishEntry");
|
1385
|
+
const res = await publishDocument({
|
1386
|
+
collectionType,
|
1387
|
+
model,
|
1388
|
+
documentId,
|
1389
|
+
data,
|
1390
|
+
params
|
1391
|
+
});
|
1392
|
+
if ("error" in res) {
|
1393
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1394
|
+
return { error: res.error };
|
1395
|
+
}
|
1396
|
+
trackUsage("didPublishEntry");
|
1397
|
+
toggleNotification({
|
1398
|
+
type: "success",
|
1399
|
+
message: formatMessage({
|
1400
|
+
id: getTranslation("success.record.publish"),
|
1401
|
+
defaultMessage: "Published document"
|
1402
|
+
})
|
1403
|
+
});
|
1404
|
+
return res.data;
|
1405
|
+
} catch (err) {
|
1406
|
+
toggleNotification({
|
1407
|
+
type: "danger",
|
1408
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1409
|
+
});
|
1410
|
+
throw err;
|
1411
|
+
}
|
1412
|
+
},
|
1413
|
+
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1414
|
+
);
|
1415
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1416
|
+
const publishMany = React__namespace.useCallback(
|
1417
|
+
async ({ model, documentIds, params }) => {
|
1418
|
+
try {
|
1419
|
+
const res = await publishManyDocuments({
|
1420
|
+
model,
|
1421
|
+
documentIds,
|
1422
|
+
params
|
1423
|
+
});
|
1424
|
+
if ("error" in res) {
|
1425
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1426
|
+
return { error: res.error };
|
1427
|
+
}
|
1428
|
+
toggleNotification({
|
1429
|
+
type: "success",
|
1430
|
+
message: formatMessage({
|
1431
|
+
id: getTranslation("success.record.publish"),
|
1432
|
+
defaultMessage: "Published document"
|
1433
|
+
})
|
1434
|
+
});
|
1435
|
+
return res.data;
|
1436
|
+
} catch (err) {
|
1437
|
+
toggleNotification({
|
1438
|
+
type: "danger",
|
1439
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1440
|
+
});
|
1441
|
+
throw err;
|
1442
|
+
}
|
1443
|
+
},
|
1444
|
+
[
|
1445
|
+
// trackUsage,
|
1446
|
+
publishManyDocuments,
|
1447
|
+
toggleNotification,
|
1448
|
+
formatMessage,
|
1449
|
+
formatAPIError
|
1450
|
+
]
|
1451
|
+
);
|
1452
|
+
const [updateDocument] = useUpdateDocumentMutation();
|
1453
|
+
const update = React__namespace.useCallback(
|
1454
|
+
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
1455
|
+
try {
|
1456
|
+
trackUsage("willEditEntry", trackerProperty);
|
1457
|
+
const res = await updateDocument({
|
1458
|
+
collectionType,
|
1459
|
+
model,
|
1460
|
+
documentId,
|
1461
|
+
data,
|
1462
|
+
params
|
1463
|
+
});
|
1464
|
+
if ("error" in res) {
|
1465
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1466
|
+
trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
|
1467
|
+
return { error: res.error };
|
1468
|
+
}
|
1469
|
+
trackUsage("didEditEntry", trackerProperty);
|
1470
|
+
toggleNotification({
|
1471
|
+
type: "success",
|
1472
|
+
message: formatMessage({
|
1473
|
+
id: getTranslation("success.record.save"),
|
1474
|
+
defaultMessage: "Saved document"
|
1475
|
+
})
|
1476
|
+
});
|
1477
|
+
return res.data;
|
1478
|
+
} catch (err) {
|
1479
|
+
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1480
|
+
toggleNotification({
|
1481
|
+
type: "danger",
|
1482
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1483
|
+
});
|
1484
|
+
throw err;
|
1485
|
+
}
|
1486
|
+
},
|
1487
|
+
[trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
|
1488
|
+
);
|
1489
|
+
const [unpublishDocument] = useUnpublishDocumentMutation();
|
1490
|
+
const unpublish = React__namespace.useCallback(
|
1491
|
+
async ({ collectionType, model, documentId, params }, discardDraft = false) => {
|
1492
|
+
try {
|
1493
|
+
trackUsage("willUnpublishEntry");
|
1494
|
+
const res = await unpublishDocument({
|
1495
|
+
collectionType,
|
1496
|
+
model,
|
1497
|
+
documentId,
|
1498
|
+
params,
|
1499
|
+
data: {
|
1500
|
+
discardDraft
|
1501
|
+
}
|
1502
|
+
});
|
1503
|
+
if ("error" in res) {
|
1504
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1505
|
+
return { error: res.error };
|
1506
|
+
}
|
1507
|
+
trackUsage("didUnpublishEntry");
|
1508
|
+
toggleNotification({
|
1509
|
+
type: "success",
|
1510
|
+
message: formatMessage({
|
1511
|
+
id: getTranslation("success.record.unpublish"),
|
1512
|
+
defaultMessage: "Unpublished document"
|
1513
|
+
})
|
1514
|
+
});
|
1515
|
+
return res.data;
|
1516
|
+
} catch (err) {
|
1517
|
+
toggleNotification({
|
1518
|
+
type: "danger",
|
1519
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1520
|
+
});
|
1521
|
+
throw err;
|
1522
|
+
}
|
1523
|
+
},
|
1524
|
+
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1525
|
+
);
|
1526
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1527
|
+
const unpublishMany = React__namespace.useCallback(
|
1528
|
+
async ({ model, documentIds, params }) => {
|
1529
|
+
try {
|
1530
|
+
trackUsage("willBulkUnpublishEntries");
|
1531
|
+
const res = await unpublishManyDocuments({
|
1532
|
+
model,
|
1533
|
+
documentIds,
|
1534
|
+
params
|
1535
|
+
});
|
1536
|
+
if ("error" in res) {
|
1537
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1538
|
+
return { error: res.error };
|
1539
|
+
}
|
1540
|
+
trackUsage("didBulkUnpublishEntries");
|
1541
|
+
toggleNotification({
|
1542
|
+
type: "success",
|
1543
|
+
title: formatMessage({
|
1544
|
+
id: getTranslation("success.records.unpublish"),
|
1545
|
+
defaultMessage: "Successfully unpublished."
|
1546
|
+
}),
|
1547
|
+
message: ""
|
1548
|
+
});
|
1549
|
+
return res.data;
|
1550
|
+
} catch (err) {
|
1551
|
+
toggleNotification({
|
1552
|
+
type: "danger",
|
1553
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1554
|
+
});
|
1555
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1556
|
+
throw err;
|
1557
|
+
}
|
1558
|
+
},
|
1559
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1560
|
+
);
|
1561
|
+
const [createDocument] = useCreateDocumentMutation();
|
1562
|
+
const create = React__namespace.useCallback(
|
1174
1563
|
async ({ model, params }, data, trackerProperty) => {
|
1175
1564
|
try {
|
1176
1565
|
const res = await createDocument({
|
@@ -1191,6 +1580,7 @@ const useDocumentActions = () => {
|
|
1191
1580
|
defaultMessage: "Saved document"
|
1192
1581
|
})
|
1193
1582
|
});
|
1583
|
+
setCurrentStep("contentManager.success");
|
1194
1584
|
return res.data;
|
1195
1585
|
} catch (err) {
|
1196
1586
|
toggleNotification({
|
@@ -1230,7 +1620,7 @@ const useDocumentActions = () => {
|
|
1230
1620
|
throw err;
|
1231
1621
|
}
|
1232
1622
|
},
|
1233
|
-
[autoCloneDocument,
|
1623
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1234
1624
|
);
|
1235
1625
|
const [cloneDocument] = useCloneDocumentMutation();
|
1236
1626
|
const clone = React__namespace.useCallback(
|
@@ -1256,6 +1646,7 @@ const useDocumentActions = () => {
|
|
1256
1646
|
defaultMessage: "Cloned document"
|
1257
1647
|
})
|
1258
1648
|
});
|
1649
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1259
1650
|
return res.data;
|
1260
1651
|
} catch (err) {
|
1261
1652
|
toggleNotification({
|
@@ -1266,7 +1657,7 @@ const useDocumentActions = () => {
|
|
1266
1657
|
throw err;
|
1267
1658
|
}
|
1268
1659
|
},
|
1269
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1660
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1270
1661
|
);
|
1271
1662
|
const [getDoc] = useLazyGetDocumentQuery();
|
1272
1663
|
const getDocument = React__namespace.useCallback(
|
@@ -1291,10 +1682,10 @@ const useDocumentActions = () => {
|
|
1291
1682
|
update
|
1292
1683
|
};
|
1293
1684
|
};
|
1294
|
-
const ProtectedHistoryPage =
|
1295
|
-
() => Promise.resolve().then(() => require("./History-
|
1685
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1686
|
+
() => Promise.resolve().then(() => require("./History-DYMicybF.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1296
1687
|
);
|
1297
|
-
const routes$
|
1688
|
+
const routes$2 = [
|
1298
1689
|
{
|
1299
1690
|
path: ":collectionType/:slug/:id/history",
|
1300
1691
|
Component: ProtectedHistoryPage
|
@@ -1304,32 +1695,45 @@ const routes$1 = [
|
|
1304
1695
|
Component: ProtectedHistoryPage
|
1305
1696
|
}
|
1306
1697
|
];
|
1698
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1699
|
+
() => Promise.resolve().then(() => require("./Preview-D4KzuJFL.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1700
|
+
);
|
1701
|
+
const routes$1 = [
|
1702
|
+
{
|
1703
|
+
path: ":collectionType/:slug/:id/preview",
|
1704
|
+
Component: ProtectedPreviewPage
|
1705
|
+
},
|
1706
|
+
{
|
1707
|
+
path: ":collectionType/:slug/preview",
|
1708
|
+
Component: ProtectedPreviewPage
|
1709
|
+
}
|
1710
|
+
];
|
1307
1711
|
const ProtectedEditViewPage = React.lazy(
|
1308
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1712
|
+
() => Promise.resolve().then(() => require("./EditViewPage-C7l2Emuj.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1309
1713
|
);
|
1310
1714
|
const ProtectedListViewPage = React.lazy(
|
1311
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1715
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BSLzd7cZ.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1312
1716
|
);
|
1313
1717
|
const ProtectedListConfiguration = React.lazy(
|
1314
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1718
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-rUF9iGWq.js")).then((mod) => ({
|
1315
1719
|
default: mod.ProtectedListConfiguration
|
1316
1720
|
}))
|
1317
1721
|
);
|
1318
1722
|
const ProtectedEditConfigurationPage = React.lazy(
|
1319
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1723
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-Cp9UzUfs.js")).then((mod) => ({
|
1320
1724
|
default: mod.ProtectedEditConfigurationPage
|
1321
1725
|
}))
|
1322
1726
|
);
|
1323
1727
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1324
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1728
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-UduDBv3m.js")).then((mod) => ({
|
1325
1729
|
default: mod.ProtectedComponentConfigurationPage
|
1326
1730
|
}))
|
1327
1731
|
);
|
1328
1732
|
const NoPermissions = React.lazy(
|
1329
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1733
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-Af32Gg2m.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1330
1734
|
);
|
1331
1735
|
const NoContentType = React.lazy(
|
1332
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1736
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-CQccVhIX.js")).then((mod) => ({ default: mod.NoContentType }))
|
1333
1737
|
);
|
1334
1738
|
const CollectionTypePages = () => {
|
1335
1739
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1341,7 +1745,7 @@ const CollectionTypePages = () => {
|
|
1341
1745
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1342
1746
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1343
1747
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1344
|
-
const LIST_PATH = `/content-manager
|
1748
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1345
1749
|
const routes = [
|
1346
1750
|
{
|
1347
1751
|
path: LIST_RELATIVE_PATH,
|
@@ -1375,6 +1779,7 @@ const routes = [
|
|
1375
1779
|
path: "no-content-types",
|
1376
1780
|
Component: NoContentType
|
1377
1781
|
},
|
1782
|
+
...routes$2,
|
1378
1783
|
...routes$1
|
1379
1784
|
];
|
1380
1785
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1443,12 +1848,14 @@ const DocumentActionButton = (action) => {
|
|
1443
1848
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1444
1849
|
designSystem.Button,
|
1445
1850
|
{
|
1446
|
-
flex:
|
1851
|
+
flex: "auto",
|
1447
1852
|
startIcon: action.icon,
|
1448
1853
|
disabled: action.disabled,
|
1449
1854
|
onClick: handleClick(action),
|
1450
1855
|
justifyContent: "center",
|
1451
1856
|
variant: action.variant || "default",
|
1857
|
+
paddingTop: "7px",
|
1858
|
+
paddingBottom: "7px",
|
1452
1859
|
children: action.label
|
1453
1860
|
}
|
1454
1861
|
),
|
@@ -1471,6 +1878,11 @@ const DocumentActionButton = (action) => {
|
|
1471
1878
|
) : null
|
1472
1879
|
] });
|
1473
1880
|
};
|
1881
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1882
|
+
&:hover {
|
1883
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1884
|
+
}
|
1885
|
+
`;
|
1474
1886
|
const DocumentActionsMenu = ({
|
1475
1887
|
actions: actions2,
|
1476
1888
|
children,
|
@@ -1513,9 +1925,9 @@ const DocumentActionsMenu = ({
|
|
1513
1925
|
disabled: isDisabled,
|
1514
1926
|
size: "S",
|
1515
1927
|
endIcon: null,
|
1516
|
-
paddingTop: "
|
1517
|
-
paddingLeft: "
|
1518
|
-
paddingRight: "
|
1928
|
+
paddingTop: "4px",
|
1929
|
+
paddingLeft: "7px",
|
1930
|
+
paddingRight: "7px",
|
1519
1931
|
variant,
|
1520
1932
|
children: [
|
1521
1933
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1526,36 +1938,35 @@ const DocumentActionsMenu = ({
|
|
1526
1938
|
]
|
1527
1939
|
}
|
1528
1940
|
),
|
1529
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1941
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1530
1942
|
actions2.map((action) => {
|
1531
1943
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1532
|
-
|
1944
|
+
MenuItem,
|
1533
1945
|
{
|
1534
1946
|
disabled: action.disabled,
|
1535
1947
|
onSelect: handleClick(action),
|
1536
1948
|
display: "block",
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
] })
|
1949
|
+
isVariantDanger: action.variant === "danger",
|
1950
|
+
isDisabled: action.disabled,
|
1951
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1952
|
+
designSystem.Flex,
|
1953
|
+
{
|
1954
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1955
|
+
gap: 2,
|
1956
|
+
tag: "span",
|
1957
|
+
children: [
|
1958
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1959
|
+
designSystem.Flex,
|
1960
|
+
{
|
1961
|
+
tag: "span",
|
1962
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1963
|
+
children: action.icon
|
1964
|
+
}
|
1965
|
+
),
|
1966
|
+
action.label
|
1967
|
+
]
|
1968
|
+
}
|
1969
|
+
) })
|
1559
1970
|
},
|
1560
1971
|
action.id
|
1561
1972
|
);
|
@@ -1635,11 +2046,11 @@ const DocumentActionConfirmDialog = ({
|
|
1635
2046
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1636
2047
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1637
2048
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1638
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
2049
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1639
2050
|
id: "app.components.Button.cancel",
|
1640
2051
|
defaultMessage: "Cancel"
|
1641
2052
|
}) }) }),
|
1642
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2053
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1643
2054
|
id: "app.components.Button.confirm",
|
1644
2055
|
defaultMessage: "Confirm"
|
1645
2056
|
}) })
|
@@ -1666,6 +2077,18 @@ const DocumentActionModal = ({
|
|
1666
2077
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1667
2078
|
] }) });
|
1668
2079
|
};
|
2080
|
+
const transformData = (data) => {
|
2081
|
+
if (Array.isArray(data)) {
|
2082
|
+
return data.map(transformData);
|
2083
|
+
}
|
2084
|
+
if (typeof data === "object" && data !== null) {
|
2085
|
+
if ("apiData" in data) {
|
2086
|
+
return data.apiData;
|
2087
|
+
}
|
2088
|
+
return mapValues__default.default(transformData)(data);
|
2089
|
+
}
|
2090
|
+
return data;
|
2091
|
+
};
|
1669
2092
|
const PublishAction$1 = ({
|
1670
2093
|
activeTab,
|
1671
2094
|
documentId,
|
@@ -1678,12 +2101,11 @@ const PublishAction$1 = ({
|
|
1678
2101
|
const navigate = reactRouterDom.useNavigate();
|
1679
2102
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1680
2103
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2104
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1681
2105
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2106
|
+
const { id } = reactRouterDom.useParams();
|
1682
2107
|
const { formatMessage } = reactIntl.useIntl();
|
1683
|
-
const { canPublish
|
1684
|
-
"PublishAction",
|
1685
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1686
|
-
);
|
2108
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1687
2109
|
const { publish } = useDocumentActions();
|
1688
2110
|
const [
|
1689
2111
|
countDraftRelations,
|
@@ -1735,24 +2157,25 @@ const PublishAction$1 = ({
|
|
1735
2157
|
}
|
1736
2158
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1737
2159
|
React__namespace.useEffect(() => {
|
1738
|
-
if (documentId) {
|
1739
|
-
|
1740
|
-
const { data, error } = await countDraftRelations({
|
1741
|
-
collectionType,
|
1742
|
-
model,
|
1743
|
-
documentId,
|
1744
|
-
params
|
1745
|
-
});
|
1746
|
-
if (error) {
|
1747
|
-
throw error;
|
1748
|
-
}
|
1749
|
-
if (data) {
|
1750
|
-
setServerCountOfDraftRelations(data.data);
|
1751
|
-
}
|
1752
|
-
};
|
1753
|
-
fetchDraftRelationsCount();
|
2160
|
+
if (!document || !document.documentId || isListView) {
|
2161
|
+
return;
|
1754
2162
|
}
|
1755
|
-
|
2163
|
+
const fetchDraftRelationsCount = async () => {
|
2164
|
+
const { data, error } = await countDraftRelations({
|
2165
|
+
collectionType,
|
2166
|
+
model,
|
2167
|
+
documentId,
|
2168
|
+
params
|
2169
|
+
});
|
2170
|
+
if (error) {
|
2171
|
+
throw error;
|
2172
|
+
}
|
2173
|
+
if (data) {
|
2174
|
+
setServerCountOfDraftRelations(data.data);
|
2175
|
+
}
|
2176
|
+
};
|
2177
|
+
fetchDraftRelationsCount();
|
2178
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1756
2179
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1757
2180
|
if (!schema?.options?.draftAndPublish) {
|
1758
2181
|
return null;
|
@@ -1760,7 +2183,9 @@ const PublishAction$1 = ({
|
|
1760
2183
|
const performPublish = async () => {
|
1761
2184
|
setSubmitting(true);
|
1762
2185
|
try {
|
1763
|
-
const { errors } = await validate(
|
2186
|
+
const { errors } = await validate(true, {
|
2187
|
+
status: "published"
|
2188
|
+
});
|
1764
2189
|
if (errors) {
|
1765
2190
|
toggleNotification({
|
1766
2191
|
type: "danger",
|
@@ -1778,13 +2203,15 @@ const PublishAction$1 = ({
|
|
1778
2203
|
documentId,
|
1779
2204
|
params
|
1780
2205
|
},
|
1781
|
-
formValues
|
2206
|
+
transformData(formValues)
|
1782
2207
|
);
|
1783
2208
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
2209
|
+
if (id === "create") {
|
2210
|
+
navigate({
|
2211
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2212
|
+
search: rawQuery
|
2213
|
+
});
|
2214
|
+
}
|
1788
2215
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1789
2216
|
setErrors(formatValidationErrors(res.error));
|
1790
2217
|
}
|
@@ -1793,7 +2220,8 @@ const PublishAction$1 = ({
|
|
1793
2220
|
}
|
1794
2221
|
};
|
1795
2222
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1796
|
-
const
|
2223
|
+
const enableDraftRelationsCount = false;
|
2224
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1797
2225
|
return {
|
1798
2226
|
/**
|
1799
2227
|
* Disabled when:
|
@@ -1803,18 +2231,13 @@ const PublishAction$1 = ({
|
|
1803
2231
|
* - the document is already published & not modified
|
1804
2232
|
* - the document is being created & not modified
|
1805
2233
|
* - the user doesn't have the permission to publish
|
1806
|
-
* - the user doesn't have the permission to create a new document
|
1807
|
-
* - the user doesn't have the permission to update the document
|
1808
2234
|
*/
|
1809
|
-
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2235
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1810
2236
|
label: formatMessage({
|
1811
2237
|
id: "app.utils.publish",
|
1812
2238
|
defaultMessage: "Publish"
|
1813
2239
|
}),
|
1814
2240
|
onClick: async () => {
|
1815
|
-
if (hasDraftRelations) {
|
1816
|
-
return;
|
1817
|
-
}
|
1818
2241
|
await performPublish();
|
1819
2242
|
},
|
1820
2243
|
dialog: hasDraftRelations ? {
|
@@ -1853,10 +2276,6 @@ const UpdateAction = ({
|
|
1853
2276
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1854
2277
|
const isCloning = cloneMatch !== null;
|
1855
2278
|
const { formatMessage } = reactIntl.useIntl();
|
1856
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1857
|
-
canCreate: canCreate2,
|
1858
|
-
canUpdate: canUpdate2
|
1859
|
-
}));
|
1860
2279
|
const { create, update, clone } = useDocumentActions();
|
1861
2280
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1862
2281
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1873,18 +2292,18 @@ const UpdateAction = ({
|
|
1873
2292
|
* - the form is submitting
|
1874
2293
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1875
2294
|
* - the active tab is the published tab
|
1876
|
-
* - the user doesn't have the permission to create a new document
|
1877
|
-
* - the user doesn't have the permission to update the document
|
1878
2295
|
*/
|
1879
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
2296
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1880
2297
|
label: formatMessage({
|
1881
|
-
id: "
|
2298
|
+
id: "global.save",
|
1882
2299
|
defaultMessage: "Save"
|
1883
2300
|
}),
|
1884
2301
|
onClick: async () => {
|
1885
2302
|
setSubmitting(true);
|
1886
2303
|
try {
|
1887
|
-
const { errors } = await validate(
|
2304
|
+
const { errors } = await validate(true, {
|
2305
|
+
status: "draft"
|
2306
|
+
});
|
1888
2307
|
if (errors) {
|
1889
2308
|
toggleNotification({
|
1890
2309
|
type: "danger",
|
@@ -1902,7 +2321,7 @@ const UpdateAction = ({
|
|
1902
2321
|
documentId: cloneMatch.params.origin,
|
1903
2322
|
params
|
1904
2323
|
},
|
1905
|
-
document
|
2324
|
+
transformData(document)
|
1906
2325
|
);
|
1907
2326
|
if ("data" in res) {
|
1908
2327
|
navigate(
|
@@ -1923,7 +2342,7 @@ const UpdateAction = ({
|
|
1923
2342
|
documentId,
|
1924
2343
|
params
|
1925
2344
|
},
|
1926
|
-
document
|
2345
|
+
transformData(document)
|
1927
2346
|
);
|
1928
2347
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1929
2348
|
setErrors(formatValidationErrors(res.error));
|
@@ -1936,7 +2355,7 @@ const UpdateAction = ({
|
|
1936
2355
|
model,
|
1937
2356
|
params
|
1938
2357
|
},
|
1939
|
-
document
|
2358
|
+
transformData(document)
|
1940
2359
|
);
|
1941
2360
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1942
2361
|
navigate(
|
@@ -1989,7 +2408,7 @@ const UnpublishAction$1 = ({
|
|
1989
2408
|
id: "app.utils.unpublish",
|
1990
2409
|
defaultMessage: "Unpublish"
|
1991
2410
|
}),
|
1992
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2411
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1993
2412
|
onClick: async () => {
|
1994
2413
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1995
2414
|
if (!documentId) {
|
@@ -2101,7 +2520,7 @@ const DiscardAction = ({
|
|
2101
2520
|
id: "content-manager.actions.discard.label",
|
2102
2521
|
defaultMessage: "Discard changes"
|
2103
2522
|
}),
|
2104
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2523
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2105
2524
|
position: ["panel", "table-row"],
|
2106
2525
|
variant: "danger",
|
2107
2526
|
dialog: {
|
@@ -2129,11 +2548,6 @@ const DiscardAction = ({
|
|
2129
2548
|
};
|
2130
2549
|
};
|
2131
2550
|
DiscardAction.type = "discard";
|
2132
|
-
const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
2133
|
-
path {
|
2134
|
-
fill: currentColor;
|
2135
|
-
}
|
2136
|
-
`;
|
2137
2551
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2138
2552
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2139
2553
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2146,7 +2560,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2146
2560
|
});
|
2147
2561
|
const unit = intervals.find((intervalUnit) => {
|
2148
2562
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2149
|
-
});
|
2563
|
+
}) ?? "seconds";
|
2150
2564
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2151
2565
|
const customInterval = customIntervals.find(
|
2152
2566
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2180,19 +2594,29 @@ const getDisplayName = ({
|
|
2180
2594
|
return email ?? "";
|
2181
2595
|
};
|
2182
2596
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2183
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2184
|
-
const statusVariant = status === "draft" ? "
|
2185
|
-
|
2597
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2598
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2599
|
+
const { formatMessage } = reactIntl.useIntl();
|
2600
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2601
|
+
id: `content-manager.containers.List.${status}`,
|
2602
|
+
defaultMessage: capitalise(status)
|
2603
|
+
}) }) });
|
2186
2604
|
};
|
2187
2605
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2188
2606
|
const { formatMessage } = reactIntl.useIntl();
|
2189
2607
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2608
|
+
const params = reactRouterDom.useParams();
|
2190
2609
|
const title = isCreating ? formatMessage({
|
2191
2610
|
id: "content-manager.containers.edit.title.new",
|
2192
2611
|
defaultMessage: "Create an entry"
|
2193
2612
|
}) : documentTitle;
|
2194
2613
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2195
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2614
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2615
|
+
strapiAdmin.BackButton,
|
2616
|
+
{
|
2617
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2618
|
+
}
|
2619
|
+
),
|
2196
2620
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2197
2621
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2198
2622
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2280,12 +2704,12 @@ const Information = ({ activeTab }) => {
|
|
2280
2704
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2281
2705
|
label: formatMessage({
|
2282
2706
|
id: "content-manager.containers.edit.information.last-published.label",
|
2283
|
-
defaultMessage: "
|
2707
|
+
defaultMessage: "Published"
|
2284
2708
|
}),
|
2285
2709
|
value: formatMessage(
|
2286
2710
|
{
|
2287
2711
|
id: "content-manager.containers.edit.information.last-published.value",
|
2288
|
-
defaultMessage: `
|
2712
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2289
2713
|
},
|
2290
2714
|
{
|
2291
2715
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2298,12 +2722,12 @@ const Information = ({ activeTab }) => {
|
|
2298
2722
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2299
2723
|
label: formatMessage({
|
2300
2724
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2301
|
-
defaultMessage: "
|
2725
|
+
defaultMessage: "Updated"
|
2302
2726
|
}),
|
2303
2727
|
value: formatMessage(
|
2304
2728
|
{
|
2305
2729
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2306
|
-
defaultMessage: `
|
2730
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2307
2731
|
},
|
2308
2732
|
{
|
2309
2733
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2321,12 +2745,12 @@ const Information = ({ activeTab }) => {
|
|
2321
2745
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2322
2746
|
label: formatMessage({
|
2323
2747
|
id: "content-manager.containers.edit.information.document.label",
|
2324
|
-
defaultMessage: "
|
2748
|
+
defaultMessage: "Created"
|
2325
2749
|
}),
|
2326
2750
|
value: formatMessage(
|
2327
2751
|
{
|
2328
2752
|
id: "content-manager.containers.edit.information.document.value",
|
2329
|
-
defaultMessage: `
|
2753
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2330
2754
|
},
|
2331
2755
|
{
|
2332
2756
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2364,28 +2788,80 @@ const Information = ({ activeTab }) => {
|
|
2364
2788
|
);
|
2365
2789
|
};
|
2366
2790
|
const HeaderActions = ({ actions: actions2 }) => {
|
2367
|
-
|
2368
|
-
|
2791
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2792
|
+
const handleClick = (action) => async (e) => {
|
2793
|
+
if (!("options" in action)) {
|
2794
|
+
const { onClick = () => false, dialog, id } = action;
|
2795
|
+
const muteDialog = await onClick(e);
|
2796
|
+
if (dialog && !muteDialog) {
|
2797
|
+
e.preventDefault();
|
2798
|
+
setDialogId(id);
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
};
|
2802
|
+
const handleClose = () => {
|
2803
|
+
setDialogId(null);
|
2804
|
+
};
|
2805
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2806
|
+
if (action.options) {
|
2369
2807
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2370
2808
|
designSystem.SingleSelect,
|
2371
2809
|
{
|
2372
2810
|
size: "S",
|
2373
|
-
disabled: action.disabled,
|
2374
|
-
"aria-label": action.label,
|
2375
2811
|
onChange: action.onSelect,
|
2376
|
-
|
2812
|
+
"aria-label": action.label,
|
2813
|
+
...action,
|
2377
2814
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2378
2815
|
},
|
2379
2816
|
action.id
|
2380
2817
|
);
|
2381
2818
|
} else {
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2819
|
+
if (action.type === "icon") {
|
2820
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2821
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2822
|
+
designSystem.IconButton,
|
2823
|
+
{
|
2824
|
+
disabled: action.disabled,
|
2825
|
+
label: action.label,
|
2826
|
+
size: "S",
|
2827
|
+
onClick: handleClick(action),
|
2828
|
+
children: action.icon
|
2829
|
+
}
|
2830
|
+
),
|
2831
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2832
|
+
HeaderActionDialog,
|
2833
|
+
{
|
2834
|
+
...action.dialog,
|
2835
|
+
isOpen: dialogId === action.id,
|
2836
|
+
onClose: handleClose
|
2837
|
+
}
|
2838
|
+
) : null
|
2839
|
+
] }, action.id);
|
2840
|
+
}
|
2841
|
+
}
|
2842
|
+
}) });
|
2843
|
+
};
|
2844
|
+
const HeaderActionDialog = ({
|
2845
|
+
onClose,
|
2846
|
+
onCancel,
|
2847
|
+
title,
|
2848
|
+
content: Content,
|
2849
|
+
isOpen
|
2850
|
+
}) => {
|
2851
|
+
const handleClose = async () => {
|
2852
|
+
if (onCancel) {
|
2853
|
+
await onCancel();
|
2854
|
+
}
|
2855
|
+
onClose();
|
2856
|
+
};
|
2857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2858
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2859
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2860
|
+
] }) });
|
2861
|
+
};
|
2862
|
+
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2863
|
+
const navigate = reactRouterDom.useNavigate();
|
2864
|
+
const { formatMessage } = reactIntl.useIntl();
|
2389
2865
|
return {
|
2390
2866
|
label: formatMessage({
|
2391
2867
|
id: "app.links.configure-view",
|
@@ -2423,12 +2899,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2423
2899
|
const { delete: deleteAction } = useDocumentActions();
|
2424
2900
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2425
2901
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2902
|
+
const isLocalized = document?.locale != null;
|
2426
2903
|
return {
|
2427
2904
|
disabled: !canDelete || !document,
|
2428
|
-
label: formatMessage(
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2905
|
+
label: formatMessage(
|
2906
|
+
{
|
2907
|
+
id: "content-manager.actions.delete.label",
|
2908
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2909
|
+
},
|
2910
|
+
{ isLocalized }
|
2911
|
+
),
|
2432
2912
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2433
2913
|
dialog: {
|
2434
2914
|
type: "dialog",
|
@@ -2465,422 +2945,120 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2465
2945
|
documentId,
|
2466
2946
|
model,
|
2467
2947
|
collectionType,
|
2468
|
-
params: {
|
2469
|
-
locale: "*"
|
2470
|
-
}
|
2471
|
-
});
|
2472
|
-
if (!("error" in res)) {
|
2473
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2474
|
-
}
|
2475
|
-
} finally {
|
2476
|
-
if (!listViewPathMatch) {
|
2477
|
-
setSubmitting(false);
|
2478
|
-
}
|
2479
|
-
}
|
2480
|
-
}
|
2481
|
-
},
|
2482
|
-
variant: "danger",
|
2483
|
-
position: ["header", "table-row"]
|
2484
|
-
};
|
2485
|
-
};
|
2486
|
-
DeleteAction$1.type = "delete";
|
2487
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2488
|
-
const Panels = () => {
|
2489
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2490
|
-
const [
|
2491
|
-
{
|
2492
|
-
query: { status }
|
2493
|
-
}
|
2494
|
-
] = strapiAdmin.useQueryParams({
|
2495
|
-
status: "draft"
|
2496
|
-
});
|
2497
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2498
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2499
|
-
const props = {
|
2500
|
-
activeTab: status,
|
2501
|
-
model,
|
2502
|
-
documentId: id,
|
2503
|
-
document: isCloning ? void 0 : document,
|
2504
|
-
meta: isCloning ? void 0 : meta,
|
2505
|
-
collectionType
|
2506
|
-
};
|
2507
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2508
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2509
|
-
{
|
2510
|
-
props,
|
2511
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2512
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2513
|
-
}
|
2514
|
-
) });
|
2515
|
-
};
|
2516
|
-
const ActionsPanel = () => {
|
2517
|
-
const { formatMessage } = reactIntl.useIntl();
|
2518
|
-
return {
|
2519
|
-
title: formatMessage({
|
2520
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2521
|
-
defaultMessage: "Document"
|
2522
|
-
}),
|
2523
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2524
|
-
};
|
2525
|
-
};
|
2526
|
-
ActionsPanel.type = "actions";
|
2527
|
-
const ActionsPanelContent = () => {
|
2528
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2529
|
-
const [
|
2530
|
-
{
|
2531
|
-
query: { status = "draft" }
|
2532
|
-
}
|
2533
|
-
] = strapiAdmin.useQueryParams();
|
2534
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2535
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2536
|
-
const props = {
|
2537
|
-
activeTab: status,
|
2538
|
-
model,
|
2539
|
-
documentId: id,
|
2540
|
-
document: isCloning ? void 0 : document,
|
2541
|
-
meta: isCloning ? void 0 : meta,
|
2542
|
-
collectionType
|
2543
|
-
};
|
2544
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2545
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2546
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2547
|
-
{
|
2548
|
-
props,
|
2549
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2550
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2551
|
-
}
|
2552
|
-
),
|
2553
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2554
|
-
] });
|
2555
|
-
};
|
2556
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2557
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2558
|
-
designSystem.Flex,
|
2559
|
-
{
|
2560
|
-
ref,
|
2561
|
-
tag: "aside",
|
2562
|
-
"aria-labelledby": "additional-information",
|
2563
|
-
background: "neutral0",
|
2564
|
-
borderColor: "neutral150",
|
2565
|
-
hasRadius: true,
|
2566
|
-
paddingBottom: 4,
|
2567
|
-
paddingLeft: 4,
|
2568
|
-
paddingRight: 4,
|
2569
|
-
paddingTop: 4,
|
2570
|
-
shadow: "tableShadow",
|
2571
|
-
gap: 3,
|
2572
|
-
direction: "column",
|
2573
|
-
justifyContent: "stretch",
|
2574
|
-
alignItems: "flex-start",
|
2575
|
-
children: [
|
2576
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2577
|
-
children
|
2578
|
-
]
|
2579
|
-
}
|
2580
|
-
);
|
2581
|
-
});
|
2582
|
-
const HOOKS = {
|
2583
|
-
/**
|
2584
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2585
|
-
* @constant
|
2586
|
-
* @type {string}
|
2587
|
-
*/
|
2588
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2589
|
-
/**
|
2590
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2591
|
-
* @constant
|
2592
|
-
* @type {string}
|
2593
|
-
*/
|
2594
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2595
|
-
/**
|
2596
|
-
* Hook that allows to mutate the CM's edit view layout
|
2597
|
-
* @constant
|
2598
|
-
* @type {string}
|
2599
|
-
*/
|
2600
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2601
|
-
/**
|
2602
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2603
|
-
* @constant
|
2604
|
-
* @type {string}
|
2605
|
-
*/
|
2606
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2607
|
-
};
|
2608
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2609
|
-
endpoints: (builder) => ({
|
2610
|
-
getContentTypeConfiguration: builder.query({
|
2611
|
-
query: (uid) => ({
|
2612
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2613
|
-
method: "GET"
|
2614
|
-
}),
|
2615
|
-
transformResponse: (response) => response.data,
|
2616
|
-
providesTags: (_result, _error, uid) => [
|
2617
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2618
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2619
|
-
]
|
2620
|
-
}),
|
2621
|
-
getAllContentTypeSettings: builder.query({
|
2622
|
-
query: () => "/content-manager/content-types-settings",
|
2623
|
-
transformResponse: (response) => response.data,
|
2624
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2625
|
-
}),
|
2626
|
-
updateContentTypeConfiguration: builder.mutation({
|
2627
|
-
query: ({ uid, ...body }) => ({
|
2628
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2629
|
-
method: "PUT",
|
2630
|
-
data: body
|
2631
|
-
}),
|
2632
|
-
transformResponse: (response) => response.data,
|
2633
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2634
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2635
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2636
|
-
// Is this necessary?
|
2637
|
-
{ type: "InitialData" }
|
2638
|
-
]
|
2639
|
-
})
|
2640
|
-
})
|
2641
|
-
});
|
2642
|
-
const {
|
2643
|
-
useGetContentTypeConfigurationQuery,
|
2644
|
-
useGetAllContentTypeSettingsQuery,
|
2645
|
-
useUpdateContentTypeConfigurationMutation
|
2646
|
-
} = contentTypesApi;
|
2647
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2648
|
-
const { type } = attribute;
|
2649
|
-
if (type === "relation") {
|
2650
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2651
|
-
}
|
2652
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2653
|
-
};
|
2654
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2655
|
-
if (!mainFieldName) {
|
2656
|
-
return void 0;
|
2657
|
-
}
|
2658
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2659
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2660
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2661
|
-
);
|
2662
|
-
return {
|
2663
|
-
name: mainFieldName,
|
2664
|
-
type: mainFieldType ?? "string"
|
2665
|
-
};
|
2666
|
-
};
|
2667
|
-
const DEFAULT_SETTINGS = {
|
2668
|
-
bulkable: false,
|
2669
|
-
filterable: false,
|
2670
|
-
searchable: false,
|
2671
|
-
pagination: false,
|
2672
|
-
defaultSortBy: "",
|
2673
|
-
defaultSortOrder: "asc",
|
2674
|
-
mainField: "id",
|
2675
|
-
pageSize: 10
|
2676
|
-
};
|
2677
|
-
const useDocumentLayout = (model) => {
|
2678
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2679
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2680
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2681
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2682
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2683
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2684
|
-
const {
|
2685
|
-
data,
|
2686
|
-
isLoading: isLoadingConfigs,
|
2687
|
-
error,
|
2688
|
-
isFetching: isFetchingConfigs
|
2689
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2690
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2691
|
-
React__namespace.useEffect(() => {
|
2692
|
-
if (error) {
|
2693
|
-
toggleNotification({
|
2694
|
-
type: "danger",
|
2695
|
-
message: formatAPIError(error)
|
2696
|
-
});
|
2697
|
-
}
|
2698
|
-
}, [error, formatAPIError, toggleNotification]);
|
2699
|
-
const editLayout = React__namespace.useMemo(
|
2700
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2701
|
-
layout: [],
|
2702
|
-
components: {},
|
2703
|
-
metadatas: {},
|
2704
|
-
options: {},
|
2705
|
-
settings: DEFAULT_SETTINGS
|
2706
|
-
},
|
2707
|
-
[data, isLoading, schemas, schema, components]
|
2708
|
-
);
|
2709
|
-
const listLayout = React__namespace.useMemo(() => {
|
2710
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2711
|
-
layout: [],
|
2712
|
-
metadatas: {},
|
2713
|
-
options: {},
|
2714
|
-
settings: DEFAULT_SETTINGS
|
2715
|
-
};
|
2716
|
-
}, [data, isLoading, schemas, schema, components]);
|
2717
|
-
const { layout: edit } = React__namespace.useMemo(
|
2718
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2719
|
-
layout: editLayout,
|
2720
|
-
query
|
2721
|
-
}),
|
2722
|
-
[editLayout, query, runHookWaterfall]
|
2723
|
-
);
|
2724
|
-
return {
|
2725
|
-
error,
|
2726
|
-
isLoading,
|
2727
|
-
edit,
|
2728
|
-
list: listLayout
|
2729
|
-
};
|
2730
|
-
};
|
2731
|
-
const useDocLayout = () => {
|
2732
|
-
const { model } = useDoc();
|
2733
|
-
return useDocumentLayout(model);
|
2734
|
-
};
|
2735
|
-
const formatEditLayout = (data, {
|
2736
|
-
schemas,
|
2737
|
-
schema,
|
2738
|
-
components
|
2739
|
-
}) => {
|
2740
|
-
let currentPanelIndex = 0;
|
2741
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2742
|
-
data.contentType.layouts.edit,
|
2743
|
-
schema?.attributes,
|
2744
|
-
data.contentType.metadatas,
|
2745
|
-
{ configurations: data.components, schemas: components },
|
2746
|
-
schemas
|
2747
|
-
).reduce((panels, row) => {
|
2748
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2749
|
-
panels.push([row]);
|
2750
|
-
currentPanelIndex += 2;
|
2751
|
-
} else {
|
2752
|
-
if (!panels[currentPanelIndex]) {
|
2753
|
-
panels.push([]);
|
2754
|
-
}
|
2755
|
-
panels[currentPanelIndex].push(row);
|
2756
|
-
}
|
2757
|
-
return panels;
|
2758
|
-
}, []);
|
2759
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2760
|
-
(acc, [uid, configuration]) => {
|
2761
|
-
acc[uid] = {
|
2762
|
-
layout: convertEditLayoutToFieldLayouts(
|
2763
|
-
configuration.layouts.edit,
|
2764
|
-
components[uid].attributes,
|
2765
|
-
configuration.metadatas
|
2766
|
-
),
|
2767
|
-
settings: {
|
2768
|
-
...configuration.settings,
|
2769
|
-
icon: components[uid].info.icon,
|
2770
|
-
displayName: components[uid].info.displayName
|
2948
|
+
params: {
|
2949
|
+
locale: "*"
|
2950
|
+
}
|
2951
|
+
});
|
2952
|
+
if (!("error" in res)) {
|
2953
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2954
|
+
}
|
2955
|
+
} finally {
|
2956
|
+
if (!listViewPathMatch) {
|
2957
|
+
setSubmitting(false);
|
2958
|
+
}
|
2771
2959
|
}
|
2772
|
-
}
|
2773
|
-
return acc;
|
2774
|
-
},
|
2775
|
-
{}
|
2776
|
-
);
|
2777
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2778
|
-
(acc, [attribute, metadata]) => {
|
2779
|
-
return {
|
2780
|
-
...acc,
|
2781
|
-
[attribute]: metadata.edit
|
2782
|
-
};
|
2783
|
-
},
|
2784
|
-
{}
|
2785
|
-
);
|
2786
|
-
return {
|
2787
|
-
layout: panelledEditAttributes,
|
2788
|
-
components: componentEditAttributes,
|
2789
|
-
metadatas: editMetadatas,
|
2790
|
-
settings: {
|
2791
|
-
...data.contentType.settings,
|
2792
|
-
displayName: schema?.info.displayName
|
2960
|
+
}
|
2793
2961
|
},
|
2794
|
-
|
2795
|
-
|
2796
|
-
...schema?.pluginOptions,
|
2797
|
-
...data.contentType.options
|
2798
|
-
}
|
2962
|
+
variant: "danger",
|
2963
|
+
position: ["header", "table-row"]
|
2799
2964
|
};
|
2800
2965
|
};
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
}
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
}
|
2828
|
-
}
|
2829
|
-
);
|
2966
|
+
DeleteAction$1.type = "delete";
|
2967
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2968
|
+
const Panels = () => {
|
2969
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2970
|
+
const [
|
2971
|
+
{
|
2972
|
+
query: { status }
|
2973
|
+
}
|
2974
|
+
] = strapiAdmin.useQueryParams({
|
2975
|
+
status: "draft"
|
2976
|
+
});
|
2977
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2978
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2979
|
+
const props = {
|
2980
|
+
activeTab: status,
|
2981
|
+
model,
|
2982
|
+
documentId: id,
|
2983
|
+
document: isCloning ? void 0 : document,
|
2984
|
+
meta: isCloning ? void 0 : meta,
|
2985
|
+
collectionType
|
2986
|
+
};
|
2987
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2988
|
+
strapiAdmin.DescriptionComponentRenderer,
|
2989
|
+
{
|
2990
|
+
props,
|
2991
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2992
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2993
|
+
}
|
2994
|
+
) });
|
2830
2995
|
};
|
2831
|
-
const
|
2832
|
-
|
2833
|
-
schema,
|
2834
|
-
components
|
2835
|
-
}) => {
|
2836
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2837
|
-
(acc, [attribute, metadata]) => {
|
2838
|
-
return {
|
2839
|
-
...acc,
|
2840
|
-
[attribute]: metadata.list
|
2841
|
-
};
|
2842
|
-
},
|
2843
|
-
{}
|
2844
|
-
);
|
2845
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2846
|
-
data.contentType.layouts.list,
|
2847
|
-
schema?.attributes,
|
2848
|
-
listMetadatas,
|
2849
|
-
{ configurations: data.components, schemas: components },
|
2850
|
-
schemas
|
2851
|
-
);
|
2996
|
+
const ActionsPanel = () => {
|
2997
|
+
const { formatMessage } = reactIntl.useIntl();
|
2852
2998
|
return {
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
...schema?.pluginOptions,
|
2859
|
-
...data.contentType.options
|
2860
|
-
}
|
2999
|
+
title: formatMessage({
|
3000
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3001
|
+
defaultMessage: "Entry"
|
3002
|
+
}),
|
3003
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2861
3004
|
};
|
2862
3005
|
};
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
3006
|
+
ActionsPanel.type = "actions";
|
3007
|
+
const ActionsPanelContent = () => {
|
3008
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3009
|
+
const [
|
3010
|
+
{
|
3011
|
+
query: { status = "draft" }
|
2868
3012
|
}
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
3013
|
+
] = strapiAdmin.useQueryParams();
|
3014
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3015
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3016
|
+
const props = {
|
3017
|
+
activeTab: status,
|
3018
|
+
model,
|
3019
|
+
documentId: id,
|
3020
|
+
document: isCloning ? void 0 : document,
|
3021
|
+
meta: isCloning ? void 0 : meta,
|
3022
|
+
collectionType
|
3023
|
+
};
|
3024
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3026
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3027
|
+
{
|
3028
|
+
props,
|
3029
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3030
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3031
|
+
}
|
3032
|
+
),
|
3033
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3034
|
+
] });
|
2883
3035
|
};
|
3036
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3037
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3038
|
+
designSystem.Flex,
|
3039
|
+
{
|
3040
|
+
ref,
|
3041
|
+
tag: "aside",
|
3042
|
+
"aria-labelledby": "additional-information",
|
3043
|
+
background: "neutral0",
|
3044
|
+
borderColor: "neutral150",
|
3045
|
+
hasRadius: true,
|
3046
|
+
paddingBottom: 4,
|
3047
|
+
paddingLeft: 4,
|
3048
|
+
paddingRight: 4,
|
3049
|
+
paddingTop: 4,
|
3050
|
+
shadow: "tableShadow",
|
3051
|
+
gap: 3,
|
3052
|
+
direction: "column",
|
3053
|
+
justifyContent: "stretch",
|
3054
|
+
alignItems: "flex-start",
|
3055
|
+
children: [
|
3056
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3057
|
+
children
|
3058
|
+
]
|
3059
|
+
}
|
3060
|
+
);
|
3061
|
+
});
|
2884
3062
|
const ConfirmBulkActionDialog = ({
|
2885
3063
|
onToggleDialog,
|
2886
3064
|
isOpen = false,
|
@@ -2919,6 +3097,7 @@ const ConfirmDialogPublishAll = ({
|
|
2919
3097
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2920
3098
|
const { model, schema } = useDoc();
|
2921
3099
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3100
|
+
const enableDraftRelationsCount = false;
|
2922
3101
|
const {
|
2923
3102
|
data: countDraftRelations = 0,
|
2924
3103
|
isLoading,
|
@@ -2930,7 +3109,7 @@ const ConfirmDialogPublishAll = ({
|
|
2930
3109
|
locale: query?.plugins?.i18n?.locale
|
2931
3110
|
},
|
2932
3111
|
{
|
2933
|
-
skip:
|
3112
|
+
skip: !enableDraftRelationsCount
|
2934
3113
|
}
|
2935
3114
|
);
|
2936
3115
|
React__namespace.useEffect(() => {
|
@@ -3115,7 +3294,7 @@ const SelectedEntriesTableContent = ({
|
|
3115
3294
|
status: row.status
|
3116
3295
|
}
|
3117
3296
|
) }),
|
3118
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3297
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3119
3298
|
designSystem.IconButton,
|
3120
3299
|
{
|
3121
3300
|
tag: reactRouterDom.Link,
|
@@ -3124,23 +3303,16 @@ const SelectedEntriesTableContent = ({
|
|
3124
3303
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3125
3304
|
},
|
3126
3305
|
state: { from: pathname },
|
3127
|
-
label: formatMessage(
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
{
|
3132
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3133
|
-
defaultMessage: "item line {number}"
|
3134
|
-
},
|
3135
|
-
{ number: index2 + 1 }
|
3136
|
-
)
|
3137
|
-
}
|
3138
|
-
),
|
3306
|
+
label: formatMessage({
|
3307
|
+
id: "content-manager.bulk-publish.edit",
|
3308
|
+
defaultMessage: "Edit"
|
3309
|
+
}),
|
3139
3310
|
target: "_blank",
|
3140
3311
|
marginLeft: "auto",
|
3141
|
-
|
3312
|
+
variant: "ghost",
|
3313
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3142
3314
|
}
|
3143
|
-
) })
|
3315
|
+
) }) })
|
3144
3316
|
] }, row.id)) })
|
3145
3317
|
] });
|
3146
3318
|
};
|
@@ -3177,7 +3349,13 @@ const SelectedEntriesModalContent = ({
|
|
3177
3349
|
);
|
3178
3350
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3179
3351
|
if (data.length > 0 && schema) {
|
3180
|
-
const validate = createYupSchema(
|
3352
|
+
const validate = createYupSchema(
|
3353
|
+
schema.attributes,
|
3354
|
+
components,
|
3355
|
+
// Since this is the "Publish" action, the validation
|
3356
|
+
// schema must enforce the rules for published entities
|
3357
|
+
{ status: "published" }
|
3358
|
+
);
|
3181
3359
|
const validationErrors2 = {};
|
3182
3360
|
const rows2 = data.map((entry) => {
|
3183
3361
|
try {
|
@@ -3527,7 +3705,7 @@ const TableActions = ({ document }) => {
|
|
3527
3705
|
strapiAdmin.DescriptionComponentRenderer,
|
3528
3706
|
{
|
3529
3707
|
props,
|
3530
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3708
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3531
3709
|
children: (actions2) => {
|
3532
3710
|
const tableRowActions = actions2.filter((action) => {
|
3533
3711
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3638,7 +3816,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3638
3816
|
}),
|
3639
3817
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3640
3818
|
footer: ({ onClose }) => {
|
3641
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3819
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3642
3820
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3643
3821
|
id: "cancel",
|
3644
3822
|
defaultMessage: "Cancel"
|
@@ -3772,17 +3950,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3772
3950
|
const { formatMessage } = reactIntl.useIntl();
|
3773
3951
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3774
3952
|
const navigate = reactRouterDom.useNavigate();
|
3953
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
3954
|
+
const { pathname } = reactRouterDom.useLocation();
|
3775
3955
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3776
3956
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3777
3957
|
return null;
|
3778
3958
|
}
|
3959
|
+
const handleOnClick = () => {
|
3960
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
3961
|
+
trackUsage("willNavigate", {
|
3962
|
+
from: pathname,
|
3963
|
+
to: `${pathname}/${destination.pathname}`
|
3964
|
+
});
|
3965
|
+
navigate(destination);
|
3966
|
+
};
|
3779
3967
|
return {
|
3780
3968
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3781
3969
|
label: formatMessage({
|
3782
3970
|
id: "content-manager.history.document-action",
|
3783
3971
|
defaultMessage: "Content History"
|
3784
3972
|
}),
|
3785
|
-
onClick:
|
3973
|
+
onClick: handleOnClick,
|
3786
3974
|
disabled: (
|
3787
3975
|
/**
|
3788
3976
|
* The user is creating a new document.
|
@@ -3850,6 +4038,90 @@ const { setInitialData } = actions;
|
|
3850
4038
|
const reducer = toolkit.combineReducers({
|
3851
4039
|
app: reducer$1
|
3852
4040
|
});
|
4041
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4042
|
+
endpoints: (builder) => ({
|
4043
|
+
getPreviewUrl: builder.query({
|
4044
|
+
query({ query, params }) {
|
4045
|
+
return {
|
4046
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4047
|
+
method: "GET",
|
4048
|
+
config: {
|
4049
|
+
params: query
|
4050
|
+
}
|
4051
|
+
};
|
4052
|
+
}
|
4053
|
+
})
|
4054
|
+
})
|
4055
|
+
});
|
4056
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4057
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4058
|
+
if (isShown) {
|
4059
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
4060
|
+
}
|
4061
|
+
return children;
|
4062
|
+
};
|
4063
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4064
|
+
const { formatMessage } = reactIntl.useIntl();
|
4065
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4066
|
+
const { pathname } = reactRouterDom.useLocation();
|
4067
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4068
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4069
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4070
|
+
params: {
|
4071
|
+
contentType: model
|
4072
|
+
},
|
4073
|
+
query: {
|
4074
|
+
documentId,
|
4075
|
+
locale: document?.locale,
|
4076
|
+
status: document?.status
|
4077
|
+
}
|
4078
|
+
});
|
4079
|
+
if (!data?.data?.url || error) {
|
4080
|
+
return null;
|
4081
|
+
}
|
4082
|
+
const trackNavigation = () => {
|
4083
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4084
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4085
|
+
};
|
4086
|
+
return {
|
4087
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4088
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4089
|
+
ConditionalTooltip,
|
4090
|
+
{
|
4091
|
+
label: formatMessage({
|
4092
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4093
|
+
defaultMessage: "Please save to open the preview"
|
4094
|
+
}),
|
4095
|
+
isShown: isModified,
|
4096
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
4097
|
+
designSystem.Button,
|
4098
|
+
{
|
4099
|
+
variant: "tertiary",
|
4100
|
+
tag: reactRouterDom.Link,
|
4101
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4102
|
+
onClick: trackNavigation,
|
4103
|
+
flex: "auto",
|
4104
|
+
disabled: isModified,
|
4105
|
+
children: formatMessage({
|
4106
|
+
id: "content-manager.preview.panel.button",
|
4107
|
+
defaultMessage: "Open preview"
|
4108
|
+
})
|
4109
|
+
}
|
4110
|
+
)
|
4111
|
+
}
|
4112
|
+
) })
|
4113
|
+
};
|
4114
|
+
};
|
4115
|
+
const FEATURE_ID = "preview";
|
4116
|
+
const previewAdmin = {
|
4117
|
+
bootstrap(app) {
|
4118
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4119
|
+
return;
|
4120
|
+
}
|
4121
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4122
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4123
|
+
}
|
4124
|
+
};
|
3853
4125
|
const index = {
|
3854
4126
|
register(app) {
|
3855
4127
|
const cm = new ContentManagerPlugin();
|
@@ -3869,7 +4141,7 @@ const index = {
|
|
3869
4141
|
app.router.addRoute({
|
3870
4142
|
path: "content-manager/*",
|
3871
4143
|
lazy: async () => {
|
3872
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4144
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-CN2bFL9V.js"));
|
3873
4145
|
return {
|
3874
4146
|
Component: Layout
|
3875
4147
|
};
|
@@ -3882,11 +4154,14 @@ const index = {
|
|
3882
4154
|
if (typeof historyAdmin.bootstrap === "function") {
|
3883
4155
|
historyAdmin.bootstrap(app);
|
3884
4156
|
}
|
4157
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4158
|
+
previewAdmin.bootstrap(app);
|
4159
|
+
}
|
3885
4160
|
},
|
3886
4161
|
async registerTrads({ locales }) {
|
3887
4162
|
const importedTrads = await Promise.all(
|
3888
4163
|
locales.map((locale) => {
|
3889
|
-
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-
|
4164
|
+
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-BK8Xyl5I.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 }) => {
|
3890
4165
|
return {
|
3891
4166
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3892
4167
|
locale
|
@@ -3904,6 +4179,7 @@ const index = {
|
|
3904
4179
|
};
|
3905
4180
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3906
4181
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4182
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3907
4183
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3908
4184
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3909
4185
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3931,6 +4207,7 @@ exports.getMainField = getMainField;
|
|
3931
4207
|
exports.getTranslation = getTranslation;
|
3932
4208
|
exports.index = index;
|
3933
4209
|
exports.setInitialData = setInitialData;
|
4210
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3934
4211
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3935
4212
|
exports.useDoc = useDoc;
|
3936
4213
|
exports.useDocLayout = useDocLayout;
|
@@ -3942,5 +4219,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3942
4219
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3943
4220
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3944
4221
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4222
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3945
4223
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3946
|
-
//# sourceMappingURL=index-
|
4224
|
+
//# sourceMappingURL=index-DwOsF7wF.js.map
|