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

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 (79) hide show
  1. package/dist/_chunks/{Layout-Cwbb9usb.js → Layout-B4fpKB9J.js} +8 -9
  2. package/dist/_chunks/Layout-B4fpKB9J.js.map +1 -0
  3. package/dist/_chunks/{Layout-BpMLb-Oo.mjs → Layout-Dko22Aly.mjs} +8 -9
  4. package/dist/_chunks/Layout-Dko22Aly.mjs.map +1 -0
  5. package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
  6. package/dist/_chunks/en-CYgjfSep.js.map +1 -0
  7. package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
  8. package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
  9. package/dist/_chunks/{_id-p9NnvlMP.js → id-BKq7JAqZ.js} +82 -49
  10. package/dist/_chunks/id-BKq7JAqZ.js.map +1 -0
  11. package/dist/_chunks/{_id-KpezMzxO.mjs → id-DINFSsrh.mjs} +82 -49
  12. package/dist/_chunks/id-DINFSsrh.mjs.map +1 -0
  13. package/dist/_chunks/{index-DqT_oXGP.js → index-BpIILEs0.js} +9 -29
  14. package/dist/_chunks/index-BpIILEs0.js.map +1 -0
  15. package/dist/_chunks/{index-BTr8zF-9.js → index-BpL7C1EG.js} +54 -71
  16. package/dist/_chunks/index-BpL7C1EG.js.map +1 -0
  17. package/dist/_chunks/{index-DtJI5ZoC.mjs → index-DAcEdoqJ.mjs} +55 -72
  18. package/dist/_chunks/index-DAcEdoqJ.mjs.map +1 -0
  19. package/dist/_chunks/{index-BxkGN0Yj.mjs → index-ZcZKwmTD.mjs} +11 -31
  20. package/dist/_chunks/index-ZcZKwmTD.mjs.map +1 -0
  21. package/dist/_chunks/{router-B8G2sh6V.mjs → router-BPH_u176.mjs} +3 -3
  22. package/dist/_chunks/router-BPH_u176.mjs.map +1 -0
  23. package/dist/_chunks/{router-Bqj-105s.js → router-DeEgX8Ao.js} +3 -3
  24. package/dist/_chunks/router-DeEgX8Ao.js.map +1 -0
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +1 -1
  27. package/dist/admin/src/services/settings.d.ts +1737 -7
  28. package/dist/server/index.js +180 -108
  29. package/dist/server/index.js.map +1 -1
  30. package/dist/server/index.mjs +180 -108
  31. package/dist/server/index.mjs.map +1 -1
  32. package/dist/server/src/bootstrap.d.ts.map +1 -1
  33. package/dist/server/src/constants/workflows.d.ts +1 -0
  34. package/dist/server/src/constants/workflows.d.ts.map +1 -1
  35. package/dist/server/src/content-types/index.d.ts +6 -0
  36. package/dist/server/src/content-types/index.d.ts.map +1 -1
  37. package/dist/server/src/content-types/workflow/index.d.ts +6 -0
  38. package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
  39. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  40. package/dist/server/src/controllers/index.d.ts +0 -1
  41. package/dist/server/src/controllers/index.d.ts.map +1 -1
  42. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  43. package/dist/server/src/controllers/workflows.d.ts +0 -7
  44. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  45. package/dist/server/src/index.d.ts +28 -7
  46. package/dist/server/src/index.d.ts.map +1 -1
  47. package/dist/server/src/register.d.ts.map +1 -1
  48. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  49. package/dist/server/src/services/assignees.d.ts +8 -4
  50. package/dist/server/src/services/assignees.d.ts.map +1 -1
  51. package/dist/server/src/services/document-service-middleware.d.ts +1 -0
  52. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  53. package/dist/server/src/services/index.d.ts +16 -6
  54. package/dist/server/src/services/index.d.ts.map +1 -1
  55. package/dist/server/src/services/metrics/index.d.ts +4 -4
  56. package/dist/server/src/services/metrics/index.d.ts.map +1 -1
  57. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  58. package/dist/server/src/services/stages.d.ts +7 -7
  59. package/dist/server/src/services/stages.d.ts.map +1 -1
  60. package/dist/server/src/services/workflows.d.ts.map +1 -1
  61. package/dist/server/src/validation/review-workflows.d.ts +4 -0
  62. package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
  63. package/dist/shared/contracts/review-workflows.d.ts +9 -17
  64. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  65. package/package.json +12 -12
  66. package/dist/_chunks/Layout-BpMLb-Oo.mjs.map +0 -1
  67. package/dist/_chunks/Layout-Cwbb9usb.js.map +0 -1
  68. package/dist/_chunks/_id-KpezMzxO.mjs.map +0 -1
  69. package/dist/_chunks/_id-p9NnvlMP.js.map +0 -1
  70. package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
  71. package/dist/_chunks/en-xcewH2pC.js.map +0 -1
  72. package/dist/_chunks/index-BTr8zF-9.js.map +0 -1
  73. package/dist/_chunks/index-BxkGN0Yj.mjs.map +0 -1
  74. package/dist/_chunks/index-DqT_oXGP.js.map +0 -1
  75. package/dist/_chunks/index-DtJI5ZoC.mjs.map +0 -1
  76. package/dist/_chunks/router-B8G2sh6V.mjs.map +0 -1
  77. package/dist/_chunks/router-Bqj-105s.js.map +0 -1
  78. package/strapi-server.js +0 -3
  79. /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
@@ -5,7 +5,7 @@ import { useIntl } from "react-intl";
5
5
  import { useParams } from "react-router-dom";
6
6
  import * as React from "react";
7
7
  import { adminApi, useAPIErrorHandler, useNotification, useRBAC, useQueryParams, useAdminUsers } from "@strapi/admin/strapi-admin";
8
- import { useSelector, useDispatch } from "react-redux";
8
+ import { useSelector } from "react-redux";
9
9
  import { useLicenseLimits } from "@strapi/admin/strapi-admin/ee";
10
10
  import { Cross } from "@strapi/icons";
11
11
  import { styled } from "styled-components";
@@ -62,7 +62,8 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
62
62
  type: "Document",
63
63
  id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
64
64
  },
65
- { type: "Document", id: `${model}_LIST` }
65
+ { type: "Document", id: `${model}_LIST` },
66
+ "ReviewWorkflowStages"
66
67
  ];
67
68
  }
68
69
  }),
@@ -155,7 +156,6 @@ const AssigneeSelect = () => {
155
156
  id,
156
157
  slug: model = ""
157
158
  } = useParams();
158
- const dispatch = useDispatch();
159
159
  const permissions = useTypedSelector((state) => state.admin_app.permissions);
160
160
  const { formatMessage } = useIntl();
161
161
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
@@ -176,13 +176,13 @@ const AssigneeSelect = () => {
176
176
  documentId: id
177
177
  },
178
178
  {
179
- skip: !id
179
+ skip: !id && collectionType !== "single-types"
180
180
  }
181
181
  );
182
182
  const users = data?.users || [];
183
183
  const currentAssignee = document ? document[ASSIGNEE_ATTRIBUTE_NAME] : null;
184
184
  const [updateAssignee, { error, isLoading: isMutating }] = useUpdateAssigneeMutation();
185
- if (!collectionType || !model || !id) {
185
+ if (!collectionType || !model || !document?.documentId) {
186
186
  return null;
187
187
  }
188
188
  const handleChange = async (assigneeId) => {
@@ -192,22 +192,13 @@ const AssigneeSelect = () => {
192
192
  const res = await updateAssignee({
193
193
  slug: collectionType,
194
194
  model,
195
- id,
195
+ id: document.documentId,
196
196
  params,
197
197
  data: {
198
198
  id: assigneeId ? parseInt(assigneeId, 10) : null
199
199
  }
200
200
  });
201
201
  if ("data" in res) {
202
- dispatch({
203
- type: "contentManagerApi/invalidateTags",
204
- payload: [
205
- {
206
- type: "Document",
207
- id: `${model}_${id}`
208
- }
209
- ]
210
- });
211
202
  toggleNotification({
212
203
  type: "success",
213
204
  message: formatMessage({
@@ -238,7 +229,7 @@ const AssigneeSelect = () => {
238
229
  id: "content-manager.reviewWorkflows.assignee.clear",
239
230
  defaultMessage: "Clear assignee"
240
231
  }),
241
- disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !id,
232
+ disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !document.documentId,
242
233
  value: currentAssignee ? currentAssignee.id.toString() : null,
243
234
  onChange: handleChange,
244
235
  onClear: () => handleChange(null),
@@ -375,31 +366,31 @@ const StageSelect = () => {
375
366
  slug: model = "",
376
367
  id = ""
377
368
  } = useParams();
378
- const dispatch = useDispatch();
379
369
  const { formatMessage } = useIntl();
380
370
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
381
371
  const { toggleNotification } = useNotification();
382
372
  const [{ query }] = useQueryParams();
383
373
  const params = React.useMemo(() => buildValidParams(query), [query]);
384
- const { data, isLoading } = useGetStagesQuery(
374
+ const { document, isLoading: isLoadingDocument } = unstable_useDocument(
385
375
  {
386
- slug: collectionType,
376
+ collectionType,
387
377
  model,
388
- id,
389
- params
378
+ documentId: id
390
379
  },
391
380
  {
392
- skip: !id
381
+ skip: !id && collectionType !== "single-types"
393
382
  }
394
383
  );
395
- const { document } = unstable_useDocument(
384
+ const { data, isLoading: isLoadingStages } = useGetStagesQuery(
396
385
  {
397
- collectionType,
386
+ slug: collectionType,
398
387
  model,
399
- documentId: id
388
+ // @ts-expect-error – `id` is not correctly typed in the DS.
389
+ id: document?.documentId,
390
+ params
400
391
  },
401
392
  {
402
- skip: !id
393
+ skip: !document?.documentId
403
394
  }
404
395
  );
405
396
  const { meta, stages = [] } = data ?? {};
@@ -415,24 +406,15 @@ const StageSelect = () => {
415
406
  } else if (limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] && parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) < stages.length) {
416
407
  setShowLimitModal("stage");
417
408
  } else {
418
- if (id) {
409
+ if (document?.documentId) {
419
410
  const res = await updateStage({
420
411
  model,
421
- id,
412
+ id: document.documentId,
422
413
  slug: collectionType,
423
414
  params,
424
415
  data: { id: stageId }
425
416
  });
426
417
  if ("data" in res) {
427
- dispatch({
428
- type: "contentManagerApi/invalidateTags",
429
- payload: [
430
- {
431
- type: "Document",
432
- id: `${model}_${id}`
433
- }
434
- ]
435
- });
436
418
  toggleNotification({
437
419
  type: "success",
438
420
  message: formatMessage({
@@ -454,6 +436,7 @@ const StageSelect = () => {
454
436
  }
455
437
  };
456
438
  const { themeColorName } = getStageColorByHex(activeWorkflowStage?.color) ?? {};
439
+ const isLoading = isLoadingStages || isLoadingDocument;
457
440
  return /* @__PURE__ */ jsxs(Fragment, { children: [
458
441
  /* @__PURE__ */ jsxs(
459
442
  Field.Root,
@@ -566,12 +549,16 @@ const StageSelect = () => {
566
549
  ] });
567
550
  };
568
551
  const Panel = () => {
569
- const { slug = "", id } = useParams();
552
+ const {
553
+ slug = "",
554
+ id,
555
+ collectionType
556
+ } = useParams();
570
557
  const {
571
558
  edit: { options }
572
559
  } = unstable_useDocumentLayout(slug);
573
560
  const { formatMessage } = useIntl();
574
- if (!window.strapi.isEE || !options?.reviewWorkflows || !id || id === "create") {
561
+ if (!window.strapi.isEE || !options?.reviewWorkflows || collectionType !== "single-types" && !id || id === "create") {
575
562
  return null;
576
563
  }
577
564
  return {
@@ -590,36 +577,25 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
590
577
  endpoints: (builder) => ({
591
578
  getWorkflows: builder.query({
592
579
  query: (args) => {
593
- const { id, ...params } = args ?? {};
594
580
  return {
595
- url: `/review-workflows/workflows${id ? `/${id}` : ""}`,
581
+ url: "/review-workflows/workflows",
596
582
  method: "GET",
597
583
  config: {
598
- params
584
+ params: args ?? {}
599
585
  }
600
586
  };
601
587
  },
602
588
  transformResponse: (res) => {
603
- let workflows = [];
604
- if (Array.isArray(res.data)) {
605
- workflows = res.data;
606
- } else {
607
- workflows = [res.data];
608
- }
609
589
  return {
610
- workflows,
590
+ workflows: res.data,
611
591
  meta: "meta" in res ? res.meta : void 0
612
592
  };
613
593
  },
614
- providesTags: (res, _err, arg) => {
615
- if (typeof arg === "object" && "id" in arg && arg.id !== "") {
616
- return [{ type: "ReviewWorkflow", id: arg.id }];
617
- } else {
618
- return [
619
- ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
620
- { type: "ReviewWorkflow", id: "LIST" }
621
- ];
622
- }
594
+ providesTags: (res) => {
595
+ return [
596
+ ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
597
+ { type: "ReviewWorkflow", id: "LIST" }
598
+ ];
623
599
  }
624
600
  }),
625
601
  createWorkflow: builder.mutation({
@@ -629,12 +605,18 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
629
605
  data
630
606
  }),
631
607
  transformResponse: (res) => res.data,
632
- invalidatesTags: [
633
- { type: "ReviewWorkflow", id: "LIST" },
634
- "ReviewWorkflowStages",
635
- { type: "Document", id: `ALL_LIST` },
636
- { type: "ContentTypeSettings", id: "LIST" }
637
- ]
608
+ invalidatesTags(res) {
609
+ return [
610
+ { type: "ReviewWorkflow", id: "LIST" },
611
+ "ReviewWorkflowStages",
612
+ { type: "Document", id: `ALL_LIST` },
613
+ { type: "ContentTypeSettings", id: "LIST" },
614
+ ...res?.contentTypes.map((uid) => ({
615
+ type: "Document",
616
+ id: `${uid}_ALL_ITEMS`
617
+ })) ?? []
618
+ ];
619
+ }
638
620
  }),
639
621
  updateWorkflow: builder.mutation({
640
622
  query: ({ id, ...data }) => ({
@@ -646,8 +628,12 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
646
628
  invalidatesTags: (res, _err, arg) => [
647
629
  { type: "ReviewWorkflow", id: arg.id },
648
630
  "ReviewWorkflowStages",
649
- { type: "Document", id: `ALL_LIST` },
650
- { type: "ContentTypeSettings", id: "LIST" }
631
+ { type: "Document", id: "ALL_LIST" },
632
+ { type: "ContentTypeSettings", id: "LIST" },
633
+ ...res?.contentTypes.map((uid) => ({
634
+ type: "Document",
635
+ id: `${uid}_ALL_ITEMS`
636
+ })) ?? []
651
637
  ]
652
638
  }),
653
639
  deleteWorkflow: builder.mutation({
@@ -745,9 +731,6 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
745
731
  };
746
732
  };
747
733
  const prefixPluginTranslations = (trad, pluginId) => {
748
- if (!pluginId) {
749
- throw new TypeError("pluginId can't be empty");
750
- }
751
734
  return Object.keys(trad).reduce((acc, current) => {
752
735
  acc[`${pluginId}.${current}`] = trad[current];
753
736
  return acc;
@@ -770,7 +753,7 @@ const admin = {
770
753
  },
771
754
  permissions: [],
772
755
  async Component() {
773
- const { Router } = await import("./router-B8G2sh6V.mjs");
756
+ const { Router } = await import("./router-BPH_u176.mjs");
774
757
  return { default: Router };
775
758
  }
776
759
  });
@@ -794,7 +777,7 @@ const admin = {
794
777
  async registerTrads({ locales }) {
795
778
  const importedTrads = await Promise.all(
796
779
  locales.map((locale) => {
797
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-D9ZrQAV6.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
780
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-D9dxziEb.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
798
781
  return {
799
782
  data: prefixPluginTranslations(data, PLUGIN_ID),
800
783
  locale
@@ -826,4 +809,4 @@ export {
826
809
  reviewWorkflowsApi as r,
827
810
  useGetContentTypesQuery as u
828
811
  };
829
- //# sourceMappingURL=index-DtJI5ZoC.mjs.map
812
+ //# sourceMappingURL=index-DAcEdoqJ.mjs.map