@strapi/review-workflows 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.e8d8fc824d0f6a695b2a9ebaa4680ed21c3645ca

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 (93) hide show
  1. package/LICENSE +12 -17
  2. package/dist/_chunks/{Layout-BemsgaWF.js → Layout-C3IORH2n.js} +12 -22
  3. package/dist/_chunks/Layout-C3IORH2n.js.map +1 -0
  4. package/dist/_chunks/{Layout-BSrg0PBJ.mjs → Layout-DNKR5bym.mjs} +11 -18
  5. package/dist/_chunks/Layout-DNKR5bym.mjs.map +1 -0
  6. package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
  7. package/dist/_chunks/en-CYgjfSep.js.map +1 -0
  8. package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
  9. package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
  10. package/dist/_chunks/{_id-DO302-GM.mjs → id-C9Ku9Br9.mjs} +384 -381
  11. package/dist/_chunks/id-C9Ku9Br9.mjs.map +1 -0
  12. package/dist/_chunks/{_id-BDSg16su.js → id-oOE1bYls.js} +389 -389
  13. package/dist/_chunks/id-oOE1bYls.js.map +1 -0
  14. package/dist/_chunks/{index-7V_6cgRk.mjs → index-ByXbOW-R.mjs} +194 -229
  15. package/dist/_chunks/index-ByXbOW-R.mjs.map +1 -0
  16. package/dist/_chunks/{index-DV2HXfsG.js → index-CmHHjN95.js} +22 -53
  17. package/dist/_chunks/index-CmHHjN95.js.map +1 -0
  18. package/dist/_chunks/{index-u8XaKwOw.mjs → index-CyhaJuJG.mjs} +23 -51
  19. package/dist/_chunks/index-CyhaJuJG.mjs.map +1 -0
  20. package/dist/_chunks/{index-BIHOhXvS.js → index-DMT27jNE.js} +192 -230
  21. package/dist/_chunks/index-DMT27jNE.js.map +1 -0
  22. package/dist/_chunks/{purchase-review-workflows-DlCDg0fD.js → purchase-review-workflows-BxoDFxQ5.js} +2 -2
  23. package/dist/_chunks/purchase-review-workflows-BxoDFxQ5.js.map +1 -0
  24. package/dist/_chunks/{purchase-review-workflows-BN-5Ube7.mjs → purchase-review-workflows-DyFV_H0I.mjs} +2 -2
  25. package/dist/_chunks/{purchase-review-workflows-BN-5Ube7.mjs.map → purchase-review-workflows-DyFV_H0I.mjs.map} +1 -1
  26. package/dist/_chunks/{router-BdBbXIaZ.mjs → router-BPl2HZMq.mjs} +3 -3
  27. package/dist/_chunks/router-BPl2HZMq.mjs.map +1 -0
  28. package/dist/_chunks/{router-BtE6OQHw.js → router-vDfGt9bq.js} +3 -3
  29. package/dist/_chunks/router-vDfGt9bq.js.map +1 -0
  30. package/dist/admin/index.js +1 -1
  31. package/dist/admin/index.mjs +1 -1
  32. package/dist/admin/src/components/LimitsModal.d.ts +2 -4
  33. package/dist/admin/src/routes/settings/hooks/useDragAndDrop.d.ts +4 -4
  34. package/dist/admin/src/routes/settings/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  35. package/dist/admin/src/routes/settings/hooks/useReviewWorkflows.d.ts +3 -3
  36. package/dist/admin/src/services/admin.d.ts +2 -2
  37. package/dist/admin/src/services/api.d.ts +2 -3
  38. package/dist/admin/src/services/content-manager.d.ts +6 -6
  39. package/dist/admin/src/services/settings.d.ts +1740 -10
  40. package/dist/admin/src/utils/api.d.ts +4 -19
  41. package/dist/server/index.js +455 -628
  42. package/dist/server/index.js.map +1 -1
  43. package/dist/server/index.mjs +455 -628
  44. package/dist/server/index.mjs.map +1 -1
  45. package/dist/server/src/bootstrap.d.ts.map +1 -1
  46. package/dist/server/src/constants/workflows.d.ts +1 -0
  47. package/dist/server/src/constants/workflows.d.ts.map +1 -1
  48. package/dist/server/src/content-types/index.d.ts +6 -0
  49. package/dist/server/src/content-types/index.d.ts.map +1 -1
  50. package/dist/server/src/content-types/workflow/index.d.ts +6 -0
  51. package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
  52. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  53. package/dist/server/src/controllers/index.d.ts +0 -1
  54. package/dist/server/src/controllers/index.d.ts.map +1 -1
  55. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  56. package/dist/server/src/controllers/workflows.d.ts +0 -7
  57. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  58. package/dist/server/src/index.d.ts +28 -7
  59. package/dist/server/src/index.d.ts.map +1 -1
  60. package/dist/server/src/register.d.ts.map +1 -1
  61. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  62. package/dist/server/src/services/assignees.d.ts +8 -4
  63. package/dist/server/src/services/assignees.d.ts.map +1 -1
  64. package/dist/server/src/services/document-service-middleware.d.ts +1 -0
  65. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  66. package/dist/server/src/services/index.d.ts +16 -6
  67. package/dist/server/src/services/index.d.ts.map +1 -1
  68. package/dist/server/src/services/metrics/index.d.ts +4 -4
  69. package/dist/server/src/services/metrics/index.d.ts.map +1 -1
  70. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  71. package/dist/server/src/services/stages.d.ts +7 -7
  72. package/dist/server/src/services/stages.d.ts.map +1 -1
  73. package/dist/server/src/services/workflows.d.ts.map +1 -1
  74. package/dist/server/src/validation/review-workflows.d.ts +4 -0
  75. package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
  76. package/dist/shared/contracts/review-workflows.d.ts +9 -17
  77. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  78. package/package.json +17 -19
  79. package/dist/_chunks/Layout-BSrg0PBJ.mjs.map +0 -1
  80. package/dist/_chunks/Layout-BemsgaWF.js.map +0 -1
  81. package/dist/_chunks/_id-BDSg16su.js.map +0 -1
  82. package/dist/_chunks/_id-DO302-GM.mjs.map +0 -1
  83. package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
  84. package/dist/_chunks/en-xcewH2pC.js.map +0 -1
  85. package/dist/_chunks/index-7V_6cgRk.mjs.map +0 -1
  86. package/dist/_chunks/index-BIHOhXvS.js.map +0 -1
  87. package/dist/_chunks/index-DV2HXfsG.js.map +0 -1
  88. package/dist/_chunks/index-u8XaKwOw.mjs.map +0 -1
  89. package/dist/_chunks/purchase-review-workflows-DlCDg0fD.js.map +0 -1
  90. package/dist/_chunks/router-BdBbXIaZ.mjs.map +0 -1
  91. package/dist/_chunks/router-BtE6OQHw.js.map +0 -1
  92. package/strapi-server.js +0 -3
  93. /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
@@ -8,18 +8,15 @@ const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const fractionalIndexing = require("fractional-indexing");
10
10
  const reactIntl = require("react-intl");
11
- const reactRedux = require("react-redux");
12
11
  const reactRouterDom = require("react-router-dom");
13
12
  const yup = require("yup");
14
- const index = require("./index-BIHOhXvS.js");
15
- const Layout = require("./Layout-BemsgaWF.js");
13
+ const index = require("./index-DMT27jNE.js");
14
+ const Layout = require("./Layout-C3IORH2n.js");
16
15
  const reactDndHtml5Backend = require("react-dnd-html5-backend");
17
- const styled = require("styled-components");
16
+ const styledComponents = require("styled-components");
18
17
  const reactDnd = require("react-dnd");
19
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
20
18
  function _interopNamespace(e) {
21
- if (e && e.__esModule)
22
- return e;
19
+ if (e && e.__esModule) return e;
23
20
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
24
21
  if (e) {
25
22
  for (const k in e) {
@@ -37,11 +34,10 @@ function _interopNamespace(e) {
37
34
  }
38
35
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
39
36
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
40
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
41
37
  const adminApi = index.reviewWorkflowsApi.injectEndpoints({
42
38
  endpoints(builder) {
43
39
  return {
44
- getRoles: builder.query({
40
+ getAdminRoles: builder.query({
45
41
  query: () => ({
46
42
  url: `/admin/roles`,
47
43
  method: "GET"
@@ -53,7 +49,7 @@ const adminApi = index.reviewWorkflowsApi.injectEndpoints({
53
49
  };
54
50
  }
55
51
  });
56
- const { useGetRolesQuery } = adminApi;
52
+ const { useGetAdminRolesQuery } = adminApi;
57
53
  const useKeyboardDragAndDrop = (active, index2, { onCancel, onDropItem, onGrabItem, onMoveItem }) => {
58
54
  const [isSelected, setIsSelected] = React__namespace.useState(false);
59
55
  const handleMove = (movement) => {
@@ -162,8 +158,7 @@ const useDragAndDrop = (active, {
162
158
  const hoverBoundingRect = objectRef.current?.getBoundingClientRect();
163
159
  const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
164
160
  const clientOffset = monitor.getClientOffset();
165
- if (!clientOffset)
166
- return;
161
+ if (!clientOffset) return;
167
162
  const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;
168
163
  if (typeof dragIndex === "number" && typeof newIndex === "number") {
169
164
  if (dragIndex === newIndex) {
@@ -216,10 +211,8 @@ const useDragAndDrop = (active, {
216
211
  const getDragDirection = (monitor) => {
217
212
  if (monitor && monitor.isDragging() && !monitor.didDrop() && monitor.getInitialClientOffset() && monitor.getClientOffset()) {
218
213
  const deltaY = monitor.getInitialClientOffset().y - monitor.getClientOffset().y;
219
- if (deltaY > 0)
220
- return DIRECTIONS.UPWARD;
221
- if (deltaY < 0)
222
- return DIRECTIONS.DOWNWARD;
214
+ if (deltaY > 0) return DIRECTIONS.UPWARD;
215
+ if (deltaY < 0) return DIRECTIONS.DOWNWARD;
223
216
  return null;
224
217
  }
225
218
  return null;
@@ -272,23 +265,23 @@ const AddStage = ({ children, ...props }) => {
272
265
  return /* @__PURE__ */ jsxRuntime.jsx(
273
266
  StyledButton,
274
267
  {
275
- as: "button",
268
+ tag: "button",
276
269
  background: "neutral0",
277
- border: "neutral150",
270
+ borderColor: "neutral150",
278
271
  paddingBottom: 3,
279
272
  paddingLeft: 4,
280
273
  paddingRight: 4,
281
274
  paddingTop: 3,
282
275
  shadow: "filterShadow",
283
276
  ...props,
284
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "inherit", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { as: "span", gap: 2, children: [
277
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
285
278
  /* @__PURE__ */ jsxRuntime.jsx(icons.PlusCircle, { width: "2.4rem", height: "2.4rem", "aria-hidden": true }),
286
279
  children
287
280
  ] }) })
288
281
  }
289
282
  );
290
283
  };
291
- const StyledButton = styled__default.default(designSystem.Box)`
284
+ const StyledButton = styledComponents.styled(designSystem.Box)`
292
285
  border-radius: 26px;
293
286
  color: ${({ theme }) => theme.colors.neutral500};
294
287
 
@@ -300,7 +293,7 @@ const StyledButton = styled__default.default(designSystem.Box)`
300
293
  color: ${({ theme }) => theme.colors.primary600};
301
294
  }
302
295
  `;
303
- const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
296
+ const Stages = ({ canDelete = true, canUpdate = true, isCreating }) => {
304
297
  const { formatMessage } = reactIntl.useIntl();
305
298
  const { trackUsage } = strapiAdmin.useTracking();
306
299
  const addFieldRow = strapiAdmin.useForm("Stages", (state) => state.addFieldRow);
@@ -315,35 +308,23 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
315
308
  left: "50%",
316
309
  position: "absolute",
317
310
  top: "0",
318
- width: 2,
319
- zIndex: 1
311
+ width: 2
320
312
  }
321
313
  ),
322
- /* @__PURE__ */ jsxRuntime.jsx(
323
- designSystem.Flex,
324
- {
325
- direction: "column",
326
- alignItems: "stretch",
327
- gap: 6,
328
- zIndex: 2,
329
- position: "relative",
330
- as: "ol",
331
- children: stages.map((stage, index2) => {
332
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { as: "li", children: /* @__PURE__ */ jsxRuntime.jsx(
333
- Stage,
334
- {
335
- index: index2,
336
- canDelete: stages.length > 1 && canDelete,
337
- canReorder: stages.length > 1,
338
- canUpdate,
339
- stagesCount: stages.length,
340
- isOpen: isCreating,
341
- ...stage
342
- }
343
- ) }, stage.__temp_key__);
344
- })
345
- }
346
- )
314
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, position: "relative", tag: "ol", children: stages.map((stage, index2) => {
315
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(
316
+ Stage,
317
+ {
318
+ index: index2,
319
+ canDelete: stages.length > 1 && canDelete,
320
+ canReorder: stages.length > 1,
321
+ canUpdate,
322
+ stagesCount: stages.length,
323
+ defaultOpen: !stage.id,
324
+ ...stage
325
+ }
326
+ ) }, stage.__temp_key__);
327
+ }) })
347
328
  ] }),
348
329
  canUpdate && /* @__PURE__ */ jsxRuntime.jsx(
349
330
  AddStage,
@@ -361,7 +342,7 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
361
342
  )
362
343
  ] });
363
344
  };
364
- const Background = styled__default.default(designSystem.Box)`
345
+ const Background = styledComponents.styled(designSystem.Box)`
365
346
  transform: translateX(-50%);
366
347
  `;
367
348
  const Stage = ({
@@ -369,16 +350,15 @@ const Stage = ({
369
350
  canDelete = false,
370
351
  canReorder = false,
371
352
  canUpdate = false,
372
- isOpen: isOpenDefault = false,
373
353
  stagesCount,
374
354
  name,
375
355
  permissions,
376
- color
356
+ color,
357
+ defaultOpen
377
358
  }) => {
378
359
  const [liveText, setLiveText] = React__namespace.useState();
379
360
  const { formatMessage } = reactIntl.useIntl();
380
361
  const { trackUsage } = strapiAdmin.useTracking();
381
- const [isOpen, setIsOpen] = React__namespace.useState(isOpenDefault);
382
362
  const stageErrors = strapiAdmin.useForm("Stages", (state) => state.errors.stages);
383
363
  const error = stageErrors?.[index2];
384
364
  const addFieldRow = strapiAdmin.useForm("Stage", (state) => state.addFieldRow);
@@ -460,7 +440,8 @@ const Stage = ({
460
440
  const handleCloneClick = () => {
461
441
  addFieldRow("stages", { name, color, permissions });
462
442
  };
463
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { ref: (ref) => composedRef(ref), children: [
443
+ const id = React__namespace.useId();
444
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { ref: composedRef, shadow: "tableShadow", children: [
464
445
  liveText && /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
465
446
  isDragging ? /* @__PURE__ */ jsxRuntime.jsx(
466
447
  designSystem.Box,
@@ -471,74 +452,61 @@ const Stage = ({
471
452
  borderWidth: "1px",
472
453
  display: "block",
473
454
  hasRadius: true,
474
- padding: 6,
475
- shadow: "tableShadow"
455
+ padding: 6
476
456
  }
477
- ) : /* @__PURE__ */ jsxRuntime.jsxs(
478
- designSystem.Accordion,
457
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
458
+ AccordionRoot,
479
459
  {
480
- size: "S",
481
- variant: "primary",
482
- onToggle: () => {
483
- setIsOpen(!isOpen);
484
- if (!isOpen) {
460
+ onValueChange: (value) => {
461
+ if (value) {
485
462
  trackUsage("willEditStage");
486
463
  }
487
464
  },
488
- expanded: isOpen,
489
- shadow: "tableShadow",
490
- error: Object.values(error ?? {})[0],
491
- hasErrorMessage: false,
492
- children: [
493
- /* @__PURE__ */ jsxRuntime.jsx(
494
- designSystem.AccordionToggle,
495
- {
496
- title: name,
497
- togglePosition: "left",
498
- action: (canDelete || canUpdate) && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
499
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
500
- /* @__PURE__ */ jsxRuntime.jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
501
- /* @__PURE__ */ jsxRuntime.jsx(icons.More, { "aria-hidden": true, focusable: false }),
502
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { as: "span", children: formatMessage({
503
- id: "[tbdb].components.DynamicZone.more-actions",
504
- defaultMessage: "More actions"
505
- }) })
506
- ] }),
507
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
508
- canUpdate && /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onClick: handleCloneClick, children: formatMessage({
509
- id: "Settings.review-workflows.stage.delete",
510
- defaultMessage: "Duplicate stage"
511
- }) }),
512
- canDelete && /* @__PURE__ */ jsxRuntime.jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index2), children: formatMessage({
513
- id: "Settings.review-workflows.stage.delete",
514
- defaultMessage: "Delete"
515
- }) })
516
- ] }) })
465
+ defaultValue: defaultOpen ? id : void 0,
466
+ $error: Object.values(error ?? {}).length > 0,
467
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: id, children: [
468
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: name }),
470
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: canDelete || canUpdate ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
471
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
472
+ /* @__PURE__ */ jsxRuntime.jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
473
+ /* @__PURE__ */ jsxRuntime.jsx(icons.More, { "aria-hidden": true, focusable: false }),
474
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage({
475
+ id: "[tbdb].components.DynamicZone.more-actions",
476
+ defaultMessage: "More actions"
477
+ }) })
517
478
  ] }),
518
- canUpdate && /* @__PURE__ */ jsxRuntime.jsx(
519
- DragIconButton,
520
- {
521
- background: "transparent",
522
- forwardedAs: "div",
523
- hasRadius: true,
524
- role: "button",
525
- noBorder: true,
526
- tabIndex: 0,
527
- "data-handler-id": handlerId,
528
- ref: dragRef,
529
- label: formatMessage({
530
- id: "Settings.review-workflows.stage.drag",
531
- defaultMessage: "Drag"
532
- }),
533
- onClick: (e) => e.stopPropagation(),
534
- onKeyDown: handleKeyDown,
535
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Drag, {})
536
- }
537
- )
538
- ] })
539
- }
540
- ),
541
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.AccordionContent, { padding: 6, background: "neutral0", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid, { gap: 4, children: [
479
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
480
+ canUpdate && /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onClick: handleCloneClick, children: formatMessage({
481
+ id: "Settings.review-workflows.stage.delete",
482
+ defaultMessage: "Duplicate stage"
483
+ }) }),
484
+ canDelete && /* @__PURE__ */ jsxRuntime.jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index2), children: formatMessage({
485
+ id: "Settings.review-workflows.stage.delete",
486
+ defaultMessage: "Delete"
487
+ }) })
488
+ ] }) })
489
+ ] }),
490
+ canUpdate && /* @__PURE__ */ jsxRuntime.jsx(
491
+ designSystem.IconButton,
492
+ {
493
+ background: "transparent",
494
+ hasRadius: true,
495
+ variant: "ghost",
496
+ "data-handler-id": handlerId,
497
+ ref: dragRef,
498
+ label: formatMessage({
499
+ id: "Settings.review-workflows.stage.drag",
500
+ defaultMessage: "Drag"
501
+ }),
502
+ onClick: (e) => e.stopPropagation(),
503
+ onKeyDown: handleKeyDown,
504
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Drag, {})
505
+ }
506
+ )
507
+ ] }) : null })
508
+ ] }),
509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, padding: 6, children: [
542
510
  {
543
511
  disabled: !canUpdate,
544
512
  label: formatMessage({
@@ -576,16 +544,20 @@ const Stage = ({
576
544
  size: 6,
577
545
  type: "permissions"
578
546
  }
579
- ].map(({ size, ...field }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, children: /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...field }) }, field.name)) }) })
580
- ]
547
+ ].map(({ size, ...field }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: size, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...field }) }, field.name)) }) })
548
+ ] })
581
549
  }
582
550
  )
583
551
  ] });
584
552
  };
585
- const DeleteMenuItem = styled__default.default(designSystem.MenuItem)`
553
+ const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
554
+ border: 1px solid
555
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
556
+ `;
557
+ const DeleteMenuItem = styledComponents.styled(designSystem.MenuItem)`
586
558
  color: ${({ theme }) => theme.colors.danger600};
587
559
  `;
588
- const ContextMenuTrigger = styled__default.default(designSystem.Menu.Trigger)`
560
+ const ContextMenuTrigger = styledComponents.styled(designSystem.Menu.Trigger)`
589
561
  :hover,
590
562
  :focus {
591
563
  background-color: ${({ theme }) => theme.colors.neutral100};
@@ -595,22 +567,6 @@ const ContextMenuTrigger = styled__default.default(designSystem.Menu.Trigger)`
595
567
  font-size: 0;
596
568
  }
597
569
  `;
598
- const DragIconButton = styled__default.default(designSystem.IconButton)`
599
- align-items: center;
600
- border-radius: ${({ theme }) => theme.borderRadius};
601
- display: flex;
602
- justify-content: center;
603
-
604
- &:hover,
605
- &:focus {
606
- background-color: ${({ theme }) => theme.colors.neutral100};
607
- }
608
-
609
- svg {
610
- height: auto;
611
- width: ${({ theme }) => theme.spaces[3]};
612
- }
613
- `;
614
570
  const InputRenderer = (props) => {
615
571
  switch (props.type) {
616
572
  case "color":
@@ -636,54 +592,55 @@ const ColorSelector = ({ disabled, label, name, required }) => {
636
592
  color: hex
637
593
  }));
638
594
  const { themeColorName } = index.getStageColorByHex(value) ?? {};
639
- return /* @__PURE__ */ jsxRuntime.jsx(
640
- designSystem.SingleSelect,
641
- {
642
- disabled,
643
- error,
644
- required,
645
- label,
646
- onChange: (v) => {
647
- onChange(name, v.toString());
648
- },
649
- value: value?.toUpperCase(),
650
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(
651
- designSystem.Flex,
652
- {
653
- as: "span",
654
- height: 2,
655
- background: value,
656
- borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
657
- hasRadius: true,
658
- shrink: 0,
659
- width: 2
660
- }
661
- ),
662
- children: colorOptions.map(({ value: value2, label: label2, color }) => {
663
- const { themeColorName: themeColorName2 } = index.getStageColorByHex(color) || {};
664
- return /* @__PURE__ */ jsxRuntime.jsx(
665
- designSystem.SingleSelectOption,
595
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error, name, required, children: [
596
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
597
+ /* @__PURE__ */ jsxRuntime.jsx(
598
+ designSystem.SingleSelect,
599
+ {
600
+ disabled,
601
+ onChange: (v) => {
602
+ onChange(name, v.toString());
603
+ },
604
+ value: value?.toUpperCase(),
605
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(
606
+ designSystem.Flex,
666
607
  {
667
- value: value2,
668
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(
669
- designSystem.Flex,
670
- {
671
- as: "span",
672
- height: 2,
673
- background: color,
674
- borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
675
- hasRadius: true,
676
- shrink: 0,
677
- width: 2
678
- }
679
- ),
680
- children: label2
681
- },
682
- value2
683
- );
684
- })
685
- }
686
- );
608
+ tag: "span",
609
+ height: 2,
610
+ background: value,
611
+ borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
612
+ hasRadius: true,
613
+ shrink: 0,
614
+ width: 2
615
+ }
616
+ ),
617
+ children: colorOptions.map(({ value: value2, label: label2, color }) => {
618
+ const { themeColorName: themeColorName2 } = index.getStageColorByHex(color) || {};
619
+ return /* @__PURE__ */ jsxRuntime.jsx(
620
+ designSystem.SingleSelectOption,
621
+ {
622
+ value: value2,
623
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(
624
+ designSystem.Flex,
625
+ {
626
+ tag: "span",
627
+ height: 2,
628
+ background: color,
629
+ borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
630
+ hasRadius: true,
631
+ shrink: 0,
632
+ width: 2
633
+ }
634
+ ),
635
+ children: label2
636
+ },
637
+ value2
638
+ );
639
+ })
640
+ }
641
+ ),
642
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
643
+ ] });
687
644
  };
688
645
  const PermissionsField = ({ disabled, name, placeholder, required }) => {
689
646
  const { formatMessage } = reactIntl.useIntl();
@@ -692,57 +649,65 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
692
649
  const { value = [], error, onChange } = strapiAdmin.useField(name);
693
650
  const allStages = strapiAdmin.useForm("PermissionsField", (state) => state.values.stages);
694
651
  const onFormValueChange = strapiAdmin.useForm("PermissionsField", (state) => state.onChange);
695
- const { data: roles = [], isLoading } = useGetRolesQuery();
652
+ const rolesErrorCount = React__namespace.useRef(0);
653
+ const { data: roles = [], isLoading, error: getRolesError } = useGetAdminRolesQuery();
696
654
  const filteredRoles = roles?.filter((role) => role.code !== "strapi-super-admin") ?? [];
697
655
  React__namespace.useEffect(() => {
698
- if (!isLoading && roles.length === 0) {
656
+ if (!isLoading && getRolesError && "status" in getRolesError && getRolesError.status == 403 && rolesErrorCount.current === 0) {
657
+ rolesErrorCount.current = 1;
699
658
  toggleNotification({
700
659
  blockTransition: true,
701
660
  type: "danger",
702
661
  message: formatMessage({
703
662
  id: "review-workflows.stage.permissions.noPermissions.description",
704
- defaultMessage: "You don’t have the permission to see roles"
663
+ defaultMessage: "You don’t have the permission to see roles. Contact your administrator."
705
664
  })
706
665
  });
707
666
  }
708
- }, [formatMessage, isLoading, roles, toggleNotification]);
667
+ }, [formatMessage, isLoading, roles, toggleNotification, getRolesError]);
709
668
  if (!isLoading && filteredRoles.length === 0) {
710
- return /* @__PURE__ */ jsxRuntime.jsx(
711
- designSystem.TextInput,
669
+ return /* @__PURE__ */ jsxRuntime.jsxs(
670
+ designSystem.Field.Root,
712
671
  {
713
- disabled: true,
714
672
  name,
715
673
  hint: formatMessage({
716
674
  id: "Settings.review-workflows.stage.permissions.noPermissions.description",
717
675
  defaultMessage: "You don’t have the permission to see roles"
718
676
  }),
719
- label: formatMessage({
720
- id: "Settings.review-workflows.stage.permissions.label",
721
- defaultMessage: "Roles that can change this stage"
722
- }),
723
- placeholder: formatMessage({
724
- id: "components.NotAllowedInput.text",
725
- defaultMessage: "No permissions to see this field"
726
- }),
727
677
  required,
728
- startAction: /* @__PURE__ */ jsxRuntime.jsx(StyledIcon, {}),
729
- type: "text",
730
- value: ""
678
+ children: [
679
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
680
+ id: "Settings.review-workflows.stage.permissions.label",
681
+ defaultMessage: "Roles that can change this stage"
682
+ }) }),
683
+ /* @__PURE__ */ jsxRuntime.jsx(
684
+ designSystem.TextInput,
685
+ {
686
+ disabled: true,
687
+ placeholder: formatMessage({
688
+ id: "components.NotAllowedInput.text",
689
+ defaultMessage: "No permissions to see this field"
690
+ }),
691
+ startAction: /* @__PURE__ */ jsxRuntime.jsx(icons.EyeStriked, { fill: "neutral600" }),
692
+ type: "text",
693
+ value: ""
694
+ }
695
+ ),
696
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
697
+ ]
731
698
  }
732
699
  );
733
700
  }
734
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
735
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-end", gap: 3, children: [
736
- /* @__PURE__ */ jsxRuntime.jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
701
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-end", gap: 3, children: [
702
+ /* @__PURE__ */ jsxRuntime.jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error, name, required: true, children: [
703
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
704
+ id: "Settings.review-workflows.stage.permissions.label",
705
+ defaultMessage: "Roles that can change this stage"
706
+ }) }),
707
+ /* @__PURE__ */ jsxRuntime.jsx(
737
708
  designSystem.MultiSelect,
738
709
  {
739
710
  disabled,
740
- error,
741
- id: name,
742
- label: formatMessage({
743
- id: "Settings.review-workflows.stage.permissions.label",
744
- defaultMessage: "Roles that can change this stage"
745
- }),
746
711
  onChange: (values) => {
747
712
  const permissions = values.map((value2) => ({
748
713
  role: parseInt(value2, 10),
@@ -751,7 +716,6 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
751
716
  onChange(name, permissions);
752
717
  },
753
718
  placeholder,
754
- required: true,
755
719
  value: value.map((permission) => `${permission.role}`),
756
720
  withTags: true,
757
721
  children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -768,70 +732,64 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
768
732
  }
769
733
  )
770
734
  }
771
- ) }),
772
- /* @__PURE__ */ jsxRuntime.jsx(
735
+ ),
736
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
737
+ ] }) }),
738
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open: isApplyAllConfirmationOpen, onOpenChange: setIsApplyAllConfirmationOpen, children: [
739
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
773
740
  designSystem.IconButton,
774
741
  {
775
742
  disabled,
776
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}),
777
743
  label: formatMessage({
778
744
  id: "Settings.review-workflows.stage.permissions.apply.label",
779
745
  defaultMessage: "Apply to all stages"
780
746
  }),
781
747
  size: "L",
782
- variant: "secondary",
783
- onClick: () => setIsApplyAllConfirmationOpen(true)
748
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {})
749
+ }
750
+ ) }),
751
+ /* @__PURE__ */ jsxRuntime.jsx(
752
+ strapiAdmin.ConfirmDialog,
753
+ {
754
+ onConfirm: () => {
755
+ onFormValueChange(
756
+ "stages",
757
+ allStages.map((stage) => ({
758
+ ...stage,
759
+ permissions: value
760
+ }))
761
+ );
762
+ setIsApplyAllConfirmationOpen(false);
763
+ toggleNotification({
764
+ type: "success",
765
+ message: formatMessage({
766
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
767
+ defaultMessage: "Applied roles to all other stages of the workflow"
768
+ })
769
+ });
770
+ },
771
+ variant: "default",
772
+ children: formatMessage({
773
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
774
+ defaultMessage: "Roles that can change that stage will be applied to all the other stages."
775
+ })
784
776
  }
785
777
  )
786
- ] }),
787
- /* @__PURE__ */ jsxRuntime.jsx(
788
- strapiAdmin.ConfirmDialog,
789
- {
790
- isOpen: isApplyAllConfirmationOpen,
791
- onClose: () => setIsApplyAllConfirmationOpen(false),
792
- onConfirm: () => {
793
- onFormValueChange(
794
- "stages",
795
- allStages.map((stage) => ({
796
- ...stage,
797
- permissions: value
798
- }))
799
- );
800
- setIsApplyAllConfirmationOpen(false);
801
- toggleNotification({
802
- type: "success",
803
- message: formatMessage({
804
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
805
- defaultMessage: "Applied roles to all other stages of the workflow"
806
- })
807
- });
808
- },
809
- variant: "default",
810
- children: formatMessage({
811
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
812
- defaultMessage: "Roles that can change that stage will be applied to all the other stages."
813
- })
814
- }
815
- )
816
- ] });
778
+ ] })
779
+ ] }) });
817
780
  };
818
- const StyledIcon = styled__default.default(icons.EyeStriked)`
819
- & > path {
820
- fill: ${({ theme }) => theme.colors.neutral600};
821
- }
822
- `;
823
- const NestedOption$1 = styled__default.default(designSystem.MultiSelectOption)`
781
+ const NestedOption$1 = styledComponents.styled(designSystem.MultiSelectOption)`
824
782
  padding-left: ${({ theme }) => theme.spaces[7]};
825
783
  `;
826
- const PermissionWrapper = styled__default.default(designSystem.Flex)`
784
+ const PermissionWrapper = styledComponents.styled(designSystem.Flex)`
827
785
  > * {
828
786
  flex-grow: 1;
829
787
  }
830
788
  `;
831
789
  const WorkflowAttributes = ({ canUpdate = true }) => {
832
790
  const { formatMessage } = reactIntl.useIntl();
833
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
834
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
791
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
792
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
835
793
  strapiAdmin.InputRenderer,
836
794
  {
837
795
  disabled: !canUpdate,
@@ -844,7 +802,8 @@ const WorkflowAttributes = ({ canUpdate = true }) => {
844
802
  type: "string"
845
803
  }
846
804
  ) }),
847
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(ContentTypesSelector, { disabled: !canUpdate }) })
805
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(ContentTypesSelector, { disabled: !canUpdate }) }),
806
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(StageSelector, { disabled: !canUpdate }) })
848
807
  ] });
849
808
  };
850
809
  const ContentTypesSelector = ({ disabled }) => {
@@ -865,97 +824,146 @@ const ContentTypesSelector = ({ disabled }) => {
865
824
  label: contentType.info.displayName,
866
825
  value: contentType.uid
867
826
  }));
868
- return /* @__PURE__ */ jsxRuntime.jsx(
869
- designSystem.MultiSelect,
870
- {
871
- customizeContent: (value2) => formatMessage(
872
- {
873
- id: "Settings.review-workflows.workflow.contentTypes.displayValue",
874
- defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
827
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error, name: "contentTypes", children: [
828
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
829
+ id: "Settings.review-workflows.workflow.contentTypes.label",
830
+ defaultMessage: "Associated to"
831
+ }) }),
832
+ /* @__PURE__ */ jsxRuntime.jsx(
833
+ designSystem.MultiSelect,
834
+ {
835
+ customizeContent: (value2) => formatMessage(
836
+ {
837
+ id: "Settings.review-workflows.workflow.contentTypes.displayValue",
838
+ defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
839
+ },
840
+ { count: value2?.length }
841
+ ),
842
+ disabled: isDisabled,
843
+ onChange: (values) => {
844
+ onChange("contentTypes", values);
875
845
  },
876
- { count: value2?.length }
877
- ),
878
- disabled: isDisabled,
846
+ value,
847
+ placeholder: formatMessage({
848
+ id: "Settings.review-workflows.workflow.contentTypes.placeholder",
849
+ defaultMessage: "Select"
850
+ }),
851
+ children: [
852
+ ...collectionTypes.length > 0 ? [
853
+ {
854
+ label: formatMessage({
855
+ id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
856
+ defaultMessage: "Collection Types"
857
+ }),
858
+ children: collectionTypes
859
+ }
860
+ ] : [],
861
+ ...singleTypes.length > 0 ? [
862
+ {
863
+ label: formatMessage({
864
+ id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
865
+ defaultMessage: "Single Types"
866
+ }),
867
+ children: singleTypes
868
+ }
869
+ ] : []
870
+ ].map((opt) => {
871
+ return /* @__PURE__ */ jsxRuntime.jsx(
872
+ designSystem.MultiSelectGroup,
873
+ {
874
+ label: opt.label,
875
+ values: opt.children.map((child) => child.value.toString()),
876
+ children: opt.children.map((child) => {
877
+ const { name: assignedWorkflowName } = workflows?.find(
878
+ (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
879
+ ) ?? {};
880
+ return /* @__PURE__ */ jsxRuntime.jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
881
+ // @ts-expect-error - formatMessage options doesn't expect to be a React component but that's what we need actually for the <i> and <em> components
882
+ children: formatMessage(
883
+ {
884
+ id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
885
+ defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
886
+ },
887
+ {
888
+ label: child.label,
889
+ name: assignedWorkflowName,
890
+ em: (...children) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "em", fontWeight: "bold", children }),
891
+ i: (...children) => /* @__PURE__ */ jsxRuntime.jsx(ContentTypeTakeNotice, { children })
892
+ }
893
+ )
894
+ }) }, child.value);
895
+ })
896
+ },
897
+ opt.label
898
+ );
899
+ })
900
+ }
901
+ )
902
+ ] });
903
+ };
904
+ const NestedOption = styledComponents.styled(designSystem.MultiSelectOption)`
905
+ padding-left: ${({ theme }) => theme.spaces[7]};
906
+ `;
907
+ const ContentTypeTakeNotice = styledComponents.styled(designSystem.Typography)`
908
+ font-style: italic;
909
+ `;
910
+ const StageSelector = ({ disabled }) => {
911
+ const { value: stages = [] } = strapiAdmin.useField("stages");
912
+ const { formatMessage } = reactIntl.useIntl();
913
+ const { error, value, onChange } = strapiAdmin.useField("stageRequiredToPublish");
914
+ const validStages = stages.filter((stage) => stage.name);
915
+ return /* @__PURE__ */ jsxRuntime.jsxs(
916
+ designSystem.Field.Root,
917
+ {
879
918
  error,
880
- label: formatMessage({
881
- id: "Settings.review-workflows.workflow.contentTypes.label",
882
- defaultMessage: "Associated to"
883
- }),
884
- onChange: (values) => {
885
- onChange("contentTypes", values);
886
- },
887
- value,
888
- placeholder: formatMessage({
889
- id: "Settings.review-workflows.workflow.contentTypes.placeholder",
890
- defaultMessage: "Select"
919
+ name: "stageRequiredToPublish",
920
+ hint: formatMessage({
921
+ id: "settings.review-workflows.workflow.stageRequiredToPublish.hint",
922
+ defaultMessage: "Prevents entries from being published if they are not at the required stage."
891
923
  }),
892
924
  children: [
893
- ...collectionTypes.length > 0 ? [
894
- {
895
- label: formatMessage({
896
- id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
897
- defaultMessage: "Collection Types"
898
- }),
899
- children: collectionTypes
900
- }
901
- ] : [],
902
- ...singleTypes.length > 0 ? [
925
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
926
+ id: "settings.review-workflows.workflow.stageRequiredToPublish.label",
927
+ defaultMessage: "Required stage for publishing"
928
+ }) }),
929
+ /* @__PURE__ */ jsxRuntime.jsxs(
930
+ designSystem.SingleSelect,
903
931
  {
904
- label: formatMessage({
905
- id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
906
- defaultMessage: "Single Types"
907
- }),
908
- children: singleTypes
932
+ disabled,
933
+ onChange: (value2) => {
934
+ onChange("stageRequiredToPublish", value2);
935
+ },
936
+ value,
937
+ children: [
938
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
939
+ id: "settings.review-workflows.workflow.stageRequiredToPublish.any",
940
+ defaultMessage: "Any stage"
941
+ }) }),
942
+ validStages.map((stage, i) => /* @__PURE__ */ jsxRuntime.jsx(
943
+ designSystem.SingleSelectOption,
944
+ {
945
+ value: stage.id?.toString() || stage.__temp_key__,
946
+ children: stage.name
947
+ },
948
+ `requiredToPublishStage-${stage.id || stage.__temp_key__}`
949
+ ))
950
+ ]
909
951
  }
910
- ] : []
911
- ].map((opt) => {
912
- return /* @__PURE__ */ jsxRuntime.jsx(
913
- designSystem.MultiSelectGroup,
914
- {
915
- label: opt.label,
916
- values: opt.children.map((child) => child.value.toString()),
917
- children: opt.children.map((child) => {
918
- const { name: assignedWorkflowName } = workflows?.find(
919
- (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
920
- ) ?? {};
921
- return /* @__PURE__ */ jsxRuntime.jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
922
- // @ts-expect-error - formatMessage options doesn't expect to be a React component but that's what we need actually for the <i> and <em> components
923
- children: formatMessage(
924
- {
925
- id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
926
- defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
927
- },
928
- {
929
- label: child.label,
930
- name: assignedWorkflowName,
931
- em: (...children) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { as: "em", fontWeight: "bold", children }),
932
- i: (...children) => /* @__PURE__ */ jsxRuntime.jsx(ContentTypeTakeNotice, { children })
933
- }
934
- )
935
- }) }, child.value);
936
- })
937
- },
938
- opt.label
939
- );
940
- })
952
+ ),
953
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
954
+ ]
941
955
  }
942
956
  );
943
957
  };
944
- const NestedOption = styled__default.default(designSystem.MultiSelectOption)`
945
- padding-left: ${({ theme }) => theme.spaces[7]};
946
- `;
947
- const ContentTypeTakeNotice = styled__default.default(designSystem.Typography)`
948
- font-style: italic;
949
- `;
950
958
  const WORKFLOW_SCHEMA = yup__namespace.object({
951
959
  contentTypes: yup__namespace.array().of(yup__namespace.string()),
952
960
  name: yup__namespace.string().max(255, {
953
961
  id: "review-workflows.validation.name.max-length",
954
962
  defaultMessage: "Name can not be longer than 255 characters"
955
- }).required(),
963
+ }).required().nullable(),
956
964
  stages: yup__namespace.array().of(
957
965
  yup__namespace.object().shape({
958
- name: yup__namespace.string().required({
966
+ name: yup__namespace.string().nullable().required({
959
967
  id: "review-workflows.validation.stage.name",
960
968
  defaultMessage: "Name is required"
961
969
  }).max(255, {
@@ -972,7 +980,7 @@ const WORKFLOW_SCHEMA = yup__namespace.object({
972
980
  return stages.filter((stage) => stage.name === stageName).length === 1;
973
981
  }
974
982
  ),
975
- color: yup__namespace.string().required({
983
+ color: yup__namespace.string().nullable().required({
976
984
  id: "review-workflows.validation.stage.color",
977
985
  defaultMessage: "Color is required"
978
986
  }).matches(/^#(?:[0-9a-fA-F]{3}){1,2}$/i),
@@ -989,7 +997,8 @@ const WORKFLOW_SCHEMA = yup__namespace.object({
989
997
  })
990
998
  ).strict()
991
999
  })
992
- ).min(1)
1000
+ ).min(1),
1001
+ stageRequiredToPublish: yup__namespace.string().nullable()
993
1002
  });
994
1003
  const EditPage = () => {
995
1004
  const { id = "" } = reactRouterDom.useParams();
@@ -998,7 +1007,6 @@ const EditPage = () => {
998
1007
  const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
999
1008
  const navigate = reactRouterDom.useNavigate();
1000
1009
  const { toggleNotification } = strapiAdmin.useNotification();
1001
- const dispatch = reactRedux.useDispatch();
1002
1010
  const {
1003
1011
  isLoading: isLoadingWorkflow,
1004
1012
  meta,
@@ -1006,7 +1014,7 @@ const EditPage = () => {
1006
1014
  error,
1007
1015
  update,
1008
1016
  create
1009
- } = Layout.useReviewWorkflows({ id: isCreatingWorkflow ? void 0 : id });
1017
+ } = Layout.useReviewWorkflows();
1010
1018
  const permissions = index.useTypedSelector(
1011
1019
  (state) => state.admin_app.permissions["settings"]?.["review-workflows"]
1012
1020
  );
@@ -1023,13 +1031,17 @@ const EditPage = () => {
1023
1031
  const stagesPerWorkflow = limits?.[index.CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME];
1024
1032
  const submitForm = async (data, helpers) => {
1025
1033
  try {
1034
+ const { stageRequiredToPublish, ...rest } = data;
1035
+ const stageRequiredToPublishName = stageRequiredToPublish === "" ? null : rest.stages.find(
1036
+ (stage) => stage.id === Number(stageRequiredToPublish) || stage.__temp_key__ === stageRequiredToPublish
1037
+ )?.name;
1026
1038
  if (!isCreatingWorkflow) {
1027
1039
  const res = await update(id, {
1028
- ...data,
1040
+ ...rest,
1029
1041
  // compare permissions of stages and only submit them if at least one has
1030
1042
  // changed; this enables partial updates e.g. for users who don't have
1031
1043
  // permissions to see roles
1032
- stages: data.stages.map((stage) => {
1044
+ stages: rest.stages.map((stage) => {
1033
1045
  let hasUpdatedPermissions = true;
1034
1046
  const serverStage = currentWorkflow?.stages?.find(
1035
1047
  (serverStage2) => serverStage2.id === stage?.id
@@ -1045,40 +1057,21 @@ const EditPage = () => {
1045
1057
  ...stage,
1046
1058
  permissions: hasUpdatedPermissions ? stage.permissions : void 0
1047
1059
  };
1048
- })
1060
+ }),
1061
+ stageRequiredToPublishName
1049
1062
  });
1050
1063
  if ("error" in res && index.isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1051
1064
  helpers.setErrors(formatValidationErrors(res.error));
1052
- } else if ("data" in res) {
1053
- for (const uid of res.data.contentTypes) {
1054
- dispatch({
1055
- type: "contentManagerApi/invalidateTags",
1056
- payload: [
1057
- {
1058
- type: "ContentTypesConfiguration",
1059
- id: uid
1060
- }
1061
- ]
1062
- });
1063
- }
1064
1065
  }
1065
1066
  } else {
1066
- const res = await create(data);
1067
+ const res = await create({
1068
+ ...rest,
1069
+ stageRequiredToPublishName
1070
+ });
1067
1071
  if ("error" in res && index.isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1068
1072
  helpers.setErrors(formatValidationErrors(res.error));
1069
1073
  } else if ("data" in res) {
1070
- for (const uid of res.data.contentTypes) {
1071
- dispatch({
1072
- type: "contentManagerApi/invalidateTags",
1073
- payload: [
1074
- {
1075
- type: "ContentTypesConfiguration",
1076
- id: uid
1077
- }
1078
- ]
1079
- });
1080
- }
1081
- navigate(`../${res.data.id}`);
1074
+ navigate(`../${res.data.id}`, { replace: true });
1082
1075
  }
1083
1076
  }
1084
1077
  } catch (error2) {
@@ -1142,13 +1135,15 @@ const EditPage = () => {
1142
1135
  return {
1143
1136
  name: "",
1144
1137
  stages: [],
1145
- contentTypes: []
1138
+ contentTypes: [],
1139
+ stageRequiredToPublish: ""
1146
1140
  };
1147
1141
  } else {
1148
1142
  return {
1149
1143
  name: currentWorkflow.name,
1150
1144
  stages: addTmpKeysToStages(currentWorkflow.stages),
1151
- contentTypes: currentWorkflow.contentTypes
1145
+ contentTypes: currentWorkflow.contentTypes,
1146
+ stageRequiredToPublish: currentWorkflow.stageRequiredToPublish?.id.toString() ?? ""
1152
1147
  };
1153
1148
  }
1154
1149
  }, [currentWorkflow, isCreatingWorkflow]);
@@ -1171,13 +1166,12 @@ const EditPage = () => {
1171
1166
  /* @__PURE__ */ jsxRuntime.jsx(
1172
1167
  Layout.Header,
1173
1168
  {
1174
- navigationAction: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
1169
+ navigationAction: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, { fallback: ".." }),
1175
1170
  primaryAction: canUpdate || canCreate ? /* @__PURE__ */ jsxRuntime.jsx(
1176
1171
  designSystem.Button,
1177
1172
  {
1178
1173
  startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
1179
1174
  type: "submit",
1180
- size: "M",
1181
1175
  disabled: !modified || isSubmitting || values.stages.length === 0,
1182
1176
  loading: !Boolean(Object.keys(savePrompts).length > 0) && isSubmitting,
1183
1177
  children: formatMessage({
@@ -1200,23 +1194,22 @@ const EditPage = () => {
1200
1194
  }
1201
1195
  ),
1202
1196
  /* @__PURE__ */ jsxRuntime.jsx(Layout.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "stretch", direction: "column", gap: 7, children: [
1203
- /* @__PURE__ */ jsxRuntime.jsx(WorkflowAttributes, { canUpdate }),
1197
+ /* @__PURE__ */ jsxRuntime.jsx(WorkflowAttributes, { canUpdate: canUpdate || canCreate }),
1204
1198
  /* @__PURE__ */ jsxRuntime.jsx(
1205
1199
  Stages,
1206
1200
  {
1207
1201
  canDelete,
1208
- canUpdate,
1202
+ canUpdate: canUpdate || canCreate,
1209
1203
  isCreating: isCreatingWorkflow
1210
1204
  }
1211
1205
  )
1212
1206
  ] }) }),
1213
1207
  /* @__PURE__ */ jsxRuntime.jsx(
1214
- strapiAdmin.ConfirmDialog,
1208
+ designSystem.Dialog.Root,
1215
1209
  {
1216
- isOpen: Object.keys(savePrompts).length > 0,
1217
- onClose: handleConfirmClose,
1218
- onConfirm: handleConfirmDeleteDialog(values, { setErrors }),
1219
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 5, children: [
1210
+ open: Object.keys(savePrompts).length > 0,
1211
+ onOpenChange: handleConfirmClose,
1212
+ children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, { onConfirm: handleConfirmDeleteDialog(values, { setErrors }), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 5, children: [
1220
1213
  savePrompts.hasDeletedServerStages && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", variant: "omega", children: formatMessage({
1221
1214
  id: "review-workflows.page.delete.confirm.stages.body",
1222
1215
  defaultMessage: "All entries assigned to deleted stages will be moved to the previous stage."
@@ -1228,7 +1221,7 @@ const EditPage = () => {
1228
1221
  },
1229
1222
  {
1230
1223
  count: contentTypesFromOtherWorkflows?.filter(
1231
- (contentType) => currentWorkflow?.contentTypes?.includes(contentType)
1224
+ (contentType) => values.contentTypes.includes(contentType)
1232
1225
  ).length ?? 0
1233
1226
  }
1234
1227
  ) }),
@@ -1236,7 +1229,7 @@ const EditPage = () => {
1236
1229
  id: "review-workflows.page.delete.confirm.confirm",
1237
1230
  defaultMessage: "Are you sure you want to save?"
1238
1231
  }) })
1239
- ] })
1232
+ ] }) })
1240
1233
  }
1241
1234
  )
1242
1235
  ] })
@@ -1245,8 +1238,8 @@ const EditPage = () => {
1245
1238
  /* @__PURE__ */ jsxRuntime.jsxs(
1246
1239
  index.LimitsModal.Root,
1247
1240
  {
1248
- isOpen: showLimitModal === "workflow",
1249
- onClose: () => setShowLimitModal(null),
1241
+ open: showLimitModal === "workflow",
1242
+ onOpenChange: () => setShowLimitModal(null),
1250
1243
  children: [
1251
1244
  /* @__PURE__ */ jsxRuntime.jsx(index.LimitsModal.Title, { children: formatMessage({
1252
1245
  id: "review-workflows.edit.page.workflows.limit.title",
@@ -1259,16 +1252,23 @@ const EditPage = () => {
1259
1252
  ]
1260
1253
  }
1261
1254
  ),
1262
- /* @__PURE__ */ jsxRuntime.jsxs(index.LimitsModal.Root, { isOpen: showLimitModal === "stage", onClose: () => setShowLimitModal(null), children: [
1263
- /* @__PURE__ */ jsxRuntime.jsx(index.LimitsModal.Title, { children: formatMessage({
1264
- id: "review-workflows.edit.page.stages.limit.title",
1265
- defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1266
- }) }),
1267
- /* @__PURE__ */ jsxRuntime.jsx(index.LimitsModal.Body, { children: formatMessage({
1268
- id: "review-workflows.edit.page.stages.limit.body",
1269
- defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1270
- }) })
1271
- ] })
1255
+ /* @__PURE__ */ jsxRuntime.jsxs(
1256
+ index.LimitsModal.Root,
1257
+ {
1258
+ open: showLimitModal === "stage",
1259
+ onOpenChange: () => setShowLimitModal(null),
1260
+ children: [
1261
+ /* @__PURE__ */ jsxRuntime.jsx(index.LimitsModal.Title, { children: formatMessage({
1262
+ id: "review-workflows.edit.page.stages.limit.title",
1263
+ defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1264
+ }) }),
1265
+ /* @__PURE__ */ jsxRuntime.jsx(index.LimitsModal.Body, { children: formatMessage({
1266
+ id: "review-workflows.edit.page.stages.limit.body",
1267
+ defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1268
+ }) })
1269
+ ]
1270
+ }
1271
+ )
1272
1272
  ] });
1273
1273
  };
1274
1274
  const addTmpKeysToStages = (data) => {
@@ -1290,4 +1290,4 @@ const ProtectedEditPage = () => {
1290
1290
  return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Protect, { permissions, children: /* @__PURE__ */ jsxRuntime.jsx(EditPage, {}) });
1291
1291
  };
1292
1292
  exports.ProtectedEditPage = ProtectedEditPage;
1293
- //# sourceMappingURL=_id-BDSg16su.js.map
1293
+ //# sourceMappingURL=id-oOE1bYls.js.map