@strapi/content-manager 5.0.0-rc.1 → 5.0.0-rc.11

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.
Files changed (101) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-D8RyVgJC.js → ComponentConfigurationPage-D_M8iBw5.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-D8RyVgJC.js.map → ComponentConfigurationPage-D_M8iBw5.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DLuACgva.mjs → ComponentConfigurationPage-qemkOlnj.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-DLuACgva.mjs.map → ComponentConfigurationPage-qemkOlnj.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-fOm5AebB.js → EditConfigurationPage-BePwPuHy.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-fOm5AebB.js.map → EditConfigurationPage-BePwPuHy.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CuCAsHWR.mjs → EditConfigurationPage-CjUrEewK.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-CuCAsHWR.mjs.map → EditConfigurationPage-CjUrEewK.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-Or0fpTwh.js → EditViewPage-B-RJeiJD.js} +19 -8
  10. package/dist/_chunks/EditViewPage-B-RJeiJD.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-BqDlT9w0.mjs → EditViewPage-De8GyU8P.mjs} +19 -8
  12. package/dist/_chunks/EditViewPage-De8GyU8P.mjs.map +1 -0
  13. package/dist/_chunks/{Field-Bix2HU_O.js → Field-dq8Tg1M_.js} +99 -33
  14. package/dist/_chunks/Field-dq8Tg1M_.js.map +1 -0
  15. package/dist/_chunks/{Field-OfBJ6x59.mjs → Field-pb2o8uBe.mjs} +101 -35
  16. package/dist/_chunks/Field-pb2o8uBe.mjs.map +1 -0
  17. package/dist/_chunks/{Form-Bv5ABnqE.js → Form-DGIf4jQU.js} +22 -11
  18. package/dist/_chunks/Form-DGIf4jQU.js.map +1 -0
  19. package/dist/_chunks/{Form-DyMXqj_v.mjs → Form-DJn0Dxha.mjs} +22 -11
  20. package/dist/_chunks/Form-DJn0Dxha.mjs.map +1 -0
  21. package/dist/_chunks/{History-rvLnluF0.mjs → History-BowL3JKP.mjs} +4 -4
  22. package/dist/_chunks/{History-rvLnluF0.mjs.map → History-BowL3JKP.mjs.map} +1 -1
  23. package/dist/_chunks/{History-fnln26gA.js → History-Dh2NEHnR.js} +4 -4
  24. package/dist/_chunks/{History-fnln26gA.js.map → History-Dh2NEHnR.js.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-DdKfJRdq.mjs → ListConfigurationPage-BpVOB-hn.mjs} +14 -4
  26. package/dist/_chunks/ListConfigurationPage-BpVOB-hn.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-BtCBP_L_.js → ListConfigurationPage-BxYCWz9e.js} +14 -4
  28. package/dist/_chunks/ListConfigurationPage-BxYCWz9e.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CGZWD2qn.js → ListViewPage-4XsciqHZ.js} +9 -4
  30. package/dist/_chunks/ListViewPage-4XsciqHZ.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-B8cPO1bK.mjs → ListViewPage-CXFUjZQC.mjs} +10 -5
  32. package/dist/_chunks/ListViewPage-CXFUjZQC.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-oJxX0WCQ.js → NoContentTypePage-C8OpoHeU.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-oJxX0WCQ.js.map → NoContentTypePage-C8OpoHeU.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CVqYTeML.mjs → NoContentTypePage-DuhOTp3x.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CVqYTeML.mjs.map → NoContentTypePage-DuhOTp3x.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-mlXqh8p6.mjs → NoPermissionsPage-DVz3mzDz.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-mlXqh8p6.mjs.map → NoPermissionsPage-DVz3mzDz.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-BB11jqM_.js → NoPermissionsPage-y_r7DVA2.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-BB11jqM_.js.map → NoPermissionsPage-y_r7DVA2.js.map} +1 -1
  41. package/dist/_chunks/{Relations-DWscdjKO.mjs → Relations-CVNLrn1Y.mjs} +4 -4
  42. package/dist/_chunks/{Relations-DWscdjKO.mjs.map → Relations-CVNLrn1Y.mjs.map} +1 -1
  43. package/dist/_chunks/{Relations-6xIumgbN.js → Relations-DPFCAa7b.js} +4 -4
  44. package/dist/_chunks/{Relations-6xIumgbN.js.map → Relations-DPFCAa7b.js.map} +1 -1
  45. package/dist/_chunks/{index-BzUwgKUj.js → index-C3fJE-1-.js} +140 -71
  46. package/dist/_chunks/index-C3fJE-1-.js.map +1 -0
  47. package/dist/_chunks/{index-JSJrqmB9.mjs → index-DiMrfcfy.mjs} +158 -89
  48. package/dist/_chunks/index-DiMrfcfy.mjs.map +1 -0
  49. package/dist/_chunks/{layout-U4xJd8Oi.js → layout-C788OmNr.js} +19 -7
  50. package/dist/_chunks/layout-C788OmNr.js.map +1 -0
  51. package/dist/_chunks/{layout-Dewoec1b.mjs → layout-ls3gxfpH.mjs} +20 -8
  52. package/dist/_chunks/layout-ls3gxfpH.mjs.map +1 -0
  53. package/dist/_chunks/{relations-DMxeUp5V.mjs → relations-CLcOmGO0.mjs} +2 -2
  54. package/dist/_chunks/{relations-DMxeUp5V.mjs.map → relations-CLcOmGO0.mjs.map} +1 -1
  55. package/dist/_chunks/{relations-BifGhhuo.js → relations-DYeotliT.js} +2 -2
  56. package/dist/_chunks/{relations-BifGhhuo.js.map → relations-DYeotliT.js.map} +1 -1
  57. package/dist/admin/index.js +1 -1
  58. package/dist/admin/index.mjs +4 -4
  59. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  60. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  61. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  62. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +10 -22
  63. package/dist/admin/src/services/api.d.ts +1 -1
  64. package/dist/admin/src/services/components.d.ts +2 -2
  65. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  66. package/dist/admin/src/services/documents.d.ts +16 -16
  67. package/dist/admin/src/services/init.d.ts +1 -1
  68. package/dist/admin/src/services/relations.d.ts +2 -2
  69. package/dist/admin/src/services/uid.d.ts +3 -3
  70. package/dist/admin/src/utils/validation.d.ts +4 -1
  71. package/dist/server/index.js +155 -103
  72. package/dist/server/index.js.map +1 -1
  73. package/dist/server/index.mjs +156 -104
  74. package/dist/server/index.mjs.map +1 -1
  75. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  76. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  77. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  78. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  79. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  80. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  81. package/dist/server/src/history/services/utils.d.ts +1 -1
  82. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  83. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  84. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  85. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  86. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  87. package/package.json +8 -8
  88. package/dist/_chunks/EditViewPage-BqDlT9w0.mjs.map +0 -1
  89. package/dist/_chunks/EditViewPage-Or0fpTwh.js.map +0 -1
  90. package/dist/_chunks/Field-Bix2HU_O.js.map +0 -1
  91. package/dist/_chunks/Field-OfBJ6x59.mjs.map +0 -1
  92. package/dist/_chunks/Form-Bv5ABnqE.js.map +0 -1
  93. package/dist/_chunks/Form-DyMXqj_v.mjs.map +0 -1
  94. package/dist/_chunks/ListConfigurationPage-BtCBP_L_.js.map +0 -1
  95. package/dist/_chunks/ListConfigurationPage-DdKfJRdq.mjs.map +0 -1
  96. package/dist/_chunks/ListViewPage-B8cPO1bK.mjs.map +0 -1
  97. package/dist/_chunks/ListViewPage-CGZWD2qn.js.map +0 -1
  98. package/dist/_chunks/index-BzUwgKUj.js.map +0 -1
  99. package/dist/_chunks/index-JSJrqmB9.mjs.map +0 -1
  100. package/dist/_chunks/layout-Dewoec1b.mjs.map +0 -1
  101. package/dist/_chunks/layout-U4xJd8Oi.js.map +0 -1
@@ -179,7 +179,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
179
179
  "Document",
180
180
  "InitialData",
181
181
  "HistoryVersion",
182
- "Relations"
182
+ "Relations",
183
+ "UidAvailability"
183
184
  ]
184
185
  });
185
186
  const documentApi = contentManagerApi.injectEndpoints({
@@ -193,7 +194,12 @@ const documentApi = contentManagerApi.injectEndpoints({
193
194
  params: query
194
195
  }
195
196
  }),
196
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
197
+ invalidatesTags: (_result, error, { model }) => {
198
+ if (error) {
199
+ return [];
200
+ }
201
+ return [{ type: "Document", id: `${model}_LIST` }];
202
+ }
197
203
  }),
198
204
  cloneDocument: builder.mutation({
199
205
  query: ({ model, sourceId, data, params }) => ({
@@ -204,7 +210,10 @@ const documentApi = contentManagerApi.injectEndpoints({
204
210
  params
205
211
  }
206
212
  }),
207
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
213
+ invalidatesTags: (_result, _error, { model }) => [
214
+ { type: "Document", id: `${model}_LIST` },
215
+ { type: "UidAvailability", id: model }
216
+ ]
208
217
  }),
209
218
  /**
210
219
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -221,7 +230,8 @@ const documentApi = contentManagerApi.injectEndpoints({
221
230
  }),
222
231
  invalidatesTags: (result, _error, { model }) => [
223
232
  { type: "Document", id: `${model}_LIST` },
224
- "Relations"
233
+ "Relations",
234
+ { type: "UidAvailability", id: model }
225
235
  ]
226
236
  }),
227
237
  deleteDocument: builder.mutation({
@@ -262,7 +272,8 @@ const documentApi = contentManagerApi.injectEndpoints({
262
272
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
263
273
  },
264
274
  { type: "Document", id: `${model}_LIST` },
265
- "Relations"
275
+ "Relations",
276
+ { type: "UidAvailability", id: model }
266
277
  ];
267
278
  }
268
279
  }),
@@ -280,6 +291,7 @@ const documentApi = contentManagerApi.injectEndpoints({
280
291
  }),
281
292
  providesTags: (result, _error, arg) => {
282
293
  return [
294
+ { type: "Document", id: `ALL_LIST` },
283
295
  { type: "Document", id: `${arg.model}_LIST` },
284
296
  ...result?.results.map(({ documentId }) => ({
285
297
  type: "Document",
@@ -318,6 +330,11 @@ const documentApi = contentManagerApi.injectEndpoints({
318
330
  {
319
331
  type: "Document",
320
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`
321
338
  }
322
339
  ];
323
340
  }
@@ -381,8 +398,21 @@ const documentApi = contentManagerApi.injectEndpoints({
381
398
  type: "Document",
382
399
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
383
400
  },
384
- "Relations"
401
+ "Relations",
402
+ { type: "UidAvailability", id: model }
385
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
+ }
386
416
  }
387
417
  }),
388
418
  unpublishDocument: builder.mutation({
@@ -452,7 +482,7 @@ const buildValidParams = (query) => {
452
482
  const isBaseQueryError = (error) => {
453
483
  return error.name !== void 0;
454
484
  };
455
- const createYupSchema = (attributes = {}, components = {}) => {
485
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
456
486
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
457
487
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
458
488
  if (DOCUMENT_META_FIELDS.includes(name)) {
@@ -465,7 +495,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
465
495
  addMinValidation,
466
496
  addMaxValidation,
467
497
  addRegexValidation
468
- ].map((fn) => fn(attribute));
498
+ ].map((fn) => fn(attribute, options));
469
499
  const transformSchema = pipe__default.default(...validations);
470
500
  switch (attribute.type) {
471
501
  case "component": {
@@ -566,6 +596,14 @@ const createAttributeSchema = (attribute) => {
566
596
  if (!value || typeof value === "string" && value.length === 0) {
567
597
  return true;
568
598
  }
599
+ if (typeof value === "object") {
600
+ try {
601
+ JSON.stringify(value);
602
+ return true;
603
+ } catch (err) {
604
+ return false;
605
+ }
606
+ }
569
607
  try {
570
608
  JSON.parse(value);
571
609
  return true;
@@ -584,13 +622,7 @@ const createAttributeSchema = (attribute) => {
584
622
  return yup__namespace.mixed();
585
623
  }
586
624
  };
587
- const addRequiredValidation = (attribute) => (schema) => {
588
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
589
- return schema.min(1, strapiAdmin.translatedErrors.required);
590
- }
591
- if (attribute.required && attribute.type !== "relation") {
592
- return schema.required(strapiAdmin.translatedErrors.required);
593
- }
625
+ const nullableSchema = (schema) => {
594
626
  return schema?.nullable ? schema.nullable() : (
595
627
  // In some cases '.nullable' will not be available on the schema.
596
628
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -598,7 +630,22 @@ const addRequiredValidation = (attribute) => (schema) => {
598
630
  schema
599
631
  );
600
632
  };
601
- const addMinLengthValidation = (attribute) => (schema) => {
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
+ }
602
649
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
603
650
  return schema.min(attribute.minLength, {
604
651
  ...strapiAdmin.translatedErrors.minLength,
@@ -620,11 +667,11 @@ const addMaxLengthValidation = (attribute) => (schema) => {
620
667
  }
621
668
  return schema;
622
669
  };
623
- const addMinValidation = (attribute) => (schema) => {
670
+ const addMinValidation = (attribute, options) => (schema) => {
624
671
  if ("min" in attribute) {
625
672
  const min = toInteger(attribute.min);
626
673
  if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
627
- if (!attribute.required && "test" in schema && min) {
674
+ if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
628
675
  return schema.test(
629
676
  "custom-min",
630
677
  {
@@ -860,6 +907,7 @@ const useDocumentActions = () => {
860
907
  const { formatMessage } = reactIntl.useIntl();
861
908
  const { trackUsage } = strapiAdmin.useTracking();
862
909
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
910
+ const navigate = reactRouterDom.useNavigate();
863
911
  const [deleteDocument] = useDeleteDocumentMutation();
864
912
  const _delete = React__namespace.useCallback(
865
913
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1195,7 +1243,6 @@ const useDocumentActions = () => {
1195
1243
  sourceId
1196
1244
  });
1197
1245
  if ("error" in res) {
1198
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1199
1246
  return { error: res.error };
1200
1247
  }
1201
1248
  toggleNotification({
@@ -1214,7 +1261,7 @@ const useDocumentActions = () => {
1214
1261
  throw err;
1215
1262
  }
1216
1263
  },
1217
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1264
+ [autoCloneDocument, formatMessage, toggleNotification]
1218
1265
  );
1219
1266
  const [cloneDocument] = useCloneDocumentMutation();
1220
1267
  const clone = React__namespace.useCallback(
@@ -1240,6 +1287,7 @@ const useDocumentActions = () => {
1240
1287
  defaultMessage: "Cloned document"
1241
1288
  })
1242
1289
  });
1290
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1243
1291
  return res.data;
1244
1292
  } catch (err) {
1245
1293
  toggleNotification({
@@ -1250,7 +1298,7 @@ const useDocumentActions = () => {
1250
1298
  throw err;
1251
1299
  }
1252
1300
  },
1253
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1301
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1254
1302
  );
1255
1303
  const [getDoc] = useLazyGetDocumentQuery();
1256
1304
  const getDocument = React__namespace.useCallback(
@@ -1276,7 +1324,7 @@ const useDocumentActions = () => {
1276
1324
  };
1277
1325
  };
1278
1326
  const ProtectedHistoryPage = React.lazy(
1279
- () => Promise.resolve().then(() => require("./History-fnln26gA.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1327
+ () => Promise.resolve().then(() => require("./History-Dh2NEHnR.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1280
1328
  );
1281
1329
  const routes$1 = [
1282
1330
  {
@@ -1289,31 +1337,31 @@ const routes$1 = [
1289
1337
  }
1290
1338
  ];
1291
1339
  const ProtectedEditViewPage = React.lazy(
1292
- () => Promise.resolve().then(() => require("./EditViewPage-Or0fpTwh.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1340
+ () => Promise.resolve().then(() => require("./EditViewPage-B-RJeiJD.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1293
1341
  );
1294
1342
  const ProtectedListViewPage = React.lazy(
1295
- () => Promise.resolve().then(() => require("./ListViewPage-CGZWD2qn.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1343
+ () => Promise.resolve().then(() => require("./ListViewPage-4XsciqHZ.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1296
1344
  );
1297
1345
  const ProtectedListConfiguration = React.lazy(
1298
- () => Promise.resolve().then(() => require("./ListConfigurationPage-BtCBP_L_.js")).then((mod) => ({
1346
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-BxYCWz9e.js")).then((mod) => ({
1299
1347
  default: mod.ProtectedListConfiguration
1300
1348
  }))
1301
1349
  );
1302
1350
  const ProtectedEditConfigurationPage = React.lazy(
1303
- () => Promise.resolve().then(() => require("./EditConfigurationPage-fOm5AebB.js")).then((mod) => ({
1351
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-BePwPuHy.js")).then((mod) => ({
1304
1352
  default: mod.ProtectedEditConfigurationPage
1305
1353
  }))
1306
1354
  );
1307
1355
  const ProtectedComponentConfigurationPage = React.lazy(
1308
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-D8RyVgJC.js")).then((mod) => ({
1356
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-D_M8iBw5.js")).then((mod) => ({
1309
1357
  default: mod.ProtectedComponentConfigurationPage
1310
1358
  }))
1311
1359
  );
1312
1360
  const NoPermissions = React.lazy(
1313
- () => Promise.resolve().then(() => require("./NoPermissionsPage-BB11jqM_.js")).then((mod) => ({ default: mod.NoPermissions }))
1361
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-y_r7DVA2.js")).then((mod) => ({ default: mod.NoPermissions }))
1314
1362
  );
1315
1363
  const NoContentType = React.lazy(
1316
- () => Promise.resolve().then(() => require("./NoContentTypePage-oJxX0WCQ.js")).then((mod) => ({ default: mod.NoContentType }))
1364
+ () => Promise.resolve().then(() => require("./NoContentTypePage-C8OpoHeU.js")).then((mod) => ({ default: mod.NoContentType }))
1317
1365
  );
1318
1366
  const CollectionTypePages = () => {
1319
1367
  const { collectionType } = reactRouterDom.useParams();
@@ -1427,12 +1475,14 @@ const DocumentActionButton = (action) => {
1427
1475
  /* @__PURE__ */ jsxRuntime.jsx(
1428
1476
  designSystem.Button,
1429
1477
  {
1430
- flex: 1,
1478
+ flex: "auto",
1431
1479
  startIcon: action.icon,
1432
1480
  disabled: action.disabled,
1433
1481
  onClick: handleClick(action),
1434
1482
  justifyContent: "center",
1435
1483
  variant: action.variant || "default",
1484
+ paddingTop: "7px",
1485
+ paddingBottom: "7px",
1436
1486
  children: action.label
1437
1487
  }
1438
1488
  ),
@@ -1492,14 +1542,14 @@ const DocumentActionsMenu = ({
1492
1542
  };
1493
1543
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1494
1544
  /* @__PURE__ */ jsxRuntime.jsxs(
1495
- designSystem.Menu.Trigger,
1545
+ StyledMoreButton,
1496
1546
  {
1497
1547
  disabled: isDisabled,
1498
1548
  size: "S",
1499
1549
  endIcon: null,
1500
- paddingTop: "7px",
1501
- paddingLeft: "9px",
1502
- paddingRight: "9px",
1550
+ paddingTop: "4px",
1551
+ paddingLeft: "7px",
1552
+ paddingRight: "7px",
1503
1553
  variant,
1504
1554
  children: [
1505
1555
  /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
@@ -1519,10 +1569,25 @@ const DocumentActionsMenu = ({
1519
1569
  onSelect: handleClick(action),
1520
1570
  display: "block",
1521
1571
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1522
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1523
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1524
- action.label
1525
- ] }),
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
+ ),
1526
1591
  action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1527
1592
  designSystem.Flex,
1528
1593
  {
@@ -1593,6 +1658,11 @@ const convertActionVariantToIconColor = (variant = "secondary") => {
1593
1658
  return "primary600";
1594
1659
  }
1595
1660
  };
1661
+ const StyledMoreButton = styledComponents.styled(designSystem.Menu.Trigger)`
1662
+ & > span {
1663
+ display: flex;
1664
+ }
1665
+ `;
1596
1666
  const DocumentActionConfirmDialog = ({
1597
1667
  onClose,
1598
1668
  onCancel,
@@ -1646,8 +1716,8 @@ const DocumentActionModal = ({
1646
1716
  };
1647
1717
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
1648
1718
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
1649
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content }),
1650
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer })
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
1651
1721
  ] }) });
1652
1722
  };
1653
1723
  const PublishAction$1 = ({
@@ -1662,12 +1732,10 @@ const PublishAction$1 = ({
1662
1732
  const navigate = reactRouterDom.useNavigate();
1663
1733
  const { toggleNotification } = strapiAdmin.useNotification();
1664
1734
  const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
1735
+ const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
1665
1736
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
1666
1737
  const { formatMessage } = reactIntl.useIntl();
1667
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1668
- "PublishAction",
1669
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1670
- );
1738
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1671
1739
  const { publish } = useDocumentActions();
1672
1740
  const [
1673
1741
  countDraftRelations,
@@ -1719,7 +1787,7 @@ const PublishAction$1 = ({
1719
1787
  }
1720
1788
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1721
1789
  React__namespace.useEffect(() => {
1722
- if (documentId) {
1790
+ if (documentId && !isListView) {
1723
1791
  const fetchDraftRelationsCount = async () => {
1724
1792
  const { data, error } = await countDraftRelations({
1725
1793
  collectionType,
@@ -1736,7 +1804,7 @@ const PublishAction$1 = ({
1736
1804
  };
1737
1805
  fetchDraftRelationsCount();
1738
1806
  }
1739
- }, [documentId, countDraftRelations, collectionType, model, params]);
1807
+ }, [isListView, documentId, countDraftRelations, collectionType, model, params]);
1740
1808
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1741
1809
  if (!schema?.options?.draftAndPublish) {
1742
1810
  return null;
@@ -1787,10 +1855,8 @@ const PublishAction$1 = ({
1787
1855
  * - the document is already published & not modified
1788
1856
  * - the document is being created & not modified
1789
1857
  * - the user doesn't have the permission to publish
1790
- * - the user doesn't have the permission to create a new document
1791
- * - the user doesn't have the permission to update the document
1792
1858
  */
1793
- disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1859
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1794
1860
  label: formatMessage({
1795
1861
  id: "app.utils.publish",
1796
1862
  defaultMessage: "Publish"
@@ -1837,10 +1903,6 @@ const UpdateAction = ({
1837
1903
  const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
1838
1904
  const isCloning = cloneMatch !== null;
1839
1905
  const { formatMessage } = reactIntl.useIntl();
1840
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1841
- canCreate: canCreate2,
1842
- canUpdate: canUpdate2
1843
- }));
1844
1906
  const { create, update, clone } = useDocumentActions();
1845
1907
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1846
1908
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
@@ -1857,10 +1919,8 @@ const UpdateAction = ({
1857
1919
  * - the form is submitting
1858
1920
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1859
1921
  * - the active tab is the published tab
1860
- * - the user doesn't have the permission to create a new document
1861
- * - the user doesn't have the permission to update the document
1862
1922
  */
1863
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
1923
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1864
1924
  label: formatMessage({
1865
1925
  id: "content-manager.containers.Edit.save",
1866
1926
  defaultMessage: "Save"
@@ -1868,16 +1928,18 @@ const UpdateAction = ({
1868
1928
  onClick: async () => {
1869
1929
  setSubmitting(true);
1870
1930
  try {
1871
- const { errors } = await validate();
1872
- if (errors) {
1873
- toggleNotification({
1874
- type: "danger",
1875
- message: formatMessage({
1876
- id: "content-manager.validation.error",
1877
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1878
- })
1879
- });
1880
- return;
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
+ }
1881
1943
  }
1882
1944
  if (isCloning) {
1883
1945
  const res = await clone(
@@ -3161,7 +3223,13 @@ const SelectedEntriesModalContent = ({
3161
3223
  );
3162
3224
  const { rows, validationErrors } = React__namespace.useMemo(() => {
3163
3225
  if (data.length > 0 && schema) {
3164
- const validate = createYupSchema(schema.attributes, components);
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
+ );
3165
3233
  const validationErrors2 = {};
3166
3234
  const rows2 = data.map((entry) => {
3167
3235
  try {
@@ -3511,7 +3579,7 @@ const TableActions = ({ document }) => {
3511
3579
  strapiAdmin.DescriptionComponentRenderer,
3512
3580
  {
3513
3581
  props,
3514
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3582
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3515
3583
  children: (actions2) => {
3516
3584
  const tableRowActions = actions2.filter((action) => {
3517
3585
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3622,7 +3690,7 @@ const CloneAction = ({ model, documentId }) => {
3622
3690
  }),
3623
3691
  content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3624
3692
  footer: ({ onClose }) => {
3625
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3693
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3626
3694
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3627
3695
  id: "cancel",
3628
3696
  defaultMessage: "Cancel"
@@ -3853,7 +3921,7 @@ const index = {
3853
3921
  app.router.addRoute({
3854
3922
  path: "content-manager/*",
3855
3923
  lazy: async () => {
3856
- const { Layout } = await Promise.resolve().then(() => require("./layout-U4xJd8Oi.js"));
3924
+ const { Layout } = await Promise.resolve().then(() => require("./layout-C788OmNr.js"));
3857
3925
  return {
3858
3926
  Component: Layout
3859
3927
  };
@@ -3888,6 +3956,7 @@ const index = {
3888
3956
  };
3889
3957
  exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
3890
3958
  exports.BulkActionsRenderer = BulkActionsRenderer;
3959
+ exports.CLONE_PATH = CLONE_PATH;
3891
3960
  exports.COLLECTION_TYPES = COLLECTION_TYPES;
3892
3961
  exports.CREATOR_FIELDS = CREATOR_FIELDS;
3893
3962
  exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
@@ -3927,4 +3996,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3927
3996
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3928
3997
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3929
3998
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3930
- //# sourceMappingURL=index-BzUwgKUj.js.map
3999
+ //# sourceMappingURL=index-C3fJE-1-.js.map