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

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 (41) hide show
  1. package/LICENSE +12 -17
  2. package/dist/_chunks/{Layout-BSrg0PBJ.mjs → Layout-BpMLb-Oo.mjs} +5 -11
  3. package/dist/_chunks/Layout-BpMLb-Oo.mjs.map +1 -0
  4. package/dist/_chunks/{Layout-BemsgaWF.js → Layout-Cwbb9usb.js} +5 -13
  5. package/dist/_chunks/Layout-Cwbb9usb.js.map +1 -0
  6. package/dist/_chunks/{_id-DO302-GM.mjs → _id-KpezMzxO.mjs} +307 -334
  7. package/dist/_chunks/_id-KpezMzxO.mjs.map +1 -0
  8. package/dist/_chunks/{_id-BDSg16su.js → _id-p9NnvlMP.js} +313 -342
  9. package/dist/_chunks/_id-p9NnvlMP.js.map +1 -0
  10. package/dist/_chunks/{index-BIHOhXvS.js → index-BTr8zF-9.js} +143 -166
  11. package/dist/_chunks/index-BTr8zF-9.js.map +1 -0
  12. package/dist/_chunks/{index-u8XaKwOw.mjs → index-BxkGN0Yj.mjs} +15 -22
  13. package/dist/_chunks/index-BxkGN0Yj.mjs.map +1 -0
  14. package/dist/_chunks/{index-DV2HXfsG.js → index-DqT_oXGP.js} +15 -24
  15. package/dist/_chunks/index-DqT_oXGP.js.map +1 -0
  16. package/dist/_chunks/{index-7V_6cgRk.mjs → index-DtJI5ZoC.mjs} +145 -166
  17. package/dist/_chunks/index-DtJI5ZoC.mjs.map +1 -0
  18. package/dist/_chunks/{router-BdBbXIaZ.mjs → router-B8G2sh6V.mjs} +3 -3
  19. package/dist/_chunks/{router-BdBbXIaZ.mjs.map → router-B8G2sh6V.mjs.map} +1 -1
  20. package/dist/_chunks/{router-BtE6OQHw.js → router-Bqj-105s.js} +3 -3
  21. package/dist/_chunks/{router-BtE6OQHw.js.map → router-Bqj-105s.js.map} +1 -1
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/admin/src/components/LimitsModal.d.ts +2 -4
  25. package/dist/admin/src/routes/settings/hooks/useDragAndDrop.d.ts +4 -4
  26. package/dist/admin/src/routes/settings/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  27. package/dist/admin/src/routes/settings/hooks/useReviewWorkflows.d.ts +3 -3
  28. package/dist/admin/src/services/admin.d.ts +2 -2
  29. package/dist/admin/src/services/api.d.ts +2 -3
  30. package/dist/admin/src/services/content-manager.d.ts +6 -6
  31. package/dist/admin/src/services/settings.d.ts +4 -4
  32. package/dist/admin/src/utils/api.d.ts +4 -19
  33. package/package.json +13 -14
  34. package/dist/_chunks/Layout-BSrg0PBJ.mjs.map +0 -1
  35. package/dist/_chunks/Layout-BemsgaWF.js.map +0 -1
  36. package/dist/_chunks/_id-BDSg16su.js.map +0 -1
  37. package/dist/_chunks/_id-DO302-GM.mjs.map +0 -1
  38. package/dist/_chunks/index-7V_6cgRk.mjs.map +0 -1
  39. package/dist/_chunks/index-BIHOhXvS.js.map +0 -1
  40. package/dist/_chunks/index-DV2HXfsG.js.map +0 -1
  41. package/dist/_chunks/index-u8XaKwOw.mjs.map +0 -1
@@ -2,22 +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, MenuItem, Menu, 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-7V_6cgRk.mjs";
13
- import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-BSrg0PBJ.mjs";
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-DtJI5ZoC.mjs";
13
+ import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-BpMLb-Oo.mjs";
14
14
  import { getEmptyImage } from "react-dnd-html5-backend";
15
- import styled from "styled-components";
15
+ import { styled } from "styled-components";
16
16
  import { useDrop, useDrag } from "react-dnd";
17
17
  const adminApi = reviewWorkflowsApi.injectEndpoints({
18
18
  endpoints(builder) {
19
19
  return {
20
- getRoles: builder.query({
20
+ getAdminRoles: builder.query({
21
21
  query: () => ({
22
22
  url: `/admin/roles`,
23
23
  method: "GET"
@@ -29,7 +29,7 @@ const adminApi = reviewWorkflowsApi.injectEndpoints({
29
29
  };
30
30
  }
31
31
  });
32
- const { useGetRolesQuery } = adminApi;
32
+ const { useGetAdminRolesQuery } = adminApi;
33
33
  const useKeyboardDragAndDrop = (active, index, { onCancel, onDropItem, onGrabItem, onMoveItem }) => {
34
34
  const [isSelected, setIsSelected] = React.useState(false);
35
35
  const handleMove = (movement) => {
@@ -248,16 +248,16 @@ const AddStage = ({ children, ...props }) => {
248
248
  return /* @__PURE__ */ jsx(
249
249
  StyledButton,
250
250
  {
251
- as: "button",
251
+ tag: "button",
252
252
  background: "neutral0",
253
- border: "neutral150",
253
+ borderColor: "neutral150",
254
254
  paddingBottom: 3,
255
255
  paddingLeft: 4,
256
256
  paddingRight: 4,
257
257
  paddingTop: 3,
258
258
  shadow: "filterShadow",
259
259
  ...props,
260
- children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "inherit", children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: 2, children: [
260
+ children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
261
261
  /* @__PURE__ */ jsx(PlusCircle, { width: "2.4rem", height: "2.4rem", "aria-hidden": true }),
262
262
  children
263
263
  ] }) })
@@ -276,7 +276,7 @@ const StyledButton = styled(Box)`
276
276
  color: ${({ theme }) => theme.colors.primary600};
277
277
  }
278
278
  `;
279
- const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
279
+ const Stages = ({ canDelete = true, canUpdate = true, isCreating }) => {
280
280
  const { formatMessage } = useIntl();
281
281
  const { trackUsage } = useTracking();
282
282
  const addFieldRow = useForm("Stages", (state) => state.addFieldRow);
@@ -291,35 +291,23 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
291
291
  left: "50%",
292
292
  position: "absolute",
293
293
  top: "0",
294
- width: 2,
295
- zIndex: 1
294
+ width: 2
296
295
  }
297
296
  ),
298
- /* @__PURE__ */ jsx(
299
- Flex,
300
- {
301
- direction: "column",
302
- alignItems: "stretch",
303
- gap: 6,
304
- zIndex: 2,
305
- position: "relative",
306
- as: "ol",
307
- children: stages.map((stage, index) => {
308
- return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
309
- Stage,
310
- {
311
- index,
312
- canDelete: stages.length > 1 && canDelete,
313
- canReorder: stages.length > 1,
314
- canUpdate,
315
- stagesCount: stages.length,
316
- isOpen: isCreating,
317
- ...stage
318
- }
319
- ) }, stage.__temp_key__);
320
- })
321
- }
322
- )
297
+ /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, position: "relative", tag: "ol", children: stages.map((stage, index) => {
298
+ return /* @__PURE__ */ jsx(Box, { tag: "li", children: /* @__PURE__ */ jsx(
299
+ Stage,
300
+ {
301
+ index,
302
+ canDelete: stages.length > 1 && canDelete,
303
+ canReorder: stages.length > 1,
304
+ canUpdate,
305
+ stagesCount: stages.length,
306
+ defaultOpen: isCreating,
307
+ ...stage
308
+ }
309
+ ) }, stage.__temp_key__);
310
+ }) })
323
311
  ] }),
324
312
  canUpdate && /* @__PURE__ */ jsx(
325
313
  AddStage,
@@ -345,16 +333,15 @@ const Stage = ({
345
333
  canDelete = false,
346
334
  canReorder = false,
347
335
  canUpdate = false,
348
- isOpen: isOpenDefault = false,
349
336
  stagesCount,
350
337
  name,
351
338
  permissions,
352
- color
339
+ color,
340
+ defaultOpen
353
341
  }) => {
354
342
  const [liveText, setLiveText] = React.useState();
355
343
  const { formatMessage } = useIntl();
356
344
  const { trackUsage } = useTracking();
357
- const [isOpen, setIsOpen] = React.useState(isOpenDefault);
358
345
  const stageErrors = useForm("Stages", (state) => state.errors.stages);
359
346
  const error = stageErrors?.[index];
360
347
  const addFieldRow = useForm("Stage", (state) => state.addFieldRow);
@@ -436,7 +423,8 @@ const Stage = ({
436
423
  const handleCloneClick = () => {
437
424
  addFieldRow("stages", { name, color, permissions });
438
425
  };
439
- return /* @__PURE__ */ jsxs(Box, { ref: (ref) => composedRef(ref), children: [
426
+ const id = React.useId();
427
+ return /* @__PURE__ */ jsxs(Box, { ref: composedRef, shadow: "tableShadow", children: [
440
428
  liveText && /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
441
429
  isDragging ? /* @__PURE__ */ jsx(
442
430
  Box,
@@ -447,74 +435,61 @@ const Stage = ({
447
435
  borderWidth: "1px",
448
436
  display: "block",
449
437
  hasRadius: true,
450
- padding: 6,
451
- shadow: "tableShadow"
438
+ padding: 6
452
439
  }
453
- ) : /* @__PURE__ */ jsxs(
454
- Accordion,
440
+ ) : /* @__PURE__ */ jsx(
441
+ AccordionRoot,
455
442
  {
456
- size: "S",
457
- variant: "primary",
458
- onToggle: () => {
459
- setIsOpen(!isOpen);
460
- if (!isOpen) {
443
+ onValueChange: (value) => {
444
+ if (value) {
461
445
  trackUsage("willEditStage");
462
446
  }
463
447
  },
464
- expanded: isOpen,
465
- shadow: "tableShadow",
466
- error: Object.values(error ?? {})[0],
467
- hasErrorMessage: false,
468
- children: [
469
- /* @__PURE__ */ jsx(
470
- AccordionToggle,
471
- {
472
- title: name,
473
- togglePosition: "left",
474
- action: (canDelete || canUpdate) && /* @__PURE__ */ jsxs(Flex, { children: [
475
- /* @__PURE__ */ jsxs(Menu.Root, { children: [
476
- /* @__PURE__ */ jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
477
- /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
478
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: formatMessage({
479
- id: "[tbdb].components.DynamicZone.more-actions",
480
- defaultMessage: "More actions"
481
- }) })
482
- ] }),
483
- /* @__PURE__ */ jsx(Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
484
- canUpdate && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCloneClick, children: formatMessage({
485
- id: "Settings.review-workflows.stage.delete",
486
- defaultMessage: "Duplicate stage"
487
- }) }),
488
- canDelete && /* @__PURE__ */ jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index), children: formatMessage({
489
- id: "Settings.review-workflows.stage.delete",
490
- defaultMessage: "Delete"
491
- }) })
492
- ] }) })
448
+ defaultValue: defaultOpen ? id : void 0,
449
+ $error: Object.values(error ?? {}).length > 0,
450
+ children: /* @__PURE__ */ jsxs(Accordion.Item, { value: id, children: [
451
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
452
+ /* @__PURE__ */ jsx(Accordion.Trigger, { children: name }),
453
+ /* @__PURE__ */ jsx(Accordion.Actions, { children: canDelete || canUpdate ? /* @__PURE__ */ jsxs(Fragment, { children: [
454
+ /* @__PURE__ */ jsxs(Menu.Root, { children: [
455
+ /* @__PURE__ */ jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
456
+ /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
457
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
458
+ id: "[tbdb].components.DynamicZone.more-actions",
459
+ defaultMessage: "More actions"
460
+ }) })
493
461
  ] }),
494
- canUpdate && /* @__PURE__ */ jsx(
495
- DragIconButton,
496
- {
497
- background: "transparent",
498
- forwardedAs: "div",
499
- hasRadius: true,
500
- role: "button",
501
- noBorder: true,
502
- tabIndex: 0,
503
- "data-handler-id": handlerId,
504
- ref: dragRef,
505
- label: formatMessage({
506
- id: "Settings.review-workflows.stage.drag",
507
- defaultMessage: "Drag"
508
- }),
509
- onClick: (e) => e.stopPropagation(),
510
- onKeyDown: handleKeyDown,
511
- children: /* @__PURE__ */ jsx(Drag, {})
512
- }
513
- )
514
- ] })
515
- }
516
- ),
517
- /* @__PURE__ */ jsx(AccordionContent, { padding: 6, background: "neutral0", hasRadius: true, children: /* @__PURE__ */ jsx(Grid, { gap: 4, children: [
462
+ /* @__PURE__ */ jsx(Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
463
+ canUpdate && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCloneClick, children: formatMessage({
464
+ id: "Settings.review-workflows.stage.delete",
465
+ defaultMessage: "Duplicate stage"
466
+ }) }),
467
+ canDelete && /* @__PURE__ */ jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index), children: formatMessage({
468
+ id: "Settings.review-workflows.stage.delete",
469
+ defaultMessage: "Delete"
470
+ }) })
471
+ ] }) })
472
+ ] }),
473
+ canUpdate && /* @__PURE__ */ jsx(
474
+ IconButton,
475
+ {
476
+ background: "transparent",
477
+ hasRadius: true,
478
+ borderWidth: 0,
479
+ "data-handler-id": handlerId,
480
+ ref: dragRef,
481
+ label: formatMessage({
482
+ id: "Settings.review-workflows.stage.drag",
483
+ defaultMessage: "Drag"
484
+ }),
485
+ onClick: (e) => e.stopPropagation(),
486
+ onKeyDown: handleKeyDown,
487
+ children: /* @__PURE__ */ jsx(Drag, {})
488
+ }
489
+ )
490
+ ] }) : null })
491
+ ] }),
492
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid.Root, { gap: 4, padding: 6, children: [
518
493
  {
519
494
  disabled: !canUpdate,
520
495
  label: formatMessage({
@@ -552,12 +527,16 @@ const Stage = ({
552
527
  size: 6,
553
528
  type: "permissions"
554
529
  }
555
- ].map(({ size, ...field }) => /* @__PURE__ */ jsx(GridItem, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
556
- ]
530
+ ].map(({ size, ...field }) => /* @__PURE__ */ jsx(Grid.Item, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
531
+ ] })
557
532
  }
558
533
  )
559
534
  ] });
560
535
  };
536
+ const AccordionRoot = styled(Accordion.Root)`
537
+ border: 1px solid
538
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
539
+ `;
561
540
  const DeleteMenuItem = styled(MenuItem)`
562
541
  color: ${({ theme }) => theme.colors.danger600};
563
542
  `;
@@ -571,22 +550,6 @@ const ContextMenuTrigger = styled(Menu.Trigger)`
571
550
  font-size: 0;
572
551
  }
573
552
  `;
574
- const DragIconButton = styled(IconButton)`
575
- align-items: center;
576
- border-radius: ${({ theme }) => theme.borderRadius};
577
- display: flex;
578
- justify-content: center;
579
-
580
- &:hover,
581
- &:focus {
582
- background-color: ${({ theme }) => theme.colors.neutral100};
583
- }
584
-
585
- svg {
586
- height: auto;
587
- width: ${({ theme }) => theme.spaces[3]};
588
- }
589
- `;
590
553
  const InputRenderer = (props) => {
591
554
  switch (props.type) {
592
555
  case "color":
@@ -612,54 +575,55 @@ const ColorSelector = ({ disabled, label, name, required }) => {
612
575
  color: hex
613
576
  }));
614
577
  const { themeColorName } = getStageColorByHex(value) ?? {};
615
- return /* @__PURE__ */ jsx(
616
- SingleSelect,
617
- {
618
- disabled,
619
- error,
620
- required,
621
- label,
622
- onChange: (v) => {
623
- onChange(name, v.toString());
624
- },
625
- value: value?.toUpperCase(),
626
- startIcon: /* @__PURE__ */ jsx(
627
- Flex,
628
- {
629
- as: "span",
630
- height: 2,
631
- background: value,
632
- borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
633
- hasRadius: true,
634
- shrink: 0,
635
- width: 2
636
- }
637
- ),
638
- children: colorOptions.map(({ value: value2, label: label2, color }) => {
639
- const { themeColorName: themeColorName2 } = getStageColorByHex(color) || {};
640
- return /* @__PURE__ */ jsx(
641
- SingleSelectOption,
578
+ return /* @__PURE__ */ jsxs(Field.Root, { error, name, required, children: [
579
+ /* @__PURE__ */ jsx(Field.Label, { children: label }),
580
+ /* @__PURE__ */ jsx(
581
+ SingleSelect,
582
+ {
583
+ disabled,
584
+ onChange: (v) => {
585
+ onChange(name, v.toString());
586
+ },
587
+ value: value?.toUpperCase(),
588
+ startIcon: /* @__PURE__ */ jsx(
589
+ Flex,
642
590
  {
643
- value: value2,
644
- startIcon: /* @__PURE__ */ jsx(
645
- Flex,
646
- {
647
- as: "span",
648
- height: 2,
649
- background: color,
650
- borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
651
- hasRadius: true,
652
- shrink: 0,
653
- width: 2
654
- }
655
- ),
656
- children: label2
657
- },
658
- value2
659
- );
660
- })
661
- }
662
- );
591
+ tag: "span",
592
+ height: 2,
593
+ background: value,
594
+ borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
595
+ hasRadius: true,
596
+ shrink: 0,
597
+ width: 2
598
+ }
599
+ ),
600
+ children: colorOptions.map(({ value: value2, label: label2, color }) => {
601
+ const { themeColorName: themeColorName2 } = getStageColorByHex(color) || {};
602
+ return /* @__PURE__ */ jsx(
603
+ SingleSelectOption,
604
+ {
605
+ value: value2,
606
+ startIcon: /* @__PURE__ */ jsx(
607
+ Flex,
608
+ {
609
+ tag: "span",
610
+ height: 2,
611
+ background: color,
612
+ borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
613
+ hasRadius: true,
614
+ shrink: 0,
615
+ width: 2
616
+ }
617
+ ),
618
+ children: label2
619
+ },
620
+ value2
621
+ );
622
+ })
623
+ }
624
+ ),
625
+ /* @__PURE__ */ jsx(Field.Error, {})
626
+ ] });
663
627
  };
664
628
  const PermissionsField = ({ disabled, name, placeholder, required }) => {
665
629
  const { formatMessage } = useIntl();
@@ -668,57 +632,65 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
668
632
  const { value = [], error, onChange } = useField(name);
669
633
  const allStages = useForm("PermissionsField", (state) => state.values.stages);
670
634
  const onFormValueChange = useForm("PermissionsField", (state) => state.onChange);
671
- const { data: roles = [], isLoading } = useGetRolesQuery();
635
+ const rolesErrorCount = React.useRef(0);
636
+ const { data: roles = [], isLoading, error: getRolesError } = useGetAdminRolesQuery();
672
637
  const filteredRoles = roles?.filter((role) => role.code !== "strapi-super-admin") ?? [];
673
638
  React.useEffect(() => {
674
- if (!isLoading && roles.length === 0) {
639
+ if (!isLoading && getRolesError && "status" in getRolesError && getRolesError.status == 403 && rolesErrorCount.current === 0) {
640
+ rolesErrorCount.current = 1;
675
641
  toggleNotification({
676
642
  blockTransition: true,
677
643
  type: "danger",
678
644
  message: formatMessage({
679
645
  id: "review-workflows.stage.permissions.noPermissions.description",
680
- defaultMessage: "You don’t have the permission to see roles"
646
+ defaultMessage: "You don’t have the permission to see roles. Contact your administrator."
681
647
  })
682
648
  });
683
649
  }
684
- }, [formatMessage, isLoading, roles, toggleNotification]);
650
+ }, [formatMessage, isLoading, roles, toggleNotification, getRolesError]);
685
651
  if (!isLoading && filteredRoles.length === 0) {
686
- return /* @__PURE__ */ jsx(
687
- TextInput,
652
+ return /* @__PURE__ */ jsxs(
653
+ Field.Root,
688
654
  {
689
- disabled: true,
690
655
  name,
691
656
  hint: formatMessage({
692
657
  id: "Settings.review-workflows.stage.permissions.noPermissions.description",
693
658
  defaultMessage: "You don’t have the permission to see roles"
694
659
  }),
695
- label: formatMessage({
696
- id: "Settings.review-workflows.stage.permissions.label",
697
- defaultMessage: "Roles that can change this stage"
698
- }),
699
- placeholder: formatMessage({
700
- id: "components.NotAllowedInput.text",
701
- defaultMessage: "No permissions to see this field"
702
- }),
703
660
  required,
704
- startAction: /* @__PURE__ */ jsx(StyledIcon, {}),
705
- type: "text",
706
- value: ""
661
+ children: [
662
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
663
+ id: "Settings.review-workflows.stage.permissions.label",
664
+ defaultMessage: "Roles that can change this stage"
665
+ }) }),
666
+ /* @__PURE__ */ jsx(
667
+ TextInput,
668
+ {
669
+ disabled: true,
670
+ placeholder: formatMessage({
671
+ id: "components.NotAllowedInput.text",
672
+ defaultMessage: "No permissions to see this field"
673
+ }),
674
+ startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
675
+ type: "text",
676
+ value: ""
677
+ }
678
+ ),
679
+ /* @__PURE__ */ jsx(Field.Hint, {})
680
+ ]
707
681
  }
708
682
  );
709
683
  }
710
- return /* @__PURE__ */ jsxs(Fragment, { children: [
711
- /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-end", gap: 3, children: [
712
- /* @__PURE__ */ jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsx(
684
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-end", gap: 3, children: [
685
+ /* @__PURE__ */ jsx(PermissionWrapper, { grow: 1, children: /* @__PURE__ */ jsxs(Field.Root, { error, name, required: true, children: [
686
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
687
+ id: "Settings.review-workflows.stage.permissions.label",
688
+ defaultMessage: "Roles that can change this stage"
689
+ }) }),
690
+ /* @__PURE__ */ jsx(
713
691
  MultiSelect,
714
692
  {
715
693
  disabled,
716
- error,
717
- id: name,
718
- label: formatMessage({
719
- id: "Settings.review-workflows.stage.permissions.label",
720
- defaultMessage: "Roles that can change this stage"
721
- }),
722
694
  onChange: (values) => {
723
695
  const permissions = values.map((value2) => ({
724
696
  role: parseInt(value2, 10),
@@ -727,7 +699,6 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
727
699
  onChange(name, permissions);
728
700
  },
729
701
  placeholder,
730
- required: true,
731
702
  value: value.map((permission) => `${permission.role}`),
732
703
  withTags: true,
733
704
  children: /* @__PURE__ */ jsx(
@@ -744,58 +715,53 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
744
715
  }
745
716
  )
746
717
  }
747
- ) }),
748
- /* @__PURE__ */ jsx(
718
+ ),
719
+ /* @__PURE__ */ jsx(Field.Error, {})
720
+ ] }) }),
721
+ /* @__PURE__ */ jsxs(Dialog.Root, { open: isApplyAllConfirmationOpen, onOpenChange: setIsApplyAllConfirmationOpen, children: [
722
+ /* @__PURE__ */ jsx(Dialog.Trigger, { children: /* @__PURE__ */ jsx(
749
723
  IconButton,
750
724
  {
751
725
  disabled,
752
- icon: /* @__PURE__ */ jsx(Duplicate, {}),
753
726
  label: formatMessage({
754
727
  id: "Settings.review-workflows.stage.permissions.apply.label",
755
728
  defaultMessage: "Apply to all stages"
756
729
  }),
757
730
  size: "L",
758
731
  variant: "secondary",
759
- onClick: () => setIsApplyAllConfirmationOpen(true)
732
+ children: /* @__PURE__ */ jsx(Duplicate, {})
733
+ }
734
+ ) }),
735
+ /* @__PURE__ */ jsx(
736
+ ConfirmDialog,
737
+ {
738
+ onConfirm: () => {
739
+ onFormValueChange(
740
+ "stages",
741
+ allStages.map((stage) => ({
742
+ ...stage,
743
+ permissions: value
744
+ }))
745
+ );
746
+ setIsApplyAllConfirmationOpen(false);
747
+ toggleNotification({
748
+ type: "success",
749
+ message: formatMessage({
750
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
751
+ defaultMessage: "Applied roles to all other stages of the workflow"
752
+ })
753
+ });
754
+ },
755
+ variant: "default",
756
+ children: formatMessage({
757
+ id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
758
+ defaultMessage: "Roles that can change that stage will be applied to all the other stages."
759
+ })
760
760
  }
761
761
  )
762
- ] }),
763
- /* @__PURE__ */ jsx(
764
- ConfirmDialog,
765
- {
766
- isOpen: isApplyAllConfirmationOpen,
767
- onClose: () => setIsApplyAllConfirmationOpen(false),
768
- onConfirm: () => {
769
- onFormValueChange(
770
- "stages",
771
- allStages.map((stage) => ({
772
- ...stage,
773
- permissions: value
774
- }))
775
- );
776
- setIsApplyAllConfirmationOpen(false);
777
- toggleNotification({
778
- type: "success",
779
- message: formatMessage({
780
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
781
- defaultMessage: "Applied roles to all other stages of the workflow"
782
- })
783
- });
784
- },
785
- variant: "default",
786
- children: formatMessage({
787
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
788
- defaultMessage: "Roles that can change that stage will be applied to all the other stages."
789
- })
790
- }
791
- )
792
- ] });
762
+ ] })
763
+ ] }) });
793
764
  };
794
- const StyledIcon = styled(EyeStriked)`
795
- & > path {
796
- fill: ${({ theme }) => theme.colors.neutral600};
797
- }
798
- `;
799
765
  const NestedOption$1 = styled(MultiSelectOption)`
800
766
  padding-left: ${({ theme }) => theme.spaces[7]};
801
767
  `;
@@ -806,8 +772,8 @@ const PermissionWrapper = styled(Flex)`
806
772
  `;
807
773
  const WorkflowAttributes = ({ canUpdate = true }) => {
808
774
  const { formatMessage } = useIntl();
809
- return /* @__PURE__ */ jsxs(Grid, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
810
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
775
+ return /* @__PURE__ */ jsxs(Grid.Root, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
776
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(
811
777
  InputRenderer$1,
812
778
  {
813
779
  disabled: !canUpdate,
@@ -820,7 +786,7 @@ const WorkflowAttributes = ({ canUpdate = true }) => {
820
786
  type: "string"
821
787
  }
822
788
  ) }),
823
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
789
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
824
790
  ] });
825
791
  };
826
792
  const ContentTypesSelector = ({ disabled }) => {
@@ -841,81 +807,82 @@ const ContentTypesSelector = ({ disabled }) => {
841
807
  label: contentType.info.displayName,
842
808
  value: contentType.uid
843
809
  }));
844
- return /* @__PURE__ */ jsx(
845
- MultiSelect,
846
- {
847
- customizeContent: (value2) => formatMessage(
848
- {
849
- id: "Settings.review-workflows.workflow.contentTypes.displayValue",
850
- defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
851
- },
852
- { count: value2?.length }
853
- ),
854
- disabled: isDisabled,
855
- error,
856
- label: formatMessage({
857
- id: "Settings.review-workflows.workflow.contentTypes.label",
858
- defaultMessage: "Associated to"
859
- }),
860
- onChange: (values) => {
861
- onChange("contentTypes", values);
862
- },
863
- value,
864
- placeholder: formatMessage({
865
- id: "Settings.review-workflows.workflow.contentTypes.placeholder",
866
- defaultMessage: "Select"
867
- }),
868
- children: [
869
- ...collectionTypes.length > 0 ? [
870
- {
871
- label: formatMessage({
872
- id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
873
- defaultMessage: "Collection Types"
874
- }),
875
- children: collectionTypes
876
- }
877
- ] : [],
878
- ...singleTypes.length > 0 ? [
879
- {
880
- label: formatMessage({
881
- id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
882
- defaultMessage: "Single Types"
883
- }),
884
- children: singleTypes
885
- }
886
- ] : []
887
- ].map((opt) => {
888
- return /* @__PURE__ */ jsx(
889
- MultiSelectGroup,
810
+ return /* @__PURE__ */ jsxs(Field.Root, { error, name: "contentTypes", children: [
811
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
812
+ id: "Settings.review-workflows.workflow.contentTypes.label",
813
+ defaultMessage: "Associated to"
814
+ }) }),
815
+ /* @__PURE__ */ jsx(
816
+ MultiSelect,
817
+ {
818
+ customizeContent: (value2) => formatMessage(
890
819
  {
891
- label: opt.label,
892
- values: opt.children.map((child) => child.value.toString()),
893
- children: opt.children.map((child) => {
894
- const { name: assignedWorkflowName } = workflows?.find(
895
- (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
896
- ) ?? {};
897
- return /* @__PURE__ */ jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsx(Typography, {
898
- // @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
899
- children: formatMessage(
900
- {
901
- id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
902
- defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
903
- },
904
- {
905
- label: child.label,
906
- name: assignedWorkflowName,
907
- em: (...children) => /* @__PURE__ */ jsx(Typography, { as: "em", fontWeight: "bold", children }),
908
- i: (...children) => /* @__PURE__ */ jsx(ContentTypeTakeNotice, { children })
909
- }
910
- )
911
- }) }, child.value);
912
- })
820
+ id: "Settings.review-workflows.workflow.contentTypes.displayValue",
821
+ defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
913
822
  },
914
- opt.label
915
- );
916
- })
917
- }
918
- );
823
+ { count: value2?.length }
824
+ ),
825
+ disabled: isDisabled,
826
+ onChange: (values) => {
827
+ onChange("contentTypes", values);
828
+ },
829
+ value,
830
+ placeholder: formatMessage({
831
+ id: "Settings.review-workflows.workflow.contentTypes.placeholder",
832
+ defaultMessage: "Select"
833
+ }),
834
+ children: [
835
+ ...collectionTypes.length > 0 ? [
836
+ {
837
+ label: formatMessage({
838
+ id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
839
+ defaultMessage: "Collection Types"
840
+ }),
841
+ children: collectionTypes
842
+ }
843
+ ] : [],
844
+ ...singleTypes.length > 0 ? [
845
+ {
846
+ label: formatMessage({
847
+ id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
848
+ defaultMessage: "Single Types"
849
+ }),
850
+ children: singleTypes
851
+ }
852
+ ] : []
853
+ ].map((opt) => {
854
+ return /* @__PURE__ */ jsx(
855
+ MultiSelectGroup,
856
+ {
857
+ label: opt.label,
858
+ values: opt.children.map((child) => child.value.toString()),
859
+ children: opt.children.map((child) => {
860
+ const { name: assignedWorkflowName } = workflows?.find(
861
+ (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
862
+ ) ?? {};
863
+ return /* @__PURE__ */ jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsx(Typography, {
864
+ // @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
865
+ children: formatMessage(
866
+ {
867
+ id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
868
+ defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
869
+ },
870
+ {
871
+ label: child.label,
872
+ name: assignedWorkflowName,
873
+ em: (...children) => /* @__PURE__ */ jsx(Typography, { tag: "em", fontWeight: "bold", children }),
874
+ i: (...children) => /* @__PURE__ */ jsx(ContentTypeTakeNotice, { children })
875
+ }
876
+ )
877
+ }) }, child.value);
878
+ })
879
+ },
880
+ opt.label
881
+ );
882
+ })
883
+ }
884
+ )
885
+ ] });
919
886
  };
920
887
  const NestedOption = styled(MultiSelectOption)`
921
888
  padding-left: ${({ theme }) => theme.spaces[7]};
@@ -1176,23 +1143,22 @@ const EditPage = () => {
1176
1143
  }
1177
1144
  ),
1178
1145
  /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "stretch", direction: "column", gap: 7, children: [
1179
- /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate }),
1146
+ /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate: canUpdate || canCreate }),
1180
1147
  /* @__PURE__ */ jsx(
1181
1148
  Stages,
1182
1149
  {
1183
1150
  canDelete,
1184
- canUpdate,
1151
+ canUpdate: canUpdate || canCreate,
1185
1152
  isCreating: isCreatingWorkflow
1186
1153
  }
1187
1154
  )
1188
1155
  ] }) }),
1189
1156
  /* @__PURE__ */ jsx(
1190
- ConfirmDialog,
1157
+ Dialog.Root,
1191
1158
  {
1192
- isOpen: Object.keys(savePrompts).length > 0,
1193
- onClose: handleConfirmClose,
1194
- onConfirm: handleConfirmDeleteDialog(values, { setErrors }),
1195
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, children: [
1159
+ open: Object.keys(savePrompts).length > 0,
1160
+ onOpenChange: handleConfirmClose,
1161
+ children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm: handleConfirmDeleteDialog(values, { setErrors }), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, children: [
1196
1162
  savePrompts.hasDeletedServerStages && /* @__PURE__ */ jsx(Typography, { textAlign: "center", variant: "omega", children: formatMessage({
1197
1163
  id: "review-workflows.page.delete.confirm.stages.body",
1198
1164
  defaultMessage: "All entries assigned to deleted stages will be moved to the previous stage."
@@ -1212,7 +1178,7 @@ const EditPage = () => {
1212
1178
  id: "review-workflows.page.delete.confirm.confirm",
1213
1179
  defaultMessage: "Are you sure you want to save?"
1214
1180
  }) })
1215
- ] })
1181
+ ] }) })
1216
1182
  }
1217
1183
  )
1218
1184
  ] })
@@ -1221,8 +1187,8 @@ const EditPage = () => {
1221
1187
  /* @__PURE__ */ jsxs(
1222
1188
  LimitsModal.Root,
1223
1189
  {
1224
- isOpen: showLimitModal === "workflow",
1225
- onClose: () => setShowLimitModal(null),
1190
+ open: showLimitModal === "workflow",
1191
+ onOpenChange: () => setShowLimitModal(null),
1226
1192
  children: [
1227
1193
  /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1228
1194
  id: "review-workflows.edit.page.workflows.limit.title",
@@ -1235,16 +1201,23 @@ const EditPage = () => {
1235
1201
  ]
1236
1202
  }
1237
1203
  ),
1238
- /* @__PURE__ */ jsxs(LimitsModal.Root, { isOpen: showLimitModal === "stage", onClose: () => setShowLimitModal(null), children: [
1239
- /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1240
- id: "review-workflows.edit.page.stages.limit.title",
1241
- defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1242
- }) }),
1243
- /* @__PURE__ */ jsx(LimitsModal.Body, { children: formatMessage({
1244
- id: "review-workflows.edit.page.stages.limit.body",
1245
- defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1246
- }) })
1247
- ] })
1204
+ /* @__PURE__ */ jsxs(
1205
+ LimitsModal.Root,
1206
+ {
1207
+ open: showLimitModal === "stage",
1208
+ onOpenChange: () => setShowLimitModal(null),
1209
+ children: [
1210
+ /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1211
+ id: "review-workflows.edit.page.stages.limit.title",
1212
+ defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1213
+ }) }),
1214
+ /* @__PURE__ */ jsx(LimitsModal.Body, { children: formatMessage({
1215
+ id: "review-workflows.edit.page.stages.limit.body",
1216
+ defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1217
+ }) })
1218
+ ]
1219
+ }
1220
+ )
1248
1221
  ] });
1249
1222
  };
1250
1223
  const addTmpKeysToStages = (data) => {
@@ -1268,4 +1241,4 @@ const ProtectedEditPage = () => {
1268
1241
  export {
1269
1242
  ProtectedEditPage
1270
1243
  };
1271
- //# sourceMappingURL=_id-DO302-GM.mjs.map
1244
+ //# sourceMappingURL=_id-KpezMzxO.mjs.map