@strapi/review-workflows 0.0.0-experimental.9df68962083938acba06546a7901c68a63266aec → 0.0.0-experimental.a13c58eec89ab119f0e381fb79c0252979e9c125

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 (81) hide show
  1. package/LICENSE +12 -17
  2. package/dist/_chunks/{Layout-D292CXD6.mjs → Layout-BIIxkAtf.mjs} +9 -10
  3. package/dist/_chunks/Layout-BIIxkAtf.mjs.map +1 -0
  4. package/dist/_chunks/{Layout-BWzD-Tfe.js → Layout-BWNbQOes.js} +9 -10
  5. package/dist/_chunks/Layout-BWNbQOes.js.map +1 -0
  6. package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
  7. package/dist/_chunks/en-CYgjfSep.js.map +1 -0
  8. package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
  9. package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
  10. package/dist/_chunks/{_id-CoX9yljN.js → id-CaHzMdxL.js} +103 -80
  11. package/dist/_chunks/id-CaHzMdxL.js.map +1 -0
  12. package/dist/_chunks/{_id-DqEUzU_u.mjs → id-CtcCl3zh.mjs} +103 -80
  13. package/dist/_chunks/id-CtcCl3zh.mjs.map +1 -0
  14. package/dist/_chunks/{index-D-KMrml_.js → index-BX5MyocW.js} +79 -68
  15. package/dist/_chunks/index-BX5MyocW.js.map +1 -0
  16. package/dist/_chunks/{index-udedGkii.mjs → index-ByTEmYbc.mjs} +80 -69
  17. package/dist/_chunks/index-ByTEmYbc.mjs.map +1 -0
  18. package/dist/_chunks/{index-2nkLt-AE.mjs → index-CGmh3cED.mjs} +11 -31
  19. package/dist/_chunks/index-CGmh3cED.mjs.map +1 -0
  20. package/dist/_chunks/{index-CDMcvtW9.js → index-DKLk-Z5E.js} +9 -29
  21. package/dist/_chunks/index-DKLk-Z5E.js.map +1 -0
  22. package/dist/_chunks/{router-C19H1Rju.js → router-Bt6JHY-e.js} +3 -3
  23. package/dist/_chunks/router-Bt6JHY-e.js.map +1 -0
  24. package/dist/_chunks/{router-bmjk-Tpf.mjs → router-Cr3nulh9.mjs} +3 -3
  25. package/dist/_chunks/router-Cr3nulh9.mjs.map +1 -0
  26. package/dist/admin/index.js +1 -1
  27. package/dist/admin/index.mjs +1 -1
  28. package/dist/admin/src/services/admin.d.ts +1 -1
  29. package/dist/admin/src/services/api.d.ts +1 -1
  30. package/dist/admin/src/services/content-manager.d.ts +4 -4
  31. package/dist/admin/src/services/settings.d.ts +1739 -9
  32. package/dist/server/index.js +165 -84
  33. package/dist/server/index.js.map +1 -1
  34. package/dist/server/index.mjs +165 -84
  35. package/dist/server/index.mjs.map +1 -1
  36. package/dist/server/src/bootstrap.d.ts.map +1 -1
  37. package/dist/server/src/constants/workflows.d.ts +1 -0
  38. package/dist/server/src/constants/workflows.d.ts.map +1 -1
  39. package/dist/server/src/content-types/index.d.ts +6 -0
  40. package/dist/server/src/content-types/index.d.ts.map +1 -1
  41. package/dist/server/src/content-types/workflow/index.d.ts +6 -0
  42. package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
  43. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  44. package/dist/server/src/controllers/index.d.ts +0 -1
  45. package/dist/server/src/controllers/index.d.ts.map +1 -1
  46. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  47. package/dist/server/src/controllers/workflows.d.ts +0 -7
  48. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  49. package/dist/server/src/index.d.ts +16 -4
  50. package/dist/server/src/index.d.ts.map +1 -1
  51. package/dist/server/src/register.d.ts.map +1 -1
  52. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  53. package/dist/server/src/services/document-service-middleware.d.ts +1 -0
  54. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  55. package/dist/server/src/services/index.d.ts +4 -3
  56. package/dist/server/src/services/index.d.ts.map +1 -1
  57. package/dist/server/src/services/metrics/index.d.ts +4 -4
  58. package/dist/server/src/services/metrics/index.d.ts.map +1 -1
  59. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  60. package/dist/server/src/services/stages.d.ts +2 -7
  61. package/dist/server/src/services/stages.d.ts.map +1 -1
  62. package/dist/server/src/services/workflows.d.ts.map +1 -1
  63. package/dist/server/src/validation/review-workflows.d.ts +4 -0
  64. package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
  65. package/dist/shared/contracts/review-workflows.d.ts +9 -17
  66. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  67. package/package.json +10 -10
  68. package/dist/_chunks/Layout-BWzD-Tfe.js.map +0 -1
  69. package/dist/_chunks/Layout-D292CXD6.mjs.map +0 -1
  70. package/dist/_chunks/_id-CoX9yljN.js.map +0 -1
  71. package/dist/_chunks/_id-DqEUzU_u.mjs.map +0 -1
  72. package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
  73. package/dist/_chunks/en-xcewH2pC.js.map +0 -1
  74. package/dist/_chunks/index-2nkLt-AE.mjs.map +0 -1
  75. package/dist/_chunks/index-CDMcvtW9.js.map +0 -1
  76. package/dist/_chunks/index-D-KMrml_.js.map +0 -1
  77. package/dist/_chunks/index-udedGkii.mjs.map +0 -1
  78. package/dist/_chunks/router-C19H1Rju.js.map +0 -1
  79. package/dist/_chunks/router-bmjk-Tpf.mjs.map +0 -1
  80. package/strapi-server.js +0 -3
  81. /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";
@@ -25,8 +25,9 @@ const CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME = "stagesPerWorkflow";
25
25
  const STAGE_COLOR_DEFAULT = lightTheme.colors.primary600;
26
26
  const useTypedSelector = useSelector;
27
27
  const reviewWorkflowsApi = adminApi.enhanceEndpoints({
28
- addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages"]
28
+ addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages", "Document", "ContentTypeSettings"]
29
29
  });
30
+ const SINGLE_TYPES = "single-types";
30
31
  const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
31
32
  endpoints: (builder) => ({
32
33
  getStages: builder.query({
@@ -54,7 +55,17 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
54
55
  params
55
56
  }
56
57
  }),
57
- transformResponse: (res) => res.data
58
+ transformResponse: (res) => res.data,
59
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
60
+ return [
61
+ {
62
+ type: "Document",
63
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
64
+ },
65
+ { type: "Document", id: `${model}_LIST` },
66
+ "ReviewWorkflowStages"
67
+ ];
68
+ }
58
69
  }),
59
70
  updateAssignee: builder.mutation({
60
71
  query: ({ model, slug, id, params, ...data }) => ({
@@ -65,7 +76,16 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
65
76
  params
66
77
  }
67
78
  }),
68
- transformResponse: (res) => res.data
79
+ transformResponse: (res) => res.data,
80
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
81
+ return [
82
+ {
83
+ type: "Document",
84
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
85
+ },
86
+ { type: "Document", id: `${model}_LIST` }
87
+ ];
88
+ }
69
89
  }),
70
90
  getContentTypes: builder.query({
71
91
  query: () => ({
@@ -136,7 +156,6 @@ const AssigneeSelect = () => {
136
156
  id,
137
157
  slug: model = ""
138
158
  } = useParams();
139
- const dispatch = useDispatch();
140
159
  const permissions = useTypedSelector((state) => state.admin_app.permissions);
141
160
  const { formatMessage } = useIntl();
142
161
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
@@ -157,13 +176,13 @@ const AssigneeSelect = () => {
157
176
  documentId: id
158
177
  },
159
178
  {
160
- skip: !id
179
+ skip: !id && collectionType !== "single-types"
161
180
  }
162
181
  );
163
182
  const users = data?.users || [];
164
183
  const currentAssignee = document ? document[ASSIGNEE_ATTRIBUTE_NAME] : null;
165
184
  const [updateAssignee, { error, isLoading: isMutating }] = useUpdateAssigneeMutation();
166
- if (!collectionType || !model || !id) {
185
+ if (!collectionType || !model || !document?.documentId) {
167
186
  return null;
168
187
  }
169
188
  const handleChange = async (assigneeId) => {
@@ -173,22 +192,13 @@ const AssigneeSelect = () => {
173
192
  const res = await updateAssignee({
174
193
  slug: collectionType,
175
194
  model,
176
- id,
195
+ id: document.documentId,
177
196
  params,
178
197
  data: {
179
198
  id: assigneeId ? parseInt(assigneeId, 10) : null
180
199
  }
181
200
  });
182
201
  if ("data" in res) {
183
- dispatch({
184
- type: "contentManagerApi/invalidateTags",
185
- payload: [
186
- {
187
- type: "Document",
188
- id: `${model}_${id}`
189
- }
190
- ]
191
- });
192
202
  toggleNotification({
193
203
  type: "success",
194
204
  message: formatMessage({
@@ -219,7 +229,7 @@ const AssigneeSelect = () => {
219
229
  id: "content-manager.reviewWorkflows.assignee.clear",
220
230
  defaultMessage: "Clear assignee"
221
231
  }),
222
- disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !id,
232
+ disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !document.documentId,
223
233
  value: currentAssignee ? currentAssignee.id.toString() : null,
224
234
  onChange: handleChange,
225
235
  onClear: () => handleChange(null),
@@ -356,31 +366,31 @@ const StageSelect = () => {
356
366
  slug: model = "",
357
367
  id = ""
358
368
  } = useParams();
359
- const dispatch = useDispatch();
360
369
  const { formatMessage } = useIntl();
361
370
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
362
371
  const { toggleNotification } = useNotification();
363
372
  const [{ query }] = useQueryParams();
364
373
  const params = React.useMemo(() => buildValidParams(query), [query]);
365
- const { data, isLoading } = useGetStagesQuery(
374
+ const { document, isLoading: isLoadingDocument } = unstable_useDocument(
366
375
  {
367
- slug: collectionType,
376
+ collectionType,
368
377
  model,
369
- id,
370
- params
378
+ documentId: id
371
379
  },
372
380
  {
373
- skip: !id
381
+ skip: !id && collectionType !== "single-types"
374
382
  }
375
383
  );
376
- const { document } = unstable_useDocument(
384
+ const { data, isLoading: isLoadingStages } = useGetStagesQuery(
377
385
  {
378
- collectionType,
386
+ slug: collectionType,
379
387
  model,
380
- documentId: id
388
+ // @ts-expect-error – `id` is not correctly typed in the DS.
389
+ id: document?.documentId,
390
+ params
381
391
  },
382
392
  {
383
- skip: !id
393
+ skip: !document?.documentId
384
394
  }
385
395
  );
386
396
  const { meta, stages = [] } = data ?? {};
@@ -396,24 +406,15 @@ const StageSelect = () => {
396
406
  } else if (limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] && parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) < stages.length) {
397
407
  setShowLimitModal("stage");
398
408
  } else {
399
- if (id) {
409
+ if (document?.documentId) {
400
410
  const res = await updateStage({
401
411
  model,
402
- id,
412
+ id: document.documentId,
403
413
  slug: collectionType,
404
414
  params,
405
415
  data: { id: stageId }
406
416
  });
407
417
  if ("data" in res) {
408
- dispatch({
409
- type: "contentManagerApi/invalidateTags",
410
- payload: [
411
- {
412
- type: "Document",
413
- id: `${model}_${id}`
414
- }
415
- ]
416
- });
417
418
  toggleNotification({
418
419
  type: "success",
419
420
  message: formatMessage({
@@ -435,6 +436,7 @@ const StageSelect = () => {
435
436
  }
436
437
  };
437
438
  const { themeColorName } = getStageColorByHex(activeWorkflowStage?.color) ?? {};
439
+ const isLoading = isLoadingStages || isLoadingDocument;
438
440
  return /* @__PURE__ */ jsxs(Fragment, { children: [
439
441
  /* @__PURE__ */ jsxs(
440
442
  Field.Root,
@@ -547,12 +549,16 @@ const StageSelect = () => {
547
549
  ] });
548
550
  };
549
551
  const Panel = () => {
550
- const { slug = "", id } = useParams();
552
+ const {
553
+ slug = "",
554
+ id,
555
+ collectionType
556
+ } = useParams();
551
557
  const {
552
558
  edit: { options }
553
559
  } = unstable_useDocumentLayout(slug);
554
560
  const { formatMessage } = useIntl();
555
- if (!window.strapi.isEE || !options?.reviewWorkflows || !id || id === "create") {
561
+ if (!window.strapi.isEE || !options?.reviewWorkflows || collectionType !== "single-types" && !id || id === "create") {
556
562
  return null;
557
563
  }
558
564
  return {
@@ -571,36 +577,25 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
571
577
  endpoints: (builder) => ({
572
578
  getWorkflows: builder.query({
573
579
  query: (args) => {
574
- const { id, ...params } = args ?? {};
575
580
  return {
576
- url: `/review-workflows/workflows${id ? `/${id}` : ""}`,
581
+ url: "/review-workflows/workflows",
577
582
  method: "GET",
578
583
  config: {
579
- params
584
+ params: args ?? {}
580
585
  }
581
586
  };
582
587
  },
583
588
  transformResponse: (res) => {
584
- let workflows = [];
585
- if (Array.isArray(res.data)) {
586
- workflows = res.data;
587
- } else {
588
- workflows = [res.data];
589
- }
590
589
  return {
591
- workflows,
590
+ workflows: res.data,
592
591
  meta: "meta" in res ? res.meta : void 0
593
592
  };
594
593
  },
595
- providesTags: (res, _err, arg) => {
596
- if (typeof arg === "object" && "id" in arg && arg.id !== "") {
597
- return [{ type: "ReviewWorkflow", id: arg.id }];
598
- } else {
599
- return [
600
- ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
601
- { type: "ReviewWorkflow", id: "LIST" }
602
- ];
603
- }
594
+ providesTags: (res) => {
595
+ return [
596
+ ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
597
+ { type: "ReviewWorkflow", id: "LIST" }
598
+ ];
604
599
  }
605
600
  }),
606
601
  createWorkflow: builder.mutation({
@@ -610,7 +605,18 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
610
605
  data
611
606
  }),
612
607
  transformResponse: (res) => res.data,
613
- invalidatesTags: [{ type: "ReviewWorkflow", id: "LIST" }, "ReviewWorkflowStages"]
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
+ }
614
620
  }),
615
621
  updateWorkflow: builder.mutation({
616
622
  query: ({ id, ...data }) => ({
@@ -621,7 +627,13 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
621
627
  transformResponse: (res) => res.data,
622
628
  invalidatesTags: (res, _err, arg) => [
623
629
  { type: "ReviewWorkflow", id: arg.id },
624
- "ReviewWorkflowStages"
630
+ "ReviewWorkflowStages",
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
+ })) ?? []
625
637
  ]
626
638
  }),
627
639
  deleteWorkflow: builder.mutation({
@@ -632,7 +644,9 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
632
644
  transformResponse: (res) => res.data,
633
645
  invalidatesTags: (res, _err, arg) => [
634
646
  { type: "ReviewWorkflow", id: arg.id },
635
- "ReviewWorkflowStages"
647
+ "ReviewWorkflowStages",
648
+ { type: "Document", id: `ALL_LIST` },
649
+ { type: "ContentTypeSettings", id: "LIST" }
636
650
  ]
637
651
  })
638
652
  }),
@@ -717,9 +731,6 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
717
731
  };
718
732
  };
719
733
  const prefixPluginTranslations = (trad, pluginId) => {
720
- if (!pluginId) {
721
- throw new TypeError("pluginId can't be empty");
722
- }
723
734
  return Object.keys(trad).reduce((acc, current) => {
724
735
  acc[`${pluginId}.${current}`] = trad[current];
725
736
  return acc;
@@ -742,7 +753,7 @@ const admin = {
742
753
  },
743
754
  permissions: [],
744
755
  async Component() {
745
- const { Router } = await import("./router-bmjk-Tpf.mjs");
756
+ const { Router } = await import("./router-Cr3nulh9.mjs");
746
757
  return { default: Router };
747
758
  }
748
759
  });
@@ -766,7 +777,7 @@ const admin = {
766
777
  async registerTrads({ locales }) {
767
778
  const importedTrads = await Promise.all(
768
779
  locales.map((locale) => {
769
- 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 }) => {
770
781
  return {
771
782
  data: prefixPluginTranslations(data, PLUGIN_ID),
772
783
  locale
@@ -798,4 +809,4 @@ export {
798
809
  reviewWorkflowsApi as r,
799
810
  useGetContentTypesQuery as u
800
811
  };
801
- //# sourceMappingURL=index-udedGkii.mjs.map
812
+ //# sourceMappingURL=index-ByTEmYbc.mjs.map