@strapi/review-workflows 0.0.0-experimental.7431ba9b3883991b77bbf6a70bd9806090706724 → 0.0.0-experimental.745741d19e90275ca6f7c928ca19f9bb0fd9d933

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 (49) hide show
  1. package/LICENSE +12 -17
  2. package/dist/_chunks/{Layout-facLKucY.mjs → Layout-5ljKgKPQ.mjs} +10 -16
  3. package/dist/_chunks/Layout-5ljKgKPQ.mjs.map +1 -0
  4. package/dist/_chunks/{Layout-dGg4FA1R.js → Layout-BiM6w0JE.js} +7 -15
  5. package/dist/_chunks/Layout-BiM6w0JE.js.map +1 -0
  6. package/dist/_chunks/{_id-B6DgrtpA.js → _id-B11TjsDY.js} +307 -364
  7. package/dist/_chunks/_id-B11TjsDY.js.map +1 -0
  8. package/dist/_chunks/{_id-D4CXKOqG.mjs → _id-D9zpHIKW.mjs} +301 -356
  9. package/dist/_chunks/_id-D9zpHIKW.mjs.map +1 -0
  10. package/dist/_chunks/{index-BuKZWpJw.js → index-BAXO_30S.js} +25 -40
  11. package/dist/_chunks/index-BAXO_30S.js.map +1 -0
  12. package/dist/_chunks/{index-QbWLXdZR.mjs → index-BvEfJ4ta.mjs} +24 -37
  13. package/dist/_chunks/index-BvEfJ4ta.mjs.map +1 -0
  14. package/dist/_chunks/{index-D7Y0ofdg.mjs → index-CWIQ-LER.mjs} +115 -165
  15. package/dist/_chunks/index-CWIQ-LER.mjs.map +1 -0
  16. package/dist/_chunks/{index-DX8AGcIP.js → index-DIXWkgzz.js} +115 -167
  17. package/dist/_chunks/index-DIXWkgzz.js.map +1 -0
  18. package/dist/_chunks/{purchase-review-workflows-B-V0sA2I.mjs → purchase-review-workflows-BN-5Ube7.mjs} +8 -7
  19. package/dist/_chunks/purchase-review-workflows-BN-5Ube7.mjs.map +1 -0
  20. package/dist/_chunks/{purchase-review-workflows-Ds61D_tk.js → purchase-review-workflows-DlCDg0fD.js} +7 -6
  21. package/dist/_chunks/purchase-review-workflows-DlCDg0fD.js.map +1 -0
  22. package/dist/_chunks/{router-ylD0eA48.mjs → router-BMH37QoK.mjs} +3 -3
  23. package/dist/_chunks/{router-ylD0eA48.mjs.map → router-BMH37QoK.mjs.map} +1 -1
  24. package/dist/_chunks/{router-CL62NScV.js → router-DRZjVs98.js} +3 -3
  25. package/dist/_chunks/{router-CL62NScV.js.map → router-DRZjVs98.js.map} +1 -1
  26. package/dist/admin/index.js +1 -1
  27. package/dist/admin/index.mjs +1 -1
  28. package/dist/admin/src/components/LimitsModal.d.ts +2 -4
  29. package/dist/admin/src/routes/content-manager/[model]/[id]/components/Panel.d.ts +1 -1
  30. package/dist/admin/src/routes/settings/hooks/useDragAndDrop.d.ts +4 -4
  31. package/dist/admin/src/routes/settings/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  32. package/dist/admin/src/routes/settings/hooks/useReviewWorkflows.d.ts +3 -3
  33. package/dist/admin/src/services/admin.d.ts +2 -2
  34. package/dist/admin/src/services/api.d.ts +2 -3
  35. package/dist/admin/src/services/content-manager.d.ts +7 -7
  36. package/dist/admin/src/services/settings.d.ts +4 -4
  37. package/dist/admin/src/utils/api.d.ts +4 -19
  38. package/dist/admin/src/utils/cm-hooks.d.ts +1 -1
  39. package/package.json +14 -15
  40. package/dist/_chunks/Layout-dGg4FA1R.js.map +0 -1
  41. package/dist/_chunks/Layout-facLKucY.mjs.map +0 -1
  42. package/dist/_chunks/_id-B6DgrtpA.js.map +0 -1
  43. package/dist/_chunks/_id-D4CXKOqG.mjs.map +0 -1
  44. package/dist/_chunks/index-BuKZWpJw.js.map +0 -1
  45. package/dist/_chunks/index-D7Y0ofdg.mjs.map +0 -1
  46. package/dist/_chunks/index-DX8AGcIP.js.map +0 -1
  47. package/dist/_chunks/index-QbWLXdZR.mjs.map +0 -1
  48. package/dist/_chunks/purchase-review-workflows-B-V0sA2I.mjs.map +0 -1
  49. package/dist/_chunks/purchase-review-workflows-Ds61D_tk.js.map +0 -1
@@ -2,23 +2,22 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { useTracking, useForm, useField, InputRenderer as InputRenderer$1, useNotification, ConfirmDialog, Page, useAPIErrorHandler, useRBAC, Form, BackButton } from "@strapi/admin/strapi-admin";
4
4
  import { useLicenseLimits } from "@strapi/admin/strapi-admin/ee";
5
- import { Box, Typography, Flex, IconButton, MultiSelectOption, useComposedRefs, VisuallyHidden, Accordion, AccordionToggle, AccordionContent, Grid, GridItem, SingleSelect, SingleSelectOption, TextInput, MultiSelect, MultiSelectGroup, useCollator, Button } from "@strapi/design-system";
6
- import { PlusCircle, EyeStriked, More, Drag, Duplicate, Check } from "@strapi/icons";
5
+ import { Box, Typography, Flex, Accordion, MenuItem, Menu, MultiSelectOption, useComposedRefs, VisuallyHidden, IconButton, Grid, Field, SingleSelect, SingleSelectOption, TextInput, MultiSelect, MultiSelectGroup, Dialog, useCollator, Button } from "@strapi/design-system";
6
+ import { PlusCircle, More, Drag, EyeStriked, Duplicate, Check } from "@strapi/icons";
7
7
  import { generateNKeysBetween } from "fractional-indexing";
8
8
  import { useIntl } from "react-intl";
9
9
  import { useDispatch } from "react-redux";
10
10
  import { useParams, useNavigate } from "react-router-dom";
11
11
  import * as yup from "yup";
12
- import { r as reviewWorkflowsApi, A as AVAILABLE_COLORS, g as getStageColorByHex, u as useGetContentTypesQuery, a as useTypedSelector, C as CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME, b as CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME, L as LimitsModal, i as isBaseQueryError } from "./index-D7Y0ofdg.mjs";
13
- import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-facLKucY.mjs";
14
- import { MenuItem, Menu } from "@strapi/design-system/v2";
12
+ import { r as reviewWorkflowsApi, A as AVAILABLE_COLORS, g as getStageColorByHex, u as useGetContentTypesQuery, a as useTypedSelector, C as CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME, b as CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME, L as LimitsModal, i as isBaseQueryError } from "./index-CWIQ-LER.mjs";
13
+ import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-5ljKgKPQ.mjs";
15
14
  import { getEmptyImage } from "react-dnd-html5-backend";
16
- import styled from "styled-components";
15
+ import { styled } from "styled-components";
17
16
  import { useDrop, useDrag } from "react-dnd";
18
17
  const adminApi = reviewWorkflowsApi.injectEndpoints({
19
18
  endpoints(builder) {
20
19
  return {
21
- getRoles: builder.query({
20
+ getAdminRoles: builder.query({
22
21
  query: () => ({
23
22
  url: `/admin/roles`,
24
23
  method: "GET"
@@ -30,7 +29,7 @@ const adminApi = reviewWorkflowsApi.injectEndpoints({
30
29
  };
31
30
  }
32
31
  });
33
- const { useGetRolesQuery } = adminApi;
32
+ const { useGetAdminRolesQuery } = adminApi;
34
33
  const useKeyboardDragAndDrop = (active, index, { onCancel, onDropItem, onGrabItem, onMoveItem }) => {
35
34
  const [isSelected, setIsSelected] = React.useState(false);
36
35
  const handleMove = (movement) => {
@@ -249,74 +248,35 @@ const AddStage = ({ children, ...props }) => {
249
248
  return /* @__PURE__ */ jsx(
250
249
  StyledButton,
251
250
  {
252
- as: "button",
251
+ tag: "button",
253
252
  background: "neutral0",
254
- border: "neutral150",
253
+ borderColor: "neutral150",
255
254
  paddingBottom: 3,
256
255
  paddingLeft: 4,
257
256
  paddingRight: 4,
258
257
  paddingTop: 3,
259
258
  shadow: "filterShadow",
260
259
  ...props,
261
- children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
262
- /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true }),
263
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral500", children })
264
- ] })
260
+ children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
261
+ /* @__PURE__ */ jsx(PlusCircle, { width: "2.4rem", height: "2.4rem", "aria-hidden": true }),
262
+ children
263
+ ] }) })
265
264
  }
266
265
  );
267
266
  };
268
- const StyledAddIcon = styled(PlusCircle)`
269
- > circle {
270
- fill: ${({ theme }) => theme.colors.neutral150};
271
- }
272
- > path {
273
- fill: ${({ theme }) => theme.colors.neutral600};
274
- }
275
- `;
276
267
  const StyledButton = styled(Box)`
277
268
  border-radius: 26px;
278
-
279
- svg {
280
- height: ${({ theme }) => theme.spaces[6]};
281
- width: ${({ theme }) => theme.spaces[6]};
282
-
283
- > path {
284
- fill: ${({ theme }) => theme.colors.neutral600};
285
- }
286
- }
269
+ color: ${({ theme }) => theme.colors.neutral500};
287
270
 
288
271
  &:hover {
289
- color: ${({ theme }) => theme.colors.primary600} !important;
290
- ${Typography} {
291
- color: ${({ theme }) => theme.colors.primary600} !important;
292
- }
293
-
294
- ${StyledAddIcon} {
295
- > circle {
296
- fill: ${({ theme }) => theme.colors.primary600};
297
- }
298
- > path {
299
- fill: ${({ theme }) => theme.colors.neutral100};
300
- }
301
- }
272
+ color: ${({ theme }) => theme.colors.primary600};
302
273
  }
303
274
 
304
275
  &:active {
305
- ${Typography} {
306
- color: ${({ theme }) => theme.colors.primary600};
307
- }
308
-
309
- ${StyledAddIcon} {
310
- > circle {
311
- fill: ${({ theme }) => theme.colors.primary600};
312
- }
313
- > path {
314
- fill: ${({ theme }) => theme.colors.neutral100};
315
- }
316
- }
276
+ color: ${({ theme }) => theme.colors.primary600};
317
277
  }
318
278
  `;
319
- const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
279
+ const Stages = ({ canDelete = true, canUpdate = true, isCreating }) => {
320
280
  const { formatMessage } = useIntl();
321
281
  const { trackUsage } = useTracking();
322
282
  const addFieldRow = useForm("Stages", (state) => state.addFieldRow);
@@ -343,9 +303,9 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
343
303
  gap: 6,
344
304
  zIndex: 2,
345
305
  position: "relative",
346
- as: "ol",
306
+ tag: "ol",
347
307
  children: stages.map((stage, index) => {
348
- return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
308
+ return /* @__PURE__ */ jsx(Box, { tag: "li", children: /* @__PURE__ */ jsx(
349
309
  Stage,
350
310
  {
351
311
  index,
@@ -353,7 +313,7 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
353
313
  canReorder: stages.length > 1,
354
314
  canUpdate,
355
315
  stagesCount: stages.length,
356
- isOpen: isCreating,
316
+ defaultOpen: isCreating,
357
317
  ...stage
358
318
  }
359
319
  ) }, stage.__temp_key__);
@@ -385,16 +345,15 @@ const Stage = ({
385
345
  canDelete = false,
386
346
  canReorder = false,
387
347
  canUpdate = false,
388
- isOpen: isOpenDefault = false,
389
348
  stagesCount,
390
349
  name,
391
350
  permissions,
392
- color
351
+ color,
352
+ defaultOpen
393
353
  }) => {
394
354
  const [liveText, setLiveText] = React.useState();
395
355
  const { formatMessage } = useIntl();
396
356
  const { trackUsage } = useTracking();
397
- const [isOpen, setIsOpen] = React.useState(isOpenDefault);
398
357
  const stageErrors = useForm("Stages", (state) => state.errors.stages);
399
358
  const error = stageErrors?.[index];
400
359
  const addFieldRow = useForm("Stage", (state) => state.addFieldRow);
@@ -476,7 +435,8 @@ const Stage = ({
476
435
  const handleCloneClick = () => {
477
436
  addFieldRow("stages", { name, color, permissions });
478
437
  };
479
- return /* @__PURE__ */ jsxs(Box, { ref: (ref) => composedRef(ref), children: [
438
+ const id = React.useId();
439
+ return /* @__PURE__ */ jsxs(Box, { ref: composedRef, shadow: "tableShadow", children: [
480
440
  liveText && /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
481
441
  isDragging ? /* @__PURE__ */ jsx(
482
442
  Box,
@@ -487,74 +447,61 @@ const Stage = ({
487
447
  borderWidth: "1px",
488
448
  display: "block",
489
449
  hasRadius: true,
490
- padding: 6,
491
- shadow: "tableShadow"
450
+ padding: 6
492
451
  }
493
- ) : /* @__PURE__ */ jsxs(
494
- Accordion,
452
+ ) : /* @__PURE__ */ jsx(
453
+ AccordionRoot,
495
454
  {
496
- size: "S",
497
- variant: "primary",
498
- onToggle: () => {
499
- setIsOpen(!isOpen);
500
- if (!isOpen) {
455
+ onValueChange: (value) => {
456
+ if (value) {
501
457
  trackUsage("willEditStage");
502
458
  }
503
459
  },
504
- expanded: isOpen,
505
- shadow: "tableShadow",
506
- error: Object.values(error ?? {})[0],
507
- hasErrorMessage: false,
508
- children: [
509
- /* @__PURE__ */ jsx(
510
- AccordionToggle,
511
- {
512
- title: name,
513
- togglePosition: "left",
514
- action: (canDelete || canUpdate) && /* @__PURE__ */ jsxs(Flex, { children: [
515
- /* @__PURE__ */ jsxs(Menu.Root, { children: [
516
- /* @__PURE__ */ jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
517
- /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
518
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: formatMessage({
519
- id: "[tbdb].components.DynamicZone.more-actions",
520
- defaultMessage: "More actions"
521
- }) })
522
- ] }),
523
- /* @__PURE__ */ jsx(Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
524
- canUpdate && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCloneClick, children: formatMessage({
525
- id: "Settings.review-workflows.stage.delete",
526
- defaultMessage: "Duplicate stage"
527
- }) }),
528
- canDelete && /* @__PURE__ */ jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index), children: formatMessage({
529
- id: "Settings.review-workflows.stage.delete",
530
- defaultMessage: "Delete"
531
- }) })
532
- ] }) })
460
+ defaultValue: defaultOpen ? id : void 0,
461
+ $error: Object.values(error ?? {}).length > 0,
462
+ children: /* @__PURE__ */ jsxs(Accordion.Item, { value: id, children: [
463
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
464
+ /* @__PURE__ */ jsx(Accordion.Trigger, { children: name }),
465
+ /* @__PURE__ */ jsx(Accordion.Actions, { children: canDelete || canUpdate ? /* @__PURE__ */ jsxs(Fragment, { children: [
466
+ /* @__PURE__ */ jsxs(Menu.Root, { children: [
467
+ /* @__PURE__ */ jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
468
+ /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
469
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
470
+ id: "[tbdb].components.DynamicZone.more-actions",
471
+ defaultMessage: "More actions"
472
+ }) })
533
473
  ] }),
534
- canUpdate && /* @__PURE__ */ jsx(
535
- DragIconButton,
536
- {
537
- background: "transparent",
538
- forwardedAs: "div",
539
- hasRadius: true,
540
- role: "button",
541
- noBorder: true,
542
- tabIndex: 0,
543
- "data-handler-id": handlerId,
544
- ref: dragRef,
545
- label: formatMessage({
546
- id: "Settings.review-workflows.stage.drag",
547
- defaultMessage: "Drag"
548
- }),
549
- onClick: (e) => e.stopPropagation(),
550
- onKeyDown: handleKeyDown,
551
- children: /* @__PURE__ */ jsx(Drag, {})
552
- }
553
- )
554
- ] })
555
- }
556
- ),
557
- /* @__PURE__ */ jsx(AccordionContent, { padding: 6, background: "neutral0", hasRadius: true, children: /* @__PURE__ */ jsx(Grid, { gap: 4, children: [
474
+ /* @__PURE__ */ jsx(Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
475
+ canUpdate && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCloneClick, children: formatMessage({
476
+ id: "Settings.review-workflows.stage.delete",
477
+ defaultMessage: "Duplicate stage"
478
+ }) }),
479
+ canDelete && /* @__PURE__ */ jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index), children: formatMessage({
480
+ id: "Settings.review-workflows.stage.delete",
481
+ defaultMessage: "Delete"
482
+ }) })
483
+ ] }) })
484
+ ] }),
485
+ canUpdate && /* @__PURE__ */ jsx(
486
+ IconButton,
487
+ {
488
+ background: "transparent",
489
+ hasRadius: true,
490
+ borderWidth: 0,
491
+ "data-handler-id": handlerId,
492
+ ref: dragRef,
493
+ label: formatMessage({
494
+ id: "Settings.review-workflows.stage.drag",
495
+ defaultMessage: "Drag"
496
+ }),
497
+ onClick: (e) => e.stopPropagation(),
498
+ onKeyDown: handleKeyDown,
499
+ children: /* @__PURE__ */ jsx(Drag, {})
500
+ }
501
+ )
502
+ ] }) : null })
503
+ ] }),
504
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid.Root, { gap: 4, padding: 6, children: [
558
505
  {
559
506
  disabled: !canUpdate,
560
507
  label: formatMessage({
@@ -592,12 +539,16 @@ const Stage = ({
592
539
  size: 6,
593
540
  type: "permissions"
594
541
  }
595
- ].map(({ size, ...field }) => /* @__PURE__ */ jsx(GridItem, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
596
- ]
542
+ ].map(({ size, ...field }) => /* @__PURE__ */ jsx(Grid.Item, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
543
+ ] })
597
544
  }
598
545
  )
599
546
  ] });
600
547
  };
548
+ const AccordionRoot = styled(Accordion.Root)`
549
+ border: 1px solid
550
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
551
+ `;
601
552
  const DeleteMenuItem = styled(MenuItem)`
602
553
  color: ${({ theme }) => theme.colors.danger600};
603
554
  `;
@@ -611,22 +562,6 @@ const ContextMenuTrigger = styled(Menu.Trigger)`
611
562
  font-size: 0;
612
563
  }
613
564
  `;
614
- const DragIconButton = styled(IconButton)`
615
- align-items: center;
616
- border-radius: ${({ theme }) => theme.borderRadius};
617
- display: flex;
618
- justify-content: center;
619
-
620
- &:hover,
621
- &:focus {
622
- background-color: ${({ theme }) => theme.colors.neutral100};
623
- }
624
-
625
- svg {
626
- height: auto;
627
- width: ${({ theme }) => theme.spaces[3]};
628
- }
629
- `;
630
565
  const InputRenderer = (props) => {
631
566
  switch (props.type) {
632
567
  case "color":
@@ -652,54 +587,55 @@ const ColorSelector = ({ disabled, label, name, required }) => {
652
587
  color: hex
653
588
  }));
654
589
  const { themeColorName } = getStageColorByHex(value) ?? {};
655
- return /* @__PURE__ */ jsx(
656
- SingleSelect,
657
- {
658
- disabled,
659
- error,
660
- required,
661
- label,
662
- onChange: (v) => {
663
- onChange(name, v.toString());
664
- },
665
- value: value?.toUpperCase(),
666
- startIcon: /* @__PURE__ */ jsx(
667
- Flex,
668
- {
669
- as: "span",
670
- height: 2,
671
- background: value,
672
- borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
673
- hasRadius: true,
674
- shrink: 0,
675
- width: 2
676
- }
677
- ),
678
- children: colorOptions.map(({ value: value2, label: label2, color }) => {
679
- const { themeColorName: themeColorName2 } = getStageColorByHex(color) || {};
680
- return /* @__PURE__ */ jsx(
681
- SingleSelectOption,
590
+ return /* @__PURE__ */ jsxs(Field.Root, { error, name, required, children: [
591
+ /* @__PURE__ */ jsx(Field.Label, { children: label }),
592
+ /* @__PURE__ */ jsx(
593
+ SingleSelect,
594
+ {
595
+ disabled,
596
+ onChange: (v) => {
597
+ onChange(name, v.toString());
598
+ },
599
+ value: value?.toUpperCase(),
600
+ startIcon: /* @__PURE__ */ jsx(
601
+ Flex,
682
602
  {
683
- value: value2,
684
- startIcon: /* @__PURE__ */ jsx(
685
- Flex,
686
- {
687
- as: "span",
688
- height: 2,
689
- background: color,
690
- borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
691
- hasRadius: true,
692
- shrink: 0,
693
- width: 2
694
- }
695
- ),
696
- children: label2
697
- },
698
- value2
699
- );
700
- })
701
- }
702
- );
603
+ tag: "span",
604
+ height: 2,
605
+ background: value,
606
+ borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
607
+ hasRadius: true,
608
+ shrink: 0,
609
+ width: 2
610
+ }
611
+ ),
612
+ children: colorOptions.map(({ value: value2, label: label2, color }) => {
613
+ const { themeColorName: themeColorName2 } = getStageColorByHex(color) || {};
614
+ return /* @__PURE__ */ jsx(
615
+ SingleSelectOption,
616
+ {
617
+ value: value2,
618
+ startIcon: /* @__PURE__ */ jsx(
619
+ Flex,
620
+ {
621
+ tag: "span",
622
+ height: 2,
623
+ background: color,
624
+ borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
625
+ hasRadius: true,
626
+ shrink: 0,
627
+ width: 2
628
+ }
629
+ ),
630
+ children: label2
631
+ },
632
+ value2
633
+ );
634
+ })
635
+ }
636
+ ),
637
+ /* @__PURE__ */ jsx(Field.Error, {})
638
+ ] });
703
639
  };
704
640
  const PermissionsField = ({ disabled, name, placeholder, required }) => {
705
641
  const { formatMessage } = useIntl();
@@ -708,57 +644,65 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
708
644
  const { value = [], error, onChange } = useField(name);
709
645
  const allStages = useForm("PermissionsField", (state) => state.values.stages);
710
646
  const onFormValueChange = useForm("PermissionsField", (state) => state.onChange);
711
- const { data: roles = [], isLoading } = useGetRolesQuery();
647
+ const rolesErrorCount = React.useRef(0);
648
+ const { data: roles = [], isLoading, error: getRolesError } = useGetAdminRolesQuery();
712
649
  const filteredRoles = roles?.filter((role) => role.code !== "strapi-super-admin") ?? [];
713
650
  React.useEffect(() => {
714
- if (!isLoading && roles.length === 0) {
651
+ if (!isLoading && getRolesError && "status" in getRolesError && getRolesError.status == 403 && rolesErrorCount.current === 0) {
652
+ rolesErrorCount.current = 1;
715
653
  toggleNotification({
716
654
  blockTransition: true,
717
655
  type: "danger",
718
656
  message: formatMessage({
719
657
  id: "review-workflows.stage.permissions.noPermissions.description",
720
- defaultMessage: "You don’t have the permission to see roles"
658
+ defaultMessage: "You don’t have the permission to see roles. Contact your administrator."
721
659
  })
722
660
  });
723
661
  }
724
- }, [formatMessage, isLoading, roles, toggleNotification]);
662
+ }, [formatMessage, isLoading, roles, toggleNotification, getRolesError]);
725
663
  if (!isLoading && filteredRoles.length === 0) {
726
- return /* @__PURE__ */ jsx(
727
- TextInput,
664
+ return /* @__PURE__ */ jsxs(
665
+ Field.Root,
728
666
  {
729
- disabled: true,
730
667
  name,
731
668
  hint: formatMessage({
732
669
  id: "Settings.review-workflows.stage.permissions.noPermissions.description",
733
670
  defaultMessage: "You don’t have the permission to see roles"
734
671
  }),
735
- label: formatMessage({
736
- id: "Settings.review-workflows.stage.permissions.label",
737
- defaultMessage: "Roles that can change this stage"
738
- }),
739
- placeholder: formatMessage({
740
- id: "components.NotAllowedInput.text",
741
- defaultMessage: "No permissions to see this field"
742
- }),
743
672
  required,
744
- startAction: /* @__PURE__ */ jsx(StyledIcon, {}),
745
- type: "text",
746
- value: ""
673
+ children: [
674
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
675
+ id: "Settings.review-workflows.stage.permissions.label",
676
+ defaultMessage: "Roles that can change this stage"
677
+ }) }),
678
+ /* @__PURE__ */ jsx(
679
+ TextInput,
680
+ {
681
+ disabled: true,
682
+ placeholder: formatMessage({
683
+ id: "components.NotAllowedInput.text",
684
+ defaultMessage: "No permissions to see this field"
685
+ }),
686
+ startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
687
+ type: "text",
688
+ value: ""
689
+ }
690
+ ),
691
+ /* @__PURE__ */ jsx(Field.Hint, {})
692
+ ]
747
693
  }
748
694
  );
749
695
  }
750
- return /* @__PURE__ */ jsxs(Fragment, { children: [
751
- /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-end", gap: 3, children: [
752
- /* @__PURE__ */ jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsx(
696
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-end", gap: 3, children: [
697
+ /* @__PURE__ */ jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsxs(Field.Root, { error, name, required: true, children: [
698
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
699
+ id: "Settings.review-workflows.stage.permissions.label",
700
+ defaultMessage: "Roles that can change this stage"
701
+ }) }),
702
+ /* @__PURE__ */ jsx(
753
703
  MultiSelect,
754
704
  {
755
705
  disabled,
756
- error,
757
- id: name,
758
- label: formatMessage({
759
- id: "Settings.review-workflows.stage.permissions.label",
760
- defaultMessage: "Roles that can change this stage"
761
- }),
762
706
  onChange: (values) => {
763
707
  const permissions = values.map((value2) => ({
764
708
  role: parseInt(value2, 10),
@@ -767,7 +711,6 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
767
711
  onChange(name, permissions);
768
712
  },
769
713
  placeholder,
770
- required: true,
771
714
  value: value.map((permission) => `${permission.role}`),
772
715
  withTags: true,
773
716
  children: /* @__PURE__ */ jsx(
@@ -784,58 +727,53 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
784
727
  }
785
728
  )
786
729
  }
787
- ) }),
788
- /* @__PURE__ */ jsx(
730
+ ),
731
+ /* @__PURE__ */ jsx(Field.Error, {})
732
+ ] }) }),
733
+ /* @__PURE__ */ jsxs(Dialog.Root, { open: isApplyAllConfirmationOpen, onOpenChange: setIsApplyAllConfirmationOpen, children: [
734
+ /* @__PURE__ */ jsx(Dialog.Trigger, { children: /* @__PURE__ */ jsx(
789
735
  IconButton,
790
736
  {
791
737
  disabled,
792
- icon: /* @__PURE__ */ jsx(Duplicate, {}),
793
738
  label: formatMessage({
794
739
  id: "Settings.review-workflows.stage.permissions.apply.label",
795
740
  defaultMessage: "Apply to all stages"
796
741
  }),
797
742
  size: "L",
798
743
  variant: "secondary",
799
- onClick: () => setIsApplyAllConfirmationOpen(true)
744
+ children: /* @__PURE__ */ jsx(Duplicate, {})
745
+ }
746
+ ) }),
747
+ /* @__PURE__ */ jsx(
748
+ ConfirmDialog,
749
+ {
750
+ onConfirm: () => {
751
+ onFormValueChange(
752
+ "stages",
753
+ allStages.map((stage) => ({
754
+ ...stage,
755
+ permissions: value
756
+ }))
757
+ );
758
+ setIsApplyAllConfirmationOpen(false);
759
+ toggleNotification({
760
+ type: "success",
761
+ message: formatMessage({
762
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
763
+ defaultMessage: "Applied roles to all other stages of the workflow"
764
+ })
765
+ });
766
+ },
767
+ variant: "default",
768
+ children: formatMessage({
769
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
770
+ defaultMessage: "Roles that can change that stage will be applied to all the other stages."
771
+ })
800
772
  }
801
773
  )
802
- ] }),
803
- /* @__PURE__ */ jsx(
804
- ConfirmDialog,
805
- {
806
- isOpen: isApplyAllConfirmationOpen,
807
- onClose: () => setIsApplyAllConfirmationOpen(false),
808
- onConfirm: () => {
809
- onFormValueChange(
810
- "stages",
811
- allStages.map((stage) => ({
812
- ...stage,
813
- permissions: value
814
- }))
815
- );
816
- setIsApplyAllConfirmationOpen(false);
817
- toggleNotification({
818
- type: "success",
819
- message: formatMessage({
820
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
821
- defaultMessage: "Applied roles to all other stages of the workflow"
822
- })
823
- });
824
- },
825
- variant: "default",
826
- children: formatMessage({
827
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
828
- defaultMessage: "Roles that can change that stage will be applied to all the other stages."
829
- })
830
- }
831
- )
832
- ] });
774
+ ] })
775
+ ] }) });
833
776
  };
834
- const StyledIcon = styled(EyeStriked)`
835
- & > path {
836
- fill: ${({ theme }) => theme.colors.neutral600};
837
- }
838
- `;
839
777
  const NestedOption$1 = styled(MultiSelectOption)`
840
778
  padding-left: ${({ theme }) => theme.spaces[7]};
841
779
  `;
@@ -846,8 +784,8 @@ const PermissionWrapper = styled(Flex)`
846
784
  `;
847
785
  const WorkflowAttributes = ({ canUpdate = true }) => {
848
786
  const { formatMessage } = useIntl();
849
- return /* @__PURE__ */ jsxs(Grid, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
850
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
787
+ return /* @__PURE__ */ jsxs(Grid.Root, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
788
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(
851
789
  InputRenderer$1,
852
790
  {
853
791
  disabled: !canUpdate,
@@ -860,7 +798,7 @@ const WorkflowAttributes = ({ canUpdate = true }) => {
860
798
  type: "string"
861
799
  }
862
800
  ) }),
863
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
801
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
864
802
  ] });
865
803
  };
866
804
  const ContentTypesSelector = ({ disabled }) => {
@@ -881,81 +819,82 @@ const ContentTypesSelector = ({ disabled }) => {
881
819
  label: contentType.info.displayName,
882
820
  value: contentType.uid
883
821
  }));
884
- return /* @__PURE__ */ jsx(
885
- MultiSelect,
886
- {
887
- customizeContent: (value2) => formatMessage(
888
- {
889
- id: "Settings.review-workflows.workflow.contentTypes.displayValue",
890
- defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
891
- },
892
- { count: value2?.length }
893
- ),
894
- disabled: isDisabled,
895
- error,
896
- label: formatMessage({
897
- id: "Settings.review-workflows.workflow.contentTypes.label",
898
- defaultMessage: "Associated to"
899
- }),
900
- onChange: (values) => {
901
- onChange("contentTypes", values);
902
- },
903
- value,
904
- placeholder: formatMessage({
905
- id: "Settings.review-workflows.workflow.contentTypes.placeholder",
906
- defaultMessage: "Select"
907
- }),
908
- children: [
909
- ...collectionTypes.length > 0 ? [
910
- {
911
- label: formatMessage({
912
- id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
913
- defaultMessage: "Collection Types"
914
- }),
915
- children: collectionTypes
916
- }
917
- ] : [],
918
- ...singleTypes.length > 0 ? [
919
- {
920
- label: formatMessage({
921
- id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
922
- defaultMessage: "Single Types"
923
- }),
924
- children: singleTypes
925
- }
926
- ] : []
927
- ].map((opt) => {
928
- return /* @__PURE__ */ jsx(
929
- MultiSelectGroup,
822
+ return /* @__PURE__ */ jsxs(Field.Root, { error, name: "contentTypes", children: [
823
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
824
+ id: "Settings.review-workflows.workflow.contentTypes.label",
825
+ defaultMessage: "Associated to"
826
+ }) }),
827
+ /* @__PURE__ */ jsx(
828
+ MultiSelect,
829
+ {
830
+ customizeContent: (value2) => formatMessage(
930
831
  {
931
- label: opt.label,
932
- values: opt.children.map((child) => child.value.toString()),
933
- children: opt.children.map((child) => {
934
- const { name: assignedWorkflowName } = workflows?.find(
935
- (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
936
- ) ?? {};
937
- return /* @__PURE__ */ jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsx(Typography, {
938
- // @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
939
- children: formatMessage(
940
- {
941
- id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
942
- defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
943
- },
944
- {
945
- label: child.label,
946
- name: assignedWorkflowName,
947
- em: (...children) => /* @__PURE__ */ jsx(Typography, { as: "em", fontWeight: "bold", children }),
948
- i: (...children) => /* @__PURE__ */ jsx(ContentTypeTakeNotice, { children })
949
- }
950
- )
951
- }) }, child.value);
952
- })
832
+ id: "Settings.review-workflows.workflow.contentTypes.displayValue",
833
+ defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
953
834
  },
954
- opt.label
955
- );
956
- })
957
- }
958
- );
835
+ { count: value2?.length }
836
+ ),
837
+ disabled: isDisabled,
838
+ onChange: (values) => {
839
+ onChange("contentTypes", values);
840
+ },
841
+ value,
842
+ placeholder: formatMessage({
843
+ id: "Settings.review-workflows.workflow.contentTypes.placeholder",
844
+ defaultMessage: "Select"
845
+ }),
846
+ children: [
847
+ ...collectionTypes.length > 0 ? [
848
+ {
849
+ label: formatMessage({
850
+ id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
851
+ defaultMessage: "Collection Types"
852
+ }),
853
+ children: collectionTypes
854
+ }
855
+ ] : [],
856
+ ...singleTypes.length > 0 ? [
857
+ {
858
+ label: formatMessage({
859
+ id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
860
+ defaultMessage: "Single Types"
861
+ }),
862
+ children: singleTypes
863
+ }
864
+ ] : []
865
+ ].map((opt) => {
866
+ return /* @__PURE__ */ jsx(
867
+ MultiSelectGroup,
868
+ {
869
+ label: opt.label,
870
+ values: opt.children.map((child) => child.value.toString()),
871
+ children: opt.children.map((child) => {
872
+ const { name: assignedWorkflowName } = workflows?.find(
873
+ (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
874
+ ) ?? {};
875
+ return /* @__PURE__ */ jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsx(Typography, {
876
+ // @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
877
+ children: formatMessage(
878
+ {
879
+ id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
880
+ defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
881
+ },
882
+ {
883
+ label: child.label,
884
+ name: assignedWorkflowName,
885
+ em: (...children) => /* @__PURE__ */ jsx(Typography, { tag: "em", fontWeight: "bold", children }),
886
+ i: (...children) => /* @__PURE__ */ jsx(ContentTypeTakeNotice, { children })
887
+ }
888
+ )
889
+ }) }, child.value);
890
+ })
891
+ },
892
+ opt.label
893
+ );
894
+ })
895
+ }
896
+ )
897
+ ] });
959
898
  };
960
899
  const NestedOption = styled(MultiSelectOption)`
961
900
  padding-left: ${({ theme }) => theme.spaces[7]};
@@ -1216,23 +1155,22 @@ const EditPage = () => {
1216
1155
  }
1217
1156
  ),
1218
1157
  /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "stretch", direction: "column", gap: 7, children: [
1219
- /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate }),
1158
+ /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate: canUpdate || canCreate }),
1220
1159
  /* @__PURE__ */ jsx(
1221
1160
  Stages,
1222
1161
  {
1223
1162
  canDelete,
1224
- canUpdate,
1163
+ canUpdate: canUpdate || canCreate,
1225
1164
  isCreating: isCreatingWorkflow
1226
1165
  }
1227
1166
  )
1228
1167
  ] }) }),
1229
1168
  /* @__PURE__ */ jsx(
1230
- ConfirmDialog,
1169
+ Dialog.Root,
1231
1170
  {
1232
- isOpen: Object.keys(savePrompts).length > 0,
1233
- onClose: handleConfirmClose,
1234
- onConfirm: handleConfirmDeleteDialog(values, { setErrors }),
1235
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, children: [
1171
+ open: Object.keys(savePrompts).length > 0,
1172
+ onOpenChange: handleConfirmClose,
1173
+ children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm: handleConfirmDeleteDialog(values, { setErrors }), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, children: [
1236
1174
  savePrompts.hasDeletedServerStages && /* @__PURE__ */ jsx(Typography, { textAlign: "center", variant: "omega", children: formatMessage({
1237
1175
  id: "review-workflows.page.delete.confirm.stages.body",
1238
1176
  defaultMessage: "All entries assigned to deleted stages will be moved to the previous stage."
@@ -1252,7 +1190,7 @@ const EditPage = () => {
1252
1190
  id: "review-workflows.page.delete.confirm.confirm",
1253
1191
  defaultMessage: "Are you sure you want to save?"
1254
1192
  }) })
1255
- ] })
1193
+ ] }) })
1256
1194
  }
1257
1195
  )
1258
1196
  ] })
@@ -1261,8 +1199,8 @@ const EditPage = () => {
1261
1199
  /* @__PURE__ */ jsxs(
1262
1200
  LimitsModal.Root,
1263
1201
  {
1264
- isOpen: showLimitModal === "workflow",
1265
- onClose: () => setShowLimitModal(null),
1202
+ open: showLimitModal === "workflow",
1203
+ onOpenChange: () => setShowLimitModal(null),
1266
1204
  children: [
1267
1205
  /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1268
1206
  id: "review-workflows.edit.page.workflows.limit.title",
@@ -1275,16 +1213,23 @@ const EditPage = () => {
1275
1213
  ]
1276
1214
  }
1277
1215
  ),
1278
- /* @__PURE__ */ jsxs(LimitsModal.Root, { isOpen: showLimitModal === "stage", onClose: () => setShowLimitModal(null), children: [
1279
- /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1280
- id: "review-workflows.edit.page.stages.limit.title",
1281
- defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1282
- }) }),
1283
- /* @__PURE__ */ jsx(LimitsModal.Body, { children: formatMessage({
1284
- id: "review-workflows.edit.page.stages.limit.body",
1285
- defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1286
- }) })
1287
- ] })
1216
+ /* @__PURE__ */ jsxs(
1217
+ LimitsModal.Root,
1218
+ {
1219
+ open: showLimitModal === "stage",
1220
+ onOpenChange: () => setShowLimitModal(null),
1221
+ children: [
1222
+ /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1223
+ id: "review-workflows.edit.page.stages.limit.title",
1224
+ defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1225
+ }) }),
1226
+ /* @__PURE__ */ jsx(LimitsModal.Body, { children: formatMessage({
1227
+ id: "review-workflows.edit.page.stages.limit.body",
1228
+ defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1229
+ }) })
1230
+ ]
1231
+ }
1232
+ )
1288
1233
  ] });
1289
1234
  };
1290
1235
  const addTmpKeysToStages = (data) => {
@@ -1308,4 +1253,4 @@ const ProtectedEditPage = () => {
1308
1253
  export {
1309
1254
  ProtectedEditPage
1310
1255
  };
1311
- //# sourceMappingURL=_id-D4CXKOqG.mjs.map
1256
+ //# sourceMappingURL=_id-D9zpHIKW.mjs.map