@strapi/review-workflows 0.0.0-experimental.defd8568ae03ef8d52f86e1f3541979f953c3941 → 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4

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-Py8gxQW2.js → Layout-D3DDQmMI.js} +6 -14
  3. package/dist/_chunks/Layout-D3DDQmMI.js.map +1 -0
  4. package/dist/_chunks/{Layout-B_cKmQA3.mjs → Layout-Da8jupiA.mjs} +8 -14
  5. package/dist/_chunks/Layout-Da8jupiA.mjs.map +1 -0
  6. package/dist/_chunks/{_id-BeUU-t6D.js → _id-CnRDP3Xx.js} +319 -387
  7. package/dist/_chunks/_id-CnRDP3Xx.js.map +1 -0
  8. package/dist/_chunks/{_id-C_HRFhcV.mjs → _id-xSrgPSJs.mjs} +313 -379
  9. package/dist/_chunks/_id-xSrgPSJs.mjs.map +1 -0
  10. package/dist/_chunks/{index-DyJcIA81.js → index-4kp4AkBB.js} +23 -37
  11. package/dist/_chunks/index-4kp4AkBB.js.map +1 -0
  12. package/dist/_chunks/{index-DjHtLGgq.mjs → index-DDsJlZQw.mjs} +114 -163
  13. package/dist/_chunks/index-DDsJlZQw.mjs.map +1 -0
  14. package/dist/_chunks/{index-D3AvHSbj.js → index-DhPxWpsW.js} +112 -163
  15. package/dist/_chunks/index-DhPxWpsW.js.map +1 -0
  16. package/dist/_chunks/{index-CAgnun9R.mjs → index-jfO5GxtW.mjs} +23 -35
  17. package/dist/_chunks/index-jfO5GxtW.mjs.map +1 -0
  18. package/dist/_chunks/{purchase-review-workflows-DyffLpyz.mjs → purchase-review-workflows-BN-5Ube7.mjs} +5 -4
  19. package/dist/_chunks/purchase-review-workflows-BN-5Ube7.mjs.map +1 -0
  20. package/dist/_chunks/{purchase-review-workflows-BaOk5p_m.js → purchase-review-workflows-DlCDg0fD.js} +4 -3
  21. package/dist/_chunks/purchase-review-workflows-DlCDg0fD.js.map +1 -0
  22. package/dist/_chunks/{router-zN3-SLwz.mjs → router-DOEULOpS.mjs} +3 -3
  23. package/dist/_chunks/{router-zN3-SLwz.mjs.map → router-DOEULOpS.mjs.map} +1 -1
  24. package/dist/_chunks/{router-BwVSq4yF.js → router-DSXpeew4.js} +3 -3
  25. package/dist/_chunks/{router-BwVSq4yF.js.map → router-DSXpeew4.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-B_cKmQA3.mjs.map +0 -1
  41. package/dist/_chunks/Layout-Py8gxQW2.js.map +0 -1
  42. package/dist/_chunks/_id-BeUU-t6D.js.map +0 -1
  43. package/dist/_chunks/_id-C_HRFhcV.mjs.map +0 -1
  44. package/dist/_chunks/index-CAgnun9R.mjs.map +0 -1
  45. package/dist/_chunks/index-D3AvHSbj.js.map +0 -1
  46. package/dist/_chunks/index-DjHtLGgq.mjs.map +0 -1
  47. package/dist/_chunks/index-DyJcIA81.js.map +0 -1
  48. package/dist/_chunks/purchase-review-workflows-BaOk5p_m.js.map +0 -1
  49. package/dist/_chunks/purchase-review-workflows-DyffLpyz.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-DjHtLGgq.mjs";
13
- import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-B_cKmQA3.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-DDsJlZQw.mjs";
13
+ import { D as DRAG_DROP_TYPES, u as useReviewWorkflows, a as DragLayerRendered, H as Header, R as Root } from "./Layout-Da8jupiA.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,74 +248,35 @@ 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__ */ jsxs(Flex, { gap: 2, children: [
261
- /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true }),
262
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral500", children })
263
- ] })
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
+ ] }) })
264
264
  }
265
265
  );
266
266
  };
267
- const StyledAddIcon = styled(PlusCircle)`
268
- > circle {
269
- fill: ${({ theme }) => theme.colors.neutral150};
270
- }
271
- > path {
272
- fill: ${({ theme }) => theme.colors.neutral600};
273
- }
274
- `;
275
267
  const StyledButton = styled(Box)`
276
268
  border-radius: 26px;
277
-
278
- svg {
279
- height: ${({ theme }) => theme.spaces[6]};
280
- width: ${({ theme }) => theme.spaces[6]};
281
-
282
- > path {
283
- fill: ${({ theme }) => theme.colors.neutral600};
284
- }
285
- }
269
+ color: ${({ theme }) => theme.colors.neutral500};
286
270
 
287
271
  &:hover {
288
- color: ${({ theme }) => theme.colors.primary600} !important;
289
- ${Typography} {
290
- color: ${({ theme }) => theme.colors.primary600} !important;
291
- }
292
-
293
- ${StyledAddIcon} {
294
- > circle {
295
- fill: ${({ theme }) => theme.colors.primary600};
296
- }
297
- > path {
298
- fill: ${({ theme }) => theme.colors.neutral100};
299
- }
300
- }
272
+ color: ${({ theme }) => theme.colors.primary600};
301
273
  }
302
274
 
303
275
  &:active {
304
- ${Typography} {
305
- color: ${({ theme }) => theme.colors.primary600};
306
- }
307
-
308
- ${StyledAddIcon} {
309
- > circle {
310
- fill: ${({ theme }) => theme.colors.primary600};
311
- }
312
- > path {
313
- fill: ${({ theme }) => theme.colors.neutral100};
314
- }
315
- }
276
+ color: ${({ theme }) => theme.colors.primary600};
316
277
  }
317
278
  `;
318
- const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
279
+ const Stages = ({ canDelete = true, canUpdate = true, isCreating }) => {
319
280
  const { formatMessage } = useIntl();
320
281
  const { trackUsage } = useTracking();
321
282
  const addFieldRow = useForm("Stages", (state) => state.addFieldRow);
@@ -330,35 +291,23 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
330
291
  left: "50%",
331
292
  position: "absolute",
332
293
  top: "0",
333
- width: 2,
334
- zIndex: 1
294
+ width: 2
335
295
  }
336
296
  ),
337
- /* @__PURE__ */ jsx(
338
- Flex,
339
- {
340
- direction: "column",
341
- alignItems: "stretch",
342
- gap: 6,
343
- zIndex: 2,
344
- position: "relative",
345
- as: "ol",
346
- children: stages.map((stage, index) => {
347
- return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
348
- Stage,
349
- {
350
- index,
351
- canDelete: stages.length > 1 && canDelete,
352
- canReorder: stages.length > 1,
353
- canUpdate,
354
- stagesCount: stages.length,
355
- isOpen: isCreating,
356
- ...stage
357
- }
358
- ) }, stage.__temp_key__);
359
- })
360
- }
361
- )
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
+ }) })
362
311
  ] }),
363
312
  canUpdate && /* @__PURE__ */ jsx(
364
313
  AddStage,
@@ -384,16 +333,15 @@ const Stage = ({
384
333
  canDelete = false,
385
334
  canReorder = false,
386
335
  canUpdate = false,
387
- isOpen: isOpenDefault = false,
388
336
  stagesCount,
389
337
  name,
390
338
  permissions,
391
- color
339
+ color,
340
+ defaultOpen
392
341
  }) => {
393
342
  const [liveText, setLiveText] = React.useState();
394
343
  const { formatMessage } = useIntl();
395
344
  const { trackUsage } = useTracking();
396
- const [isOpen, setIsOpen] = React.useState(isOpenDefault);
397
345
  const stageErrors = useForm("Stages", (state) => state.errors.stages);
398
346
  const error = stageErrors?.[index];
399
347
  const addFieldRow = useForm("Stage", (state) => state.addFieldRow);
@@ -475,7 +423,8 @@ const Stage = ({
475
423
  const handleCloneClick = () => {
476
424
  addFieldRow("stages", { name, color, permissions });
477
425
  };
478
- return /* @__PURE__ */ jsxs(Box, { ref: (ref) => composedRef(ref), children: [
426
+ const id = React.useId();
427
+ return /* @__PURE__ */ jsxs(Box, { ref: composedRef, shadow: "tableShadow", children: [
479
428
  liveText && /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
480
429
  isDragging ? /* @__PURE__ */ jsx(
481
430
  Box,
@@ -486,74 +435,61 @@ const Stage = ({
486
435
  borderWidth: "1px",
487
436
  display: "block",
488
437
  hasRadius: true,
489
- padding: 6,
490
- shadow: "tableShadow"
438
+ padding: 6
491
439
  }
492
- ) : /* @__PURE__ */ jsxs(
493
- Accordion,
440
+ ) : /* @__PURE__ */ jsx(
441
+ AccordionRoot,
494
442
  {
495
- size: "S",
496
- variant: "primary",
497
- onToggle: () => {
498
- setIsOpen(!isOpen);
499
- if (!isOpen) {
443
+ onValueChange: (value) => {
444
+ if (value) {
500
445
  trackUsage("willEditStage");
501
446
  }
502
447
  },
503
- expanded: isOpen,
504
- shadow: "tableShadow",
505
- error: Object.values(error ?? {})[0],
506
- hasErrorMessage: false,
507
- children: [
508
- /* @__PURE__ */ jsx(
509
- AccordionToggle,
510
- {
511
- title: name,
512
- togglePosition: "left",
513
- action: (canDelete || canUpdate) && /* @__PURE__ */ jsxs(Flex, { children: [
514
- /* @__PURE__ */ jsxs(Menu.Root, { children: [
515
- /* @__PURE__ */ jsxs(ContextMenuTrigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
516
- /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
517
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: formatMessage({
518
- id: "[tbdb].components.DynamicZone.more-actions",
519
- defaultMessage: "More actions"
520
- }) })
521
- ] }),
522
- /* @__PURE__ */ jsx(Menu.Content, { popoverPlacement: "bottom-end", zIndex: 2, children: /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
523
- canUpdate && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCloneClick, children: formatMessage({
524
- id: "Settings.review-workflows.stage.delete",
525
- defaultMessage: "Duplicate stage"
526
- }) }),
527
- canDelete && /* @__PURE__ */ jsx(DeleteMenuItem, { onClick: () => removeFieldRow("stages", index), children: formatMessage({
528
- id: "Settings.review-workflows.stage.delete",
529
- defaultMessage: "Delete"
530
- }) })
531
- ] }) })
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
+ }) })
532
461
  ] }),
533
- canUpdate && /* @__PURE__ */ jsx(
534
- DragIconButton,
535
- {
536
- background: "transparent",
537
- forwardedAs: "div",
538
- hasRadius: true,
539
- role: "button",
540
- noBorder: true,
541
- tabIndex: 0,
542
- "data-handler-id": handlerId,
543
- ref: dragRef,
544
- label: formatMessage({
545
- id: "Settings.review-workflows.stage.drag",
546
- defaultMessage: "Drag"
547
- }),
548
- onClick: (e) => e.stopPropagation(),
549
- onKeyDown: handleKeyDown,
550
- children: /* @__PURE__ */ jsx(Drag, {})
551
- }
552
- )
553
- ] })
554
- }
555
- ),
556
- /* @__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: [
557
493
  {
558
494
  disabled: !canUpdate,
559
495
  label: formatMessage({
@@ -591,12 +527,16 @@ const Stage = ({
591
527
  size: 6,
592
528
  type: "permissions"
593
529
  }
594
- ].map(({ size, ...field }) => /* @__PURE__ */ jsx(GridItem, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
595
- ]
530
+ ].map(({ size, ...field }) => /* @__PURE__ */ jsx(Grid.Item, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
531
+ ] })
596
532
  }
597
533
  )
598
534
  ] });
599
535
  };
536
+ const AccordionRoot = styled(Accordion.Root)`
537
+ border: 1px solid
538
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
539
+ `;
600
540
  const DeleteMenuItem = styled(MenuItem)`
601
541
  color: ${({ theme }) => theme.colors.danger600};
602
542
  `;
@@ -610,22 +550,6 @@ const ContextMenuTrigger = styled(Menu.Trigger)`
610
550
  font-size: 0;
611
551
  }
612
552
  `;
613
- const DragIconButton = styled(IconButton)`
614
- align-items: center;
615
- border-radius: ${({ theme }) => theme.borderRadius};
616
- display: flex;
617
- justify-content: center;
618
-
619
- &:hover,
620
- &:focus {
621
- background-color: ${({ theme }) => theme.colors.neutral100};
622
- }
623
-
624
- svg {
625
- height: auto;
626
- width: ${({ theme }) => theme.spaces[3]};
627
- }
628
- `;
629
553
  const InputRenderer = (props) => {
630
554
  switch (props.type) {
631
555
  case "color":
@@ -651,54 +575,55 @@ const ColorSelector = ({ disabled, label, name, required }) => {
651
575
  color: hex
652
576
  }));
653
577
  const { themeColorName } = getStageColorByHex(value) ?? {};
654
- return /* @__PURE__ */ jsx(
655
- SingleSelect,
656
- {
657
- disabled,
658
- error,
659
- required,
660
- label,
661
- onChange: (v) => {
662
- onChange(name, v.toString());
663
- },
664
- value: value?.toUpperCase(),
665
- startIcon: /* @__PURE__ */ jsx(
666
- Flex,
667
- {
668
- as: "span",
669
- height: 2,
670
- background: value,
671
- borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
672
- hasRadius: true,
673
- shrink: 0,
674
- width: 2
675
- }
676
- ),
677
- children: colorOptions.map(({ value: value2, label: label2, color }) => {
678
- const { themeColorName: themeColorName2 } = getStageColorByHex(color) || {};
679
- return /* @__PURE__ */ jsx(
680
- 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,
681
590
  {
682
- value: value2,
683
- startIcon: /* @__PURE__ */ jsx(
684
- Flex,
685
- {
686
- as: "span",
687
- height: 2,
688
- background: color,
689
- borderColor: themeColorName2 === "neutral0" ? "neutral150" : "transparent",
690
- hasRadius: true,
691
- shrink: 0,
692
- width: 2
693
- }
694
- ),
695
- children: label2
696
- },
697
- value2
698
- );
699
- })
700
- }
701
- );
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
+ ] });
702
627
  };
703
628
  const PermissionsField = ({ disabled, name, placeholder, required }) => {
704
629
  const { formatMessage } = useIntl();
@@ -707,57 +632,65 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
707
632
  const { value = [], error, onChange } = useField(name);
708
633
  const allStages = useForm("PermissionsField", (state) => state.values.stages);
709
634
  const onFormValueChange = useForm("PermissionsField", (state) => state.onChange);
710
- const { data: roles = [], isLoading } = useGetRolesQuery();
635
+ const rolesErrorCount = React.useRef(0);
636
+ const { data: roles = [], isLoading, error: getRolesError } = useGetAdminRolesQuery();
711
637
  const filteredRoles = roles?.filter((role) => role.code !== "strapi-super-admin") ?? [];
712
638
  React.useEffect(() => {
713
- if (!isLoading && roles.length === 0) {
639
+ if (!isLoading && getRolesError && "status" in getRolesError && getRolesError.status == 403 && rolesErrorCount.current === 0) {
640
+ rolesErrorCount.current = 1;
714
641
  toggleNotification({
715
642
  blockTransition: true,
716
643
  type: "danger",
717
644
  message: formatMessage({
718
645
  id: "review-workflows.stage.permissions.noPermissions.description",
719
- defaultMessage: "You don’t have the permission to see roles"
646
+ defaultMessage: "You don’t have the permission to see roles. Contact your administrator."
720
647
  })
721
648
  });
722
649
  }
723
- }, [formatMessage, isLoading, roles, toggleNotification]);
650
+ }, [formatMessage, isLoading, roles, toggleNotification, getRolesError]);
724
651
  if (!isLoading && filteredRoles.length === 0) {
725
- return /* @__PURE__ */ jsx(
726
- TextInput,
652
+ return /* @__PURE__ */ jsxs(
653
+ Field.Root,
727
654
  {
728
- disabled: true,
729
655
  name,
730
656
  hint: formatMessage({
731
657
  id: "Settings.review-workflows.stage.permissions.noPermissions.description",
732
658
  defaultMessage: "You don’t have the permission to see roles"
733
659
  }),
734
- label: formatMessage({
735
- id: "Settings.review-workflows.stage.permissions.label",
736
- defaultMessage: "Roles that can change this stage"
737
- }),
738
- placeholder: formatMessage({
739
- id: "components.NotAllowedInput.text",
740
- defaultMessage: "No permissions to see this field"
741
- }),
742
660
  required,
743
- startAction: /* @__PURE__ */ jsx(StyledIcon, {}),
744
- type: "text",
745
- 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
+ ]
746
681
  }
747
682
  );
748
683
  }
749
- return /* @__PURE__ */ jsxs(Fragment, { children: [
750
- /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-end", gap: 3, children: [
751
- /* @__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(
752
691
  MultiSelect,
753
692
  {
754
693
  disabled,
755
- error,
756
- id: name,
757
- label: formatMessage({
758
- id: "Settings.review-workflows.stage.permissions.label",
759
- defaultMessage: "Roles that can change this stage"
760
- }),
761
694
  onChange: (values) => {
762
695
  const permissions = values.map((value2) => ({
763
696
  role: parseInt(value2, 10),
@@ -766,7 +699,6 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
766
699
  onChange(name, permissions);
767
700
  },
768
701
  placeholder,
769
- required: true,
770
702
  value: value.map((permission) => `${permission.role}`),
771
703
  withTags: true,
772
704
  children: /* @__PURE__ */ jsx(
@@ -783,58 +715,53 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
783
715
  }
784
716
  )
785
717
  }
786
- ) }),
787
- /* @__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(
788
723
  IconButton,
789
724
  {
790
725
  disabled,
791
- icon: /* @__PURE__ */ jsx(Duplicate, {}),
792
726
  label: formatMessage({
793
727
  id: "Settings.review-workflows.stage.permissions.apply.label",
794
728
  defaultMessage: "Apply to all stages"
795
729
  }),
796
730
  size: "L",
797
731
  variant: "secondary",
798
- 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
+ })
799
760
  }
800
761
  )
801
- ] }),
802
- /* @__PURE__ */ jsx(
803
- ConfirmDialog,
804
- {
805
- isOpen: isApplyAllConfirmationOpen,
806
- onClose: () => setIsApplyAllConfirmationOpen(false),
807
- onConfirm: () => {
808
- onFormValueChange(
809
- "stages",
810
- allStages.map((stage) => ({
811
- ...stage,
812
- permissions: value
813
- }))
814
- );
815
- setIsApplyAllConfirmationOpen(false);
816
- toggleNotification({
817
- type: "success",
818
- message: formatMessage({
819
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy.success",
820
- defaultMessage: "Applied roles to all other stages of the workflow"
821
- })
822
- });
823
- },
824
- variant: "default",
825
- children: formatMessage({
826
- id: "Settings.review-workflows.page.edit.confirm.stages.permissions.copy",
827
- defaultMessage: "Roles that can change that stage will be applied to all the other stages."
828
- })
829
- }
830
- )
831
- ] });
762
+ ] })
763
+ ] }) });
832
764
  };
833
- const StyledIcon = styled(EyeStriked)`
834
- & > path {
835
- fill: ${({ theme }) => theme.colors.neutral600};
836
- }
837
- `;
838
765
  const NestedOption$1 = styled(MultiSelectOption)`
839
766
  padding-left: ${({ theme }) => theme.spaces[7]};
840
767
  `;
@@ -845,8 +772,8 @@ const PermissionWrapper = styled(Flex)`
845
772
  `;
846
773
  const WorkflowAttributes = ({ canUpdate = true }) => {
847
774
  const { formatMessage } = useIntl();
848
- return /* @__PURE__ */ jsxs(Grid, { background: "neutral0", hasRadius: true, gap: 4, padding: 6, shadow: "tableShadow", children: [
849
- /* @__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(
850
777
  InputRenderer$1,
851
778
  {
852
779
  disabled: !canUpdate,
@@ -859,7 +786,7 @@ const WorkflowAttributes = ({ canUpdate = true }) => {
859
786
  type: "string"
860
787
  }
861
788
  ) }),
862
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
789
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
863
790
  ] });
864
791
  };
865
792
  const ContentTypesSelector = ({ disabled }) => {
@@ -880,81 +807,82 @@ const ContentTypesSelector = ({ disabled }) => {
880
807
  label: contentType.info.displayName,
881
808
  value: contentType.uid
882
809
  }));
883
- return /* @__PURE__ */ jsx(
884
- MultiSelect,
885
- {
886
- customizeContent: (value2) => formatMessage(
887
- {
888
- id: "Settings.review-workflows.workflow.contentTypes.displayValue",
889
- defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
890
- },
891
- { count: value2?.length }
892
- ),
893
- disabled: isDisabled,
894
- error,
895
- label: formatMessage({
896
- id: "Settings.review-workflows.workflow.contentTypes.label",
897
- defaultMessage: "Associated to"
898
- }),
899
- onChange: (values) => {
900
- onChange("contentTypes", values);
901
- },
902
- value,
903
- placeholder: formatMessage({
904
- id: "Settings.review-workflows.workflow.contentTypes.placeholder",
905
- defaultMessage: "Select"
906
- }),
907
- children: [
908
- ...collectionTypes.length > 0 ? [
909
- {
910
- label: formatMessage({
911
- id: "Settings.review-workflows.workflow.contentTypes.collectionTypes.label",
912
- defaultMessage: "Collection Types"
913
- }),
914
- children: collectionTypes
915
- }
916
- ] : [],
917
- ...singleTypes.length > 0 ? [
918
- {
919
- label: formatMessage({
920
- id: "Settings.review-workflows.workflow.contentTypes.singleTypes.label",
921
- defaultMessage: "Single Types"
922
- }),
923
- children: singleTypes
924
- }
925
- ] : []
926
- ].map((opt) => {
927
- return /* @__PURE__ */ jsx(
928
- 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(
929
819
  {
930
- label: opt.label,
931
- values: opt.children.map((child) => child.value.toString()),
932
- children: opt.children.map((child) => {
933
- const { name: assignedWorkflowName } = workflows?.find(
934
- (workflow) => (currentWorkflow && workflow.id !== currentWorkflow.id || !currentWorkflow) && workflow.contentTypes.includes(child.value)
935
- ) ?? {};
936
- return /* @__PURE__ */ jsx(NestedOption, { value: child.value, children: /* @__PURE__ */ jsx(Typography, {
937
- // @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
938
- children: formatMessage(
939
- {
940
- id: "Settings.review-workflows.workflow.contentTypes.assigned.notice",
941
- defaultMessage: "{label} {name, select, undefined {} other {<i>(assigned to <em>{name}</em> workflow)</i>}}"
942
- },
943
- {
944
- label: child.label,
945
- name: assignedWorkflowName,
946
- em: (...children) => /* @__PURE__ */ jsx(Typography, { as: "em", fontWeight: "bold", children }),
947
- i: (...children) => /* @__PURE__ */ jsx(ContentTypeTakeNotice, { children })
948
- }
949
- )
950
- }) }, child.value);
951
- })
820
+ id: "Settings.review-workflows.workflow.contentTypes.displayValue",
821
+ defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
952
822
  },
953
- opt.label
954
- );
955
- })
956
- }
957
- );
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
+ ] });
958
886
  };
959
887
  const NestedOption = styled(MultiSelectOption)`
960
888
  padding-left: ${({ theme }) => theme.spaces[7]};
@@ -1215,23 +1143,22 @@ const EditPage = () => {
1215
1143
  }
1216
1144
  ),
1217
1145
  /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "stretch", direction: "column", gap: 7, children: [
1218
- /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate }),
1146
+ /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate: canUpdate || canCreate }),
1219
1147
  /* @__PURE__ */ jsx(
1220
1148
  Stages,
1221
1149
  {
1222
1150
  canDelete,
1223
- canUpdate,
1151
+ canUpdate: canUpdate || canCreate,
1224
1152
  isCreating: isCreatingWorkflow
1225
1153
  }
1226
1154
  )
1227
1155
  ] }) }),
1228
1156
  /* @__PURE__ */ jsx(
1229
- ConfirmDialog,
1157
+ Dialog.Root,
1230
1158
  {
1231
- isOpen: Object.keys(savePrompts).length > 0,
1232
- onClose: handleConfirmClose,
1233
- onConfirm: handleConfirmDeleteDialog(values, { setErrors }),
1234
- 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: [
1235
1162
  savePrompts.hasDeletedServerStages && /* @__PURE__ */ jsx(Typography, { textAlign: "center", variant: "omega", children: formatMessage({
1236
1163
  id: "review-workflows.page.delete.confirm.stages.body",
1237
1164
  defaultMessage: "All entries assigned to deleted stages will be moved to the previous stage."
@@ -1251,7 +1178,7 @@ const EditPage = () => {
1251
1178
  id: "review-workflows.page.delete.confirm.confirm",
1252
1179
  defaultMessage: "Are you sure you want to save?"
1253
1180
  }) })
1254
- ] })
1181
+ ] }) })
1255
1182
  }
1256
1183
  )
1257
1184
  ] })
@@ -1260,8 +1187,8 @@ const EditPage = () => {
1260
1187
  /* @__PURE__ */ jsxs(
1261
1188
  LimitsModal.Root,
1262
1189
  {
1263
- isOpen: showLimitModal === "workflow",
1264
- onClose: () => setShowLimitModal(null),
1190
+ open: showLimitModal === "workflow",
1191
+ onOpenChange: () => setShowLimitModal(null),
1265
1192
  children: [
1266
1193
  /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1267
1194
  id: "review-workflows.edit.page.workflows.limit.title",
@@ -1274,16 +1201,23 @@ const EditPage = () => {
1274
1201
  ]
1275
1202
  }
1276
1203
  ),
1277
- /* @__PURE__ */ jsxs(LimitsModal.Root, { isOpen: showLimitModal === "stage", onClose: () => setShowLimitModal(null), children: [
1278
- /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1279
- id: "review-workflows.edit.page.stages.limit.title",
1280
- defaultMessage: "You have reached the limit of stages for this workflow in your plan"
1281
- }) }),
1282
- /* @__PURE__ */ jsx(LimitsModal.Body, { children: formatMessage({
1283
- id: "review-workflows.edit.page.stages.limit.body",
1284
- defaultMessage: "Try deleting some stages or contact Sales to enable more stages."
1285
- }) })
1286
- ] })
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
+ )
1287
1221
  ] });
1288
1222
  };
1289
1223
  const addTmpKeysToStages = (data) => {
@@ -1307,4 +1241,4 @@ const ProtectedEditPage = () => {
1307
1241
  export {
1308
1242
  ProtectedEditPage
1309
1243
  };
1310
- //# sourceMappingURL=_id-C_HRFhcV.mjs.map
1244
+ //# sourceMappingURL=_id-xSrgPSJs.mjs.map