@strapi/content-manager 0.0.0-experimental.17b4116f461a49b8ce5386f7c8d79c511d40fb3b → 0.0.0-experimental.25e22c6cc9bc6b35392bb55d09f641a0a65e7403
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/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
- package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
- package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js → ComponentConfigurationPage-WRPUXGd6.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js.map → ComponentConfigurationPage-WRPUXGd6.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs → ComponentConfigurationPage-gdUj_t-O.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs.map → ComponentConfigurationPage-gdUj_t-O.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-BXdiCGQp.js} +8 -2
- package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
- package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
- package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs → EditConfigurationPage-BwuIPOJG.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs.map → EditConfigurationPage-BwuIPOJG.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js → EditConfigurationPage-C1vjMBgy.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js.map → EditConfigurationPage-C1vjMBgy.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-aUnqL-63.mjs → EditViewPage-0MiFkXa8.mjs} +47 -47
- package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-KRG56aCq.js → EditViewPage-DbcGfyqK.js} +46 -48
- package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +1 -0
- package/dist/_chunks/{Field-kVFO4ZKB.mjs → Field-BDMSCcy5.mjs} +585 -705
- package/dist/_chunks/Field-BDMSCcy5.mjs.map +1 -0
- package/dist/_chunks/{Field-kq1c2TF1.js → Field-BG1xu38N.js} +637 -758
- package/dist/_chunks/Field-BG1xu38N.js.map +1 -0
- package/dist/_chunks/{Form-CQ67ZifP.js → Form-9BnFyUjy.js} +35 -37
- package/dist/_chunks/Form-9BnFyUjy.js.map +1 -0
- package/dist/_chunks/{Form-Jgh5hGTu.mjs → Form-CPVWavB8.mjs} +35 -36
- package/dist/_chunks/Form-CPVWavB8.mjs.map +1 -0
- package/dist/_chunks/{History-DKhZAPcK.mjs → History-BVpd8LP3.mjs} +121 -48
- package/dist/_chunks/History-BVpd8LP3.mjs.map +1 -0
- package/dist/_chunks/{History-BLEnudTX.js → History-BWWxLt2Z.js} +122 -50
- package/dist/_chunks/History-BWWxLt2Z.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Zso_LUjn.js → ListConfigurationPage-6swzjdAZ.js} +53 -56
- package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-nrXcxNYi.mjs → ListConfigurationPage-DozVMKcR.mjs} +49 -51
- package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-DsaOakWQ.js → ListViewPage-BlzfjS2Q.js} +80 -105
- package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +1 -0
- package/dist/_chunks/{ListViewPage-ChhYmA-L.mjs → ListViewPage-Ds0ulgfG.mjs} +75 -100
- package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-BrdFcN33.mjs → NoContentTypePage-BH11kaKt.mjs} +3 -3
- package/dist/_chunks/NoContentTypePage-BH11kaKt.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DPCuS9Y1.js → NoContentTypePage-D2nCCWEl.js} +3 -3
- package/dist/_chunks/NoContentTypePage-D2nCCWEl.js.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs → NoPermissionsPage-BT2Tn0D_.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs.map → NoPermissionsPage-BT2Tn0D_.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js → NoPermissionsPage-DN_JlsU2.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js.map → NoPermissionsPage-DN_JlsU2.js.map} +1 -1
- package/dist/_chunks/{Relations-CY8Isqdu.js → Relations-CcgFTcWo.js} +70 -61
- package/dist/_chunks/Relations-CcgFTcWo.js.map +1 -0
- package/dist/_chunks/{Relations-DjFiYd7-.mjs → Relations-Dnag3fhV.mjs} +66 -56
- package/dist/_chunks/Relations-Dnag3fhV.mjs.map +1 -0
- package/dist/_chunks/{en-MBPul9Su.mjs → en-Ux26r5pl.mjs} +7 -1
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-Ux26r5pl.mjs.map} +1 -1
- package/dist/_chunks/{en-C-V1_90f.js → en-fbKQxLGn.js} +7 -1
- package/dist/_chunks/{en-C-V1_90f.js.map → en-fbKQxLGn.js.map} +1 -1
- package/dist/_chunks/{index-DNa1J4HE.js → index-CWpLBSt0.js} +1391 -808
- package/dist/_chunks/index-CWpLBSt0.js.map +1 -0
- package/dist/_chunks/{index-CAc9yTnx.mjs → index-JNNNKUHs.mjs} +1465 -881
- package/dist/_chunks/index-JNNNKUHs.mjs.map +1 -0
- package/dist/_chunks/{layout-BqtLA6Lb.js → layout--iHdZzRk.js} +26 -23
- package/dist/_chunks/layout--iHdZzRk.js.map +1 -0
- package/dist/_chunks/{layout-CXsHbc3E.mjs → layout-DC503LnF.mjs} +24 -19
- package/dist/_chunks/layout-DC503LnF.mjs.map +1 -0
- package/dist/_chunks/{relations-BHY_KDJ_.js → relations-BbHizA5K.js} +2 -2
- package/dist/_chunks/{relations-BHY_KDJ_.js.map → relations-BbHizA5K.js.map} +1 -1
- package/dist/_chunks/{relations-mMFEcZRq.mjs → relations-CTje5t-a.mjs} +2 -2
- package/dist/_chunks/{relations-mMFEcZRq.mjs.map → relations-CTje5t-a.mjs.map} +1 -1
- package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
- package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js +15 -0
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +8 -7
- package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
- package/dist/admin/src/content-manager.d.ts +3 -3
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +5 -8
- package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
- package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
- package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +10 -4
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +10 -18
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +59 -52
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
- package/dist/admin/src/services/api.d.ts +2 -3
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +5 -5
- package/dist/admin/src/services/documents.d.ts +29 -17
- package/dist/admin/src/services/init.d.ts +2 -2
- package/dist/admin/src/services/relations.d.ts +3 -3
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +4 -18
- package/dist/admin/src/utils/validation.d.ts +1 -6
- package/dist/server/index.js +285 -197
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +287 -199
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts +9 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/index.d.ts +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/index.d.ts +17 -33
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts +11 -6
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -29
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +17 -33
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +8 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +14 -6
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- package/package.json +13 -14
- package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
- package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-KRG56aCq.js.map +0 -1
- package/dist/_chunks/EditViewPage-aUnqL-63.mjs.map +0 -1
- package/dist/_chunks/Field-kVFO4ZKB.mjs.map +0 -1
- package/dist/_chunks/Field-kq1c2TF1.js.map +0 -1
- package/dist/_chunks/Form-CQ67ZifP.js.map +0 -1
- package/dist/_chunks/Form-Jgh5hGTu.mjs.map +0 -1
- package/dist/_chunks/History-BLEnudTX.js.map +0 -1
- package/dist/_chunks/History-DKhZAPcK.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Zso_LUjn.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-nrXcxNYi.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-ChhYmA-L.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-DsaOakWQ.js.map +0 -1
- package/dist/_chunks/NoContentTypePage-BrdFcN33.mjs.map +0 -1
- package/dist/_chunks/NoContentTypePage-DPCuS9Y1.js.map +0 -1
- package/dist/_chunks/Relations-CY8Isqdu.js.map +0 -1
- package/dist/_chunks/Relations-DjFiYd7-.mjs.map +0 -1
- package/dist/_chunks/index-CAc9yTnx.mjs.map +0 -1
- package/dist/_chunks/index-DNa1J4HE.js.map +0 -1
- package/dist/_chunks/layout-BqtLA6Lb.js.map +0 -1
- package/dist/_chunks/layout-CXsHbc3E.mjs.map +0 -1
- package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
- package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
- package/dist/_chunks/urls-DzZya_gm.js +0 -6
- package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
@@ -7,10 +7,8 @@ const reactIntl = require("react-intl");
|
|
7
7
|
const reactRouterDom = require("react-router-dom");
|
8
8
|
const React = require("react");
|
9
9
|
const designSystem = require("@strapi/design-system");
|
10
|
-
const
|
10
|
+
const styledComponents = require("styled-components");
|
11
11
|
const yup = require("yup");
|
12
|
-
const react = require("@reduxjs/toolkit/query/react");
|
13
|
-
const axios = require("axios");
|
14
12
|
const pipe = require("lodash/fp/pipe");
|
15
13
|
const dateFns = require("date-fns");
|
16
14
|
const toolkit = require("@reduxjs/toolkit");
|
@@ -34,7 +32,6 @@ function _interopNamespace(e) {
|
|
34
32
|
return Object.freeze(n);
|
35
33
|
}
|
36
34
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
37
|
-
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
38
35
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
39
36
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
40
37
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -179,9 +176,8 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
179
176
|
const name = removeNumericalStrings(fieldName.split("."));
|
180
177
|
const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
|
181
178
|
if (fieldType === "component") {
|
182
|
-
|
183
|
-
|
184
|
-
return field.includes(fieldName);
|
179
|
+
return componentFieldNames.some((field) => {
|
180
|
+
return field.includes(name.join("."));
|
185
181
|
});
|
186
182
|
}
|
187
183
|
if (name.length > 1) {
|
@@ -211,78 +207,8 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
211
207
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
212
208
|
);
|
213
209
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
214
|
-
const
|
215
|
-
|
216
|
-
return query;
|
217
|
-
const { plugins: _, ...validQueryParams } = {
|
218
|
-
...query,
|
219
|
-
...Object.values(query?.plugins ?? {}).reduce(
|
220
|
-
(acc, current) => Object.assign(acc, current),
|
221
|
-
{}
|
222
|
-
)
|
223
|
-
};
|
224
|
-
if ("_q" in validQueryParams) {
|
225
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
226
|
-
}
|
227
|
-
return validQueryParams;
|
228
|
-
};
|
229
|
-
const axiosBaseQuery = () => async (query, { signal }) => {
|
230
|
-
try {
|
231
|
-
const { get, post, del, put } = strapiAdmin.getFetchClient();
|
232
|
-
if (typeof query === "string") {
|
233
|
-
const result = await get(query, { signal });
|
234
|
-
return { data: result.data };
|
235
|
-
} else {
|
236
|
-
const { url, method = "GET", data, config } = query;
|
237
|
-
if (method === "POST") {
|
238
|
-
const result2 = await post(url, data, { ...config, signal });
|
239
|
-
return { data: result2.data };
|
240
|
-
}
|
241
|
-
if (method === "DELETE") {
|
242
|
-
const result2 = await del(url, { ...config, signal });
|
243
|
-
return { data: result2.data };
|
244
|
-
}
|
245
|
-
if (method === "PUT") {
|
246
|
-
const result2 = await put(url, data, { ...config, signal });
|
247
|
-
return { data: result2.data };
|
248
|
-
}
|
249
|
-
const result = await get(url, { ...config, signal });
|
250
|
-
return { data: result.data };
|
251
|
-
}
|
252
|
-
} catch (err) {
|
253
|
-
if (axios.isAxiosError(err)) {
|
254
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
255
|
-
return { data: void 0, error: err.response?.data.error };
|
256
|
-
} else {
|
257
|
-
return {
|
258
|
-
data: void 0,
|
259
|
-
error: {
|
260
|
-
name: "UnknownError",
|
261
|
-
message: "There was an unknown error response from the API",
|
262
|
-
details: err.response?.data,
|
263
|
-
status: err.response?.status
|
264
|
-
}
|
265
|
-
};
|
266
|
-
}
|
267
|
-
}
|
268
|
-
const error = err;
|
269
|
-
return {
|
270
|
-
data: void 0,
|
271
|
-
error: {
|
272
|
-
name: error.name,
|
273
|
-
message: error.message,
|
274
|
-
stack: error.stack
|
275
|
-
}
|
276
|
-
};
|
277
|
-
}
|
278
|
-
};
|
279
|
-
const isBaseQueryError = (error) => {
|
280
|
-
return error.name !== void 0;
|
281
|
-
};
|
282
|
-
const contentManagerApi = react.createApi({
|
283
|
-
reducerPath: "contentManagerApi",
|
284
|
-
baseQuery: axiosBaseQuery(),
|
285
|
-
tagTypes: [
|
210
|
+
const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
211
|
+
addTagTypes: [
|
286
212
|
"ComponentConfiguration",
|
287
213
|
"ContentTypesConfiguration",
|
288
214
|
"ContentTypeSettings",
|
@@ -290,8 +216,7 @@ const contentManagerApi = react.createApi({
|
|
290
216
|
"InitialData",
|
291
217
|
"HistoryVersion",
|
292
218
|
"Relations"
|
293
|
-
]
|
294
|
-
endpoints: () => ({})
|
219
|
+
]
|
295
220
|
});
|
296
221
|
const documentApi = contentManagerApi.injectEndpoints({
|
297
222
|
endpoints: (builder) => ({
|
@@ -347,12 +272,15 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
347
272
|
]
|
348
273
|
}),
|
349
274
|
deleteManyDocuments: builder.mutation({
|
350
|
-
query: ({ model, ...body }) => ({
|
275
|
+
query: ({ model, params, ...body }) => ({
|
351
276
|
url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
|
352
277
|
method: "POST",
|
353
|
-
data: body
|
278
|
+
data: body,
|
279
|
+
config: {
|
280
|
+
params
|
281
|
+
}
|
354
282
|
}),
|
355
|
-
invalidatesTags: (_res, _error, { model
|
283
|
+
invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
|
356
284
|
}),
|
357
285
|
discardDocument: builder.mutation({
|
358
286
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -463,10 +391,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
463
391
|
}
|
464
392
|
}),
|
465
393
|
publishManyDocuments: builder.mutation({
|
466
|
-
query: ({ model, ...body }) => ({
|
394
|
+
query: ({ model, params, ...body }) => ({
|
467
395
|
url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
|
468
396
|
method: "POST",
|
469
|
-
data: body
|
397
|
+
data: body,
|
398
|
+
config: {
|
399
|
+
params
|
400
|
+
}
|
470
401
|
}),
|
471
402
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
472
403
|
}),
|
@@ -508,10 +439,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
508
439
|
}
|
509
440
|
}),
|
510
441
|
unpublishManyDocuments: builder.mutation({
|
511
|
-
query: ({ model, ...body }) => ({
|
442
|
+
query: ({ model, params, ...body }) => ({
|
512
443
|
url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
|
513
444
|
method: "POST",
|
514
|
-
data: body
|
445
|
+
data: body,
|
446
|
+
config: {
|
447
|
+
params
|
448
|
+
}
|
515
449
|
}),
|
516
450
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
517
451
|
})
|
@@ -535,6 +469,24 @@ const {
|
|
535
469
|
useUnpublishDocumentMutation,
|
536
470
|
useUnpublishManyDocumentsMutation
|
537
471
|
} = documentApi;
|
472
|
+
const buildValidParams = (query) => {
|
473
|
+
if (!query)
|
474
|
+
return query;
|
475
|
+
const { plugins: _, ...validQueryParams } = {
|
476
|
+
...query,
|
477
|
+
...Object.values(query?.plugins ?? {}).reduce(
|
478
|
+
(acc, current) => Object.assign(acc, current),
|
479
|
+
{}
|
480
|
+
)
|
481
|
+
};
|
482
|
+
if ("_q" in validQueryParams) {
|
483
|
+
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
484
|
+
}
|
485
|
+
return validQueryParams;
|
486
|
+
};
|
487
|
+
const isBaseQueryError = (error) => {
|
488
|
+
return error.name !== void 0;
|
489
|
+
};
|
538
490
|
const createYupSchema = (attributes = {}, components = {}) => {
|
539
491
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
540
492
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -574,10 +526,14 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
574
526
|
yup__namespace.array().of(
|
575
527
|
yup__namespace.lazy(
|
576
528
|
(data) => {
|
577
|
-
const
|
578
|
-
|
529
|
+
const attributes3 = components?.[data?.__component]?.attributes;
|
530
|
+
const validation = yup__namespace.object().shape({
|
579
531
|
__component: yup__namespace.string().required().oneOf(Object.keys(components))
|
580
|
-
}).nullable(false)
|
532
|
+
}).nullable(false);
|
533
|
+
if (!attributes3) {
|
534
|
+
return validation;
|
535
|
+
}
|
536
|
+
return validation.concat(createModelSchema(attributes3));
|
581
537
|
}
|
582
538
|
)
|
583
539
|
)
|
@@ -587,11 +543,25 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
587
543
|
return {
|
588
544
|
...acc,
|
589
545
|
[name]: transformSchema(
|
590
|
-
yup__namespace.
|
591
|
-
|
592
|
-
|
593
|
-
})
|
594
|
-
|
546
|
+
yup__namespace.lazy((value) => {
|
547
|
+
if (!value) {
|
548
|
+
return yup__namespace.mixed().nullable(true);
|
549
|
+
} else if (Array.isArray(value)) {
|
550
|
+
return yup__namespace.array().of(
|
551
|
+
yup__namespace.object().shape({
|
552
|
+
id: yup__namespace.string().required()
|
553
|
+
})
|
554
|
+
);
|
555
|
+
} else if (typeof value === "object") {
|
556
|
+
return yup__namespace.object();
|
557
|
+
} else {
|
558
|
+
return yup__namespace.mixed().test(
|
559
|
+
"type-error",
|
560
|
+
"Relation values must be either null, an array of objects with {id} or an object.",
|
561
|
+
() => false
|
562
|
+
);
|
563
|
+
}
|
564
|
+
})
|
595
565
|
)
|
596
566
|
};
|
597
567
|
default:
|
@@ -656,7 +626,12 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
656
626
|
defaultMessage: "This field is required."
|
657
627
|
});
|
658
628
|
}
|
659
|
-
return schema.nullable()
|
629
|
+
return schema?.nullable ? schema.nullable() : (
|
630
|
+
// In some cases '.nullable' will not be available on the schema.
|
631
|
+
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
632
|
+
// In these cases we should just return the schema as it is.
|
633
|
+
schema
|
634
|
+
);
|
660
635
|
};
|
661
636
|
const addMinLengthValidation = (attribute) => (schema) => {
|
662
637
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
@@ -728,24 +703,6 @@ const addRegexValidation = (attribute) => (schema) => {
|
|
728
703
|
}
|
729
704
|
return schema;
|
730
705
|
};
|
731
|
-
const extractValuesFromYupError = (errorType, errorParams) => {
|
732
|
-
if (!errorType || !errorParams) {
|
733
|
-
return {};
|
734
|
-
}
|
735
|
-
return {
|
736
|
-
[errorType]: errorParams[errorType]
|
737
|
-
};
|
738
|
-
};
|
739
|
-
const getInnerErrors = (error) => (error?.inner || []).reduce((acc, currentError) => {
|
740
|
-
if (currentError.path) {
|
741
|
-
acc[currentError.path.split("[").join(".").split("]").join("")] = {
|
742
|
-
id: currentError.message,
|
743
|
-
defaultMessage: currentError.message,
|
744
|
-
values: extractValuesFromYupError(currentError?.type, currentError?.params)
|
745
|
-
};
|
746
|
-
}
|
747
|
-
return acc;
|
748
|
-
}, {});
|
749
706
|
const initApi = contentManagerApi.injectEndpoints({
|
750
707
|
endpoints: (builder) => ({
|
751
708
|
getInitialData: builder.query({
|
@@ -759,27 +716,20 @@ const { useGetInitialDataQuery } = initApi;
|
|
759
716
|
const useContentTypeSchema = (model) => {
|
760
717
|
const { toggleNotification } = strapiAdmin.useNotification();
|
761
718
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
762
|
-
const {
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
)
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
error: res.error,
|
777
|
-
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
778
|
-
contentType: contentType2,
|
779
|
-
contentTypes: res.data?.contentTypes ?? []
|
780
|
-
};
|
781
|
-
}
|
782
|
-
});
|
719
|
+
const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
|
720
|
+
const { components, contentType, contentTypes } = React__namespace.useMemo(() => {
|
721
|
+
const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
|
722
|
+
const componentsByKey = data?.components.reduce((acc, component) => {
|
723
|
+
acc[component.uid] = component;
|
724
|
+
return acc;
|
725
|
+
}, {});
|
726
|
+
const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
|
727
|
+
return {
|
728
|
+
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
729
|
+
contentType: contentType2,
|
730
|
+
contentTypes: data?.contentTypes ?? []
|
731
|
+
};
|
732
|
+
}, [model, data]);
|
783
733
|
React__namespace.useEffect(() => {
|
784
734
|
if (error) {
|
785
735
|
toggleNotification({
|
@@ -862,7 +812,7 @@ const useDocument = (args, opts) => {
|
|
862
812
|
return null;
|
863
813
|
} catch (error2) {
|
864
814
|
if (error2 instanceof yup.ValidationError) {
|
865
|
-
return
|
815
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
866
816
|
}
|
867
817
|
throw error2;
|
868
818
|
}
|
@@ -958,14 +908,53 @@ const useDocumentActions = () => {
|
|
958
908
|
},
|
959
909
|
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
960
910
|
);
|
911
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
912
|
+
const deleteMany = React__namespace.useCallback(
|
913
|
+
async ({ model, documentIds, params }) => {
|
914
|
+
try {
|
915
|
+
trackUsage("willBulkDeleteEntries");
|
916
|
+
const res = await deleteManyDocuments({
|
917
|
+
model,
|
918
|
+
documentIds,
|
919
|
+
params
|
920
|
+
});
|
921
|
+
if ("error" in res) {
|
922
|
+
toggleNotification({
|
923
|
+
type: "danger",
|
924
|
+
message: formatAPIError(res.error)
|
925
|
+
});
|
926
|
+
return { error: res.error };
|
927
|
+
}
|
928
|
+
toggleNotification({
|
929
|
+
type: "success",
|
930
|
+
title: formatMessage({
|
931
|
+
id: getTranslation("success.records.delete"),
|
932
|
+
defaultMessage: "Successfully deleted."
|
933
|
+
}),
|
934
|
+
message: ""
|
935
|
+
});
|
936
|
+
trackUsage("didBulkDeleteEntries");
|
937
|
+
return res.data;
|
938
|
+
} catch (err) {
|
939
|
+
toggleNotification({
|
940
|
+
type: "danger",
|
941
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
942
|
+
});
|
943
|
+
trackUsage("didNotBulkDeleteEntries");
|
944
|
+
throw err;
|
945
|
+
}
|
946
|
+
},
|
947
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
948
|
+
);
|
961
949
|
const [discardDocument] = useDiscardDocumentMutation();
|
962
950
|
const discard = React__namespace.useCallback(
|
963
|
-
async ({ collectionType, model, documentId }) => {
|
951
|
+
async ({ collectionType, model, documentId, params }) => {
|
964
952
|
try {
|
965
953
|
const res = await discardDocument({
|
966
954
|
collectionType,
|
967
955
|
model,
|
968
|
-
documentId
|
956
|
+
documentId,
|
957
|
+
params
|
969
958
|
});
|
970
959
|
if ("error" in res) {
|
971
960
|
toggleNotification({
|
@@ -1027,6 +1016,43 @@ const useDocumentActions = () => {
|
|
1027
1016
|
},
|
1028
1017
|
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1029
1018
|
);
|
1019
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1020
|
+
const publishMany = React__namespace.useCallback(
|
1021
|
+
async ({ model, documentIds, params }) => {
|
1022
|
+
try {
|
1023
|
+
const res = await publishManyDocuments({
|
1024
|
+
model,
|
1025
|
+
documentIds,
|
1026
|
+
params
|
1027
|
+
});
|
1028
|
+
if ("error" in res) {
|
1029
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1030
|
+
return { error: res.error };
|
1031
|
+
}
|
1032
|
+
toggleNotification({
|
1033
|
+
type: "success",
|
1034
|
+
message: formatMessage({
|
1035
|
+
id: getTranslation("success.record.publish"),
|
1036
|
+
defaultMessage: "Published document"
|
1037
|
+
})
|
1038
|
+
});
|
1039
|
+
return res.data;
|
1040
|
+
} catch (err) {
|
1041
|
+
toggleNotification({
|
1042
|
+
type: "danger",
|
1043
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1044
|
+
});
|
1045
|
+
throw err;
|
1046
|
+
}
|
1047
|
+
},
|
1048
|
+
[
|
1049
|
+
// trackUsage,
|
1050
|
+
publishManyDocuments,
|
1051
|
+
toggleNotification,
|
1052
|
+
formatMessage,
|
1053
|
+
formatAPIError
|
1054
|
+
]
|
1055
|
+
);
|
1030
1056
|
const [updateDocument] = useUpdateDocumentMutation();
|
1031
1057
|
const update = React__namespace.useCallback(
|
1032
1058
|
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
@@ -1101,6 +1127,41 @@ const useDocumentActions = () => {
|
|
1101
1127
|
},
|
1102
1128
|
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1103
1129
|
);
|
1130
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1131
|
+
const unpublishMany = React__namespace.useCallback(
|
1132
|
+
async ({ model, documentIds, params }) => {
|
1133
|
+
try {
|
1134
|
+
trackUsage("willBulkUnpublishEntries");
|
1135
|
+
const res = await unpublishManyDocuments({
|
1136
|
+
model,
|
1137
|
+
documentIds,
|
1138
|
+
params
|
1139
|
+
});
|
1140
|
+
if ("error" in res) {
|
1141
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1142
|
+
return { error: res.error };
|
1143
|
+
}
|
1144
|
+
trackUsage("didBulkUnpublishEntries");
|
1145
|
+
toggleNotification({
|
1146
|
+
type: "success",
|
1147
|
+
title: formatMessage({
|
1148
|
+
id: getTranslation("success.records.unpublish"),
|
1149
|
+
defaultMessage: "Successfully unpublished."
|
1150
|
+
}),
|
1151
|
+
message: ""
|
1152
|
+
});
|
1153
|
+
return res.data;
|
1154
|
+
} catch (err) {
|
1155
|
+
toggleNotification({
|
1156
|
+
type: "danger",
|
1157
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1158
|
+
});
|
1159
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1160
|
+
throw err;
|
1161
|
+
}
|
1162
|
+
},
|
1163
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1164
|
+
);
|
1104
1165
|
const [createDocument] = useCreateDocumentMutation();
|
1105
1166
|
const create = React__namespace.useCallback(
|
1106
1167
|
async ({ model, params }, data, trackerProperty) => {
|
@@ -1214,15 +1275,18 @@ const useDocumentActions = () => {
|
|
1214
1275
|
clone,
|
1215
1276
|
create,
|
1216
1277
|
delete: _delete,
|
1278
|
+
deleteMany,
|
1217
1279
|
discard,
|
1218
1280
|
getDocument,
|
1219
1281
|
publish,
|
1282
|
+
publishMany,
|
1220
1283
|
unpublish,
|
1284
|
+
unpublishMany,
|
1221
1285
|
update
|
1222
1286
|
};
|
1223
1287
|
};
|
1224
1288
|
const ProtectedHistoryPage = React.lazy(
|
1225
|
-
() => Promise.resolve().then(() => require("./History-
|
1289
|
+
() => Promise.resolve().then(() => require("./History-BWWxLt2Z.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1226
1290
|
);
|
1227
1291
|
const routes$1 = [
|
1228
1292
|
{
|
@@ -1235,31 +1299,31 @@ const routes$1 = [
|
|
1235
1299
|
}
|
1236
1300
|
];
|
1237
1301
|
const ProtectedEditViewPage = React.lazy(
|
1238
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1302
|
+
() => Promise.resolve().then(() => require("./EditViewPage-DbcGfyqK.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1239
1303
|
);
|
1240
1304
|
const ProtectedListViewPage = React.lazy(
|
1241
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1305
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BlzfjS2Q.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1242
1306
|
);
|
1243
1307
|
const ProtectedListConfiguration = React.lazy(
|
1244
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1308
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-6swzjdAZ.js")).then((mod) => ({
|
1245
1309
|
default: mod.ProtectedListConfiguration
|
1246
1310
|
}))
|
1247
1311
|
);
|
1248
1312
|
const ProtectedEditConfigurationPage = React.lazy(
|
1249
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1313
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-C1vjMBgy.js")).then((mod) => ({
|
1250
1314
|
default: mod.ProtectedEditConfigurationPage
|
1251
1315
|
}))
|
1252
1316
|
);
|
1253
1317
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1254
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1318
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-WRPUXGd6.js")).then((mod) => ({
|
1255
1319
|
default: mod.ProtectedComponentConfigurationPage
|
1256
1320
|
}))
|
1257
1321
|
);
|
1258
1322
|
const NoPermissions = React.lazy(
|
1259
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1323
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-DN_JlsU2.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1260
1324
|
);
|
1261
1325
|
const NoContentType = React.lazy(
|
1262
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1326
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-D2nCCWEl.js")).then((mod) => ({ default: mod.NoContentType }))
|
1263
1327
|
);
|
1264
1328
|
const CollectionTypePages = () => {
|
1265
1329
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1449,7 +1513,7 @@ const DocumentActionsMenu = ({
|
|
1449
1513
|
variant,
|
1450
1514
|
children: [
|
1451
1515
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
1452
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, {
|
1516
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: label || formatMessage({
|
1453
1517
|
id: "content-manager.containers.edit.panels.default.more-actions",
|
1454
1518
|
defaultMessage: "More document actions"
|
1455
1519
|
}) })
|
@@ -1465,7 +1529,7 @@ const DocumentActionsMenu = ({
|
|
1465
1529
|
onSelect: handleClick(action),
|
1466
1530
|
display: "block",
|
1467
1531
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1468
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2,
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
|
1469
1533
|
action.icon,
|
1470
1534
|
action.label
|
1471
1535
|
] }),
|
@@ -1549,61 +1613,42 @@ const DocumentActionConfirmDialog = ({
|
|
1549
1613
|
}
|
1550
1614
|
onClose();
|
1551
1615
|
};
|
1552
|
-
return /* @__PURE__ */ jsxRuntime.
|
1553
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1554
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1555
|
-
|
1556
|
-
{
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
)
|
1567
|
-
] });
|
1616
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
1617
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1618
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1619
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1620
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
1621
|
+
id: "app.components.Button.cancel",
|
1622
|
+
defaultMessage: "Cancel"
|
1623
|
+
}) }) }),
|
1624
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1625
|
+
id: "app.components.Button.confirm",
|
1626
|
+
defaultMessage: "Confirm"
|
1627
|
+
}) })
|
1628
|
+
] })
|
1629
|
+
] }) });
|
1568
1630
|
};
|
1569
1631
|
const DocumentActionModal = ({
|
1570
1632
|
isOpen,
|
1571
1633
|
title,
|
1572
1634
|
onClose,
|
1573
1635
|
footer: Footer,
|
1574
|
-
content,
|
1636
|
+
content: Content,
|
1575
1637
|
onModalClose
|
1576
1638
|
}) => {
|
1577
|
-
const id = React__namespace.useId();
|
1578
|
-
if (!isOpen) {
|
1579
|
-
return null;
|
1580
|
-
}
|
1581
1639
|
const handleClose = () => {
|
1582
1640
|
if (onClose) {
|
1583
1641
|
onClose();
|
1584
1642
|
}
|
1585
1643
|
onModalClose();
|
1586
1644
|
};
|
1587
|
-
return /* @__PURE__ */ jsxRuntime.
|
1588
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1589
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1590
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1591
|
-
|
1592
|
-
{
|
1593
|
-
paddingTop: 4,
|
1594
|
-
paddingBottom: 4,
|
1595
|
-
paddingLeft: 5,
|
1596
|
-
paddingRight: 5,
|
1597
|
-
borderWidth: "1px 0 0 0",
|
1598
|
-
borderStyle: "solid",
|
1599
|
-
borderColor: "neutral150",
|
1600
|
-
background: "neutral100",
|
1601
|
-
children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1602
|
-
}
|
1603
|
-
)
|
1604
|
-
] });
|
1645
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
1646
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
1647
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
1648
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1649
|
+
] }) });
|
1605
1650
|
};
|
1606
|
-
const PublishAction = ({
|
1651
|
+
const PublishAction$1 = ({
|
1607
1652
|
activeTab,
|
1608
1653
|
documentId,
|
1609
1654
|
model,
|
@@ -1688,7 +1733,7 @@ const PublishAction = ({
|
|
1688
1733
|
}
|
1689
1734
|
};
|
1690
1735
|
};
|
1691
|
-
PublishAction.type = "publish";
|
1736
|
+
PublishAction$1.type = "publish";
|
1692
1737
|
const UpdateAction = ({
|
1693
1738
|
activeTab,
|
1694
1739
|
documentId,
|
@@ -1803,7 +1848,7 @@ const UNPUBLISH_DRAFT_OPTIONS = {
|
|
1803
1848
|
KEEP: "keep",
|
1804
1849
|
DISCARD: "discard"
|
1805
1850
|
};
|
1806
|
-
const UnpublishAction = ({
|
1851
|
+
const UnpublishAction$1 = ({
|
1807
1852
|
activeTab,
|
1808
1853
|
documentId,
|
1809
1854
|
model,
|
@@ -1819,10 +1864,8 @@ const UnpublishAction = ({
|
|
1819
1864
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1820
1865
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1821
1866
|
const isDocumentModified = document?.status === "modified";
|
1822
|
-
const handleChange = (
|
1823
|
-
|
1824
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1825
|
-
}
|
1867
|
+
const handleChange = (value) => {
|
1868
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1826
1869
|
};
|
1827
1870
|
if (!schema?.options?.draftAndPublish) {
|
1828
1871
|
return null;
|
@@ -1866,45 +1909,30 @@ const UnpublishAction = ({
|
|
1866
1909
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
|
1867
1910
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", direction: "column", gap: 2, children: [
|
1868
1911
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1869
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
1912
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1870
1913
|
id: "content-manager.actions.unpublish.dialog.body",
|
1871
1914
|
defaultMessage: "Are you sure?"
|
1872
1915
|
}) })
|
1873
1916
|
] }),
|
1874
1917
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1875
|
-
designSystem.
|
1918
|
+
designSystem.Radio.Group,
|
1876
1919
|
{
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1920
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
1921
|
+
name: "discard-options",
|
1922
|
+
"aria-label": formatMessage({
|
1923
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
1924
|
+
defaultMessage: "Choose an option to unpublish the document."
|
1925
|
+
}),
|
1926
|
+
onValueChange: handleChange,
|
1882
1927
|
children: [
|
1883
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1892
|
-
defaultMessage: "Keep draft"
|
1893
|
-
})
|
1894
|
-
}
|
1895
|
-
),
|
1896
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1897
|
-
designSystem.Radio,
|
1898
|
-
{
|
1899
|
-
checked: !shouldKeepDraft,
|
1900
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1901
|
-
name: "discard-options",
|
1902
|
-
children: formatMessage({
|
1903
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1904
|
-
defaultMessage: "Replace draft"
|
1905
|
-
})
|
1906
|
-
}
|
1907
|
-
)
|
1928
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
1929
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1930
|
+
defaultMessage: "Keep draft"
|
1931
|
+
}) }),
|
1932
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
1933
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1934
|
+
defaultMessage: "Replace draft"
|
1935
|
+
}) })
|
1908
1936
|
]
|
1909
1937
|
}
|
1910
1938
|
)
|
@@ -1937,7 +1965,7 @@ const UnpublishAction = ({
|
|
1937
1965
|
position: ["panel", "table-row"]
|
1938
1966
|
};
|
1939
1967
|
};
|
1940
|
-
UnpublishAction.type = "unpublish";
|
1968
|
+
UnpublishAction$1.type = "unpublish";
|
1941
1969
|
const DiscardAction = ({
|
1942
1970
|
activeTab,
|
1943
1971
|
documentId,
|
@@ -1971,7 +1999,7 @@ const DiscardAction = ({
|
|
1971
1999
|
}),
|
1972
2000
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
1973
2001
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1974
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2002
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1975
2003
|
id: "content-manager.actions.discard.dialog.body",
|
1976
2004
|
defaultMessage: "Are you sure?"
|
1977
2005
|
}) })
|
@@ -1988,12 +2016,12 @@ const DiscardAction = ({
|
|
1988
2016
|
};
|
1989
2017
|
};
|
1990
2018
|
DiscardAction.type = "discard";
|
1991
|
-
const StyledCrossCircle =
|
2019
|
+
const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
1992
2020
|
path {
|
1993
2021
|
fill: currentColor;
|
1994
2022
|
}
|
1995
2023
|
`;
|
1996
|
-
const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction, DiscardAction];
|
2024
|
+
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
1997
2025
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
1998
2026
|
const RelativeTime = React__namespace.forwardRef(
|
1999
2027
|
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
@@ -2041,7 +2069,7 @@ const getDisplayName = ({
|
|
2041
2069
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2042
2070
|
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2043
2071
|
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
2044
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2072
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
|
2045
2073
|
};
|
2046
2074
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2047
2075
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2061,7 +2089,7 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2061
2089
|
gap: "80px",
|
2062
2090
|
alignItems: "flex-start",
|
2063
2091
|
children: [
|
2064
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha",
|
2092
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2065
2093
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2066
2094
|
]
|
2067
2095
|
}
|
@@ -2218,7 +2246,7 @@ const Information = ({ activeTab }) => {
|
|
2218
2246
|
borderColor: "neutral150",
|
2219
2247
|
direction: "column",
|
2220
2248
|
marginTop: 2,
|
2221
|
-
|
2249
|
+
tag: "dl",
|
2222
2250
|
padding: 5,
|
2223
2251
|
gap: 3,
|
2224
2252
|
alignItems: "flex-start",
|
@@ -2226,8 +2254,8 @@ const Information = ({ activeTab }) => {
|
|
2226
2254
|
marginRight: "-0.4rem",
|
2227
2255
|
width: "calc(100% + 8px)",
|
2228
2256
|
children: information.map((info) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
|
2229
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2230
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2257
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
|
2258
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
|
2231
2259
|
] }, info.label))
|
2232
2260
|
}
|
2233
2261
|
);
|
@@ -2260,7 +2288,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2260
2288
|
id: "app.links.configure-view",
|
2261
2289
|
defaultMessage: "Configure the view"
|
2262
2290
|
}),
|
2263
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2291
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
2264
2292
|
onClick: () => {
|
2265
2293
|
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2266
2294
|
},
|
@@ -2268,11 +2296,6 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2268
2296
|
};
|
2269
2297
|
};
|
2270
2298
|
ConfigureTheViewAction.type = "configure-the-view";
|
2271
|
-
const StyledCog = styled__default.default(Icons.Cog)`
|
2272
|
-
path {
|
2273
|
-
fill: currentColor;
|
2274
|
-
}
|
2275
|
-
`;
|
2276
2299
|
const EditTheModelAction = ({ model }) => {
|
2277
2300
|
const navigate = reactRouterDom.useNavigate();
|
2278
2301
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2281,7 +2304,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2281
2304
|
id: "content-manager.link-to-ctb",
|
2282
2305
|
defaultMessage: "Edit the model"
|
2283
2306
|
}),
|
2284
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2307
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2285
2308
|
onClick: () => {
|
2286
2309
|
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2287
2310
|
},
|
@@ -2289,12 +2312,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2289
2312
|
};
|
2290
2313
|
};
|
2291
2314
|
EditTheModelAction.type = "edit-the-model";
|
2292
|
-
const
|
2293
|
-
path {
|
2294
|
-
fill: currentColor;
|
2295
|
-
}
|
2296
|
-
`;
|
2297
|
-
const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
2315
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2298
2316
|
const navigate = reactRouterDom.useNavigate();
|
2299
2317
|
const { formatMessage } = reactIntl.useIntl();
|
2300
2318
|
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
@@ -2308,7 +2326,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2308
2326
|
id: "content-manager.actions.delete.label",
|
2309
2327
|
defaultMessage: "Delete document"
|
2310
2328
|
}),
|
2311
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2329
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2312
2330
|
dialog: {
|
2313
2331
|
type: "dialog",
|
2314
2332
|
title: formatMessage({
|
@@ -2317,7 +2335,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2317
2335
|
}),
|
2318
2336
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2319
2337
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2320
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2338
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2321
2339
|
id: "content-manager.actions.delete.dialog.body",
|
2322
2340
|
defaultMessage: "Are you sure?"
|
2323
2341
|
}) })
|
@@ -2362,13 +2380,8 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2362
2380
|
position: ["header", "table-row"]
|
2363
2381
|
};
|
2364
2382
|
};
|
2365
|
-
DeleteAction.type = "delete";
|
2366
|
-
const
|
2367
|
-
path {
|
2368
|
-
fill: currentColor;
|
2369
|
-
}
|
2370
|
-
`;
|
2371
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];
|
2383
|
+
DeleteAction$1.type = "delete";
|
2384
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2372
2385
|
const Panels = () => {
|
2373
2386
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2374
2387
|
const [
|
@@ -2442,7 +2455,7 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
|
2442
2455
|
designSystem.Flex,
|
2443
2456
|
{
|
2444
2457
|
ref,
|
2445
|
-
|
2458
|
+
tag: "aside",
|
2446
2459
|
"aria-labelledby": "additional-information",
|
2447
2460
|
background: "neutral0",
|
2448
2461
|
borderColor: "neutral150",
|
@@ -2457,359 +2470,12 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
|
2457
2470
|
justifyContent: "stretch",
|
2458
2471
|
alignItems: "flex-start",
|
2459
2472
|
children: [
|
2460
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2473
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2461
2474
|
children
|
2462
2475
|
]
|
2463
2476
|
}
|
2464
2477
|
);
|
2465
2478
|
});
|
2466
|
-
const DEFAULT_BULK_ACTIONS = [];
|
2467
|
-
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
2468
|
-
const { formatMessage } = reactIntl.useIntl();
|
2469
|
-
const getDefaultErrorMessage = (reason) => {
|
2470
|
-
switch (reason) {
|
2471
|
-
case "relation":
|
2472
|
-
return "Duplicating the relation could remove it from the original entry.";
|
2473
|
-
case "unique":
|
2474
|
-
return "Identical values in a unique field are not allowed";
|
2475
|
-
default:
|
2476
|
-
return reason;
|
2477
|
-
}
|
2478
|
-
};
|
2479
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
2480
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
|
2481
|
-
id: getTranslation("containers.list.autoCloneModal.title"),
|
2482
|
-
defaultMessage: "This entry can't be duplicated directly."
|
2483
|
-
}) }),
|
2484
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
2485
|
-
id: getTranslation("containers.list.autoCloneModal.description"),
|
2486
|
-
defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
|
2487
|
-
}) }) }),
|
2488
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
|
2489
|
-
designSystem.Flex,
|
2490
|
-
{
|
2491
|
-
direction: "column",
|
2492
|
-
gap: 2,
|
2493
|
-
alignItems: "flex-start",
|
2494
|
-
borderColor: "neutral200",
|
2495
|
-
hasRadius: true,
|
2496
|
-
padding: 6,
|
2497
|
-
children: [
|
2498
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", as: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", as: "li", children: [
|
2499
|
-
pathSegment,
|
2500
|
-
index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
2501
|
-
Icons.ChevronRight,
|
2502
|
-
{
|
2503
|
-
fill: "neutral500",
|
2504
|
-
height: "0.8rem",
|
2505
|
-
width: "0.8rem",
|
2506
|
-
style: { margin: "0 0.8rem" }
|
2507
|
-
}
|
2508
|
-
)
|
2509
|
-
] }, index2)) }),
|
2510
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { as: "p", textColor: "neutral600", children: formatMessage({
|
2511
|
-
id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
|
2512
|
-
defaultMessage: getDefaultErrorMessage(reason)
|
2513
|
-
}) })
|
2514
|
-
]
|
2515
|
-
},
|
2516
|
-
fieldPath.join()
|
2517
|
-
)) })
|
2518
|
-
] });
|
2519
|
-
};
|
2520
|
-
const TableActions = ({ document }) => {
|
2521
|
-
const { formatMessage } = reactIntl.useIntl();
|
2522
|
-
const { model, collectionType } = useDoc();
|
2523
|
-
const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
|
2524
|
-
const props = {
|
2525
|
-
activeTab: null,
|
2526
|
-
model,
|
2527
|
-
documentId: document.documentId,
|
2528
|
-
collectionType,
|
2529
|
-
document
|
2530
|
-
};
|
2531
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
2532
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2533
|
-
{
|
2534
|
-
props,
|
2535
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2536
|
-
children: (actions2) => {
|
2537
|
-
const tableRowActions = actions2.filter((action) => {
|
2538
|
-
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
2539
|
-
return positions.includes("table-row");
|
2540
|
-
});
|
2541
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
2542
|
-
DocumentActionsMenu,
|
2543
|
-
{
|
2544
|
-
actions: tableRowActions,
|
2545
|
-
label: formatMessage({
|
2546
|
-
id: "content-manager.containers.list.table.row-actions",
|
2547
|
-
defaultMessage: "Row action"
|
2548
|
-
}),
|
2549
|
-
variant: "ghost"
|
2550
|
-
}
|
2551
|
-
);
|
2552
|
-
}
|
2553
|
-
}
|
2554
|
-
);
|
2555
|
-
};
|
2556
|
-
const EditAction = ({ documentId }) => {
|
2557
|
-
const navigate = reactRouterDom.useNavigate();
|
2558
|
-
const { formatMessage } = reactIntl.useIntl();
|
2559
|
-
const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
|
2560
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2561
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2562
|
-
return {
|
2563
|
-
disabled: !canRead,
|
2564
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
|
2565
|
-
label: formatMessage({
|
2566
|
-
id: "content-manager.actions.edit.label",
|
2567
|
-
defaultMessage: "Edit"
|
2568
|
-
}),
|
2569
|
-
position: "table-row",
|
2570
|
-
onClick: async () => {
|
2571
|
-
if (!documentId) {
|
2572
|
-
console.error(
|
2573
|
-
"You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2574
|
-
);
|
2575
|
-
toggleNotification({
|
2576
|
-
message: formatMessage({
|
2577
|
-
id: "content-manager.actions.edit.error",
|
2578
|
-
defaultMessage: "An error occurred while trying to edit the document."
|
2579
|
-
}),
|
2580
|
-
type: "danger"
|
2581
|
-
});
|
2582
|
-
return;
|
2583
|
-
}
|
2584
|
-
navigate({
|
2585
|
-
pathname: documentId,
|
2586
|
-
search: qs.stringify({
|
2587
|
-
plugins: query.plugins
|
2588
|
-
})
|
2589
|
-
});
|
2590
|
-
}
|
2591
|
-
};
|
2592
|
-
};
|
2593
|
-
EditAction.type = "edit";
|
2594
|
-
const StyledPencil = styled__default.default(Icons.Pencil)`
|
2595
|
-
path {
|
2596
|
-
fill: currentColor;
|
2597
|
-
}
|
2598
|
-
`;
|
2599
|
-
const CloneAction = ({ model, documentId }) => {
|
2600
|
-
const navigate = reactRouterDom.useNavigate();
|
2601
|
-
const { formatMessage } = reactIntl.useIntl();
|
2602
|
-
const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
|
2603
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2604
|
-
const { autoClone } = useDocumentActions();
|
2605
|
-
const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
|
2606
|
-
return {
|
2607
|
-
disabled: !canCreate,
|
2608
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
|
2609
|
-
label: formatMessage({
|
2610
|
-
id: "content-manager.actions.clone.label",
|
2611
|
-
defaultMessage: "Duplicate"
|
2612
|
-
}),
|
2613
|
-
position: "table-row",
|
2614
|
-
onClick: async () => {
|
2615
|
-
if (!documentId) {
|
2616
|
-
console.error(
|
2617
|
-
"You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
|
2618
|
-
);
|
2619
|
-
toggleNotification({
|
2620
|
-
message: formatMessage({
|
2621
|
-
id: "content-manager.actions.clone.error",
|
2622
|
-
defaultMessage: "An error occurred while trying to clone the document."
|
2623
|
-
}),
|
2624
|
-
type: "danger"
|
2625
|
-
});
|
2626
|
-
return;
|
2627
|
-
}
|
2628
|
-
const res = await autoClone({ model, sourceId: documentId });
|
2629
|
-
if ("data" in res) {
|
2630
|
-
navigate(res.data.documentId);
|
2631
|
-
return true;
|
2632
|
-
}
|
2633
|
-
if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
|
2634
|
-
const prohibitedFields2 = res.error.details.prohibitedFields;
|
2635
|
-
setProhibitedFields(prohibitedFields2);
|
2636
|
-
}
|
2637
|
-
},
|
2638
|
-
dialog: {
|
2639
|
-
type: "modal",
|
2640
|
-
title: formatMessage({
|
2641
|
-
id: "content-manager.containers.list.autoCloneModal.header",
|
2642
|
-
defaultMessage: "Duplicate"
|
2643
|
-
}),
|
2644
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
2645
|
-
footer: ({ onClose }) => {
|
2646
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
2647
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
2648
|
-
id: "cancel",
|
2649
|
-
defaultMessage: "Cancel"
|
2650
|
-
}) }),
|
2651
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2652
|
-
designSystem.LinkButton,
|
2653
|
-
{
|
2654
|
-
as: reactRouterDom.NavLink,
|
2655
|
-
to: {
|
2656
|
-
pathname: `clone/${documentId}`
|
2657
|
-
},
|
2658
|
-
children: formatMessage({
|
2659
|
-
id: "content-manager.containers.list.autoCloneModal.create",
|
2660
|
-
defaultMessage: "Create"
|
2661
|
-
})
|
2662
|
-
}
|
2663
|
-
)
|
2664
|
-
] });
|
2665
|
-
}
|
2666
|
-
}
|
2667
|
-
};
|
2668
|
-
};
|
2669
|
-
CloneAction.type = "clone";
|
2670
|
-
const StyledDuplicate = styled__default.default(Icons.Duplicate)`
|
2671
|
-
path {
|
2672
|
-
fill: currentColor;
|
2673
|
-
}
|
2674
|
-
`;
|
2675
|
-
const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
|
2676
|
-
class ContentManagerPlugin {
|
2677
|
-
/**
|
2678
|
-
* The following properties are the stored ones provided by any plugins registering with
|
2679
|
-
* the content-manager. The function calls however, need to be called at runtime in the
|
2680
|
-
* application, so instead we collate them and run them later with the complete list incl.
|
2681
|
-
* ones already registered & the context of the view.
|
2682
|
-
*/
|
2683
|
-
bulkActions = [...DEFAULT_BULK_ACTIONS];
|
2684
|
-
documentActions = [
|
2685
|
-
...DEFAULT_ACTIONS,
|
2686
|
-
...DEFAULT_TABLE_ROW_ACTIONS,
|
2687
|
-
...DEFAULT_HEADER_ACTIONS,
|
2688
|
-
HistoryAction
|
2689
|
-
];
|
2690
|
-
editViewSidePanels = [ActionsPanel];
|
2691
|
-
headerActions = [];
|
2692
|
-
constructor() {
|
2693
|
-
}
|
2694
|
-
addEditViewSidePanel(panels) {
|
2695
|
-
if (Array.isArray(panels)) {
|
2696
|
-
this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
|
2697
|
-
} else if (typeof panels === "function") {
|
2698
|
-
this.editViewSidePanels = panels(this.editViewSidePanels);
|
2699
|
-
} else {
|
2700
|
-
throw new Error(
|
2701
|
-
`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
|
2702
|
-
panels
|
2703
|
-
)}`
|
2704
|
-
);
|
2705
|
-
}
|
2706
|
-
}
|
2707
|
-
addDocumentAction(actions2) {
|
2708
|
-
if (Array.isArray(actions2)) {
|
2709
|
-
this.documentActions = [...this.documentActions, ...actions2];
|
2710
|
-
} else if (typeof actions2 === "function") {
|
2711
|
-
this.documentActions = actions2(this.documentActions);
|
2712
|
-
} else {
|
2713
|
-
throw new Error(
|
2714
|
-
`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
|
2715
|
-
actions2
|
2716
|
-
)}`
|
2717
|
-
);
|
2718
|
-
}
|
2719
|
-
}
|
2720
|
-
addDocumentHeaderAction(actions2) {
|
2721
|
-
if (Array.isArray(actions2)) {
|
2722
|
-
this.headerActions = [...this.headerActions, ...actions2];
|
2723
|
-
} else if (typeof actions2 === "function") {
|
2724
|
-
this.headerActions = actions2(this.headerActions);
|
2725
|
-
} else {
|
2726
|
-
throw new Error(
|
2727
|
-
`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
|
2728
|
-
actions2
|
2729
|
-
)}`
|
2730
|
-
);
|
2731
|
-
}
|
2732
|
-
}
|
2733
|
-
addBulkAction(actions2) {
|
2734
|
-
if (Array.isArray(actions2)) {
|
2735
|
-
this.bulkActions = [...this.bulkActions, ...actions2];
|
2736
|
-
} else if (typeof actions2 === "function") {
|
2737
|
-
this.bulkActions = actions2(this.bulkActions);
|
2738
|
-
} else {
|
2739
|
-
throw new Error(
|
2740
|
-
`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
|
2741
|
-
actions2
|
2742
|
-
)}`
|
2743
|
-
);
|
2744
|
-
}
|
2745
|
-
}
|
2746
|
-
get config() {
|
2747
|
-
return {
|
2748
|
-
id: PLUGIN_ID,
|
2749
|
-
name: "Content Manager",
|
2750
|
-
injectionZones: INJECTION_ZONES,
|
2751
|
-
apis: {
|
2752
|
-
addBulkAction: this.addBulkAction.bind(this),
|
2753
|
-
addDocumentAction: this.addDocumentAction.bind(this),
|
2754
|
-
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
2755
|
-
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
2756
|
-
getBulkActions: () => this.bulkActions,
|
2757
|
-
getDocumentActions: () => this.documentActions,
|
2758
|
-
getEditViewSidePanels: () => this.editViewSidePanels,
|
2759
|
-
getHeaderActions: () => this.headerActions
|
2760
|
-
}
|
2761
|
-
};
|
2762
|
-
}
|
2763
|
-
}
|
2764
|
-
const getPrintableType = (value) => {
|
2765
|
-
const nativeType = typeof value;
|
2766
|
-
if (nativeType === "object") {
|
2767
|
-
if (value === null)
|
2768
|
-
return "null";
|
2769
|
-
if (Array.isArray(value))
|
2770
|
-
return "array";
|
2771
|
-
if (value instanceof Object && value.constructor.name !== "Object") {
|
2772
|
-
return value.constructor.name;
|
2773
|
-
}
|
2774
|
-
}
|
2775
|
-
return nativeType;
|
2776
|
-
};
|
2777
|
-
const initialState = {
|
2778
|
-
collectionTypeLinks: [],
|
2779
|
-
components: [],
|
2780
|
-
fieldSizes: {},
|
2781
|
-
models: [],
|
2782
|
-
singleTypeLinks: [],
|
2783
|
-
isLoading: true
|
2784
|
-
};
|
2785
|
-
const appSlice = toolkit.createSlice({
|
2786
|
-
name: "app",
|
2787
|
-
initialState,
|
2788
|
-
reducers: {
|
2789
|
-
setInitialData(state, action) {
|
2790
|
-
const {
|
2791
|
-
authorizedCollectionTypeLinks,
|
2792
|
-
authorizedSingleTypeLinks,
|
2793
|
-
components,
|
2794
|
-
contentTypeSchemas,
|
2795
|
-
fieldSizes
|
2796
|
-
} = action.payload;
|
2797
|
-
state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
|
2798
|
-
({ isDisplayed }) => isDisplayed
|
2799
|
-
);
|
2800
|
-
state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
|
2801
|
-
state.components = components;
|
2802
|
-
state.models = contentTypeSchemas;
|
2803
|
-
state.fieldSizes = fieldSizes;
|
2804
|
-
state.isLoading = false;
|
2805
|
-
}
|
2806
|
-
}
|
2807
|
-
});
|
2808
|
-
const { actions, reducer: reducer$1 } = appSlice;
|
2809
|
-
const { setInitialData } = actions;
|
2810
|
-
const reducer = toolkit.combineReducers({
|
2811
|
-
app: reducer$1
|
2812
|
-
});
|
2813
2479
|
const HOOKS = {
|
2814
2480
|
/**
|
2815
2481
|
* Hook that allows to mutate the displayed headers of the list view table
|
@@ -2882,244 +2548,1159 @@ const checkIfAttributeIsDisplayable = (attribute) => {
|
|
2882
2548
|
}
|
2883
2549
|
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2884
2550
|
};
|
2885
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2886
|
-
if (!mainFieldName) {
|
2887
|
-
return void 0;
|
2888
|
-
}
|
2889
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2890
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2891
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2551
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2552
|
+
if (!mainFieldName) {
|
2553
|
+
return void 0;
|
2554
|
+
}
|
2555
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2556
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2557
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2558
|
+
);
|
2559
|
+
return {
|
2560
|
+
name: mainFieldName,
|
2561
|
+
type: mainFieldType ?? "string"
|
2562
|
+
};
|
2563
|
+
};
|
2564
|
+
const DEFAULT_SETTINGS = {
|
2565
|
+
bulkable: false,
|
2566
|
+
filterable: false,
|
2567
|
+
searchable: false,
|
2568
|
+
pagination: false,
|
2569
|
+
defaultSortBy: "",
|
2570
|
+
defaultSortOrder: "asc",
|
2571
|
+
mainField: "id",
|
2572
|
+
pageSize: 10
|
2573
|
+
};
|
2574
|
+
const useDocumentLayout = (model) => {
|
2575
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2576
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
2577
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2578
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
2579
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2580
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2581
|
+
const {
|
2582
|
+
data,
|
2583
|
+
isLoading: isLoadingConfigs,
|
2584
|
+
error,
|
2585
|
+
isFetching: isFetchingConfigs
|
2586
|
+
} = useGetContentTypeConfigurationQuery(model);
|
2587
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2588
|
+
React__namespace.useEffect(() => {
|
2589
|
+
if (error) {
|
2590
|
+
toggleNotification({
|
2591
|
+
type: "danger",
|
2592
|
+
message: formatAPIError(error)
|
2593
|
+
});
|
2594
|
+
}
|
2595
|
+
}, [error, formatAPIError, toggleNotification]);
|
2596
|
+
const editLayout = React__namespace.useMemo(
|
2597
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2598
|
+
layout: [],
|
2599
|
+
components: {},
|
2600
|
+
metadatas: {},
|
2601
|
+
options: {},
|
2602
|
+
settings: DEFAULT_SETTINGS
|
2603
|
+
},
|
2604
|
+
[data, isLoading, schemas, schema, components]
|
2605
|
+
);
|
2606
|
+
const listLayout = React__namespace.useMemo(() => {
|
2607
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2608
|
+
layout: [],
|
2609
|
+
metadatas: {},
|
2610
|
+
options: {},
|
2611
|
+
settings: DEFAULT_SETTINGS
|
2612
|
+
};
|
2613
|
+
}, [data, isLoading, schemas, schema, components]);
|
2614
|
+
const { layout: edit } = React__namespace.useMemo(
|
2615
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2616
|
+
layout: editLayout,
|
2617
|
+
query
|
2618
|
+
}),
|
2619
|
+
[editLayout, query, runHookWaterfall]
|
2620
|
+
);
|
2621
|
+
return {
|
2622
|
+
error,
|
2623
|
+
isLoading,
|
2624
|
+
edit,
|
2625
|
+
list: listLayout
|
2626
|
+
};
|
2627
|
+
};
|
2628
|
+
const useDocLayout = () => {
|
2629
|
+
const { model } = useDoc();
|
2630
|
+
return useDocumentLayout(model);
|
2631
|
+
};
|
2632
|
+
const formatEditLayout = (data, {
|
2633
|
+
schemas,
|
2634
|
+
schema,
|
2635
|
+
components
|
2636
|
+
}) => {
|
2637
|
+
let currentPanelIndex = 0;
|
2638
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2639
|
+
data.contentType.layouts.edit,
|
2640
|
+
schema?.attributes,
|
2641
|
+
data.contentType.metadatas,
|
2642
|
+
{ configurations: data.components, schemas: components },
|
2643
|
+
schemas
|
2644
|
+
).reduce((panels, row) => {
|
2645
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
2646
|
+
panels.push([row]);
|
2647
|
+
currentPanelIndex += 2;
|
2648
|
+
} else {
|
2649
|
+
if (!panels[currentPanelIndex]) {
|
2650
|
+
panels.push([]);
|
2651
|
+
}
|
2652
|
+
panels[currentPanelIndex].push(row);
|
2653
|
+
}
|
2654
|
+
return panels;
|
2655
|
+
}, []);
|
2656
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
2657
|
+
(acc, [uid, configuration]) => {
|
2658
|
+
acc[uid] = {
|
2659
|
+
layout: convertEditLayoutToFieldLayouts(
|
2660
|
+
configuration.layouts.edit,
|
2661
|
+
components[uid].attributes,
|
2662
|
+
configuration.metadatas
|
2663
|
+
),
|
2664
|
+
settings: {
|
2665
|
+
...configuration.settings,
|
2666
|
+
icon: components[uid].info.icon,
|
2667
|
+
displayName: components[uid].info.displayName
|
2668
|
+
}
|
2669
|
+
};
|
2670
|
+
return acc;
|
2671
|
+
},
|
2672
|
+
{}
|
2673
|
+
);
|
2674
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2675
|
+
(acc, [attribute, metadata]) => {
|
2676
|
+
return {
|
2677
|
+
...acc,
|
2678
|
+
[attribute]: metadata.edit
|
2679
|
+
};
|
2680
|
+
},
|
2681
|
+
{}
|
2682
|
+
);
|
2683
|
+
return {
|
2684
|
+
layout: panelledEditAttributes,
|
2685
|
+
components: componentEditAttributes,
|
2686
|
+
metadatas: editMetadatas,
|
2687
|
+
settings: {
|
2688
|
+
...data.contentType.settings,
|
2689
|
+
displayName: schema?.info.displayName
|
2690
|
+
},
|
2691
|
+
options: {
|
2692
|
+
...schema?.options,
|
2693
|
+
...schema?.pluginOptions,
|
2694
|
+
...data.contentType.options
|
2695
|
+
}
|
2696
|
+
};
|
2697
|
+
};
|
2698
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2699
|
+
return rows.map(
|
2700
|
+
(row) => row.map((field) => {
|
2701
|
+
const attribute = attributes[field.name];
|
2702
|
+
if (!attribute) {
|
2703
|
+
return null;
|
2704
|
+
}
|
2705
|
+
const { edit: metadata } = metadatas[field.name];
|
2706
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2707
|
+
return {
|
2708
|
+
attribute,
|
2709
|
+
disabled: !metadata.editable,
|
2710
|
+
hint: metadata.description,
|
2711
|
+
label: metadata.label ?? "",
|
2712
|
+
name: field.name,
|
2713
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2714
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2715
|
+
schemas,
|
2716
|
+
components: components?.schemas ?? {}
|
2717
|
+
}),
|
2718
|
+
placeholder: metadata.placeholder ?? "",
|
2719
|
+
required: attribute.required ?? false,
|
2720
|
+
size: field.size,
|
2721
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
2722
|
+
visible: metadata.visible ?? true,
|
2723
|
+
type: attribute.type
|
2724
|
+
};
|
2725
|
+
}).filter((field) => field !== null)
|
2726
|
+
);
|
2727
|
+
};
|
2728
|
+
const formatListLayout = (data, {
|
2729
|
+
schemas,
|
2730
|
+
schema,
|
2731
|
+
components
|
2732
|
+
}) => {
|
2733
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2734
|
+
(acc, [attribute, metadata]) => {
|
2735
|
+
return {
|
2736
|
+
...acc,
|
2737
|
+
[attribute]: metadata.list
|
2738
|
+
};
|
2739
|
+
},
|
2740
|
+
{}
|
2741
|
+
);
|
2742
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
2743
|
+
data.contentType.layouts.list,
|
2744
|
+
schema?.attributes,
|
2745
|
+
listMetadatas,
|
2746
|
+
{ configurations: data.components, schemas: components },
|
2747
|
+
schemas
|
2892
2748
|
);
|
2893
2749
|
return {
|
2894
|
-
|
2895
|
-
|
2750
|
+
layout: listAttributes,
|
2751
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2752
|
+
metadatas: listMetadatas,
|
2753
|
+
options: {
|
2754
|
+
...schema?.options,
|
2755
|
+
...schema?.pluginOptions,
|
2756
|
+
...data.contentType.options
|
2757
|
+
}
|
2896
2758
|
};
|
2897
2759
|
};
|
2898
|
-
const
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2760
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2761
|
+
return columns.map((name) => {
|
2762
|
+
const attribute = attributes[name];
|
2763
|
+
if (!attribute) {
|
2764
|
+
return null;
|
2765
|
+
}
|
2766
|
+
const metadata = metadatas[name];
|
2767
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2768
|
+
return {
|
2769
|
+
attribute,
|
2770
|
+
label: metadata.label ?? "",
|
2771
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2772
|
+
schemas,
|
2773
|
+
components: components?.schemas ?? {}
|
2774
|
+
}),
|
2775
|
+
name,
|
2776
|
+
searchable: metadata.searchable ?? true,
|
2777
|
+
sortable: metadata.sortable ?? true
|
2778
|
+
};
|
2779
|
+
}).filter((field) => field !== null);
|
2907
2780
|
};
|
2908
|
-
const
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2781
|
+
const ConfirmBulkActionDialog = ({
|
2782
|
+
onToggleDialog,
|
2783
|
+
isOpen = false,
|
2784
|
+
dialogBody,
|
2785
|
+
endAction
|
2786
|
+
}) => {
|
2787
|
+
const { formatMessage } = reactIntl.useIntl();
|
2788
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2789
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2790
|
+
id: "app.components.ConfirmDialog.title",
|
2791
|
+
defaultMessage: "Confirmation"
|
2792
|
+
}) }),
|
2793
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2794
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2795
|
+
dialogBody
|
2796
|
+
] }) }),
|
2797
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2798
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2799
|
+
id: "app.components.Button.cancel",
|
2800
|
+
defaultMessage: "Cancel"
|
2801
|
+
}) }) }),
|
2802
|
+
endAction
|
2803
|
+
] })
|
2804
|
+
] }) });
|
2805
|
+
};
|
2806
|
+
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2807
|
+
const ConfirmDialogPublishAll = ({
|
2808
|
+
isOpen,
|
2809
|
+
onToggleDialog,
|
2810
|
+
isConfirmButtonLoading = false,
|
2811
|
+
onConfirm
|
2812
|
+
}) => {
|
2813
|
+
const { formatMessage } = reactIntl.useIntl();
|
2814
|
+
const selectedEntries = strapiAdmin.useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
|
2912
2815
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2913
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2914
|
-
const {
|
2816
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2817
|
+
const { model, schema } = useDoc();
|
2818
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
2915
2819
|
const {
|
2916
|
-
data,
|
2917
|
-
isLoading
|
2918
|
-
error
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2820
|
+
data: countDraftRelations = 0,
|
2821
|
+
isLoading,
|
2822
|
+
error
|
2823
|
+
} = useGetManyDraftRelationCountQuery(
|
2824
|
+
{
|
2825
|
+
model,
|
2826
|
+
documentIds: selectedEntries.map((entry) => entry.documentId),
|
2827
|
+
locale: query?.plugins?.i18n?.locale
|
2828
|
+
},
|
2829
|
+
{
|
2830
|
+
skip: selectedEntries.length === 0
|
2831
|
+
}
|
2832
|
+
);
|
2922
2833
|
React__namespace.useEffect(() => {
|
2923
2834
|
if (error) {
|
2924
|
-
toggleNotification({
|
2925
|
-
type: "danger",
|
2926
|
-
message: formatAPIError(error)
|
2927
|
-
});
|
2835
|
+
toggleNotification({ type: "danger", message: formatAPIError(error) });
|
2928
2836
|
}
|
2929
2837
|
}, [error, formatAPIError, toggleNotification]);
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2838
|
+
if (error) {
|
2839
|
+
return null;
|
2840
|
+
}
|
2841
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
2842
|
+
ConfirmBulkActionDialog,
|
2843
|
+
{
|
2844
|
+
isOpen: isOpen && !isLoading,
|
2845
|
+
onToggleDialog,
|
2846
|
+
dialogBody: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
2847
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: [
|
2848
|
+
countDraftRelations > 0 && formatMessage(
|
2849
|
+
{
|
2850
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2851
|
+
defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
|
2852
|
+
},
|
2853
|
+
{
|
2854
|
+
b: BoldChunk$1,
|
2855
|
+
count: countDraftRelations,
|
2856
|
+
entities: selectedEntries.length
|
2857
|
+
}
|
2858
|
+
),
|
2859
|
+
formatMessage({
|
2860
|
+
id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
|
2861
|
+
defaultMessage: "Are you sure you want to publish these entries?"
|
2862
|
+
})
|
2863
|
+
] }),
|
2864
|
+
schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
|
2865
|
+
{
|
2866
|
+
id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
|
2867
|
+
defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
|
2868
|
+
},
|
2869
|
+
{
|
2870
|
+
em: Emphasis
|
2871
|
+
}
|
2872
|
+
) })
|
2873
|
+
] }),
|
2874
|
+
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
2875
|
+
designSystem.Button,
|
2876
|
+
{
|
2877
|
+
onClick: onConfirm,
|
2878
|
+
variant: "secondary",
|
2879
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
2880
|
+
loading: isConfirmButtonLoading,
|
2881
|
+
children: formatMessage({
|
2882
|
+
id: "app.utils.publish",
|
2883
|
+
defaultMessage: "Publish"
|
2884
|
+
})
|
2885
|
+
}
|
2886
|
+
)
|
2887
|
+
}
|
2888
|
+
);
|
2889
|
+
};
|
2890
|
+
const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
|
2891
|
+
max-width: 300px;
|
2892
|
+
`;
|
2893
|
+
const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
2894
|
+
const messages = [];
|
2895
|
+
Object.entries(errors).forEach(([key, value]) => {
|
2896
|
+
const currentKey = parentKey ? `${parentKey}.${key}` : key;
|
2897
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
2898
|
+
if ("id" in value && "defaultMessage" in value) {
|
2899
|
+
messages.push(
|
2900
|
+
formatMessage(
|
2901
|
+
{
|
2902
|
+
id: `${value.id}.withField`,
|
2903
|
+
defaultMessage: value.defaultMessage
|
2904
|
+
},
|
2905
|
+
{ field: currentKey }
|
2906
|
+
)
|
2907
|
+
);
|
2908
|
+
} else {
|
2909
|
+
messages.push(...formatErrorMessages(value, currentKey, formatMessage));
|
2910
|
+
}
|
2911
|
+
} else {
|
2912
|
+
messages.push(
|
2913
|
+
formatMessage(
|
2914
|
+
{
|
2915
|
+
id: `${value}.withField`,
|
2916
|
+
defaultMessage: value
|
2917
|
+
},
|
2918
|
+
{ field: currentKey }
|
2919
|
+
)
|
2920
|
+
);
|
2921
|
+
}
|
2922
|
+
});
|
2923
|
+
return messages;
|
2924
|
+
};
|
2925
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
2926
|
+
const { formatMessage } = reactIntl.useIntl();
|
2927
|
+
if (validationErrors) {
|
2928
|
+
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
2929
|
+
" "
|
2930
|
+
);
|
2931
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2932
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CrossCircle, { fill: "danger600" }),
|
2933
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
2934
|
+
] });
|
2935
|
+
}
|
2936
|
+
if (status === "published") {
|
2937
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2938
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2939
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
2940
|
+
id: "content-manager.bulk-publish.already-published",
|
2941
|
+
defaultMessage: "Already Published"
|
2942
|
+
}) })
|
2943
|
+
] });
|
2944
|
+
}
|
2945
|
+
if (status === "modified") {
|
2946
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2947
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
2948
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
2949
|
+
id: "content-manager.bulk-publish.modified",
|
2950
|
+
defaultMessage: "Ready to publish changes"
|
2951
|
+
}) })
|
2952
|
+
] });
|
2953
|
+
}
|
2954
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2955
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2956
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
2957
|
+
id: "app.utils.ready-to-publish",
|
2958
|
+
defaultMessage: "Ready to publish"
|
2959
|
+
}) })
|
2960
|
+
] });
|
2961
|
+
};
|
2962
|
+
const TABLE_HEADERS = [
|
2963
|
+
{ name: "id", label: "id" },
|
2964
|
+
{ name: "name", label: "name" },
|
2965
|
+
{ name: "status", label: "status" },
|
2966
|
+
{ name: "publicationStatus", label: "Publication status" }
|
2967
|
+
];
|
2968
|
+
const SelectedEntriesTableContent = ({
|
2969
|
+
isPublishing,
|
2970
|
+
rowsToDisplay = [],
|
2971
|
+
entriesToPublish = [],
|
2972
|
+
validationErrors = {}
|
2973
|
+
}) => {
|
2974
|
+
const { pathname } = reactRouterDom.useLocation();
|
2975
|
+
const { formatMessage } = reactIntl.useIntl();
|
2976
|
+
const {
|
2977
|
+
list: {
|
2978
|
+
settings: { mainField }
|
2979
|
+
}
|
2980
|
+
} = useDocLayout();
|
2981
|
+
const shouldDisplayMainField = mainField != null && mainField !== "id";
|
2982
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
2983
|
+
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
2984
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
|
2985
|
+
TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
|
2986
|
+
(head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name)
|
2987
|
+
)
|
2988
|
+
] }),
|
2989
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Loading, {}),
|
2990
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
|
2991
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: row.id }),
|
2992
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row.id }) }),
|
2993
|
+
shouldDisplayMainField && /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row[mainField] }) }),
|
2994
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
|
2995
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2996
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
2997
|
+
id: "content-manager.success.record.publishing",
|
2998
|
+
defaultMessage: "Publishing..."
|
2999
|
+
}) }),
|
3000
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true })
|
3001
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
3002
|
+
EntryValidationText,
|
3003
|
+
{
|
3004
|
+
validationErrors: validationErrors[row.documentId],
|
3005
|
+
status: row.status
|
3006
|
+
}
|
3007
|
+
) }),
|
3008
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3009
|
+
designSystem.IconButton,
|
3010
|
+
{
|
3011
|
+
tag: reactRouterDom.Link,
|
3012
|
+
to: {
|
3013
|
+
pathname: `${pathname}/${row.documentId}`,
|
3014
|
+
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3015
|
+
},
|
3016
|
+
state: { from: pathname },
|
3017
|
+
label: formatMessage(
|
3018
|
+
{ id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
|
3019
|
+
{
|
3020
|
+
target: formatMessage(
|
3021
|
+
{
|
3022
|
+
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3023
|
+
defaultMessage: "item line {number}"
|
3024
|
+
},
|
3025
|
+
{ number: index2 + 1 }
|
3026
|
+
)
|
3027
|
+
}
|
3028
|
+
),
|
3029
|
+
target: "_blank",
|
3030
|
+
marginLeft: "auto",
|
3031
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
|
3032
|
+
}
|
3033
|
+
) })
|
3034
|
+
] }, row.id)) })
|
3035
|
+
] });
|
3036
|
+
};
|
3037
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
3038
|
+
const SelectedEntriesModalContent = ({
|
3039
|
+
listViewSelectedEntries,
|
3040
|
+
toggleModal,
|
3041
|
+
setListViewSelectedDocuments,
|
3042
|
+
model
|
3043
|
+
}) => {
|
3044
|
+
const { formatMessage } = reactIntl.useIntl();
|
3045
|
+
const { schema, components } = useContentTypeSchema(model);
|
3046
|
+
const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
|
3047
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3048
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3049
|
+
const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
|
3050
|
+
{
|
3051
|
+
model,
|
3052
|
+
params: {
|
3053
|
+
page: "1",
|
3054
|
+
pageSize: documentIds.length.toString(),
|
3055
|
+
sort: query.sort,
|
3056
|
+
filters: {
|
3057
|
+
documentId: {
|
3058
|
+
$in: documentIds
|
3059
|
+
}
|
3060
|
+
},
|
3061
|
+
locale: query.plugins?.i18n?.locale
|
3062
|
+
}
|
2937
3063
|
},
|
2938
|
-
|
3064
|
+
{
|
3065
|
+
selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
|
3066
|
+
}
|
2939
3067
|
);
|
2940
|
-
const
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
3068
|
+
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3069
|
+
if (data.length > 0 && schema) {
|
3070
|
+
const validate = createYupSchema(schema.attributes, components);
|
3071
|
+
const validationErrors2 = {};
|
3072
|
+
const rows2 = data.map((entry) => {
|
3073
|
+
try {
|
3074
|
+
validate.validateSync(entry, { abortEarly: false });
|
3075
|
+
return entry;
|
3076
|
+
} catch (e) {
|
3077
|
+
if (e instanceof yup.ValidationError) {
|
3078
|
+
validationErrors2[entry.documentId] = strapiAdmin.getYupValidationErrors(e);
|
3079
|
+
}
|
3080
|
+
return entry;
|
3081
|
+
}
|
3082
|
+
});
|
3083
|
+
return { rows: rows2, validationErrors: validationErrors2 };
|
3084
|
+
}
|
3085
|
+
return {
|
3086
|
+
rows: [],
|
3087
|
+
validationErrors: {}
|
2946
3088
|
};
|
2947
|
-
}, [
|
2948
|
-
const
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
3089
|
+
}, [components, data, schema]);
|
3090
|
+
const [publishedCount, setPublishedCount] = React__namespace.useState(0);
|
3091
|
+
const [isDialogOpen, setIsDialogOpen] = React__namespace.useState(false);
|
3092
|
+
const { publishMany: bulkPublishAction } = useDocumentActions();
|
3093
|
+
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
3094
|
+
const selectedRows = strapiAdmin.useTable("publishAction", (state) => state.selectedRows);
|
3095
|
+
const selectedEntries = rows.filter(
|
3096
|
+
(entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
|
2954
3097
|
);
|
3098
|
+
const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
|
3099
|
+
const selectedEntriesWithErrorsCount = selectedEntries.filter(
|
3100
|
+
({ documentId }) => validationErrors[documentId]
|
3101
|
+
).length;
|
3102
|
+
const selectedEntriesPublished = selectedEntries.filter(
|
3103
|
+
({ status }) => status === "published"
|
3104
|
+
).length;
|
3105
|
+
const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
|
3106
|
+
const toggleDialog = () => setIsDialogOpen((prev) => !prev);
|
3107
|
+
const handleConfirmBulkPublish = async () => {
|
3108
|
+
toggleDialog();
|
3109
|
+
const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
|
3110
|
+
if (!("error" in res)) {
|
3111
|
+
setPublishedCount(res.count);
|
3112
|
+
const unpublishedEntries = rows.filter((row) => {
|
3113
|
+
return !entriesToPublish.includes(row.documentId);
|
3114
|
+
});
|
3115
|
+
setListViewSelectedDocuments(unpublishedEntries);
|
3116
|
+
}
|
3117
|
+
};
|
3118
|
+
const getFormattedCountMessage = () => {
|
3119
|
+
if (publishedCount) {
|
3120
|
+
return formatMessage(
|
3121
|
+
{
|
3122
|
+
id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
|
3123
|
+
defaultMessage: "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
|
3124
|
+
},
|
3125
|
+
{
|
3126
|
+
publishedCount,
|
3127
|
+
withErrorsCount: selectedEntriesWithErrorsCount,
|
3128
|
+
b: BoldChunk
|
3129
|
+
}
|
3130
|
+
);
|
3131
|
+
}
|
3132
|
+
return formatMessage(
|
3133
|
+
{
|
3134
|
+
id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
|
3135
|
+
defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
|
3136
|
+
},
|
3137
|
+
{
|
3138
|
+
readyToPublishCount: selectedEntriesWithNoErrorsCount,
|
3139
|
+
withErrorsCount: selectedEntriesWithErrorsCount,
|
3140
|
+
alreadyPublishedCount: selectedEntriesPublished,
|
3141
|
+
b: BoldChunk
|
3142
|
+
}
|
3143
|
+
);
|
3144
|
+
};
|
3145
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3146
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3147
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3148
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3149
|
+
SelectedEntriesTableContent,
|
3150
|
+
{
|
3151
|
+
isPublishing: isSubmittingForm,
|
3152
|
+
rowsToDisplay: rows,
|
3153
|
+
entriesToPublish,
|
3154
|
+
validationErrors
|
3155
|
+
}
|
3156
|
+
) })
|
3157
|
+
] }),
|
3158
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3159
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3160
|
+
id: "app.components.Button.cancel",
|
3161
|
+
defaultMessage: "Cancel"
|
3162
|
+
}) }),
|
3163
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3164
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3165
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3166
|
+
designSystem.Button,
|
3167
|
+
{
|
3168
|
+
onClick: toggleDialog,
|
3169
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3170
|
+
loading: isSubmittingForm,
|
3171
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3172
|
+
}
|
3173
|
+
)
|
3174
|
+
] })
|
3175
|
+
] }),
|
3176
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3177
|
+
ConfirmDialogPublishAll,
|
3178
|
+
{
|
3179
|
+
isOpen: isDialogOpen,
|
3180
|
+
onToggleDialog: toggleDialog,
|
3181
|
+
isConfirmButtonLoading: isSubmittingForm,
|
3182
|
+
onConfirm: handleConfirmBulkPublish
|
3183
|
+
}
|
3184
|
+
)
|
3185
|
+
] });
|
3186
|
+
};
|
3187
|
+
const PublishAction = ({ documents, model }) => {
|
3188
|
+
const { formatMessage } = reactIntl.useIntl();
|
3189
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3190
|
+
const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
|
3191
|
+
const setListViewSelectedDocuments = strapiAdmin.useTable("publishAction", (state) => state.selectRow);
|
3192
|
+
const refetchList = () => {
|
3193
|
+
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3194
|
+
};
|
3195
|
+
if (!showPublishButton)
|
3196
|
+
return null;
|
3197
|
+
return {
|
3198
|
+
actionType: "publish",
|
3199
|
+
variant: "tertiary",
|
3200
|
+
label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
|
3201
|
+
dialog: {
|
3202
|
+
type: "modal",
|
3203
|
+
title: formatMessage({
|
3204
|
+
id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
|
3205
|
+
defaultMessage: "Publish entries"
|
3206
|
+
}),
|
3207
|
+
content: ({ onClose }) => {
|
3208
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3209
|
+
SelectedEntriesModalContent,
|
3210
|
+
{
|
3211
|
+
listViewSelectedEntries: documents,
|
3212
|
+
toggleModal: () => {
|
3213
|
+
onClose();
|
3214
|
+
refetchList();
|
3215
|
+
},
|
3216
|
+
setListViewSelectedDocuments,
|
3217
|
+
model
|
3218
|
+
}
|
3219
|
+
) });
|
3220
|
+
},
|
3221
|
+
onClose: () => {
|
3222
|
+
refetchList();
|
3223
|
+
}
|
3224
|
+
}
|
3225
|
+
};
|
3226
|
+
};
|
3227
|
+
const BulkActionsRenderer = () => {
|
3228
|
+
const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
|
3229
|
+
const { model, collectionType } = useDoc();
|
3230
|
+
const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
|
3231
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3232
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3233
|
+
{
|
3234
|
+
props: {
|
3235
|
+
model,
|
3236
|
+
collectionType,
|
3237
|
+
documents: selectedRows
|
3238
|
+
},
|
3239
|
+
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3240
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3241
|
+
}
|
3242
|
+
) });
|
3243
|
+
};
|
3244
|
+
const DeleteAction = ({ documents, model }) => {
|
3245
|
+
const { formatMessage } = reactIntl.useIntl();
|
3246
|
+
const { schema: contentType } = useDoc();
|
3247
|
+
const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
|
3248
|
+
const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
|
3249
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3250
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3251
|
+
const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
|
3252
|
+
const { deleteMany: bulkDeleteAction } = useDocumentActions();
|
3253
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3254
|
+
const handleConfirmBulkDelete = async () => {
|
3255
|
+
const res = await bulkDeleteAction({
|
3256
|
+
documentIds,
|
3257
|
+
model,
|
3258
|
+
params
|
3259
|
+
});
|
3260
|
+
if (!("error" in res)) {
|
3261
|
+
selectRow([]);
|
3262
|
+
}
|
3263
|
+
};
|
3264
|
+
if (!hasDeletePermission)
|
3265
|
+
return null;
|
2955
3266
|
return {
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
3267
|
+
variant: "danger-light",
|
3268
|
+
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
3269
|
+
dialog: {
|
3270
|
+
type: "dialog",
|
3271
|
+
title: formatMessage({
|
3272
|
+
id: "app.components.ConfirmDialog.title",
|
3273
|
+
defaultMessage: "Confirmation"
|
3274
|
+
}),
|
3275
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3276
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3277
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3278
|
+
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3279
|
+
defaultMessage: "Are you sure you want to delete these entries?"
|
3280
|
+
}) }),
|
3281
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
3282
|
+
{
|
3283
|
+
id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
|
3284
|
+
defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
|
3285
|
+
},
|
3286
|
+
{
|
3287
|
+
em: Emphasis
|
3288
|
+
}
|
3289
|
+
) }) })
|
3290
|
+
] }),
|
3291
|
+
onConfirm: handleConfirmBulkDelete
|
3292
|
+
}
|
2960
3293
|
};
|
2961
3294
|
};
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
};
|
2966
|
-
const
|
2967
|
-
|
2968
|
-
schema
|
2969
|
-
|
2970
|
-
}
|
2971
|
-
|
2972
|
-
const
|
2973
|
-
|
2974
|
-
|
2975
|
-
data
|
2976
|
-
|
2977
|
-
|
2978
|
-
).reduce((panels, row) => {
|
2979
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2980
|
-
panels.push([row]);
|
2981
|
-
currentPanelIndex += 2;
|
2982
|
-
} else {
|
2983
|
-
if (!panels[currentPanelIndex]) {
|
2984
|
-
panels.push([]);
|
2985
|
-
}
|
2986
|
-
panels[currentPanelIndex].push(row);
|
3295
|
+
DeleteAction.type = "delete";
|
3296
|
+
const UnpublishAction = ({ documents, model }) => {
|
3297
|
+
const { formatMessage } = reactIntl.useIntl();
|
3298
|
+
const { schema } = useDoc();
|
3299
|
+
const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
|
3300
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3301
|
+
const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
|
3302
|
+
const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
|
3303
|
+
const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
|
3304
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3305
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3306
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3307
|
+
const handleConfirmBulkUnpublish = async () => {
|
3308
|
+
const data = await bulkUnpublishAction({ documentIds, model, params });
|
3309
|
+
if (!("error" in data)) {
|
3310
|
+
selectRow([]);
|
2987
3311
|
}
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
acc[uid] = {
|
2993
|
-
layout: convertEditLayoutToFieldLayouts(
|
2994
|
-
configuration.layouts.edit,
|
2995
|
-
components[uid].attributes,
|
2996
|
-
configuration.metadatas
|
2997
|
-
),
|
2998
|
-
settings: {
|
2999
|
-
...configuration.settings,
|
3000
|
-
icon: components[uid].info.icon,
|
3001
|
-
displayName: components[uid].info.displayName
|
3002
|
-
}
|
3003
|
-
};
|
3004
|
-
return acc;
|
3005
|
-
},
|
3006
|
-
{}
|
3007
|
-
);
|
3008
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
3009
|
-
(acc, [attribute, metadata]) => {
|
3010
|
-
return {
|
3011
|
-
...acc,
|
3012
|
-
[attribute]: metadata.edit
|
3013
|
-
};
|
3014
|
-
},
|
3015
|
-
{}
|
3016
|
-
);
|
3312
|
+
};
|
3313
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3314
|
+
if (!showUnpublishButton)
|
3315
|
+
return null;
|
3017
3316
|
return {
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3317
|
+
variant: "tertiary",
|
3318
|
+
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
3319
|
+
dialog: {
|
3320
|
+
type: "dialog",
|
3321
|
+
title: formatMessage({
|
3322
|
+
id: "app.components.ConfirmDialog.title",
|
3323
|
+
defaultMessage: "Confirmation"
|
3324
|
+
}),
|
3325
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3326
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3327
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3328
|
+
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3329
|
+
defaultMessage: "Are you sure you want to unpublish these entries?"
|
3330
|
+
}) }),
|
3331
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
3332
|
+
{
|
3333
|
+
id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
|
3334
|
+
defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
|
3335
|
+
},
|
3336
|
+
{
|
3337
|
+
em: Emphasis
|
3338
|
+
}
|
3339
|
+
) }) })
|
3340
|
+
] }),
|
3341
|
+
confirmButton: formatMessage({
|
3342
|
+
id: "app.utils.unpublish",
|
3343
|
+
defaultMessage: "Unpublish"
|
3344
|
+
}),
|
3345
|
+
onConfirm: handleConfirmBulkUnpublish
|
3029
3346
|
}
|
3030
3347
|
};
|
3031
3348
|
};
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3349
|
+
UnpublishAction.type = "unpublish";
|
3350
|
+
const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
|
3351
|
+
const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
|
3352
|
+
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
3353
|
+
const { formatMessage } = reactIntl.useIntl();
|
3354
|
+
const getDefaultErrorMessage = (reason) => {
|
3355
|
+
switch (reason) {
|
3356
|
+
case "relation":
|
3357
|
+
return "Duplicating the relation could remove it from the original entry.";
|
3358
|
+
case "unique":
|
3359
|
+
return "Identical values in a unique field are not allowed";
|
3360
|
+
default:
|
3361
|
+
return reason;
|
3362
|
+
}
|
3363
|
+
};
|
3364
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3365
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
|
3366
|
+
id: getTranslation("containers.list.autoCloneModal.title"),
|
3367
|
+
defaultMessage: "This entry can't be duplicated directly."
|
3368
|
+
}) }),
|
3369
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
3370
|
+
id: getTranslation("containers.list.autoCloneModal.description"),
|
3371
|
+
defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
|
3372
|
+
}) }) }),
|
3373
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
|
3374
|
+
designSystem.Flex,
|
3375
|
+
{
|
3376
|
+
direction: "column",
|
3377
|
+
gap: 2,
|
3378
|
+
alignItems: "flex-start",
|
3379
|
+
borderColor: "neutral200",
|
3380
|
+
hasRadius: true,
|
3381
|
+
padding: 6,
|
3382
|
+
children: [
|
3383
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
|
3384
|
+
pathSegment,
|
3385
|
+
index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
3386
|
+
Icons.ChevronRight,
|
3387
|
+
{
|
3388
|
+
fill: "neutral500",
|
3389
|
+
height: "0.8rem",
|
3390
|
+
width: "0.8rem",
|
3391
|
+
style: { margin: "0 0.8rem" }
|
3392
|
+
}
|
3393
|
+
)
|
3394
|
+
] }, index2)) }),
|
3395
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
|
3396
|
+
id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
|
3397
|
+
defaultMessage: getDefaultErrorMessage(reason)
|
3398
|
+
}) })
|
3399
|
+
]
|
3400
|
+
},
|
3401
|
+
fieldPath.join()
|
3402
|
+
)) })
|
3403
|
+
] });
|
3404
|
+
};
|
3405
|
+
const TableActions = ({ document }) => {
|
3406
|
+
const { formatMessage } = reactIntl.useIntl();
|
3407
|
+
const { model, collectionType } = useDoc();
|
3408
|
+
const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
|
3409
|
+
const props = {
|
3410
|
+
activeTab: null,
|
3411
|
+
model,
|
3412
|
+
documentId: document.documentId,
|
3413
|
+
collectionType,
|
3414
|
+
document
|
3415
|
+
};
|
3416
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
3417
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3418
|
+
{
|
3419
|
+
props,
|
3420
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3421
|
+
children: (actions2) => {
|
3422
|
+
const tableRowActions = actions2.filter((action) => {
|
3423
|
+
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
3424
|
+
return positions.includes("table-row");
|
3425
|
+
});
|
3426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
3427
|
+
DocumentActionsMenu,
|
3428
|
+
{
|
3429
|
+
actions: tableRowActions,
|
3430
|
+
label: formatMessage({
|
3431
|
+
id: "content-manager.containers.list.table.row-actions",
|
3432
|
+
defaultMessage: "Row action"
|
3433
|
+
}),
|
3434
|
+
variant: "ghost"
|
3435
|
+
}
|
3436
|
+
);
|
3038
3437
|
}
|
3039
|
-
|
3040
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
3041
|
-
return {
|
3042
|
-
attribute,
|
3043
|
-
disabled: !metadata.editable,
|
3044
|
-
hint: metadata.description,
|
3045
|
-
label: metadata.label ?? "",
|
3046
|
-
name: field.name,
|
3047
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
3048
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
3049
|
-
schemas,
|
3050
|
-
components: components?.schemas ?? {}
|
3051
|
-
}),
|
3052
|
-
placeholder: metadata.placeholder ?? "",
|
3053
|
-
required: attribute.required ?? false,
|
3054
|
-
size: field.size,
|
3055
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
3056
|
-
visible: metadata.visible ?? true,
|
3057
|
-
type: attribute.type
|
3058
|
-
};
|
3059
|
-
}).filter((field) => field !== null)
|
3438
|
+
}
|
3060
3439
|
);
|
3061
3440
|
};
|
3062
|
-
const
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
}
|
3067
|
-
const
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
3077
|
-
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3081
|
-
|
3082
|
-
|
3441
|
+
const EditAction = ({ documentId }) => {
|
3442
|
+
const navigate = reactRouterDom.useNavigate();
|
3443
|
+
const { formatMessage } = reactIntl.useIntl();
|
3444
|
+
const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
|
3445
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
3446
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3447
|
+
return {
|
3448
|
+
disabled: !canRead,
|
3449
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
|
3450
|
+
label: formatMessage({
|
3451
|
+
id: "content-manager.actions.edit.label",
|
3452
|
+
defaultMessage: "Edit"
|
3453
|
+
}),
|
3454
|
+
position: "table-row",
|
3455
|
+
onClick: async () => {
|
3456
|
+
if (!documentId) {
|
3457
|
+
console.error(
|
3458
|
+
"You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
|
3459
|
+
);
|
3460
|
+
toggleNotification({
|
3461
|
+
message: formatMessage({
|
3462
|
+
id: "content-manager.actions.edit.error",
|
3463
|
+
defaultMessage: "An error occurred while trying to edit the document."
|
3464
|
+
}),
|
3465
|
+
type: "danger"
|
3466
|
+
});
|
3467
|
+
return;
|
3468
|
+
}
|
3469
|
+
navigate({
|
3470
|
+
pathname: documentId,
|
3471
|
+
search: qs.stringify({
|
3472
|
+
plugins: query.plugins
|
3473
|
+
})
|
3474
|
+
});
|
3475
|
+
}
|
3476
|
+
};
|
3477
|
+
};
|
3478
|
+
EditAction.type = "edit";
|
3479
|
+
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3480
|
+
path {
|
3481
|
+
fill: currentColor;
|
3482
|
+
}
|
3483
|
+
`;
|
3484
|
+
const CloneAction = ({ model, documentId }) => {
|
3485
|
+
const navigate = reactRouterDom.useNavigate();
|
3486
|
+
const { formatMessage } = reactIntl.useIntl();
|
3487
|
+
const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
|
3488
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
3489
|
+
const { autoClone } = useDocumentActions();
|
3490
|
+
const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
|
3083
3491
|
return {
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3492
|
+
disabled: !canCreate,
|
3493
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
|
3494
|
+
label: formatMessage({
|
3495
|
+
id: "content-manager.actions.clone.label",
|
3496
|
+
defaultMessage: "Duplicate"
|
3497
|
+
}),
|
3498
|
+
position: "table-row",
|
3499
|
+
onClick: async () => {
|
3500
|
+
if (!documentId) {
|
3501
|
+
console.error(
|
3502
|
+
"You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
|
3503
|
+
);
|
3504
|
+
toggleNotification({
|
3505
|
+
message: formatMessage({
|
3506
|
+
id: "content-manager.actions.clone.error",
|
3507
|
+
defaultMessage: "An error occurred while trying to clone the document."
|
3508
|
+
}),
|
3509
|
+
type: "danger"
|
3510
|
+
});
|
3511
|
+
return;
|
3512
|
+
}
|
3513
|
+
const res = await autoClone({ model, sourceId: documentId });
|
3514
|
+
if ("data" in res) {
|
3515
|
+
navigate(res.data.documentId);
|
3516
|
+
return true;
|
3517
|
+
}
|
3518
|
+
if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
|
3519
|
+
const prohibitedFields2 = res.error.details.prohibitedFields;
|
3520
|
+
setProhibitedFields(prohibitedFields2);
|
3521
|
+
}
|
3522
|
+
},
|
3523
|
+
dialog: {
|
3524
|
+
type: "modal",
|
3525
|
+
title: formatMessage({
|
3526
|
+
id: "content-manager.containers.list.autoCloneModal.header",
|
3527
|
+
defaultMessage: "Duplicate"
|
3528
|
+
}),
|
3529
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3530
|
+
footer: ({ onClose }) => {
|
3531
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
3532
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3533
|
+
id: "cancel",
|
3534
|
+
defaultMessage: "Cancel"
|
3535
|
+
}) }),
|
3536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3537
|
+
designSystem.LinkButton,
|
3538
|
+
{
|
3539
|
+
tag: reactRouterDom.NavLink,
|
3540
|
+
to: {
|
3541
|
+
pathname: `clone/${documentId}`
|
3542
|
+
},
|
3543
|
+
children: formatMessage({
|
3544
|
+
id: "content-manager.containers.list.autoCloneModal.create",
|
3545
|
+
defaultMessage: "Create"
|
3546
|
+
})
|
3547
|
+
}
|
3548
|
+
)
|
3549
|
+
] });
|
3550
|
+
}
|
3091
3551
|
}
|
3092
3552
|
};
|
3093
3553
|
};
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3554
|
+
CloneAction.type = "clone";
|
3555
|
+
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3556
|
+
path {
|
3557
|
+
fill: currentColor;
|
3558
|
+
}
|
3559
|
+
`;
|
3560
|
+
const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
|
3561
|
+
class ContentManagerPlugin {
|
3562
|
+
/**
|
3563
|
+
* The following properties are the stored ones provided by any plugins registering with
|
3564
|
+
* the content-manager. The function calls however, need to be called at runtime in the
|
3565
|
+
* application, so instead we collate them and run them later with the complete list incl.
|
3566
|
+
* ones already registered & the context of the view.
|
3567
|
+
*/
|
3568
|
+
bulkActions = [...DEFAULT_BULK_ACTIONS];
|
3569
|
+
documentActions = [
|
3570
|
+
...DEFAULT_ACTIONS,
|
3571
|
+
...DEFAULT_TABLE_ROW_ACTIONS,
|
3572
|
+
...DEFAULT_HEADER_ACTIONS,
|
3573
|
+
HistoryAction
|
3574
|
+
];
|
3575
|
+
editViewSidePanels = [ActionsPanel];
|
3576
|
+
headerActions = [];
|
3577
|
+
constructor() {
|
3578
|
+
}
|
3579
|
+
addEditViewSidePanel(panels) {
|
3580
|
+
if (Array.isArray(panels)) {
|
3581
|
+
this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
|
3582
|
+
} else if (typeof panels === "function") {
|
3583
|
+
this.editViewSidePanels = panels(this.editViewSidePanels);
|
3584
|
+
} else {
|
3585
|
+
throw new Error(
|
3586
|
+
`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
|
3587
|
+
panels
|
3588
|
+
)}`
|
3589
|
+
);
|
3099
3590
|
}
|
3100
|
-
|
3101
|
-
|
3591
|
+
}
|
3592
|
+
addDocumentAction(actions2) {
|
3593
|
+
if (Array.isArray(actions2)) {
|
3594
|
+
this.documentActions = [...this.documentActions, ...actions2];
|
3595
|
+
} else if (typeof actions2 === "function") {
|
3596
|
+
this.documentActions = actions2(this.documentActions);
|
3597
|
+
} else {
|
3598
|
+
throw new Error(
|
3599
|
+
`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
|
3600
|
+
actions2
|
3601
|
+
)}`
|
3602
|
+
);
|
3603
|
+
}
|
3604
|
+
}
|
3605
|
+
addDocumentHeaderAction(actions2) {
|
3606
|
+
if (Array.isArray(actions2)) {
|
3607
|
+
this.headerActions = [...this.headerActions, ...actions2];
|
3608
|
+
} else if (typeof actions2 === "function") {
|
3609
|
+
this.headerActions = actions2(this.headerActions);
|
3610
|
+
} else {
|
3611
|
+
throw new Error(
|
3612
|
+
`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
|
3613
|
+
actions2
|
3614
|
+
)}`
|
3615
|
+
);
|
3616
|
+
}
|
3617
|
+
}
|
3618
|
+
addBulkAction(actions2) {
|
3619
|
+
if (Array.isArray(actions2)) {
|
3620
|
+
this.bulkActions = [...this.bulkActions, ...actions2];
|
3621
|
+
} else if (typeof actions2 === "function") {
|
3622
|
+
this.bulkActions = actions2(this.bulkActions);
|
3623
|
+
} else {
|
3624
|
+
throw new Error(
|
3625
|
+
`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
|
3626
|
+
actions2
|
3627
|
+
)}`
|
3628
|
+
);
|
3629
|
+
}
|
3630
|
+
}
|
3631
|
+
get config() {
|
3102
3632
|
return {
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3633
|
+
id: PLUGIN_ID,
|
3634
|
+
name: "Content Manager",
|
3635
|
+
injectionZones: INJECTION_ZONES,
|
3636
|
+
apis: {
|
3637
|
+
addBulkAction: this.addBulkAction.bind(this),
|
3638
|
+
addDocumentAction: this.addDocumentAction.bind(this),
|
3639
|
+
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3640
|
+
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3641
|
+
getBulkActions: () => this.bulkActions,
|
3642
|
+
getDocumentActions: () => this.documentActions,
|
3643
|
+
getEditViewSidePanels: () => this.editViewSidePanels,
|
3644
|
+
getHeaderActions: () => this.headerActions
|
3645
|
+
}
|
3112
3646
|
};
|
3113
|
-
}
|
3647
|
+
}
|
3648
|
+
}
|
3649
|
+
const getPrintableType = (value) => {
|
3650
|
+
const nativeType = typeof value;
|
3651
|
+
if (nativeType === "object") {
|
3652
|
+
if (value === null)
|
3653
|
+
return "null";
|
3654
|
+
if (Array.isArray(value))
|
3655
|
+
return "array";
|
3656
|
+
if (value instanceof Object && value.constructor.name !== "Object") {
|
3657
|
+
return value.constructor.name;
|
3658
|
+
}
|
3659
|
+
}
|
3660
|
+
return nativeType;
|
3661
|
+
};
|
3662
|
+
const initialState = {
|
3663
|
+
collectionTypeLinks: [],
|
3664
|
+
components: [],
|
3665
|
+
fieldSizes: {},
|
3666
|
+
models: [],
|
3667
|
+
singleTypeLinks: [],
|
3668
|
+
isLoading: true
|
3114
3669
|
};
|
3670
|
+
const appSlice = toolkit.createSlice({
|
3671
|
+
name: "app",
|
3672
|
+
initialState,
|
3673
|
+
reducers: {
|
3674
|
+
setInitialData(state, action) {
|
3675
|
+
const {
|
3676
|
+
authorizedCollectionTypeLinks,
|
3677
|
+
authorizedSingleTypeLinks,
|
3678
|
+
components,
|
3679
|
+
contentTypeSchemas,
|
3680
|
+
fieldSizes
|
3681
|
+
} = action.payload;
|
3682
|
+
state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
|
3683
|
+
({ isDisplayed }) => isDisplayed
|
3684
|
+
);
|
3685
|
+
state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
|
3686
|
+
state.components = components;
|
3687
|
+
state.models = contentTypeSchemas;
|
3688
|
+
state.fieldSizes = fieldSizes;
|
3689
|
+
state.isLoading = false;
|
3690
|
+
}
|
3691
|
+
}
|
3692
|
+
});
|
3693
|
+
const { actions, reducer: reducer$1 } = appSlice;
|
3694
|
+
const { setInitialData } = actions;
|
3695
|
+
const reducer = toolkit.combineReducers({
|
3696
|
+
app: reducer$1
|
3697
|
+
});
|
3115
3698
|
const index = {
|
3116
3699
|
register(app) {
|
3117
3700
|
const cm = new ContentManagerPlugin();
|
3118
3701
|
app.addReducers({
|
3119
|
-
[contentManagerApi.reducerPath]: contentManagerApi.reducer,
|
3120
3702
|
[PLUGIN_ID]: reducer
|
3121
3703
|
});
|
3122
|
-
app.addMiddlewares([() => contentManagerApi.middleware]);
|
3123
3704
|
app.addMenuLink({
|
3124
3705
|
to: PLUGIN_ID,
|
3125
3706
|
icon: Icons.Feather,
|
@@ -3128,14 +3709,15 @@ const index = {
|
|
3128
3709
|
defaultMessage: "Content Manager"
|
3129
3710
|
},
|
3130
3711
|
permissions: [],
|
3131
|
-
Component: () => Promise.resolve().then(() => require("./layout
|
3712
|
+
Component: () => Promise.resolve().then(() => require("./layout--iHdZzRk.js")).then((mod) => ({ default: mod.Layout })),
|
3713
|
+
position: 1
|
3132
3714
|
});
|
3133
3715
|
app.registerPlugin(cm.config);
|
3134
3716
|
},
|
3135
3717
|
async registerTrads({ locales }) {
|
3136
3718
|
const importedTrads = await Promise.all(
|
3137
3719
|
locales.map((locale) => {
|
3138
|
-
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-
|
3720
|
+
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-fbKQxLGn.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3139
3721
|
return {
|
3140
3722
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3141
3723
|
locale
|
@@ -3152,6 +3734,7 @@ const index = {
|
|
3152
3734
|
}
|
3153
3735
|
};
|
3154
3736
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3737
|
+
exports.BulkActionsRenderer = BulkActionsRenderer;
|
3155
3738
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3156
3739
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3157
3740
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3192,4 +3775,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3192
3775
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3193
3776
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3194
3777
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3195
|
-
//# sourceMappingURL=index-
|
3778
|
+
//# sourceMappingURL=index-CWpLBSt0.js.map
|