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

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-BEJqMzZA.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-D8RyVgJC.js.map → ComponentConfigurationPage-BEJqMzZA.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DLuACgva.mjs → ComponentConfigurationPage-C1B5XNIM.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-DLuACgva.mjs.map → ComponentConfigurationPage-C1B5XNIM.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-CuCAsHWR.mjs → EditConfigurationPage-D2DPoQ3j.mjs} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-CuCAsHWR.mjs.map → EditConfigurationPage-D2DPoQ3j.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-fOm5AebB.js → EditConfigurationPage-DOyPS5Tv.js} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-fOm5AebB.js.map → EditConfigurationPage-DOyPS5Tv.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-BqDlT9w0.mjs → EditViewPage-Ymi21g_V.mjs} +19 -8
  10. package/dist/_chunks/EditViewPage-Ymi21g_V.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-Or0fpTwh.js → EditViewPage-fuASFJIx.js} +19 -8
  12. package/dist/_chunks/EditViewPage-fuASFJIx.js.map +1 -0
  13. package/dist/_chunks/{Field-OfBJ6x59.mjs → Field-BOo2Rz0Z.mjs} +101 -35
  14. package/dist/_chunks/Field-BOo2Rz0Z.mjs.map +1 -0
  15. package/dist/_chunks/{Field-Bix2HU_O.js → Field-Ce4O31Zm.js} +99 -33
  16. package/dist/_chunks/Field-Ce4O31Zm.js.map +1 -0
  17. package/dist/_chunks/{Form-Bv5ABnqE.js → Form-CCGDm2PL.js} +22 -11
  18. package/dist/_chunks/Form-CCGDm2PL.js.map +1 -0
  19. package/dist/_chunks/{Form-DyMXqj_v.mjs → Form-D2_h3W-h.mjs} +22 -11
  20. package/dist/_chunks/Form-D2_h3W-h.mjs.map +1 -0
  21. package/dist/_chunks/{History-fnln26gA.js → History-CARFXr5U.js} +4 -4
  22. package/dist/_chunks/{History-fnln26gA.js.map → History-CARFXr5U.js.map} +1 -1
  23. package/dist/_chunks/{History-rvLnluF0.mjs → History-KY23tw1N.mjs} +4 -4
  24. package/dist/_chunks/{History-rvLnluF0.mjs.map → History-KY23tw1N.mjs.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-DdKfJRdq.mjs → ListConfigurationPage-BrwfEo-f.mjs} +14 -4
  26. package/dist/_chunks/ListConfigurationPage-BrwfEo-f.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-BtCBP_L_.js → ListConfigurationPage-fZjkRyi9.js} +14 -4
  28. package/dist/_chunks/ListConfigurationPage-fZjkRyi9.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CGZWD2qn.js → ListViewPage-CY6a70Y-.js} +9 -4
  30. package/dist/_chunks/ListViewPage-CY6a70Y-.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-B8cPO1bK.mjs → ListViewPage-CjkCjT3z.mjs} +10 -5
  32. package/dist/_chunks/ListViewPage-CjkCjT3z.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-CVqYTeML.mjs → NoContentTypePage-C8XPPlCu.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-CVqYTeML.mjs.map → NoContentTypePage-C8XPPlCu.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-oJxX0WCQ.js → NoContentTypePage-DId86YmW.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-oJxX0WCQ.js.map → NoContentTypePage-DId86YmW.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-BB11jqM_.js → NoPermissionsPage-CT9LmH-v.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-BB11jqM_.js.map → NoPermissionsPage-CT9LmH-v.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-mlXqh8p6.mjs → NoPermissionsPage-gwaMeI0N.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-mlXqh8p6.mjs.map → NoPermissionsPage-gwaMeI0N.mjs.map} +1 -1
  41. package/dist/_chunks/{Relations-DWscdjKO.mjs → Relations-BHyHGiTJ.mjs} +4 -4
  42. package/dist/_chunks/{Relations-DWscdjKO.mjs.map → Relations-BHyHGiTJ.mjs.map} +1 -1
  43. package/dist/_chunks/{Relations-6xIumgbN.js → Relations-Zqwo0Moa.js} +4 -4
  44. package/dist/_chunks/{Relations-6xIumgbN.js.map → Relations-Zqwo0Moa.js.map} +1 -1
  45. package/dist/_chunks/{index-BzUwgKUj.js → index-9nr_f9vB.js} +137 -69
  46. package/dist/_chunks/index-9nr_f9vB.js.map +1 -0
  47. package/dist/_chunks/{index-JSJrqmB9.mjs → index-CS6TpAQJ.mjs} +155 -87
  48. package/dist/_chunks/index-CS6TpAQJ.mjs.map +1 -0
  49. package/dist/_chunks/{layout-Dewoec1b.mjs → layout-2aGdWAdb.mjs} +20 -8
  50. package/dist/_chunks/layout-2aGdWAdb.mjs.map +1 -0
  51. package/dist/_chunks/{layout-U4xJd8Oi.js → layout-BssHa4-L.js} +19 -7
  52. package/dist/_chunks/layout-BssHa4-L.js.map +1 -0
  53. package/dist/_chunks/{relations-BifGhhuo.js → relations-BuxzjpZ_.js} +2 -2
  54. package/dist/_chunks/{relations-BifGhhuo.js.map → relations-BuxzjpZ_.js.map} +1 -1
  55. package/dist/_chunks/{relations-DMxeUp5V.mjs → relations-DBOO7qaP.mjs} +2 -2
  56. package/dist/_chunks/{relations-DMxeUp5V.mjs.map → relations-DBOO7qaP.mjs.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
@@ -3,9 +3,9 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
3
  import { useStrapiApp, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useQueryParams, useTracking, useForm, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
4
4
  import * as React from "react";
5
5
  import { lazy } from "react";
6
- import { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
6
+ import { Menu, Button, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
7
7
  import { useIntl } from "react-intl";
8
- import { useParams, Navigate, useNavigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
8
+ import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
9
9
  import { styled } from "styled-components";
10
10
  import * as yup from "yup";
11
11
  import { ValidationError } from "yup";
@@ -158,7 +158,8 @@ const contentManagerApi = adminApi.enhanceEndpoints({
158
158
  "Document",
159
159
  "InitialData",
160
160
  "HistoryVersion",
161
- "Relations"
161
+ "Relations",
162
+ "UidAvailability"
162
163
  ]
163
164
  });
164
165
  const documentApi = contentManagerApi.injectEndpoints({
@@ -172,7 +173,12 @@ const documentApi = contentManagerApi.injectEndpoints({
172
173
  params: query
173
174
  }
174
175
  }),
175
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
176
+ invalidatesTags: (_result, error, { model }) => {
177
+ if (error) {
178
+ return [];
179
+ }
180
+ return [{ type: "Document", id: `${model}_LIST` }];
181
+ }
176
182
  }),
177
183
  cloneDocument: builder.mutation({
178
184
  query: ({ model, sourceId, data, params }) => ({
@@ -183,7 +189,10 @@ const documentApi = contentManagerApi.injectEndpoints({
183
189
  params
184
190
  }
185
191
  }),
186
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
192
+ invalidatesTags: (_result, _error, { model }) => [
193
+ { type: "Document", id: `${model}_LIST` },
194
+ { type: "UidAvailability", id: model }
195
+ ]
187
196
  }),
188
197
  /**
189
198
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -200,7 +209,8 @@ const documentApi = contentManagerApi.injectEndpoints({
200
209
  }),
201
210
  invalidatesTags: (result, _error, { model }) => [
202
211
  { type: "Document", id: `${model}_LIST` },
203
- "Relations"
212
+ "Relations",
213
+ { type: "UidAvailability", id: model }
204
214
  ]
205
215
  }),
206
216
  deleteDocument: builder.mutation({
@@ -241,7 +251,8 @@ const documentApi = contentManagerApi.injectEndpoints({
241
251
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
242
252
  },
243
253
  { type: "Document", id: `${model}_LIST` },
244
- "Relations"
254
+ "Relations",
255
+ { type: "UidAvailability", id: model }
245
256
  ];
246
257
  }
247
258
  }),
@@ -259,6 +270,7 @@ const documentApi = contentManagerApi.injectEndpoints({
259
270
  }),
260
271
  providesTags: (result, _error, arg) => {
261
272
  return [
273
+ { type: "Document", id: `ALL_LIST` },
262
274
  { type: "Document", id: `${arg.model}_LIST` },
263
275
  ...result?.results.map(({ documentId }) => ({
264
276
  type: "Document",
@@ -297,6 +309,11 @@ const documentApi = contentManagerApi.injectEndpoints({
297
309
  {
298
310
  type: "Document",
299
311
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
312
+ },
313
+ // Make it easy to invalidate all individual documents queries for a model
314
+ {
315
+ type: "Document",
316
+ id: `${model}_ALL_ITEMS`
300
317
  }
301
318
  ];
302
319
  }
@@ -360,8 +377,21 @@ const documentApi = contentManagerApi.injectEndpoints({
360
377
  type: "Document",
361
378
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
362
379
  },
363
- "Relations"
380
+ "Relations",
381
+ { type: "UidAvailability", id: model }
364
382
  ];
383
+ },
384
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
385
+ const patchResult = dispatch(
386
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
387
+ Object.assign(draft.data, data);
388
+ })
389
+ );
390
+ try {
391
+ await queryFulfilled;
392
+ } catch {
393
+ patchResult.undo();
394
+ }
365
395
  }
366
396
  }),
367
397
  unpublishDocument: builder.mutation({
@@ -431,7 +461,7 @@ const buildValidParams = (query) => {
431
461
  const isBaseQueryError = (error) => {
432
462
  return error.name !== void 0;
433
463
  };
434
- const createYupSchema = (attributes = {}, components = {}) => {
464
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
435
465
  const createModelSchema = (attributes2) => yup.object().shape(
436
466
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
437
467
  if (DOCUMENT_META_FIELDS.includes(name)) {
@@ -444,7 +474,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
444
474
  addMinValidation,
445
475
  addMaxValidation,
446
476
  addRegexValidation
447
- ].map((fn) => fn(attribute));
477
+ ].map((fn) => fn(attribute, options));
448
478
  const transformSchema = pipe(...validations);
449
479
  switch (attribute.type) {
450
480
  case "component": {
@@ -545,6 +575,14 @@ const createAttributeSchema = (attribute) => {
545
575
  if (!value || typeof value === "string" && value.length === 0) {
546
576
  return true;
547
577
  }
578
+ if (typeof value === "object") {
579
+ try {
580
+ JSON.stringify(value);
581
+ return true;
582
+ } catch (err) {
583
+ return false;
584
+ }
585
+ }
548
586
  try {
549
587
  JSON.parse(value);
550
588
  return true;
@@ -563,13 +601,7 @@ const createAttributeSchema = (attribute) => {
563
601
  return yup.mixed();
564
602
  }
565
603
  };
566
- const addRequiredValidation = (attribute) => (schema) => {
567
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
568
- return schema.min(1, translatedErrors.required);
569
- }
570
- if (attribute.required && attribute.type !== "relation") {
571
- return schema.required(translatedErrors.required);
572
- }
604
+ const nullableSchema = (schema) => {
573
605
  return schema?.nullable ? schema.nullable() : (
574
606
  // In some cases '.nullable' will not be available on the schema.
575
607
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -577,7 +609,22 @@ const addRequiredValidation = (attribute) => (schema) => {
577
609
  schema
578
610
  );
579
611
  };
580
- const addMinLengthValidation = (attribute) => (schema) => {
612
+ const addRequiredValidation = (attribute, options) => (schema) => {
613
+ if (options.status === "draft") {
614
+ return nullableSchema(schema);
615
+ }
616
+ if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
617
+ return schema.min(1, translatedErrors.required);
618
+ }
619
+ if (attribute.required && attribute.type !== "relation") {
620
+ return schema.required(translatedErrors.required);
621
+ }
622
+ return nullableSchema(schema);
623
+ };
624
+ const addMinLengthValidation = (attribute, options) => (schema) => {
625
+ if (options.status === "draft") {
626
+ return schema;
627
+ }
581
628
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
582
629
  return schema.min(attribute.minLength, {
583
630
  ...translatedErrors.minLength,
@@ -599,11 +646,11 @@ const addMaxLengthValidation = (attribute) => (schema) => {
599
646
  }
600
647
  return schema;
601
648
  };
602
- const addMinValidation = (attribute) => (schema) => {
649
+ const addMinValidation = (attribute, options) => (schema) => {
603
650
  if ("min" in attribute) {
604
651
  const min = toInteger(attribute.min);
605
652
  if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
606
- if (!attribute.required && "test" in schema && min) {
653
+ if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
607
654
  return schema.test(
608
655
  "custom-min",
609
656
  {
@@ -839,6 +886,7 @@ const useDocumentActions = () => {
839
886
  const { formatMessage } = useIntl();
840
887
  const { trackUsage } = useTracking();
841
888
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
889
+ const navigate = useNavigate();
842
890
  const [deleteDocument] = useDeleteDocumentMutation();
843
891
  const _delete = React.useCallback(
844
892
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1174,7 +1222,6 @@ const useDocumentActions = () => {
1174
1222
  sourceId
1175
1223
  });
1176
1224
  if ("error" in res) {
1177
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1178
1225
  return { error: res.error };
1179
1226
  }
1180
1227
  toggleNotification({
@@ -1193,7 +1240,7 @@ const useDocumentActions = () => {
1193
1240
  throw err;
1194
1241
  }
1195
1242
  },
1196
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1243
+ [autoCloneDocument, formatMessage, toggleNotification]
1197
1244
  );
1198
1245
  const [cloneDocument] = useCloneDocumentMutation();
1199
1246
  const clone = React.useCallback(
@@ -1219,6 +1266,7 @@ const useDocumentActions = () => {
1219
1266
  defaultMessage: "Cloned document"
1220
1267
  })
1221
1268
  });
1269
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1222
1270
  return res.data;
1223
1271
  } catch (err) {
1224
1272
  toggleNotification({
@@ -1229,7 +1277,7 @@ const useDocumentActions = () => {
1229
1277
  throw err;
1230
1278
  }
1231
1279
  },
1232
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1280
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1233
1281
  );
1234
1282
  const [getDoc] = useLazyGetDocumentQuery();
1235
1283
  const getDocument = React.useCallback(
@@ -1255,7 +1303,7 @@ const useDocumentActions = () => {
1255
1303
  };
1256
1304
  };
1257
1305
  const ProtectedHistoryPage = lazy(
1258
- () => import("./History-rvLnluF0.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1306
+ () => import("./History-KY23tw1N.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1259
1307
  );
1260
1308
  const routes$1 = [
1261
1309
  {
@@ -1268,31 +1316,31 @@ const routes$1 = [
1268
1316
  }
1269
1317
  ];
1270
1318
  const ProtectedEditViewPage = lazy(
1271
- () => import("./EditViewPage-BqDlT9w0.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1319
+ () => import("./EditViewPage-Ymi21g_V.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1272
1320
  );
1273
1321
  const ProtectedListViewPage = lazy(
1274
- () => import("./ListViewPage-B8cPO1bK.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1322
+ () => import("./ListViewPage-CjkCjT3z.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1275
1323
  );
1276
1324
  const ProtectedListConfiguration = lazy(
1277
- () => import("./ListConfigurationPage-DdKfJRdq.mjs").then((mod) => ({
1325
+ () => import("./ListConfigurationPage-BrwfEo-f.mjs").then((mod) => ({
1278
1326
  default: mod.ProtectedListConfiguration
1279
1327
  }))
1280
1328
  );
1281
1329
  const ProtectedEditConfigurationPage = lazy(
1282
- () => import("./EditConfigurationPage-CuCAsHWR.mjs").then((mod) => ({
1330
+ () => import("./EditConfigurationPage-D2DPoQ3j.mjs").then((mod) => ({
1283
1331
  default: mod.ProtectedEditConfigurationPage
1284
1332
  }))
1285
1333
  );
1286
1334
  const ProtectedComponentConfigurationPage = lazy(
1287
- () => import("./ComponentConfigurationPage-DLuACgva.mjs").then((mod) => ({
1335
+ () => import("./ComponentConfigurationPage-C1B5XNIM.mjs").then((mod) => ({
1288
1336
  default: mod.ProtectedComponentConfigurationPage
1289
1337
  }))
1290
1338
  );
1291
1339
  const NoPermissions = lazy(
1292
- () => import("./NoPermissionsPage-mlXqh8p6.mjs").then((mod) => ({ default: mod.NoPermissions }))
1340
+ () => import("./NoPermissionsPage-gwaMeI0N.mjs").then((mod) => ({ default: mod.NoPermissions }))
1293
1341
  );
1294
1342
  const NoContentType = lazy(
1295
- () => import("./NoContentTypePage-CVqYTeML.mjs").then((mod) => ({ default: mod.NoContentType }))
1343
+ () => import("./NoContentTypePage-C8XPPlCu.mjs").then((mod) => ({ default: mod.NoContentType }))
1296
1344
  );
1297
1345
  const CollectionTypePages = () => {
1298
1346
  const { collectionType } = useParams();
@@ -1406,12 +1454,14 @@ const DocumentActionButton = (action) => {
1406
1454
  /* @__PURE__ */ jsx(
1407
1455
  Button,
1408
1456
  {
1409
- flex: 1,
1457
+ flex: "auto",
1410
1458
  startIcon: action.icon,
1411
1459
  disabled: action.disabled,
1412
1460
  onClick: handleClick(action),
1413
1461
  justifyContent: "center",
1414
1462
  variant: action.variant || "default",
1463
+ paddingTop: "7px",
1464
+ paddingBottom: "7px",
1415
1465
  children: action.label
1416
1466
  }
1417
1467
  ),
@@ -1471,14 +1521,14 @@ const DocumentActionsMenu = ({
1471
1521
  };
1472
1522
  return /* @__PURE__ */ jsxs(Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1473
1523
  /* @__PURE__ */ jsxs(
1474
- Menu.Trigger,
1524
+ StyledMoreButton,
1475
1525
  {
1476
1526
  disabled: isDisabled,
1477
1527
  size: "S",
1478
1528
  endIcon: null,
1479
- paddingTop: "7px",
1480
- paddingLeft: "9px",
1481
- paddingRight: "9px",
1529
+ paddingTop: "4px",
1530
+ paddingLeft: "7px",
1531
+ paddingRight: "7px",
1482
1532
  variant,
1483
1533
  children: [
1484
1534
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
@@ -1498,10 +1548,25 @@ const DocumentActionsMenu = ({
1498
1548
  onSelect: handleClick(action),
1499
1549
  display: "block",
1500
1550
  children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1501
- /* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1502
- /* @__PURE__ */ jsx(Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1503
- action.label
1504
- ] }),
1551
+ /* @__PURE__ */ jsxs(
1552
+ Flex,
1553
+ {
1554
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1555
+ gap: 2,
1556
+ tag: "span",
1557
+ children: [
1558
+ /* @__PURE__ */ jsx(
1559
+ Flex,
1560
+ {
1561
+ tag: "span",
1562
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1563
+ children: action.icon
1564
+ }
1565
+ ),
1566
+ action.label
1567
+ ]
1568
+ }
1569
+ ),
1505
1570
  action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1506
1571
  Flex,
1507
1572
  {
@@ -1572,6 +1637,11 @@ const convertActionVariantToIconColor = (variant = "secondary") => {
1572
1637
  return "primary600";
1573
1638
  }
1574
1639
  };
1640
+ const StyledMoreButton = styled(Menu.Trigger)`
1641
+ & > span {
1642
+ display: flex;
1643
+ }
1644
+ `;
1575
1645
  const DocumentActionConfirmDialog = ({
1576
1646
  onClose,
1577
1647
  onCancel,
@@ -1625,8 +1695,8 @@ const DocumentActionModal = ({
1625
1695
  };
1626
1696
  return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
1627
1697
  /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
1628
- /* @__PURE__ */ jsx(Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content }),
1629
- /* @__PURE__ */ jsx(Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer })
1698
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsx(Modal.Body, { children: Content }),
1699
+ typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1630
1700
  ] }) });
1631
1701
  };
1632
1702
  const PublishAction$1 = ({
@@ -1643,10 +1713,7 @@ const PublishAction$1 = ({
1643
1713
  const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
1644
1714
  const isCloning = useMatch(CLONE_PATH) !== null;
1645
1715
  const { formatMessage } = useIntl();
1646
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1647
- "PublishAction",
1648
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1649
- );
1716
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1650
1717
  const { publish } = useDocumentActions();
1651
1718
  const [
1652
1719
  countDraftRelations,
@@ -1766,10 +1833,8 @@ const PublishAction$1 = ({
1766
1833
  * - the document is already published & not modified
1767
1834
  * - the document is being created & not modified
1768
1835
  * - the user doesn't have the permission to publish
1769
- * - the user doesn't have the permission to create a new document
1770
- * - the user doesn't have the permission to update the document
1771
1836
  */
1772
- disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1837
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1773
1838
  label: formatMessage({
1774
1839
  id: "app.utils.publish",
1775
1840
  defaultMessage: "Publish"
@@ -1816,10 +1881,6 @@ const UpdateAction = ({
1816
1881
  const cloneMatch = useMatch(CLONE_PATH);
1817
1882
  const isCloning = cloneMatch !== null;
1818
1883
  const { formatMessage } = useIntl();
1819
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1820
- canCreate: canCreate2,
1821
- canUpdate: canUpdate2
1822
- }));
1823
1884
  const { create, update, clone } = useDocumentActions();
1824
1885
  const [{ query, rawQuery }] = useQueryParams();
1825
1886
  const params = React.useMemo(() => buildValidParams(query), [query]);
@@ -1836,10 +1897,8 @@ const UpdateAction = ({
1836
1897
  * - the form is submitting
1837
1898
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1838
1899
  * - the active tab is the published tab
1839
- * - the user doesn't have the permission to create a new document
1840
- * - the user doesn't have the permission to update the document
1841
1900
  */
1842
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
1901
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1843
1902
  label: formatMessage({
1844
1903
  id: "content-manager.containers.Edit.save",
1845
1904
  defaultMessage: "Save"
@@ -1847,16 +1906,18 @@ const UpdateAction = ({
1847
1906
  onClick: async () => {
1848
1907
  setSubmitting(true);
1849
1908
  try {
1850
- const { errors } = await validate();
1851
- if (errors) {
1852
- toggleNotification({
1853
- type: "danger",
1854
- message: formatMessage({
1855
- id: "content-manager.validation.error",
1856
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1857
- })
1858
- });
1859
- return;
1909
+ if (activeTab !== "draft") {
1910
+ const { errors } = await validate();
1911
+ if (errors) {
1912
+ toggleNotification({
1913
+ type: "danger",
1914
+ message: formatMessage({
1915
+ id: "content-manager.validation.error",
1916
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
1917
+ })
1918
+ });
1919
+ return;
1920
+ }
1860
1921
  }
1861
1922
  if (isCloning) {
1862
1923
  const res = await clone(
@@ -3140,7 +3201,13 @@ const SelectedEntriesModalContent = ({
3140
3201
  );
3141
3202
  const { rows, validationErrors } = React.useMemo(() => {
3142
3203
  if (data.length > 0 && schema) {
3143
- const validate = createYupSchema(schema.attributes, components);
3204
+ const validate = createYupSchema(
3205
+ schema.attributes,
3206
+ components,
3207
+ // Since this is the "Publish" action, the validation
3208
+ // schema must enforce the rules for published entities
3209
+ { status: "published" }
3210
+ );
3144
3211
  const validationErrors2 = {};
3145
3212
  const rows2 = data.map((entry) => {
3146
3213
  try {
@@ -3490,7 +3557,7 @@ const TableActions = ({ document }) => {
3490
3557
  DescriptionComponentRenderer,
3491
3558
  {
3492
3559
  props,
3493
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3560
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3494
3561
  children: (actions2) => {
3495
3562
  const tableRowActions = actions2.filter((action) => {
3496
3563
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3601,7 +3668,7 @@ const CloneAction = ({ model, documentId }) => {
3601
3668
  }),
3602
3669
  content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3603
3670
  footer: ({ onClose }) => {
3604
- return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
3671
+ return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3605
3672
  /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3606
3673
  id: "cancel",
3607
3674
  defaultMessage: "Cancel"
@@ -3832,7 +3899,7 @@ const index = {
3832
3899
  app.router.addRoute({
3833
3900
  path: "content-manager/*",
3834
3901
  lazy: async () => {
3835
- const { Layout } = await import("./layout-Dewoec1b.mjs");
3902
+ const { Layout } = await import("./layout-2aGdWAdb.mjs");
3836
3903
  return {
3837
3904
  Component: Layout
3838
3905
  };
@@ -3870,13 +3937,14 @@ export {
3870
3937
  BulkActionsRenderer as B,
3871
3938
  COLLECTION_TYPES as C,
3872
3939
  DocumentStatus as D,
3873
- DEFAULT_SETTINGS as E,
3874
- convertEditLayoutToFieldLayouts as F,
3875
- useDocument as G,
3940
+ extractContentTypeComponents as E,
3941
+ DEFAULT_SETTINGS as F,
3942
+ convertEditLayoutToFieldLayouts as G,
3876
3943
  HOOKS as H,
3877
3944
  InjectionZone as I,
3878
- index as J,
3879
- useDocumentActions as K,
3945
+ useDocument as J,
3946
+ index as K,
3947
+ useDocumentActions as L,
3880
3948
  Panels as P,
3881
3949
  RelativeTime as R,
3882
3950
  SINGLE_TYPES as S,
@@ -3894,18 +3962,18 @@ export {
3894
3962
  PERMISSIONS as k,
3895
3963
  DocumentRBAC as l,
3896
3964
  DOCUMENT_META_FIELDS as m,
3897
- useDocLayout as n,
3898
- useGetContentTypeConfigurationQuery as o,
3899
- CREATOR_FIELDS as p,
3900
- getMainField as q,
3901
- getDisplayName as r,
3965
+ CLONE_PATH as n,
3966
+ useDocLayout as o,
3967
+ useGetContentTypeConfigurationQuery as p,
3968
+ CREATOR_FIELDS as q,
3969
+ getMainField as r,
3902
3970
  setInitialData as s,
3903
- checkIfAttributeIsDisplayable as t,
3971
+ getDisplayName as t,
3904
3972
  useContentTypeSchema as u,
3905
- useGetAllDocumentsQuery as v,
3906
- convertListLayoutToFieldLayouts as w,
3907
- capitalise as x,
3908
- useUpdateContentTypeConfigurationMutation as y,
3909
- extractContentTypeComponents as z
3973
+ checkIfAttributeIsDisplayable as v,
3974
+ useGetAllDocumentsQuery as w,
3975
+ convertListLayoutToFieldLayouts as x,
3976
+ capitalise as y,
3977
+ useUpdateContentTypeConfigurationMutation as z
3910
3978
  };
3911
- //# sourceMappingURL=index-JSJrqmB9.mjs.map
3979
+ //# sourceMappingURL=index-CS6TpAQJ.mjs.map