@strapi/review-workflows 0.0.0-experimental.76447298a89499e415c97916c03f4f90c25ff336 → 0.0.0-experimental.779667bd163026468f566293decf331a0246fff9

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-dGg4FA1R.js → Layout-D3DDQmMI.js} +7 -15
  3. package/dist/_chunks/Layout-D3DDQmMI.js.map +1 -0
  4. package/dist/_chunks/{Layout-facLKucY.mjs → Layout-Da8jupiA.mjs} +10 -16
  5. package/dist/_chunks/Layout-Da8jupiA.mjs.map +1 -0
  6. package/dist/_chunks/{_id-B6DgrtpA.js → _id-CnRDP3Xx.js} +319 -388
  7. package/dist/_chunks/_id-CnRDP3Xx.js.map +1 -0
  8. package/dist/_chunks/{_id-D4CXKOqG.mjs → _id-xSrgPSJs.mjs} +313 -380
  9. package/dist/_chunks/_id-xSrgPSJs.mjs.map +1 -0
  10. package/dist/_chunks/{index-BuKZWpJw.js → index-4kp4AkBB.js} +25 -40
  11. package/dist/_chunks/index-4kp4AkBB.js.map +1 -0
  12. package/dist/_chunks/{index-D7Y0ofdg.mjs → index-DDsJlZQw.mjs} +115 -165
  13. package/dist/_chunks/index-DDsJlZQw.mjs.map +1 -0
  14. package/dist/_chunks/{index-DX8AGcIP.js → index-DhPxWpsW.js} +115 -167
  15. package/dist/_chunks/index-DhPxWpsW.js.map +1 -0
  16. package/dist/_chunks/{index-QbWLXdZR.mjs → index-jfO5GxtW.mjs} +24 -37
  17. package/dist/_chunks/index-jfO5GxtW.mjs.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-DOEULOpS.mjs} +3 -3
  23. package/dist/_chunks/{router-ylD0eA48.mjs.map → router-DOEULOpS.mjs.map} +1 -1
  24. package/dist/_chunks/{router-CL62NScV.js → router-DSXpeew4.js} +3 -3
  25. package/dist/_chunks/{router-CL62NScV.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-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-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";
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);
@@ -331,35 +291,23 @@ const Stages = ({ canDelete = true, canUpdate = true, isCreating = false }) => {
331
291
  left: "50%",
332
292
  position: "absolute",
333
293
  top: "0",
334
- width: 2,
335
- zIndex: 1
294
+ width: 2
336
295
  }
337
296
  ),
338
- /* @__PURE__ */ jsx(
339
- Flex,
340
- {
341
- direction: "column",
342
- alignItems: "stretch",
343
- gap: 6,
344
- zIndex: 2,
345
- position: "relative",
346
- as: "ol",
347
- children: stages.map((stage, index) => {
348
- return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
349
- Stage,
350
- {
351
- index,
352
- canDelete: stages.length > 1 && canDelete,
353
- canReorder: stages.length > 1,
354
- canUpdate,
355
- stagesCount: stages.length,
356
- isOpen: isCreating,
357
- ...stage
358
- }
359
- ) }, stage.__temp_key__);
360
- })
361
- }
362
- )
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
+ }) })
363
311
  ] }),
364
312
  canUpdate && /* @__PURE__ */ jsx(
365
313
  AddStage,
@@ -385,16 +333,15 @@ const Stage = ({
385
333
  canDelete = false,
386
334
  canReorder = false,
387
335
  canUpdate = false,
388
- isOpen: isOpenDefault = false,
389
336
  stagesCount,
390
337
  name,
391
338
  permissions,
392
- color
339
+ color,
340
+ defaultOpen
393
341
  }) => {
394
342
  const [liveText, setLiveText] = React.useState();
395
343
  const { formatMessage } = useIntl();
396
344
  const { trackUsage } = useTracking();
397
- const [isOpen, setIsOpen] = React.useState(isOpenDefault);
398
345
  const stageErrors = useForm("Stages", (state) => state.errors.stages);
399
346
  const error = stageErrors?.[index];
400
347
  const addFieldRow = useForm("Stage", (state) => state.addFieldRow);
@@ -476,7 +423,8 @@ const Stage = ({
476
423
  const handleCloneClick = () => {
477
424
  addFieldRow("stages", { name, color, permissions });
478
425
  };
479
- return /* @__PURE__ */ jsxs(Box, { ref: (ref) => composedRef(ref), children: [
426
+ const id = React.useId();
427
+ return /* @__PURE__ */ jsxs(Box, { ref: composedRef, shadow: "tableShadow", children: [
480
428
  liveText && /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
481
429
  isDragging ? /* @__PURE__ */ jsx(
482
430
  Box,
@@ -487,74 +435,61 @@ const Stage = ({
487
435
  borderWidth: "1px",
488
436
  display: "block",
489
437
  hasRadius: true,
490
- padding: 6,
491
- shadow: "tableShadow"
438
+ padding: 6
492
439
  }
493
- ) : /* @__PURE__ */ jsxs(
494
- Accordion,
440
+ ) : /* @__PURE__ */ jsx(
441
+ AccordionRoot,
495
442
  {
496
- size: "S",
497
- variant: "primary",
498
- onToggle: () => {
499
- setIsOpen(!isOpen);
500
- if (!isOpen) {
443
+ onValueChange: (value) => {
444
+ if (value) {
501
445
  trackUsage("willEditStage");
502
446
  }
503
447
  },
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
- ] }) })
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
+ }) })
533
461
  ] }),
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: [
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: [
558
493
  {
559
494
  disabled: !canUpdate,
560
495
  label: formatMessage({
@@ -592,12 +527,16 @@ const Stage = ({
592
527
  size: 6,
593
528
  type: "permissions"
594
529
  }
595
- ].map(({ size, ...field }) => /* @__PURE__ */ jsx(GridItem, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
596
- ]
530
+ ].map(({ size, ...field }) => /* @__PURE__ */ jsx(Grid.Item, { col: size, children: /* @__PURE__ */ jsx(InputRenderer, { ...field }) }, field.name)) }) })
531
+ ] })
597
532
  }
598
533
  )
599
534
  ] });
600
535
  };
536
+ const AccordionRoot = styled(Accordion.Root)`
537
+ border: 1px solid
538
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
539
+ `;
601
540
  const DeleteMenuItem = styled(MenuItem)`
602
541
  color: ${({ theme }) => theme.colors.danger600};
603
542
  `;
@@ -611,22 +550,6 @@ const ContextMenuTrigger = styled(Menu.Trigger)`
611
550
  font-size: 0;
612
551
  }
613
552
  `;
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
553
  const InputRenderer = (props) => {
631
554
  switch (props.type) {
632
555
  case "color":
@@ -652,54 +575,55 @@ const ColorSelector = ({ disabled, label, name, required }) => {
652
575
  color: hex
653
576
  }));
654
577
  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,
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,
682
590
  {
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
- );
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
+ ] });
703
627
  };
704
628
  const PermissionsField = ({ disabled, name, placeholder, required }) => {
705
629
  const { formatMessage } = useIntl();
@@ -708,57 +632,65 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
708
632
  const { value = [], error, onChange } = useField(name);
709
633
  const allStages = useForm("PermissionsField", (state) => state.values.stages);
710
634
  const onFormValueChange = useForm("PermissionsField", (state) => state.onChange);
711
- const { data: roles = [], isLoading } = useGetRolesQuery();
635
+ const rolesErrorCount = React.useRef(0);
636
+ const { data: roles = [], isLoading, error: getRolesError } = useGetAdminRolesQuery();
712
637
  const filteredRoles = roles?.filter((role) => role.code !== "strapi-super-admin") ?? [];
713
638
  React.useEffect(() => {
714
- if (!isLoading && roles.length === 0) {
639
+ if (!isLoading && getRolesError && "status" in getRolesError && getRolesError.status == 403 && rolesErrorCount.current === 0) {
640
+ rolesErrorCount.current = 1;
715
641
  toggleNotification({
716
642
  blockTransition: true,
717
643
  type: "danger",
718
644
  message: formatMessage({
719
645
  id: "review-workflows.stage.permissions.noPermissions.description",
720
- defaultMessage: "You don’t have the permission to see roles"
646
+ defaultMessage: "You don’t have the permission to see roles. Contact your administrator."
721
647
  })
722
648
  });
723
649
  }
724
- }, [formatMessage, isLoading, roles, toggleNotification]);
650
+ }, [formatMessage, isLoading, roles, toggleNotification, getRolesError]);
725
651
  if (!isLoading && filteredRoles.length === 0) {
726
- return /* @__PURE__ */ jsx(
727
- TextInput,
652
+ return /* @__PURE__ */ jsxs(
653
+ Field.Root,
728
654
  {
729
- disabled: true,
730
655
  name,
731
656
  hint: formatMessage({
732
657
  id: "Settings.review-workflows.stage.permissions.noPermissions.description",
733
658
  defaultMessage: "You don’t have the permission to see roles"
734
659
  }),
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
660
  required,
744
- startAction: /* @__PURE__ */ jsx(StyledIcon, {}),
745
- type: "text",
746
- 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
+ ]
747
681
  }
748
682
  );
749
683
  }
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(
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(
753
691
  MultiSelect,
754
692
  {
755
693
  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
694
  onChange: (values) => {
763
695
  const permissions = values.map((value2) => ({
764
696
  role: parseInt(value2, 10),
@@ -767,7 +699,6 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
767
699
  onChange(name, permissions);
768
700
  },
769
701
  placeholder,
770
- required: true,
771
702
  value: value.map((permission) => `${permission.role}`),
772
703
  withTags: true,
773
704
  children: /* @__PURE__ */ jsx(
@@ -784,58 +715,53 @@ const PermissionsField = ({ disabled, name, placeholder, required }) => {
784
715
  }
785
716
  )
786
717
  }
787
- ) }),
788
- /* @__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(
789
723
  IconButton,
790
724
  {
791
725
  disabled,
792
- icon: /* @__PURE__ */ jsx(Duplicate, {}),
793
726
  label: formatMessage({
794
727
  id: "Settings.review-workflows.stage.permissions.apply.label",
795
728
  defaultMessage: "Apply to all stages"
796
729
  }),
797
730
  size: "L",
798
731
  variant: "secondary",
799
- 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
+ })
800
760
  }
801
761
  )
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
- ] });
762
+ ] })
763
+ ] }) });
833
764
  };
834
- const StyledIcon = styled(EyeStriked)`
835
- & > path {
836
- fill: ${({ theme }) => theme.colors.neutral600};
837
- }
838
- `;
839
765
  const NestedOption$1 = styled(MultiSelectOption)`
840
766
  padding-left: ${({ theme }) => theme.spaces[7]};
841
767
  `;
@@ -846,8 +772,8 @@ const PermissionWrapper = styled(Flex)`
846
772
  `;
847
773
  const WorkflowAttributes = ({ canUpdate = true }) => {
848
774
  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(
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(
851
777
  InputRenderer$1,
852
778
  {
853
779
  disabled: !canUpdate,
@@ -860,7 +786,7 @@ const WorkflowAttributes = ({ canUpdate = true }) => {
860
786
  type: "string"
861
787
  }
862
788
  ) }),
863
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
789
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, children: /* @__PURE__ */ jsx(ContentTypesSelector, { disabled: !canUpdate }) })
864
790
  ] });
865
791
  };
866
792
  const ContentTypesSelector = ({ disabled }) => {
@@ -881,81 +807,82 @@ const ContentTypesSelector = ({ disabled }) => {
881
807
  label: contentType.info.displayName,
882
808
  value: contentType.uid
883
809
  }));
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,
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(
930
819
  {
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
- })
820
+ id: "Settings.review-workflows.workflow.contentTypes.displayValue",
821
+ defaultMessage: "{count} {count, plural, one {content type} other {content types}} selected"
953
822
  },
954
- opt.label
955
- );
956
- })
957
- }
958
- );
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
+ ] });
959
886
  };
960
887
  const NestedOption = styled(MultiSelectOption)`
961
888
  padding-left: ${({ theme }) => theme.spaces[7]};
@@ -1216,23 +1143,22 @@ const EditPage = () => {
1216
1143
  }
1217
1144
  ),
1218
1145
  /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "stretch", direction: "column", gap: 7, children: [
1219
- /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate }),
1146
+ /* @__PURE__ */ jsx(WorkflowAttributes, { canUpdate: canUpdate || canCreate }),
1220
1147
  /* @__PURE__ */ jsx(
1221
1148
  Stages,
1222
1149
  {
1223
1150
  canDelete,
1224
- canUpdate,
1151
+ canUpdate: canUpdate || canCreate,
1225
1152
  isCreating: isCreatingWorkflow
1226
1153
  }
1227
1154
  )
1228
1155
  ] }) }),
1229
1156
  /* @__PURE__ */ jsx(
1230
- ConfirmDialog,
1157
+ Dialog.Root,
1231
1158
  {
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: [
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: [
1236
1162
  savePrompts.hasDeletedServerStages && /* @__PURE__ */ jsx(Typography, { textAlign: "center", variant: "omega", children: formatMessage({
1237
1163
  id: "review-workflows.page.delete.confirm.stages.body",
1238
1164
  defaultMessage: "All entries assigned to deleted stages will be moved to the previous stage."
@@ -1252,7 +1178,7 @@ const EditPage = () => {
1252
1178
  id: "review-workflows.page.delete.confirm.confirm",
1253
1179
  defaultMessage: "Are you sure you want to save?"
1254
1180
  }) })
1255
- ] })
1181
+ ] }) })
1256
1182
  }
1257
1183
  )
1258
1184
  ] })
@@ -1261,8 +1187,8 @@ const EditPage = () => {
1261
1187
  /* @__PURE__ */ jsxs(
1262
1188
  LimitsModal.Root,
1263
1189
  {
1264
- isOpen: showLimitModal === "workflow",
1265
- onClose: () => setShowLimitModal(null),
1190
+ open: showLimitModal === "workflow",
1191
+ onOpenChange: () => setShowLimitModal(null),
1266
1192
  children: [
1267
1193
  /* @__PURE__ */ jsx(LimitsModal.Title, { children: formatMessage({
1268
1194
  id: "review-workflows.edit.page.workflows.limit.title",
@@ -1275,16 +1201,23 @@ const EditPage = () => {
1275
1201
  ]
1276
1202
  }
1277
1203
  ),
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
- ] })
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
+ )
1288
1221
  ] });
1289
1222
  };
1290
1223
  const addTmpKeysToStages = (data) => {
@@ -1308,4 +1241,4 @@ const ProtectedEditPage = () => {
1308
1241
  export {
1309
1242
  ProtectedEditPage
1310
1243
  };
1311
- //# sourceMappingURL=_id-D4CXKOqG.mjs.map
1244
+ //# sourceMappingURL=_id-xSrgPSJs.mjs.map