@strapi/content-manager 0.0.0-experimental.7afdc9b682bc83a53ce599c4fb7c9e4506b31fff → 0.0.0-experimental.81dfdf02b1367004c7deed9e01afa9d3a15d0fa5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js → ComponentConfigurationPage-D_M8iBw5.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js.map → ComponentConfigurationPage-D_M8iBw5.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs → ComponentConfigurationPage-qemkOlnj.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs.map → ComponentConfigurationPage-qemkOlnj.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js → EditConfigurationPage-BePwPuHy.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js.map → EditConfigurationPage-BePwPuHy.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs → EditConfigurationPage-CjUrEewK.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs.map → EditConfigurationPage-CjUrEewK.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CoQEnFlC.js → EditViewPage-B-RJeiJD.js} +57 -46
- package/dist/_chunks/EditViewPage-B-RJeiJD.js.map +1 -0
- package/dist/_chunks/{EditViewPage-DvaV7U9b.mjs → EditViewPage-De8GyU8P.mjs} +58 -47
- package/dist/_chunks/EditViewPage-De8GyU8P.mjs.map +1 -0
- package/dist/_chunks/{Field-ZdrmmQ4Y.js → Field-dq8Tg1M_.js} +514 -168
- package/dist/_chunks/Field-dq8Tg1M_.js.map +1 -0
- package/dist/_chunks/{Field-Cz_J9551.mjs → Field-pb2o8uBe.mjs} +516 -170
- package/dist/_chunks/Field-pb2o8uBe.mjs.map +1 -0
- package/dist/_chunks/{Form-Bpig5rch.js → Form-DGIf4jQU.js} +38 -28
- package/dist/_chunks/Form-DGIf4jQU.js.map +1 -0
- package/dist/_chunks/{Form-Dxmihyw8.mjs → Form-DJn0Dxha.mjs} +40 -30
- package/dist/_chunks/Form-DJn0Dxha.mjs.map +1 -0
- package/dist/_chunks/{History-BZP8n7KT.mjs → History-BowL3JKP.mjs} +141 -37
- package/dist/_chunks/History-BowL3JKP.mjs.map +1 -0
- package/dist/_chunks/{History-BfX6XmZK.js → History-Dh2NEHnR.js} +140 -36
- package/dist/_chunks/History-Dh2NEHnR.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DxKuVkKz.mjs → ListConfigurationPage-BpVOB-hn.mjs} +58 -48
- package/dist/_chunks/ListConfigurationPage-BpVOB-hn.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-B3CXj8PY.js → ListConfigurationPage-BxYCWz9e.js} +57 -46
- package/dist/_chunks/ListConfigurationPage-BxYCWz9e.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Bk9VO__I.js → ListViewPage-4XsciqHZ.js} +65 -68
- package/dist/_chunks/ListViewPage-4XsciqHZ.js.map +1 -0
- package/dist/_chunks/{ListViewPage-D5D3tVPq.mjs → ListViewPage-CXFUjZQC.mjs} +67 -70
- package/dist/_chunks/ListViewPage-CXFUjZQC.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js → NoContentTypePage-C8OpoHeU.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js.map → NoContentTypePage-C8OpoHeU.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs → NoContentTypePage-DuhOTp3x.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs.map → NoContentTypePage-DuhOTp3x.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs → NoPermissionsPage-DVz3mzDz.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs.map → NoPermissionsPage-DVz3mzDz.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js → NoPermissionsPage-y_r7DVA2.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js.map → NoPermissionsPage-y_r7DVA2.js.map} +1 -1
- package/dist/_chunks/{Relations-BOYZmuWy.mjs → Relations-CVNLrn1Y.mjs} +4 -4
- package/dist/_chunks/Relations-CVNLrn1Y.mjs.map +1 -0
- package/dist/_chunks/{Relations-B6B3A3mb.js → Relations-DPFCAa7b.js} +4 -4
- package/dist/_chunks/Relations-DPFCAa7b.js.map +1 -0
- package/dist/_chunks/{en-Dzv55oQw.mjs → en-BrCTWlZv.mjs} +8 -4
- package/dist/_chunks/{en-Dzv55oQw.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-BN1bvFK7.js → en-uOUIxfcQ.js} +8 -4
- package/dist/_chunks/{en-BN1bvFK7.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-DzN3kBgx.js → index-C3fJE-1-.js} +491 -431
- package/dist/_chunks/index-C3fJE-1-.js.map +1 -0
- package/dist/_chunks/{index-VHviNMeW.mjs → index-DiMrfcfy.mjs} +511 -451
- package/dist/_chunks/index-DiMrfcfy.mjs.map +1 -0
- package/dist/_chunks/{layout-b91XRlD2.js → layout-C788OmNr.js} +37 -20
- package/dist/_chunks/layout-C788OmNr.js.map +1 -0
- package/dist/_chunks/{layout-CPn1PM6x.mjs → layout-ls3gxfpH.mjs} +39 -22
- package/dist/_chunks/layout-ls3gxfpH.mjs.map +1 -0
- package/dist/_chunks/{relations-BsqxS6tR.mjs → relations-CLcOmGO0.mjs} +2 -2
- package/dist/_chunks/{relations-BsqxS6tR.mjs.map → relations-CLcOmGO0.mjs.map} +1 -1
- package/dist/_chunks/{relations-CA7IYmcP.js → relations-DYeotliT.js} +2 -2
- package/dist/_chunks/{relations-CA7IYmcP.js.map → relations-DYeotliT.js.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +5 -5
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +12 -32
- 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/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +16 -16
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +164 -103
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +165 -104
- 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/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +1 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CoQEnFlC.js.map +0 -1
- package/dist/_chunks/EditViewPage-DvaV7U9b.mjs.map +0 -1
- package/dist/_chunks/Field-Cz_J9551.mjs.map +0 -1
- package/dist/_chunks/Field-ZdrmmQ4Y.js.map +0 -1
- package/dist/_chunks/Form-Bpig5rch.js.map +0 -1
- package/dist/_chunks/Form-Dxmihyw8.mjs.map +0 -1
- package/dist/_chunks/History-BZP8n7KT.mjs.map +0 -1
- package/dist/_chunks/History-BfX6XmZK.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-B3CXj8PY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DxKuVkKz.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-Bk9VO__I.js.map +0 -1
- package/dist/_chunks/ListViewPage-D5D3tVPq.mjs.map +0 -1
- package/dist/_chunks/Relations-B6B3A3mb.js.map +0 -1
- package/dist/_chunks/Relations-BOYZmuWy.mjs.map +0 -1
- package/dist/_chunks/index-DzN3kBgx.js.map +0 -1
- package/dist/_chunks/index-VHviNMeW.mjs.map +0 -1
- package/dist/_chunks/layout-CPn1PM6x.mjs.map +0 -1
- package/dist/_chunks/layout-b91XRlD2.js.map +0 -1
@@ -2,15 +2,15 @@
|
|
2
2
|
const Icons = require("@strapi/icons");
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
|
-
const qs = require("qs");
|
6
|
-
const reactIntl = require("react-intl");
|
7
|
-
const reactRouterDom = require("react-router-dom");
|
8
5
|
const React = require("react");
|
9
6
|
const designSystem = require("@strapi/design-system");
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const reactRouterDom = require("react-router-dom");
|
10
9
|
const styledComponents = require("styled-components");
|
11
10
|
const yup = require("yup");
|
12
11
|
const pipe = require("lodash/fp/pipe");
|
13
12
|
const dateFns = require("date-fns");
|
13
|
+
const qs = require("qs");
|
14
14
|
const toolkit = require("@reduxjs/toolkit");
|
15
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
16
|
function _interopNamespace(e) {
|
@@ -70,42 +70,6 @@ const useInjectionZone = (area) => {
|
|
70
70
|
const [page, position] = area.split(".");
|
71
71
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
72
72
|
};
|
73
|
-
const HistoryAction = ({ model, document }) => {
|
74
|
-
const { formatMessage } = reactIntl.useIntl();
|
75
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
76
|
-
const navigate = reactRouterDom.useNavigate();
|
77
|
-
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
78
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
return {
|
82
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
83
|
-
label: formatMessage({
|
84
|
-
id: "content-manager.history.document-action",
|
85
|
-
defaultMessage: "Content History"
|
86
|
-
}),
|
87
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
88
|
-
disabled: (
|
89
|
-
/**
|
90
|
-
* The user is creating a new document.
|
91
|
-
* It hasn't been saved yet, so there's no history to go to
|
92
|
-
*/
|
93
|
-
!document || /**
|
94
|
-
* The document has been created but the current dimension has never been saved.
|
95
|
-
* For example, the user is creating a new locale in an existing document,
|
96
|
-
* so there's no history for the document in that locale
|
97
|
-
*/
|
98
|
-
!document.id || /**
|
99
|
-
* History is only available for content types created by the user.
|
100
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
101
|
-
* which start with `admin::` or `plugin::`
|
102
|
-
*/
|
103
|
-
!model.startsWith("api::")
|
104
|
-
),
|
105
|
-
position: "header"
|
106
|
-
};
|
107
|
-
};
|
108
|
-
HistoryAction.type = "history";
|
109
73
|
const ID = "id";
|
110
74
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
111
75
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -215,10 +179,12 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
215
179
|
"Document",
|
216
180
|
"InitialData",
|
217
181
|
"HistoryVersion",
|
218
|
-
"Relations"
|
182
|
+
"Relations",
|
183
|
+
"UidAvailability"
|
219
184
|
]
|
220
185
|
});
|
221
186
|
const documentApi = contentManagerApi.injectEndpoints({
|
187
|
+
overrideExisting: true,
|
222
188
|
endpoints: (builder) => ({
|
223
189
|
autoCloneDocument: builder.mutation({
|
224
190
|
query: ({ model, sourceId, query }) => ({
|
@@ -228,7 +194,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
228
194
|
params: query
|
229
195
|
}
|
230
196
|
}),
|
231
|
-
invalidatesTags: (_result,
|
197
|
+
invalidatesTags: (_result, error, { model }) => {
|
198
|
+
if (error) {
|
199
|
+
return [];
|
200
|
+
}
|
201
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
202
|
+
}
|
232
203
|
}),
|
233
204
|
cloneDocument: builder.mutation({
|
234
205
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -239,7 +210,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
239
210
|
params
|
240
211
|
}
|
241
212
|
}),
|
242
|
-
invalidatesTags: (_result, _error, { model }) => [
|
213
|
+
invalidatesTags: (_result, _error, { model }) => [
|
214
|
+
{ type: "Document", id: `${model}_LIST` },
|
215
|
+
{ type: "UidAvailability", id: model }
|
216
|
+
]
|
243
217
|
}),
|
244
218
|
/**
|
245
219
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -256,7 +230,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
256
230
|
}),
|
257
231
|
invalidatesTags: (result, _error, { model }) => [
|
258
232
|
{ type: "Document", id: `${model}_LIST` },
|
259
|
-
"Relations"
|
233
|
+
"Relations",
|
234
|
+
{ type: "UidAvailability", id: model }
|
260
235
|
]
|
261
236
|
}),
|
262
237
|
deleteDocument: builder.mutation({
|
@@ -297,7 +272,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
297
272
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
298
273
|
},
|
299
274
|
{ type: "Document", id: `${model}_LIST` },
|
300
|
-
"Relations"
|
275
|
+
"Relations",
|
276
|
+
{ type: "UidAvailability", id: model }
|
301
277
|
];
|
302
278
|
}
|
303
279
|
}),
|
@@ -315,6 +291,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
315
291
|
}),
|
316
292
|
providesTags: (result, _error, arg) => {
|
317
293
|
return [
|
294
|
+
{ type: "Document", id: `ALL_LIST` },
|
318
295
|
{ type: "Document", id: `${arg.model}_LIST` },
|
319
296
|
...result?.results.map(({ documentId }) => ({
|
320
297
|
type: "Document",
|
@@ -353,6 +330,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
353
330
|
{
|
354
331
|
type: "Document",
|
355
332
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
333
|
+
},
|
334
|
+
// Make it easy to invalidate all individual documents queries for a model
|
335
|
+
{
|
336
|
+
type: "Document",
|
337
|
+
id: `${model}_ALL_ITEMS`
|
356
338
|
}
|
357
339
|
];
|
358
340
|
}
|
@@ -416,8 +398,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
416
398
|
type: "Document",
|
417
399
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
418
400
|
},
|
419
|
-
"Relations"
|
401
|
+
"Relations",
|
402
|
+
{ type: "UidAvailability", id: model }
|
420
403
|
];
|
404
|
+
},
|
405
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
406
|
+
const patchResult = dispatch(
|
407
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
408
|
+
Object.assign(draft.data, data);
|
409
|
+
})
|
410
|
+
);
|
411
|
+
try {
|
412
|
+
await queryFulfilled;
|
413
|
+
} catch {
|
414
|
+
patchResult.undo();
|
415
|
+
}
|
421
416
|
}
|
422
417
|
}),
|
423
418
|
unpublishDocument: builder.mutation({
|
@@ -487,7 +482,7 @@ const buildValidParams = (query) => {
|
|
487
482
|
const isBaseQueryError = (error) => {
|
488
483
|
return error.name !== void 0;
|
489
484
|
};
|
490
|
-
const createYupSchema = (attributes = {}, components = {}) => {
|
485
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
491
486
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
492
487
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
493
488
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
@@ -500,7 +495,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
500
495
|
addMinValidation,
|
501
496
|
addMaxValidation,
|
502
497
|
addRegexValidation
|
503
|
-
].map((fn) => fn(attribute));
|
498
|
+
].map((fn) => fn(attribute, options));
|
504
499
|
const transformSchema = pipe__default.default(...validations);
|
505
500
|
switch (attribute.type) {
|
506
501
|
case "component": {
|
@@ -601,6 +596,14 @@ const createAttributeSchema = (attribute) => {
|
|
601
596
|
if (!value || typeof value === "string" && value.length === 0) {
|
602
597
|
return true;
|
603
598
|
}
|
599
|
+
if (typeof value === "object") {
|
600
|
+
try {
|
601
|
+
JSON.stringify(value);
|
602
|
+
return true;
|
603
|
+
} catch (err) {
|
604
|
+
return false;
|
605
|
+
}
|
606
|
+
}
|
604
607
|
try {
|
605
608
|
JSON.parse(value);
|
606
609
|
return true;
|
@@ -619,13 +622,7 @@ const createAttributeSchema = (attribute) => {
|
|
619
622
|
return yup__namespace.mixed();
|
620
623
|
}
|
621
624
|
};
|
622
|
-
const
|
623
|
-
if (attribute.required) {
|
624
|
-
return schema.required({
|
625
|
-
id: strapiAdmin.translatedErrors.required.id,
|
626
|
-
defaultMessage: "This field is required."
|
627
|
-
});
|
628
|
-
}
|
625
|
+
const nullableSchema = (schema) => {
|
629
626
|
return schema?.nullable ? schema.nullable() : (
|
630
627
|
// In some cases '.nullable' will not be available on the schema.
|
631
628
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -633,7 +630,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
633
630
|
schema
|
634
631
|
);
|
635
632
|
};
|
636
|
-
const
|
633
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
634
|
+
if (options.status === "draft") {
|
635
|
+
return nullableSchema(schema);
|
636
|
+
}
|
637
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
638
|
+
return schema.min(1, strapiAdmin.translatedErrors.required);
|
639
|
+
}
|
640
|
+
if (attribute.required && attribute.type !== "relation") {
|
641
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
642
|
+
}
|
643
|
+
return nullableSchema(schema);
|
644
|
+
};
|
645
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
|
+
if (options.status === "draft") {
|
647
|
+
return schema;
|
648
|
+
}
|
637
649
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
638
650
|
return schema.min(attribute.minLength, {
|
639
651
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -655,9 +667,31 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
655
667
|
}
|
656
668
|
return schema;
|
657
669
|
};
|
658
|
-
const addMinValidation = (attribute) => (schema) => {
|
670
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
659
671
|
if ("min" in attribute) {
|
660
672
|
const min = toInteger(attribute.min);
|
673
|
+
if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
|
674
|
+
if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
|
675
|
+
return schema.test(
|
676
|
+
"custom-min",
|
677
|
+
{
|
678
|
+
...strapiAdmin.translatedErrors.min,
|
679
|
+
values: {
|
680
|
+
min: attribute.min
|
681
|
+
}
|
682
|
+
},
|
683
|
+
(value) => {
|
684
|
+
if (!value) {
|
685
|
+
return true;
|
686
|
+
}
|
687
|
+
if (Array.isArray(value) && value.length === 0) {
|
688
|
+
return true;
|
689
|
+
}
|
690
|
+
return value.length >= min;
|
691
|
+
}
|
692
|
+
);
|
693
|
+
}
|
694
|
+
}
|
661
695
|
if ("min" in schema && min) {
|
662
696
|
return schema.min(min, {
|
663
697
|
...strapiAdmin.translatedErrors.min,
|
@@ -784,7 +818,10 @@ const useDocument = (args, opts) => {
|
|
784
818
|
isLoading: isLoadingDocument,
|
785
819
|
isFetching: isFetchingDocument,
|
786
820
|
error
|
787
|
-
} = useGetDocumentQuery(args,
|
821
|
+
} = useGetDocumentQuery(args, {
|
822
|
+
...opts,
|
823
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
824
|
+
});
|
788
825
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
789
826
|
React__namespace.useEffect(() => {
|
790
827
|
if (error) {
|
@@ -870,6 +907,7 @@ const useDocumentActions = () => {
|
|
870
907
|
const { formatMessage } = reactIntl.useIntl();
|
871
908
|
const { trackUsage } = strapiAdmin.useTracking();
|
872
909
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
910
|
+
const navigate = reactRouterDom.useNavigate();
|
873
911
|
const [deleteDocument] = useDeleteDocumentMutation();
|
874
912
|
const _delete = React__namespace.useCallback(
|
875
913
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -948,12 +986,13 @@ const useDocumentActions = () => {
|
|
948
986
|
);
|
949
987
|
const [discardDocument] = useDiscardDocumentMutation();
|
950
988
|
const discard = React__namespace.useCallback(
|
951
|
-
async ({ collectionType, model, documentId }) => {
|
989
|
+
async ({ collectionType, model, documentId, params }) => {
|
952
990
|
try {
|
953
991
|
const res = await discardDocument({
|
954
992
|
collectionType,
|
955
993
|
model,
|
956
|
-
documentId
|
994
|
+
documentId,
|
995
|
+
params
|
957
996
|
});
|
958
997
|
if ("error" in res) {
|
959
998
|
toggleNotification({
|
@@ -1204,7 +1243,6 @@ const useDocumentActions = () => {
|
|
1204
1243
|
sourceId
|
1205
1244
|
});
|
1206
1245
|
if ("error" in res) {
|
1207
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1208
1246
|
return { error: res.error };
|
1209
1247
|
}
|
1210
1248
|
toggleNotification({
|
@@ -1223,7 +1261,7 @@ const useDocumentActions = () => {
|
|
1223
1261
|
throw err;
|
1224
1262
|
}
|
1225
1263
|
},
|
1226
|
-
[autoCloneDocument,
|
1264
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1227
1265
|
);
|
1228
1266
|
const [cloneDocument] = useCloneDocumentMutation();
|
1229
1267
|
const clone = React__namespace.useCallback(
|
@@ -1249,6 +1287,7 @@ const useDocumentActions = () => {
|
|
1249
1287
|
defaultMessage: "Cloned document"
|
1250
1288
|
})
|
1251
1289
|
});
|
1290
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1252
1291
|
return res.data;
|
1253
1292
|
} catch (err) {
|
1254
1293
|
toggleNotification({
|
@@ -1259,7 +1298,7 @@ const useDocumentActions = () => {
|
|
1259
1298
|
throw err;
|
1260
1299
|
}
|
1261
1300
|
},
|
1262
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1301
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1263
1302
|
);
|
1264
1303
|
const [getDoc] = useLazyGetDocumentQuery();
|
1265
1304
|
const getDocument = React__namespace.useCallback(
|
@@ -1285,7 +1324,7 @@ const useDocumentActions = () => {
|
|
1285
1324
|
};
|
1286
1325
|
};
|
1287
1326
|
const ProtectedHistoryPage = React.lazy(
|
1288
|
-
() => Promise.resolve().then(() => require("./History-
|
1327
|
+
() => Promise.resolve().then(() => require("./History-Dh2NEHnR.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1289
1328
|
);
|
1290
1329
|
const routes$1 = [
|
1291
1330
|
{
|
@@ -1298,31 +1337,31 @@ const routes$1 = [
|
|
1298
1337
|
}
|
1299
1338
|
];
|
1300
1339
|
const ProtectedEditViewPage = React.lazy(
|
1301
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1340
|
+
() => Promise.resolve().then(() => require("./EditViewPage-B-RJeiJD.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1302
1341
|
);
|
1303
1342
|
const ProtectedListViewPage = React.lazy(
|
1304
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1343
|
+
() => Promise.resolve().then(() => require("./ListViewPage-4XsciqHZ.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1305
1344
|
);
|
1306
1345
|
const ProtectedListConfiguration = React.lazy(
|
1307
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1346
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-BxYCWz9e.js")).then((mod) => ({
|
1308
1347
|
default: mod.ProtectedListConfiguration
|
1309
1348
|
}))
|
1310
1349
|
);
|
1311
1350
|
const ProtectedEditConfigurationPage = React.lazy(
|
1312
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1351
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BePwPuHy.js")).then((mod) => ({
|
1313
1352
|
default: mod.ProtectedEditConfigurationPage
|
1314
1353
|
}))
|
1315
1354
|
);
|
1316
1355
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1317
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1356
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-D_M8iBw5.js")).then((mod) => ({
|
1318
1357
|
default: mod.ProtectedComponentConfigurationPage
|
1319
1358
|
}))
|
1320
1359
|
);
|
1321
1360
|
const NoPermissions = React.lazy(
|
1322
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1361
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-y_r7DVA2.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1323
1362
|
);
|
1324
1363
|
const NoContentType = React.lazy(
|
1325
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1364
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-C8OpoHeU.js")).then((mod) => ({ default: mod.NoContentType }))
|
1326
1365
|
);
|
1327
1366
|
const CollectionTypePages = () => {
|
1328
1367
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1436,12 +1475,14 @@ const DocumentActionButton = (action) => {
|
|
1436
1475
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1437
1476
|
designSystem.Button,
|
1438
1477
|
{
|
1439
|
-
flex:
|
1478
|
+
flex: "auto",
|
1440
1479
|
startIcon: action.icon,
|
1441
1480
|
disabled: action.disabled,
|
1442
1481
|
onClick: handleClick(action),
|
1443
1482
|
justifyContent: "center",
|
1444
1483
|
variant: action.variant || "default",
|
1484
|
+
paddingTop: "7px",
|
1485
|
+
paddingBottom: "7px",
|
1445
1486
|
children: action.label
|
1446
1487
|
}
|
1447
1488
|
),
|
@@ -1449,7 +1490,7 @@ const DocumentActionButton = (action) => {
|
|
1449
1490
|
DocumentActionConfirmDialog,
|
1450
1491
|
{
|
1451
1492
|
...action.dialog,
|
1452
|
-
variant: action.variant,
|
1493
|
+
variant: action.dialog?.variant ?? action.variant,
|
1453
1494
|
isOpen: dialogId === action.id,
|
1454
1495
|
onClose: handleClose
|
1455
1496
|
}
|
@@ -1501,14 +1542,14 @@ const DocumentActionsMenu = ({
|
|
1501
1542
|
};
|
1502
1543
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
|
1503
1544
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1504
|
-
|
1545
|
+
StyledMoreButton,
|
1505
1546
|
{
|
1506
1547
|
disabled: isDisabled,
|
1507
1548
|
size: "S",
|
1508
1549
|
endIcon: null,
|
1509
|
-
paddingTop: "
|
1510
|
-
paddingLeft: "
|
1511
|
-
paddingRight: "
|
1550
|
+
paddingTop: "4px",
|
1551
|
+
paddingLeft: "7px",
|
1552
|
+
paddingRight: "7px",
|
1512
1553
|
variant,
|
1513
1554
|
children: [
|
1514
1555
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1528,10 +1569,25 @@ const DocumentActionsMenu = ({
|
|
1528
1569
|
onSelect: handleClick(action),
|
1529
1570
|
display: "block",
|
1530
1571
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1531
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1572
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
1573
|
+
designSystem.Flex,
|
1574
|
+
{
|
1575
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1576
|
+
gap: 2,
|
1577
|
+
tag: "span",
|
1578
|
+
children: [
|
1579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1580
|
+
designSystem.Flex,
|
1581
|
+
{
|
1582
|
+
tag: "span",
|
1583
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1584
|
+
children: action.icon
|
1585
|
+
}
|
1586
|
+
),
|
1587
|
+
action.label
|
1588
|
+
]
|
1589
|
+
}
|
1590
|
+
),
|
1535
1591
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
|
1536
1592
|
designSystem.Flex,
|
1537
1593
|
{
|
@@ -1590,6 +1646,23 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1590
1646
|
return "primary600";
|
1591
1647
|
}
|
1592
1648
|
};
|
1649
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1650
|
+
switch (variant) {
|
1651
|
+
case "danger":
|
1652
|
+
return "danger600";
|
1653
|
+
case "secondary":
|
1654
|
+
return "neutral500";
|
1655
|
+
case "success":
|
1656
|
+
return "success600";
|
1657
|
+
default:
|
1658
|
+
return "primary600";
|
1659
|
+
}
|
1660
|
+
};
|
1661
|
+
const StyledMoreButton = styledComponents.styled(designSystem.Menu.Trigger)`
|
1662
|
+
& > span {
|
1663
|
+
display: flex;
|
1664
|
+
}
|
1665
|
+
`;
|
1593
1666
|
const DocumentActionConfirmDialog = ({
|
1594
1667
|
onClose,
|
1595
1668
|
onCancel,
|
@@ -1612,22 +1685,20 @@ const DocumentActionConfirmDialog = ({
|
|
1612
1685
|
}
|
1613
1686
|
onClose();
|
1614
1687
|
};
|
1615
|
-
return /* @__PURE__ */ jsxRuntime.
|
1616
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1617
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1618
|
-
|
1619
|
-
{
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
)
|
1630
|
-
] });
|
1688
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
1689
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1690
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1691
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1692
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
1693
|
+
id: "app.components.Button.cancel",
|
1694
|
+
defaultMessage: "Cancel"
|
1695
|
+
}) }) }),
|
1696
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1697
|
+
id: "app.components.Button.confirm",
|
1698
|
+
defaultMessage: "Confirm"
|
1699
|
+
}) })
|
1700
|
+
] })
|
1701
|
+
] }) });
|
1631
1702
|
};
|
1632
1703
|
const DocumentActionModal = ({
|
1633
1704
|
isOpen,
|
@@ -1637,34 +1708,17 @@ const DocumentActionModal = ({
|
|
1637
1708
|
content: Content,
|
1638
1709
|
onModalClose
|
1639
1710
|
}) => {
|
1640
|
-
const id = React__namespace.useId();
|
1641
|
-
if (!isOpen) {
|
1642
|
-
return null;
|
1643
|
-
}
|
1644
1711
|
const handleClose = () => {
|
1645
1712
|
if (onClose) {
|
1646
1713
|
onClose();
|
1647
1714
|
}
|
1648
1715
|
onModalClose();
|
1649
1716
|
};
|
1650
|
-
return /* @__PURE__ */ jsxRuntime.
|
1651
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1652
|
-
|
1653
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1654
|
-
|
1655
|
-
{
|
1656
|
-
paddingTop: 4,
|
1657
|
-
paddingBottom: 4,
|
1658
|
-
paddingLeft: 5,
|
1659
|
-
paddingRight: 5,
|
1660
|
-
borderWidth: "1px 0 0 0",
|
1661
|
-
borderStyle: "solid",
|
1662
|
-
borderColor: "neutral150",
|
1663
|
-
background: "neutral100",
|
1664
|
-
children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1665
|
-
}
|
1666
|
-
)
|
1667
|
-
] });
|
1717
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
1718
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
1719
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
1720
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1721
|
+
] }) });
|
1668
1722
|
};
|
1669
1723
|
const PublishAction$1 = ({
|
1670
1724
|
activeTab,
|
@@ -1678,13 +1732,17 @@ const PublishAction$1 = ({
|
|
1678
1732
|
const navigate = reactRouterDom.useNavigate();
|
1679
1733
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1680
1734
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1735
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1681
1736
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
1682
1737
|
const { formatMessage } = reactIntl.useIntl();
|
1683
|
-
const { canPublish
|
1684
|
-
"PublishAction",
|
1685
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1686
|
-
);
|
1738
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1687
1739
|
const { publish } = useDocumentActions();
|
1740
|
+
const [
|
1741
|
+
countDraftRelations,
|
1742
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
1743
|
+
] = useLazyGetDraftRelationCountQuery();
|
1744
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
1745
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1688
1746
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1689
1747
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1690
1748
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1693,10 +1751,101 @@ const PublishAction$1 = ({
|
|
1693
1751
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1694
1752
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1695
1753
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
1754
|
+
React__namespace.useEffect(() => {
|
1755
|
+
if (isErrorDraftRelations) {
|
1756
|
+
toggleNotification({
|
1757
|
+
type: "danger",
|
1758
|
+
message: formatMessage({
|
1759
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
1760
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
1761
|
+
})
|
1762
|
+
});
|
1763
|
+
}
|
1764
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
1765
|
+
React__namespace.useEffect(() => {
|
1766
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
1767
|
+
const extractDraftRelations = (data) => {
|
1768
|
+
const relations = data.connect || [];
|
1769
|
+
relations.forEach((relation) => {
|
1770
|
+
if (relation.status === "draft") {
|
1771
|
+
localDraftRelations.add(relation.id);
|
1772
|
+
}
|
1773
|
+
});
|
1774
|
+
};
|
1775
|
+
const traverseAndExtract = (data) => {
|
1776
|
+
Object.entries(data).forEach(([key, value]) => {
|
1777
|
+
if (key === "connect" && Array.isArray(value)) {
|
1778
|
+
extractDraftRelations({ connect: value });
|
1779
|
+
} else if (typeof value === "object" && value !== null) {
|
1780
|
+
traverseAndExtract(value);
|
1781
|
+
}
|
1782
|
+
});
|
1783
|
+
};
|
1784
|
+
if (!documentId || modified) {
|
1785
|
+
traverseAndExtract(formValues);
|
1786
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
1787
|
+
}
|
1788
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1789
|
+
React__namespace.useEffect(() => {
|
1790
|
+
if (documentId && !isListView) {
|
1791
|
+
const fetchDraftRelationsCount = async () => {
|
1792
|
+
const { data, error } = await countDraftRelations({
|
1793
|
+
collectionType,
|
1794
|
+
model,
|
1795
|
+
documentId,
|
1796
|
+
params
|
1797
|
+
});
|
1798
|
+
if (error) {
|
1799
|
+
throw error;
|
1800
|
+
}
|
1801
|
+
if (data) {
|
1802
|
+
setServerCountOfDraftRelations(data.data);
|
1803
|
+
}
|
1804
|
+
};
|
1805
|
+
fetchDraftRelationsCount();
|
1806
|
+
}
|
1807
|
+
}, [isListView, documentId, countDraftRelations, collectionType, model, params]);
|
1696
1808
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1697
1809
|
if (!schema?.options?.draftAndPublish) {
|
1698
1810
|
return null;
|
1699
1811
|
}
|
1812
|
+
const performPublish = async () => {
|
1813
|
+
setSubmitting(true);
|
1814
|
+
try {
|
1815
|
+
const { errors } = await validate();
|
1816
|
+
if (errors) {
|
1817
|
+
toggleNotification({
|
1818
|
+
type: "danger",
|
1819
|
+
message: formatMessage({
|
1820
|
+
id: "content-manager.validation.error",
|
1821
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1822
|
+
})
|
1823
|
+
});
|
1824
|
+
return;
|
1825
|
+
}
|
1826
|
+
const res = await publish(
|
1827
|
+
{
|
1828
|
+
collectionType,
|
1829
|
+
model,
|
1830
|
+
documentId,
|
1831
|
+
params
|
1832
|
+
},
|
1833
|
+
formValues
|
1834
|
+
);
|
1835
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1836
|
+
navigate({
|
1837
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1838
|
+
search: rawQuery
|
1839
|
+
});
|
1840
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1841
|
+
setErrors(formatValidationErrors(res.error));
|
1842
|
+
}
|
1843
|
+
} finally {
|
1844
|
+
setSubmitting(false);
|
1845
|
+
}
|
1846
|
+
};
|
1847
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1848
|
+
const hasDraftRelations = totalDraftRelations > 0;
|
1700
1849
|
return {
|
1701
1850
|
/**
|
1702
1851
|
* Disabled when:
|
@@ -1706,49 +1855,39 @@ const PublishAction$1 = ({
|
|
1706
1855
|
* - the document is already published & not modified
|
1707
1856
|
* - the document is being created & not modified
|
1708
1857
|
* - the user doesn't have the permission to publish
|
1709
|
-
* - the user doesn't have the permission to create a new document
|
1710
|
-
* - the user doesn't have the permission to update the document
|
1711
1858
|
*/
|
1712
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
1859
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1713
1860
|
label: formatMessage({
|
1714
1861
|
id: "app.utils.publish",
|
1715
1862
|
defaultMessage: "Publish"
|
1716
1863
|
}),
|
1717
1864
|
onClick: async () => {
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
formValues
|
1739
|
-
);
|
1740
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1741
|
-
navigate({
|
1742
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1743
|
-
search: rawQuery
|
1744
|
-
});
|
1745
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1746
|
-
setErrors(formatValidationErrors(res.error));
|
1865
|
+
if (hasDraftRelations) {
|
1866
|
+
return;
|
1867
|
+
}
|
1868
|
+
await performPublish();
|
1869
|
+
},
|
1870
|
+
dialog: hasDraftRelations ? {
|
1871
|
+
type: "dialog",
|
1872
|
+
variant: "danger",
|
1873
|
+
footer: null,
|
1874
|
+
title: formatMessage({
|
1875
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
1876
|
+
defaultMessage: "Confirmation"
|
1877
|
+
}),
|
1878
|
+
content: formatMessage(
|
1879
|
+
{
|
1880
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
1881
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
1882
|
+
},
|
1883
|
+
{
|
1884
|
+
count: totalDraftRelations
|
1747
1885
|
}
|
1748
|
-
|
1749
|
-
|
1886
|
+
),
|
1887
|
+
onConfirm: async () => {
|
1888
|
+
await performPublish();
|
1750
1889
|
}
|
1751
|
-
}
|
1890
|
+
} : void 0
|
1752
1891
|
};
|
1753
1892
|
};
|
1754
1893
|
PublishAction$1.type = "publish";
|
@@ -1764,10 +1903,6 @@ const UpdateAction = ({
|
|
1764
1903
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1765
1904
|
const isCloning = cloneMatch !== null;
|
1766
1905
|
const { formatMessage } = reactIntl.useIntl();
|
1767
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1768
|
-
canCreate: canCreate2,
|
1769
|
-
canUpdate: canUpdate2
|
1770
|
-
}));
|
1771
1906
|
const { create, update, clone } = useDocumentActions();
|
1772
1907
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1773
1908
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1784,10 +1919,8 @@ const UpdateAction = ({
|
|
1784
1919
|
* - the form is submitting
|
1785
1920
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1786
1921
|
* - the active tab is the published tab
|
1787
|
-
* - the user doesn't have the permission to create a new document
|
1788
|
-
* - the user doesn't have the permission to update the document
|
1789
1922
|
*/
|
1790
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
1923
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1791
1924
|
label: formatMessage({
|
1792
1925
|
id: "content-manager.containers.Edit.save",
|
1793
1926
|
defaultMessage: "Save"
|
@@ -1795,16 +1928,18 @@ const UpdateAction = ({
|
|
1795
1928
|
onClick: async () => {
|
1796
1929
|
setSubmitting(true);
|
1797
1930
|
try {
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1931
|
+
if (activeTab !== "draft") {
|
1932
|
+
const { errors } = await validate();
|
1933
|
+
if (errors) {
|
1934
|
+
toggleNotification({
|
1935
|
+
type: "danger",
|
1936
|
+
message: formatMessage({
|
1937
|
+
id: "content-manager.validation.error",
|
1938
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1939
|
+
})
|
1940
|
+
});
|
1941
|
+
return;
|
1942
|
+
}
|
1808
1943
|
}
|
1809
1944
|
if (isCloning) {
|
1810
1945
|
const res = await clone(
|
@@ -1816,10 +1951,13 @@ const UpdateAction = ({
|
|
1816
1951
|
document
|
1817
1952
|
);
|
1818
1953
|
if ("data" in res) {
|
1819
|
-
navigate(
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1954
|
+
navigate(
|
1955
|
+
{
|
1956
|
+
pathname: `../${res.data.documentId}`,
|
1957
|
+
search: rawQuery
|
1958
|
+
},
|
1959
|
+
{ relative: "path" }
|
1960
|
+
);
|
1823
1961
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1824
1962
|
setErrors(formatValidationErrors(res.error));
|
1825
1963
|
}
|
@@ -1847,10 +1985,13 @@ const UpdateAction = ({
|
|
1847
1985
|
document
|
1848
1986
|
);
|
1849
1987
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1850
|
-
navigate(
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1988
|
+
navigate(
|
1989
|
+
{
|
1990
|
+
pathname: `../${res.data.documentId}`,
|
1991
|
+
search: rawQuery
|
1992
|
+
},
|
1993
|
+
{ replace: true, relative: "path" }
|
1994
|
+
);
|
1854
1995
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1855
1996
|
setErrors(formatValidationErrors(res.error));
|
1856
1997
|
}
|
@@ -1882,10 +2023,8 @@ const UnpublishAction$1 = ({
|
|
1882
2023
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1883
2024
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1884
2025
|
const isDocumentModified = document?.status === "modified";
|
1885
|
-
const handleChange = (
|
1886
|
-
|
1887
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1888
|
-
}
|
2026
|
+
const handleChange = (value) => {
|
2027
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1889
2028
|
};
|
1890
2029
|
if (!schema?.options?.draftAndPublish) {
|
1891
2030
|
return null;
|
@@ -1935,40 +2074,24 @@ const UnpublishAction$1 = ({
|
|
1935
2074
|
}) })
|
1936
2075
|
] }),
|
1937
2076
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1938
|
-
designSystem.
|
2077
|
+
designSystem.Radio.Group,
|
1939
2078
|
{
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
2079
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2080
|
+
name: "discard-options",
|
2081
|
+
"aria-label": formatMessage({
|
2082
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2083
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2084
|
+
}),
|
2085
|
+
onValueChange: handleChange,
|
1946
2086
|
children: [
|
1947
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1956
|
-
defaultMessage: "Keep draft"
|
1957
|
-
})
|
1958
|
-
}
|
1959
|
-
),
|
1960
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1961
|
-
designSystem.Radio,
|
1962
|
-
{
|
1963
|
-
checked: !shouldKeepDraft,
|
1964
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1965
|
-
name: "discard-options",
|
1966
|
-
children: formatMessage({
|
1967
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1968
|
-
defaultMessage: "Replace draft"
|
1969
|
-
})
|
1970
|
-
}
|
1971
|
-
)
|
2087
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2088
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2089
|
+
defaultMessage: "Keep draft"
|
2090
|
+
}) }),
|
2091
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2092
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2093
|
+
defaultMessage: "Replace draft"
|
2094
|
+
}) })
|
1972
2095
|
]
|
1973
2096
|
}
|
1974
2097
|
)
|
@@ -2114,23 +2237,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2114
2237
|
id: "content-manager.containers.edit.title.new",
|
2115
2238
|
defaultMessage: "Create an entry"
|
2116
2239
|
}) : documentTitle;
|
2117
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2240
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2118
2241
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2119
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2120
|
-
designSystem.
|
2121
|
-
{
|
2122
|
-
|
2123
|
-
|
2124
|
-
paddingTop: 1,
|
2125
|
-
gap: "80px",
|
2126
|
-
alignItems: "flex-start",
|
2127
|
-
children: [
|
2128
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2129
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2130
|
-
]
|
2131
|
-
}
|
2132
|
-
),
|
2133
|
-
status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2242
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2243
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2244
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2245
|
+
] }),
|
2246
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2134
2247
|
] });
|
2135
2248
|
};
|
2136
2249
|
const HeaderToolbar = () => {
|
@@ -2821,30 +2934,23 @@ const ConfirmBulkActionDialog = ({
|
|
2821
2934
|
endAction
|
2822
2935
|
}) => {
|
2823
2936
|
const { formatMessage } = reactIntl.useIntl();
|
2824
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2825
|
-
designSystem.Dialog,
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
}) }),
|
2842
|
-
endAction
|
2843
|
-
}
|
2844
|
-
)
|
2845
|
-
]
|
2846
|
-
}
|
2847
|
-
);
|
2937
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2938
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2939
|
+
id: "app.components.ConfirmDialog.title",
|
2940
|
+
defaultMessage: "Confirmation"
|
2941
|
+
}) }),
|
2942
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2943
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2944
|
+
dialogBody
|
2945
|
+
] }) }),
|
2946
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2947
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2948
|
+
id: "app.components.Button.cancel",
|
2949
|
+
defaultMessage: "Cancel"
|
2950
|
+
}) }) }),
|
2951
|
+
endAction
|
2952
|
+
] })
|
2953
|
+
] }) });
|
2848
2954
|
};
|
2849
2955
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2850
2956
|
const ConfirmDialogPublishAll = ({
|
@@ -2949,16 +3055,30 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2949
3055
|
)
|
2950
3056
|
);
|
2951
3057
|
} else {
|
2952
|
-
messages.push(
|
3058
|
+
messages.push(
|
3059
|
+
...formatErrorMessages(
|
3060
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3061
|
+
value,
|
3062
|
+
currentKey,
|
3063
|
+
formatMessage
|
3064
|
+
)
|
3065
|
+
);
|
2953
3066
|
}
|
3067
|
+
} else {
|
3068
|
+
messages.push(
|
3069
|
+
formatMessage(
|
3070
|
+
{
|
3071
|
+
id: `${value}.withField`,
|
3072
|
+
defaultMessage: value
|
3073
|
+
},
|
3074
|
+
{ field: currentKey }
|
3075
|
+
)
|
3076
|
+
);
|
2954
3077
|
}
|
2955
3078
|
});
|
2956
3079
|
return messages;
|
2957
3080
|
};
|
2958
|
-
const EntryValidationText = ({
|
2959
|
-
validationErrors,
|
2960
|
-
isPublished = false
|
2961
|
-
}) => {
|
3081
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
2962
3082
|
const { formatMessage } = reactIntl.useIntl();
|
2963
3083
|
if (validationErrors) {
|
2964
3084
|
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
@@ -2969,7 +3089,7 @@ const EntryValidationText = ({
|
|
2969
3089
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
2970
3090
|
] });
|
2971
3091
|
}
|
2972
|
-
if (
|
3092
|
+
if (status === "published") {
|
2973
3093
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2974
3094
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2975
3095
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
@@ -2978,6 +3098,15 @@ const EntryValidationText = ({
|
|
2978
3098
|
}) })
|
2979
3099
|
] });
|
2980
3100
|
}
|
3101
|
+
if (status === "modified") {
|
3102
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3103
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
3104
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
3105
|
+
id: "content-manager.bulk-publish.modified",
|
3106
|
+
defaultMessage: "Ready to publish changes"
|
3107
|
+
}) })
|
3108
|
+
] });
|
3109
|
+
}
|
2981
3110
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2982
3111
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2983
3112
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
@@ -3029,7 +3158,7 @@ const SelectedEntriesTableContent = ({
|
|
3029
3158
|
EntryValidationText,
|
3030
3159
|
{
|
3031
3160
|
validationErrors: validationErrors[row.documentId],
|
3032
|
-
|
3161
|
+
status: row.status
|
3033
3162
|
}
|
3034
3163
|
) }),
|
3035
3164
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -3094,7 +3223,13 @@ const SelectedEntriesModalContent = ({
|
|
3094
3223
|
);
|
3095
3224
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3096
3225
|
if (data.length > 0 && schema) {
|
3097
|
-
const validate = createYupSchema(
|
3226
|
+
const validate = createYupSchema(
|
3227
|
+
schema.attributes,
|
3228
|
+
components,
|
3229
|
+
// Since this is the "Publish" action, the validation
|
3230
|
+
// schema must enforce the rules for published entities
|
3231
|
+
{ status: "published" }
|
3232
|
+
);
|
3098
3233
|
const validationErrors2 = {};
|
3099
3234
|
const rows2 = data.map((entry) => {
|
3100
3235
|
try {
|
@@ -3170,7 +3305,7 @@ const SelectedEntriesModalContent = ({
|
|
3170
3305
|
);
|
3171
3306
|
};
|
3172
3307
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3173
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3308
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3174
3309
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3175
3310
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3176
3311
|
SelectedEntriesTableContent,
|
@@ -3182,27 +3317,24 @@ const SelectedEntriesModalContent = ({
|
|
3182
3317
|
}
|
3183
3318
|
) })
|
3184
3319
|
] }),
|
3185
|
-
/* @__PURE__ */ jsxRuntime.
|
3186
|
-
designSystem.
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3191
|
-
}) }),
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
] })
|
3204
|
-
}
|
3205
|
-
),
|
3320
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3321
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3322
|
+
id: "app.components.Button.cancel",
|
3323
|
+
defaultMessage: "Cancel"
|
3324
|
+
}) }),
|
3325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3326
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3327
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3328
|
+
designSystem.Button,
|
3329
|
+
{
|
3330
|
+
onClick: toggleDialog,
|
3331
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3332
|
+
loading: isSubmittingForm,
|
3333
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3334
|
+
}
|
3335
|
+
)
|
3336
|
+
] })
|
3337
|
+
] }),
|
3206
3338
|
/* @__PURE__ */ jsxRuntime.jsx(
|
3207
3339
|
ConfirmDialogPublishAll,
|
3208
3340
|
{
|
@@ -3267,143 +3399,10 @@ const BulkActionsRenderer = () => {
|
|
3267
3399
|
documents: selectedRows
|
3268
3400
|
},
|
3269
3401
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3270
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
3402
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3271
3403
|
}
|
3272
3404
|
) });
|
3273
3405
|
};
|
3274
|
-
const BulkActionAction = (action) => {
|
3275
|
-
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3276
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
3277
|
-
const handleClick = (action2) => (e) => {
|
3278
|
-
const { onClick, dialog, id } = action2;
|
3279
|
-
if (onClick) {
|
3280
|
-
onClick(e);
|
3281
|
-
}
|
3282
|
-
if (dialog) {
|
3283
|
-
switch (dialog.type) {
|
3284
|
-
case "notification":
|
3285
|
-
toggleNotification({
|
3286
|
-
title: dialog.title,
|
3287
|
-
message: dialog.content,
|
3288
|
-
type: dialog.status,
|
3289
|
-
timeout: dialog.timeout,
|
3290
|
-
onClose: dialog.onClose
|
3291
|
-
});
|
3292
|
-
break;
|
3293
|
-
case "dialog":
|
3294
|
-
case "modal": {
|
3295
|
-
e.preventDefault();
|
3296
|
-
setDialogId(id);
|
3297
|
-
}
|
3298
|
-
}
|
3299
|
-
}
|
3300
|
-
};
|
3301
|
-
const handleClose = () => {
|
3302
|
-
setDialogId(null);
|
3303
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3304
|
-
action.dialog.onClose();
|
3305
|
-
}
|
3306
|
-
};
|
3307
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3308
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3309
|
-
designSystem.Button,
|
3310
|
-
{
|
3311
|
-
disabled: action.disabled,
|
3312
|
-
startIcon: action.icon,
|
3313
|
-
variant: action.variant,
|
3314
|
-
onClick: handleClick(action),
|
3315
|
-
children: action.label
|
3316
|
-
}
|
3317
|
-
),
|
3318
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3319
|
-
BulkActionConfirmDialog,
|
3320
|
-
{
|
3321
|
-
...action.dialog,
|
3322
|
-
variant: action.variant,
|
3323
|
-
isOpen: dialogId === action.id,
|
3324
|
-
onClose: handleClose
|
3325
|
-
}
|
3326
|
-
) : null,
|
3327
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3328
|
-
BulkActionModal,
|
3329
|
-
{
|
3330
|
-
...action.dialog,
|
3331
|
-
onModalClose: handleClose,
|
3332
|
-
isOpen: dialogId === action.id
|
3333
|
-
}
|
3334
|
-
) : null
|
3335
|
-
] });
|
3336
|
-
};
|
3337
|
-
const BulkActionConfirmDialog = ({
|
3338
|
-
onClose,
|
3339
|
-
onCancel,
|
3340
|
-
onConfirm,
|
3341
|
-
title,
|
3342
|
-
content,
|
3343
|
-
confirmButton,
|
3344
|
-
isOpen,
|
3345
|
-
variant = "secondary"
|
3346
|
-
}) => {
|
3347
|
-
const { formatMessage } = reactIntl.useIntl();
|
3348
|
-
const handleClose = async () => {
|
3349
|
-
if (onCancel) {
|
3350
|
-
await onCancel();
|
3351
|
-
}
|
3352
|
-
onClose();
|
3353
|
-
};
|
3354
|
-
const handleConfirm = async () => {
|
3355
|
-
if (onConfirm) {
|
3356
|
-
await onConfirm();
|
3357
|
-
}
|
3358
|
-
onClose();
|
3359
|
-
};
|
3360
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
|
3361
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
|
3362
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3363
|
-
designSystem.DialogFooter,
|
3364
|
-
{
|
3365
|
-
startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3366
|
-
id: "app.components.Button.cancel",
|
3367
|
-
defaultMessage: "Cancel"
|
3368
|
-
}) }),
|
3369
|
-
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
3370
|
-
designSystem.Button,
|
3371
|
-
{
|
3372
|
-
onClick: handleConfirm,
|
3373
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3374
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
3375
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3376
|
-
id: "app.components.Button.confirm",
|
3377
|
-
defaultMessage: "Confirm"
|
3378
|
-
})
|
3379
|
-
}
|
3380
|
-
)
|
3381
|
-
}
|
3382
|
-
)
|
3383
|
-
] });
|
3384
|
-
};
|
3385
|
-
const BulkActionModal = ({
|
3386
|
-
isOpen,
|
3387
|
-
title,
|
3388
|
-
onClose,
|
3389
|
-
content: Content,
|
3390
|
-
onModalClose
|
3391
|
-
}) => {
|
3392
|
-
const id = React__namespace.useId();
|
3393
|
-
if (!isOpen) {
|
3394
|
-
return null;
|
3395
|
-
}
|
3396
|
-
const handleClose = () => {
|
3397
|
-
if (onClose) {
|
3398
|
-
onClose();
|
3399
|
-
}
|
3400
|
-
onModalClose();
|
3401
|
-
};
|
3402
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3403
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3404
|
-
/* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
|
3405
|
-
] });
|
3406
|
-
};
|
3407
3406
|
const DeleteAction = ({ documents, model }) => {
|
3408
3407
|
const { formatMessage } = reactIntl.useIntl();
|
3409
3408
|
const { schema: contentType } = useDoc();
|
@@ -3436,6 +3435,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3436
3435
|
defaultMessage: "Confirmation"
|
3437
3436
|
}),
|
3438
3437
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3438
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3439
3439
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3440
3440
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3441
3441
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3472,7 +3472,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3472
3472
|
selectRow([]);
|
3473
3473
|
}
|
3474
3474
|
};
|
3475
|
-
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
|
3475
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3476
3476
|
if (!showUnpublishButton)
|
3477
3477
|
return null;
|
3478
3478
|
return {
|
@@ -3485,6 +3485,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3485
3485
|
defaultMessage: "Confirmation"
|
3486
3486
|
}),
|
3487
3487
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3488
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3488
3489
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3489
3490
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3490
3491
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3578,7 +3579,7 @@ const TableActions = ({ document }) => {
|
|
3578
3579
|
strapiAdmin.DescriptionComponentRenderer,
|
3579
3580
|
{
|
3580
3581
|
props,
|
3581
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3582
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3582
3583
|
children: (actions2) => {
|
3583
3584
|
const tableRowActions = actions2.filter((action) => {
|
3584
3585
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3689,7 +3690,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3689
3690
|
}),
|
3690
3691
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3691
3692
|
footer: ({ onClose }) => {
|
3692
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3693
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3693
3694
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3694
3695
|
id: "cancel",
|
3695
3696
|
defaultMessage: "Cancel"
|
@@ -3730,8 +3731,7 @@ class ContentManagerPlugin {
|
|
3730
3731
|
documentActions = [
|
3731
3732
|
...DEFAULT_ACTIONS,
|
3732
3733
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3733
|
-
...DEFAULT_HEADER_ACTIONS
|
3734
|
-
HistoryAction
|
3734
|
+
...DEFAULT_HEADER_ACTIONS
|
3735
3735
|
];
|
3736
3736
|
editViewSidePanels = [ActionsPanel];
|
3737
3737
|
headerActions = [];
|
@@ -3820,6 +3820,52 @@ const getPrintableType = (value) => {
|
|
3820
3820
|
}
|
3821
3821
|
return nativeType;
|
3822
3822
|
};
|
3823
|
+
const HistoryAction = ({ model, document }) => {
|
3824
|
+
const { formatMessage } = reactIntl.useIntl();
|
3825
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3826
|
+
const navigate = reactRouterDom.useNavigate();
|
3827
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3828
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3829
|
+
return null;
|
3830
|
+
}
|
3831
|
+
return {
|
3832
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3833
|
+
label: formatMessage({
|
3834
|
+
id: "content-manager.history.document-action",
|
3835
|
+
defaultMessage: "Content History"
|
3836
|
+
}),
|
3837
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3838
|
+
disabled: (
|
3839
|
+
/**
|
3840
|
+
* The user is creating a new document.
|
3841
|
+
* It hasn't been saved yet, so there's no history to go to
|
3842
|
+
*/
|
3843
|
+
!document || /**
|
3844
|
+
* The document has been created but the current dimension has never been saved.
|
3845
|
+
* For example, the user is creating a new locale in an existing document,
|
3846
|
+
* so there's no history for the document in that locale
|
3847
|
+
*/
|
3848
|
+
!document.id || /**
|
3849
|
+
* History is only available for content types created by the user.
|
3850
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3851
|
+
* which start with `admin::` or `plugin::`
|
3852
|
+
*/
|
3853
|
+
!model.startsWith("api::")
|
3854
|
+
),
|
3855
|
+
position: "header"
|
3856
|
+
};
|
3857
|
+
};
|
3858
|
+
HistoryAction.type = "history";
|
3859
|
+
const historyAdmin = {
|
3860
|
+
bootstrap(app) {
|
3861
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3862
|
+
addDocumentAction((actions2) => {
|
3863
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3864
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3865
|
+
return actions2;
|
3866
|
+
});
|
3867
|
+
}
|
3868
|
+
};
|
3823
3869
|
const initialState = {
|
3824
3870
|
collectionTypeLinks: [],
|
3825
3871
|
components: [],
|
@@ -3870,15 +3916,29 @@ const index = {
|
|
3870
3916
|
defaultMessage: "Content Manager"
|
3871
3917
|
},
|
3872
3918
|
permissions: [],
|
3873
|
-
Component: () => Promise.resolve().then(() => require("./layout-b91XRlD2.js")).then((mod) => ({ default: mod.Layout })),
|
3874
3919
|
position: 1
|
3875
3920
|
});
|
3921
|
+
app.router.addRoute({
|
3922
|
+
path: "content-manager/*",
|
3923
|
+
lazy: async () => {
|
3924
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-C788OmNr.js"));
|
3925
|
+
return {
|
3926
|
+
Component: Layout
|
3927
|
+
};
|
3928
|
+
},
|
3929
|
+
children: routes
|
3930
|
+
});
|
3876
3931
|
app.registerPlugin(cm.config);
|
3877
3932
|
},
|
3933
|
+
bootstrap(app) {
|
3934
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3935
|
+
historyAdmin.bootstrap(app);
|
3936
|
+
}
|
3937
|
+
},
|
3878
3938
|
async registerTrads({ locales }) {
|
3879
3939
|
const importedTrads = await Promise.all(
|
3880
3940
|
locales.map((locale) => {
|
3881
|
-
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-
|
3941
|
+
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-uOUIxfcQ.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 }) => {
|
3882
3942
|
return {
|
3883
3943
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3884
3944
|
locale
|
@@ -3896,6 +3956,7 @@ const index = {
|
|
3896
3956
|
};
|
3897
3957
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3898
3958
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
3959
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3899
3960
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3900
3961
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3901
3962
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3922,7 +3983,6 @@ exports.getDisplayName = getDisplayName;
|
|
3922
3983
|
exports.getMainField = getMainField;
|
3923
3984
|
exports.getTranslation = getTranslation;
|
3924
3985
|
exports.index = index;
|
3925
|
-
exports.routes = routes;
|
3926
3986
|
exports.setInitialData = setInitialData;
|
3927
3987
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3928
3988
|
exports.useDoc = useDoc;
|
@@ -3936,4 +3996,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3936
3996
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3937
3997
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3938
3998
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3939
|
-
//# sourceMappingURL=index-
|
3999
|
+
//# sourceMappingURL=index-C3fJE-1-.js.map
|