@strapi/admin 4.12.6 → 4.13.0-alpha.0

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 (211) hide show
  1. package/admin/src/StrapiApp.js +1 -1
  2. package/admin/src/components/AuthenticatedApp/index.js +118 -0
  3. package/admin/src/components/AuthenticatedApp/utils/api.js +85 -0
  4. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +11 -0
  5. package/admin/src/components/GuidedTour/Modal/index.js +3 -1
  6. package/admin/src/components/NpsSurvey/hooks/useNpsSurveySettings.js +17 -0
  7. package/admin/src/components/NpsSurvey/index.js +365 -0
  8. package/admin/src/components/PluginsInitializer/index.js +68 -0
  9. package/admin/src/components/PluginsInitializer/init.js +11 -0
  10. package/admin/src/components/PluginsInitializer/reducer.js +22 -0
  11. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumns.js +2 -0
  12. package/admin/src/content-manager/components/DynamicZone/components/DynamicZoneLabel.js +1 -1
  13. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +8 -1
  14. package/admin/src/content-manager/components/Filter/CustomInputs/AdminUsersFilter.js +42 -0
  15. package/admin/src/content-manager/components/Filter/Filter.js +54 -0
  16. package/admin/src/content-manager/components/Filter/index.js +1 -0
  17. package/admin/src/content-manager/components/InputUID/index.js +222 -216
  18. package/admin/src/content-manager/components/RelationInput/RelationInput.js +4 -0
  19. package/admin/src/content-manager/components/RepeatableComponent/index.js +32 -2
  20. package/admin/src/content-manager/components/Wysiwyg/Editor.js +432 -68
  21. package/admin/src/content-manager/components/Wysiwyg/WysiwygStyles.js +0 -7
  22. package/admin/src/content-manager/components/Wysiwyg/index.js +147 -152
  23. package/admin/src/content-manager/hooks/useAllowedAttributes.js +47 -0
  24. package/admin/src/content-manager/pages/App/index.js +16 -5
  25. package/admin/src/content-manager/pages/EditView/Information/index.js +9 -8
  26. package/admin/src/content-manager/pages/ListSettingsView/components/Settings.js +40 -7
  27. package/admin/src/content-manager/pages/ListSettingsView/index.js +6 -2
  28. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  29. package/admin/src/content-manager/pages/ListView/components/FieldPicker/index.js +67 -69
  30. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  31. package/admin/src/content-manager/pages/ListView/components/ViewSettingsMenu/index.js +80 -0
  32. package/admin/src/content-manager/pages/ListView/index.js +236 -67
  33. package/admin/src/content-manager/utils/getDisplayName.js +33 -0
  34. package/admin/src/content-manager/utils/index.js +1 -0
  35. package/admin/src/hooks/useSettingsForm/index.js +3 -14
  36. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  37. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +3 -1
  38. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +3 -1
  39. package/admin/src/index.js +1 -1
  40. package/admin/src/layouts/AppLayout/index.js +33 -0
  41. package/admin/src/pages/Admin/Onboarding/index.js +3 -1
  42. package/admin/src/pages/Admin/index.js +73 -77
  43. package/admin/src/pages/App/constants.js +1 -1
  44. package/admin/src/pages/App/index.js +122 -160
  45. package/admin/src/pages/AuthPage/components/Register/index.js +5 -0
  46. package/admin/src/pages/AuthPage/index.js +4 -2
  47. package/admin/src/pages/HomePage/index.js +3 -1
  48. package/admin/src/pages/InstalledPluginsPage/index.js +3 -1
  49. package/admin/src/pages/{InternalErrorPage.js → InternalErrorPage/index.js} +4 -3
  50. package/admin/src/pages/{NotFoundPage.js → NotFoundPage/index.js} +3 -1
  51. package/admin/src/pages/ProfilePage/index.js +4 -2
  52. package/admin/src/pages/SettingsPage/constants.js +132 -67
  53. package/admin/src/pages/SettingsPage/index.js +18 -23
  54. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  55. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  56. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +1 -2
  57. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  58. package/admin/src/pages/UseCasePage/index.js +175 -0
  59. package/admin/src/plugins.js +7 -8
  60. package/admin/src/translations/en.json +10 -1
  61. package/admin/src/utils/checkFormValidity.js +15 -0
  62. package/admin/src/utils/createRoute.js +7 -5
  63. package/admin/src/utils/formatAPIErrors.js +3 -1
  64. package/admin/src/utils/getAttributesToDisplay.js +19 -0
  65. package/admin/src/utils/getExistingActions.js +32 -0
  66. package/admin/src/utils/getFullName.js +1 -1
  67. package/admin/src/utils/index.js +9 -0
  68. package/admin/src/utils/makeUniqueRoutes.js +6 -0
  69. package/admin/src/utils/sortLinks.js +3 -1
  70. package/admin/src/utils/uniqueAdminHash.js +9 -2
  71. package/build/{1049.9d69d231.chunk.js → 1049.ec69f5e0.chunk.js} +1 -1
  72. package/build/1227.9f37e1dc.chunk.js +1 -0
  73. package/build/1386.ea73b677.chunk.js +7 -0
  74. package/build/{2225.33287e1b.chunk.js → 2225.649fb7bc.chunk.js} +2 -2
  75. package/build/{2237.03792b63.chunk.js → 2237.b832ae6e.chunk.js} +4 -4
  76. package/build/{2379.401f56f3.chunk.js → 2379.1f98a31a.chunk.js} +1 -1
  77. package/build/{2395.e6a79fbb.chunk.js → 2395.0e5e8ded.chunk.js} +1 -1
  78. package/build/{2801.31393ffe.chunk.js → 2801.8e1aa82a.chunk.js} +1 -1
  79. package/build/3483.19381b40.chunk.js +1 -0
  80. package/build/3739.63e352f1.chunk.js +103 -0
  81. package/build/4174.f1f39e40.chunk.js +1 -0
  82. package/build/448.829e1344.chunk.js +1 -0
  83. package/build/4546.a5946d22.chunk.js +1 -0
  84. package/build/4724.aea5c8c1.chunk.js +6 -0
  85. package/build/{502.8dd074ff.chunk.js → 502.7bba43b1.chunk.js} +1 -1
  86. package/build/6158.c3c13c20.chunk.js +1 -0
  87. package/build/6691.4985ef22.chunk.js +105 -0
  88. package/build/{7464.592a9295.chunk.js → 7464.eb057bec.chunk.js} +1 -1
  89. package/build/78.dcc6df5c.chunk.js +1 -0
  90. package/build/{8276.e519a707.chunk.js → 8276.be3ed581.chunk.js} +2 -2
  91. package/build/{2747.d1442a90.chunk.js → 9806.5d5a0e8d.chunk.js} +64 -72
  92. package/build/9944.7af075a5.chunk.js +26 -0
  93. package/build/Admin-authenticatedApp.43b6ec9a.chunk.js +79 -0
  94. package/build/Admin_InternalErrorPage.38155af3.chunk.js +1 -0
  95. package/build/Admin_homePage.6f128523.chunk.js +81 -0
  96. package/build/Admin_marketplace.061a6e5a.chunk.js +55 -0
  97. package/build/Admin_pluginsPage.16f837b8.chunk.js +6 -0
  98. package/build/Admin_profilePage.678bce24.chunk.js +13 -0
  99. package/build/Admin_settingsPage.af7309e4.chunk.js +111 -0
  100. package/build/{Upload_ConfigureTheView.345ac1e0.chunk.js → Upload_ConfigureTheView.3fc1c100.chunk.js} +1 -1
  101. package/build/admin-app.d63bd229.chunk.js +36 -0
  102. package/build/{admin-edit-roles-page.24bdf746.chunk.js → admin-edit-roles-page.38a6c863.chunk.js} +3 -3
  103. package/build/admin-edit-users.545fc882.chunk.js +10 -0
  104. package/build/{admin-roles-list.23ddff26.chunk.js → admin-roles-list.1e2e814d.chunk.js} +1 -1
  105. package/build/admin-users.b8ea5677.chunk.js +11 -0
  106. package/build/{api-tokens-create-page.46c2ea84.chunk.js → api-tokens-create-page.e0c15627.chunk.js} +1 -1
  107. package/build/{api-tokens-edit-page.58139df9.chunk.js → api-tokens-edit-page.9f2dce47.chunk.js} +1 -1
  108. package/build/{api-tokens-list-page.0af7d431.chunk.js → api-tokens-list-page.d747051c.chunk.js} +2 -2
  109. package/build/{audit-logs-settings-page.0f73ccf8.chunk.js → audit-logs-settings-page.96f9d608.chunk.js} +1 -1
  110. package/build/content-manager.ccff1078.chunk.js +1097 -0
  111. package/build/{content-type-builder-list-view.bf9be456.chunk.js → content-type-builder-list-view.b71cf240.chunk.js} +1 -1
  112. package/build/{content-type-builder.66066281.chunk.js → content-type-builder.e5669749.chunk.js} +18 -18
  113. package/build/{email-settings-page.2f7e35c0.chunk.js → email-settings-page.2809f0bf.chunk.js} +1 -1
  114. package/build/en-json.e12fd5fc.chunk.js +1 -0
  115. package/build/{i18n-settings-page.47f78016.chunk.js → i18n-settings-page.5f716172.chunk.js} +1 -1
  116. package/build/index.html +1 -1
  117. package/build/main.c6c9e04c.js +2859 -0
  118. package/build/{review-workflows-settings-create-view.d24a32b9.chunk.js → review-workflows-settings-create-view.4a156a19.chunk.js} +1 -1
  119. package/build/{review-workflows-settings-edit-view.6044b022.chunk.js → review-workflows-settings-edit-view.ce984d1f.chunk.js} +1 -1
  120. package/build/{review-workflows-settings-list-view.3f0ef4bc.chunk.js → review-workflows-settings-list-view.419b8deb.chunk.js} +2 -2
  121. package/build/runtime~main.dcf1cb45.js +2 -0
  122. package/build/{sso-settings-page.4dba0670.chunk.js → sso-settings-page.45153df5.chunk.js} +1 -1
  123. package/build/{transfer-tokens-create-page.1597e6ab.chunk.js → transfer-tokens-create-page.ebba16d8.chunk.js} +1 -1
  124. package/build/{transfer-tokens-edit-page.8741529f.chunk.js → transfer-tokens-edit-page.d7bb2b3e.chunk.js} +1 -1
  125. package/build/{transfer-tokens-list-page.d6986b03.chunk.js → transfer-tokens-list-page.cfe1736c.chunk.js} +2 -2
  126. package/build/{upload-settings.7f93d4c0.chunk.js → upload-settings.cc5ad813.chunk.js} +1 -1
  127. package/build/{upload.37488080.chunk.js → upload.756efc28.chunk.js} +1 -1
  128. package/build/{users-advanced-settings-page.17052d72.chunk.js → users-advanced-settings-page.818d84eb.chunk.js} +1 -1
  129. package/build/{users-email-settings-page.3de8ea50.chunk.js → users-email-settings-page.c1967c09.chunk.js} +1 -1
  130. package/build/{users-providers-settings-page.0eaa916d.chunk.js → users-providers-settings-page.11893e08.chunk.js} +1 -1
  131. package/build/{users-roles-settings-page.957ad48b.chunk.js → users-roles-settings-page.2b051e6a.chunk.js} +1 -1
  132. package/build/webhook-edit-page.de45c635.chunk.js +33 -0
  133. package/build/{webhook-list-page.65e1b5bb.chunk.js → webhook-list-page.ca91df8b.chunk.js} +1 -1
  134. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/AssigneeFilter.js +42 -0
  135. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/StageFilter.js +70 -0
  136. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/constants.js +71 -0
  137. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +9 -217
  138. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/AssigneeSelect.js +147 -0
  139. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/index.js +1 -0
  140. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/StageSelect.js +243 -0
  141. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/index.js +1 -0
  142. package/ee/admin/content-manager/pages/EditView/InformationBox/constants.js +2 -0
  143. package/ee/admin/content-manager/pages/ListSettingsView/constants.js +7 -0
  144. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/ReviewWorkflowsAssigneeEE.js +21 -0
  145. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants.js +44 -17
  146. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/index.js +1 -0
  147. package/ee/admin/pages/App/constants.js +5 -6
  148. package/ee/admin/pages/SettingsPage/constants.js +42 -27
  149. package/ee/server/constants/workflows.js +1 -0
  150. package/ee/server/controllers/index.js +1 -0
  151. package/ee/server/controllers/workflows/assignees/index.js +44 -0
  152. package/ee/server/routes/review-workflows.js +17 -0
  153. package/ee/server/services/index.js +1 -0
  154. package/ee/server/services/review-workflows/assignees.js +54 -0
  155. package/ee/server/services/review-workflows/metrics/index.js +5 -0
  156. package/ee/server/services/review-workflows/review-workflows.js +20 -11
  157. package/ee/server/validation/review-workflows.js +8 -0
  158. package/index.js +2 -6
  159. package/package.json +9 -9
  160. package/scripts/build.js +15 -15
  161. package/scripts/create-dev-plugins-file.js +5 -38
  162. package/server/controllers/role.js +2 -0
  163. package/server/controllers/user.js +2 -0
  164. package/server/services/permission/permissions-manager/index.js +3 -1
  165. package/server/services/permission/permissions-manager/sanitize.js +19 -7
  166. package/server/services/permission/permissions-manager/validate.js +218 -0
  167. package/utils/create-cache-dir.js +62 -16
  168. package/utils/create-plugins-exclude-path.js +3 -23
  169. package/utils/get-plugins.js +110 -0
  170. package/utils/index.js +1 -1
  171. package/webpack.config.js +10 -13
  172. package/admin/src/components/AuthenticatedApp.js +0 -229
  173. package/admin/src/content-manager/components/AttributeFilter/Filters.js +0 -58
  174. package/admin/src/content-manager/components/AttributeFilter/hooks/useAllowedAttributes.js +0 -42
  175. package/admin/src/content-manager/components/AttributeFilter/index.js +0 -40
  176. package/admin/src/content-manager/components/Wysiwyg/EditorStylesContainer.js +0 -344
  177. package/admin/src/pages/UseCasePage.js +0 -174
  178. package/build/2166.c837469a.chunk.js +0 -1
  179. package/build/3483.8517171f.chunk.js +0 -1
  180. package/build/3984.dda474f7.chunk.js +0 -1
  181. package/build/4546.7a3c0d03.chunk.js +0 -1
  182. package/build/5483.5bfbb00d.chunk.js +0 -6
  183. package/build/6158.c974fd83.chunk.js +0 -1
  184. package/build/748.fd2e5afd.chunk.js +0 -105
  185. package/build/773.6381d62d.chunk.js +0 -18
  186. package/build/7826.399afe81.chunk.js +0 -103
  187. package/build/8261.2525d35c.chunk.js +0 -7
  188. package/build/8299.62b67c72.chunk.js +0 -1
  189. package/build/Admin-AuthPage.90d64342.chunk.js +0 -35
  190. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +0 -24
  191. package/build/Admin-UseCasePage.1f757db5.chunk.js +0 -13
  192. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +0 -12
  193. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +0 -9
  194. package/build/Admin_NotFoundPage.21620424.chunk.js +0 -9
  195. package/build/Admin_Onboarding.dbfa32f6.chunk.js +0 -43
  196. package/build/Admin_homePage.2000cbe9.chunk.js +0 -86
  197. package/build/Admin_marketplace.ec80e29b.chunk.js +0 -63
  198. package/build/Admin_pluginsPage.0c6851f8.chunk.js +0 -14
  199. package/build/Admin_profilePage.78cd8495.chunk.js +0 -21
  200. package/build/Admin_settingsPage.1760c3ce.chunk.js +0 -119
  201. package/build/StrapiApp.221fac30.chunk.js +0 -5
  202. package/build/admin-edit-users.5d10d444.chunk.js +0 -10
  203. package/build/admin-users.2b3e4305.chunk.js +0 -11
  204. package/build/content-manager.fb0833bd.chunk.js +0 -1099
  205. package/build/en-json.08c05fcf.chunk.js +0 -1
  206. package/build/main.ee3c1938.js +0 -2859
  207. package/build/runtime~main.397ee447.js +0 -2
  208. package/build/webhook-edit-page.665210af.chunk.js +0 -33
  209. package/scripts/create-plugins-file.js +0 -92
  210. package/utils/get-plugins-path.js +0 -41
  211. /package/server/services/permission/permissions-manager/{query-builers.js → query-builders.js} +0 -0
@@ -0,0 +1,243 @@
1
+ import * as React from 'react';
2
+
3
+ import {
4
+ SingleSelect,
5
+ SingleSelectOption,
6
+ Field,
7
+ FieldError,
8
+ Flex,
9
+ Loader,
10
+ Typography,
11
+ } from '@strapi/design-system';
12
+ import {
13
+ useCMEditViewDataManager,
14
+ useAPIErrorHandler,
15
+ useFetchClient,
16
+ useNotification,
17
+ } from '@strapi/helper-plugin';
18
+ import { useIntl } from 'react-intl';
19
+ import { useMutation } from 'react-query';
20
+
21
+ import { useLicenseLimits } from '../../../../../../hooks/useLicenseLimits';
22
+ import * as LimitsModal from '../../../../../../pages/SettingsPage/pages/ReviewWorkflows/components/LimitsModal';
23
+ import {
24
+ CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME,
25
+ CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME,
26
+ } from '../../../../../../pages/SettingsPage/pages/ReviewWorkflows/constants';
27
+ import { useReviewWorkflows } from '../../../../../../pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows';
28
+ import { getStageColorByHex } from '../../../../../../pages/SettingsPage/pages/ReviewWorkflows/utils/colors';
29
+ import { STAGE_ATTRIBUTE_NAME } from '../../constants';
30
+
31
+ export function StageSelect() {
32
+ const {
33
+ initialData,
34
+ layout: { uid },
35
+ isSingleType,
36
+ onChange,
37
+ } = useCMEditViewDataManager();
38
+ const { put } = useFetchClient();
39
+ const { formatMessage } = useIntl();
40
+ const { formatAPIError } = useAPIErrorHandler();
41
+ const toggleNotification = useNotification();
42
+ const {
43
+ meta,
44
+ workflows: [workflow],
45
+ isLoading,
46
+ } = useReviewWorkflows({ filters: { contentTypes: uid } });
47
+ const { getFeature } = useLicenseLimits();
48
+ const [showLimitModal, setShowLimitModal] = React.useState(false);
49
+
50
+ const limits = getFeature('review-workflows');
51
+ // it is possible to rely on initialData here, because it always will
52
+ // be updated at the same time when modifiedData is updated, otherwise
53
+ // the entity is flagged as modified
54
+ const activeWorkflowStage = initialData?.[STAGE_ATTRIBUTE_NAME] ?? null;
55
+
56
+ const mutation = useMutation(
57
+ async ({ entityId, stageId, uid }) => {
58
+ const typeSlug = isSingleType ? 'single-types' : 'collection-types';
59
+
60
+ const {
61
+ data: { data: createdEntity },
62
+ } = await put(`/admin/content-manager/${typeSlug}/${uid}/${entityId}/stage`, {
63
+ data: { id: stageId },
64
+ });
65
+
66
+ // initialData and modifiedData have to stay in sync, otherwise the entity would be flagged
67
+ // as modified, which is what the boolean flag is for
68
+ onChange(
69
+ { target: { name: STAGE_ATTRIBUTE_NAME, value: createdEntity[STAGE_ATTRIBUTE_NAME] } },
70
+ true
71
+ );
72
+
73
+ return createdEntity;
74
+ },
75
+ {
76
+ onSuccess() {
77
+ toggleNotification({
78
+ type: 'success',
79
+ message: {
80
+ id: 'content-manager.reviewWorkflows.stage.notification.saved',
81
+ defaultMessage: 'Review stage updated',
82
+ },
83
+ });
84
+ },
85
+ }
86
+ );
87
+
88
+ const handleChange = async ({ value: stageId }) => {
89
+ try {
90
+ /**
91
+ * If the current license has a limit:
92
+ * check if the total count of workflows exceeds that limit and display
93
+ * the limits modal.
94
+ *
95
+ * If the current license does not have a limit (e.g. offline license):
96
+ * do nothing (for now).
97
+ *
98
+ */
99
+
100
+ if (
101
+ limits?.[CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME] &&
102
+ parseInt(limits[CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME], 10) < meta.workflowCount
103
+ ) {
104
+ setShowLimitModal('workflow');
105
+
106
+ /**
107
+ * If the current license has a limit:
108
+ * check if the total count of stages exceeds that limit and display
109
+ * the limits modal.
110
+ *
111
+ * If the current license does not have a limit (e.g. offline license):
112
+ * do nothing (for now).
113
+ *
114
+ */
115
+ } else if (
116
+ limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] &&
117
+ parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) <
118
+ workflow.stages.length
119
+ ) {
120
+ setShowLimitModal('stage');
121
+ } else {
122
+ mutation.mutateAsync({
123
+ entityId: initialData.id,
124
+ stageId,
125
+ uid,
126
+ });
127
+ }
128
+ } catch (error) {
129
+ // react-query@v3: the error doesn't have to be handled here
130
+ // see: https://github.com/TanStack/query/issues/121
131
+ }
132
+ };
133
+
134
+ const { themeColorName } = activeWorkflowStage?.color
135
+ ? getStageColorByHex(activeWorkflowStage?.color)
136
+ : {};
137
+
138
+ return (
139
+ <>
140
+ <Field name={STAGE_ATTRIBUTE_NAME} id={STAGE_ATTRIBUTE_NAME}>
141
+ <Flex direction="column" gap={2} alignItems="stretch">
142
+ <SingleSelect
143
+ error={(mutation.error && formatAPIError(mutation.error)) || null}
144
+ name={STAGE_ATTRIBUTE_NAME}
145
+ id={STAGE_ATTRIBUTE_NAME}
146
+ value={activeWorkflowStage?.id}
147
+ onChange={(value) => handleChange({ value })}
148
+ label={formatMessage({
149
+ id: 'content-manager.reviewWorkflows.stage.label',
150
+ defaultMessage: 'Review stage',
151
+ })}
152
+ startIcon={
153
+ <Flex
154
+ as="span"
155
+ height={2}
156
+ background={activeWorkflowStage?.color}
157
+ borderColor={themeColorName === 'neutral0' ? 'neutral150' : 'transparent'}
158
+ hasRadius
159
+ shrink={0}
160
+ width={2}
161
+ marginRight="-3px"
162
+ />
163
+ }
164
+ // eslint-disable-next-line react/no-unstable-nested-components
165
+ customizeContent={() => (
166
+ <Flex as="span" justifyContent="space-between" alignItems="center" width="100%">
167
+ <Typography textColor="neutral800" ellipsis>
168
+ {activeWorkflowStage?.name}
169
+ </Typography>
170
+ {isLoading ? <Loader small style={{ display: 'flex' }} /> : null}
171
+ </Flex>
172
+ )}
173
+ >
174
+ {workflow
175
+ ? workflow.stages.map(({ id, color, name }) => {
176
+ const { themeColorName } = getStageColorByHex(color);
177
+
178
+ return (
179
+ <SingleSelectOption
180
+ key={id}
181
+ startIcon={
182
+ <Flex
183
+ height={2}
184
+ background={color}
185
+ borderColor={themeColorName === 'neutral0' ? 'neutral150' : 'transparent'}
186
+ hasRadius
187
+ shrink={0}
188
+ width={2}
189
+ />
190
+ }
191
+ value={id}
192
+ textValue={name}
193
+ >
194
+ {name}
195
+ </SingleSelectOption>
196
+ );
197
+ })
198
+ : []}
199
+ </SingleSelect>
200
+ <FieldError />
201
+ </Flex>
202
+ </Field>
203
+
204
+ <LimitsModal.Root
205
+ isOpen={showLimitModal === 'workflow'}
206
+ onClose={() => setShowLimitModal(false)}
207
+ >
208
+ <LimitsModal.Title>
209
+ {formatMessage({
210
+ id: 'content-manager.reviewWorkflows.workflows.limit.title',
211
+ defaultMessage: 'You’ve reached the limit of workflows in your plan',
212
+ })}
213
+ </LimitsModal.Title>
214
+
215
+ <LimitsModal.Body>
216
+ {formatMessage({
217
+ id: 'content-manager.reviewWorkflows.workflows.limit.body',
218
+ defaultMessage: 'Delete a workflow or contact Sales to enable more workflows.',
219
+ })}
220
+ </LimitsModal.Body>
221
+ </LimitsModal.Root>
222
+
223
+ <LimitsModal.Root
224
+ isOpen={showLimitModal === 'stage'}
225
+ onClose={() => setShowLimitModal(false)}
226
+ >
227
+ <LimitsModal.Title>
228
+ {formatMessage({
229
+ id: 'content-manager.reviewWorkflows.stages.limit.title',
230
+ defaultMessage: 'You have reached the limit of stages for this workflow in your plan',
231
+ })}
232
+ </LimitsModal.Title>
233
+
234
+ <LimitsModal.Body>
235
+ {formatMessage({
236
+ id: 'content-manager.reviewWorkflows.stages.limit.body',
237
+ defaultMessage: 'Try deleting some stages or contact Sales to enable more stages.',
238
+ })}
239
+ </LimitsModal.Body>
240
+ </LimitsModal.Root>
241
+ </>
242
+ );
243
+ }
@@ -0,0 +1,2 @@
1
+ export const STAGE_ATTRIBUTE_NAME = 'strapi_stage';
2
+ export const ASSIGNEE_ATTRIBUTE_NAME = 'strapi_assignee';
@@ -0,0 +1,7 @@
1
+ export const REVIEW_WORKFLOW_STAGE_SORT_OPTION_NAME = {
2
+ value: 'strapi_stage[name]',
3
+ label: {
4
+ id: 'settings.defaultSortOrder.reviewWorkflows.label',
5
+ defaultMessage: 'Review Stage',
6
+ },
7
+ };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+
3
+ import { Typography } from '@strapi/design-system';
4
+ import PropTypes from 'prop-types';
5
+ import { useIntl } from 'react-intl';
6
+
7
+ import { getDisplayName } from '../../../../../../admin/src/content-manager/utils';
8
+
9
+ export function ReviewWorkflowsAssigneeEE({ user }) {
10
+ const { formatMessage } = useIntl();
11
+
12
+ return <Typography textColor="neutral800">{getDisplayName(user, formatMessage)}</Typography>;
13
+ }
14
+
15
+ ReviewWorkflowsAssigneeEE.propTypes = {
16
+ user: PropTypes.shape({
17
+ firstname: PropTypes.string,
18
+ lastname: PropTypes.string,
19
+ username: PropTypes.string,
20
+ }).isRequired,
21
+ };
@@ -1,24 +1,51 @@
1
1
  import getTrad from '../../../../../../admin/src/content-manager/utils/getTrad';
2
+ import {
3
+ ASSIGNEE_ATTRIBUTE_NAME,
4
+ STAGE_ATTRIBUTE_NAME,
5
+ } from '../../EditView/InformationBox/constants';
2
6
 
3
- export const REVIEW_WORKFLOW_COLUMNS_EE = {
4
- key: '__strapi_stage_temp_key__',
5
- name: 'strapi_stage',
6
- fieldSchema: {
7
- type: 'relation',
7
+ export const REVIEW_WORKFLOW_COLUMNS_EE = [
8
+ {
9
+ key: `__${STAGE_ATTRIBUTE_NAME}_temp_key__`,
10
+ name: STAGE_ATTRIBUTE_NAME,
11
+ fieldSchema: {
12
+ type: 'relation',
13
+ },
14
+ metadatas: {
15
+ // formatMessage() will be applied when the column is rendered
16
+ label: {
17
+ id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
18
+ defaultMessage: 'Review stage',
19
+ },
20
+ searchable: false,
21
+ sortable: true,
22
+ mainField: {
23
+ name: 'name',
24
+ schema: {
25
+ type: 'string',
26
+ },
27
+ },
28
+ },
8
29
  },
9
- metadatas: {
10
- // formatMessage() will be applied when the column is rendered
11
- label: {
12
- id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
13
- defaultMessage: 'Review stage',
30
+ {
31
+ key: `__${ASSIGNEE_ATTRIBUTE_NAME}_temp_key__`,
32
+ name: ASSIGNEE_ATTRIBUTE_NAME,
33
+ fieldSchema: {
34
+ type: 'relation',
14
35
  },
15
- searchable: false,
16
- sortable: true,
17
- mainField: {
18
- name: 'name',
19
- schema: {
20
- type: 'string',
36
+ metadatas: {
37
+ label: {
38
+ id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.assignee`),
39
+ defaultMessage: 'Assignee',
40
+ },
41
+ searchable: false,
42
+ sortable: true,
43
+ mainField: {
44
+ name: 'firstname',
45
+ schema: {
46
+ type: 'string',
47
+ },
21
48
  },
22
49
  },
23
50
  },
24
- };
51
+ ];
@@ -1 +1,2 @@
1
1
  export * from './ReviewWorkflowsStageEE';
2
+ export * from './ReviewWorkflowsAssigneeEE';
@@ -1,10 +1,9 @@
1
- import * as React from 'react';
1
+ import { AuthResponse } from '../AuthResponse';
2
2
 
3
- export const AUTH_ROUTES_EE = [
3
+ export const ROUTES_EE = [
4
4
  {
5
- component: React.lazy(() =>
6
- import('../AuthResponse').then((module) => ({ default: module.AuthResponse }))
7
- ),
8
- path: '/auth/login/:authResponse',
5
+ Component: () => ({ default: AuthResponse }),
6
+ to: '/auth/login/:authResponse',
7
+ exact: true,
9
8
  },
10
9
  ];
@@ -1,15 +1,16 @@
1
- import * as React from 'react';
2
-
3
- export const SETTINGS_ROUTES_EE = [
1
+ export const ROUTES_EE = [
4
2
  ...(window.strapi.features.isEnabled(window.strapi.features.AUDIT_LOGS)
5
3
  ? [
6
4
  {
7
- component: React.lazy(() =>
8
- import(
5
+ async Component() {
6
+ const component = await import(
9
7
  /* webpackChunkName: "audit-logs-settings-page" */ './pages/AuditLogs/ProtectedListPage'
10
- )
11
- ),
12
- path: '/settings/audit-logs',
8
+ );
9
+
10
+ return component;
11
+ },
12
+ to: '/settings/audit-logs',
13
+ exact: true,
13
14
  },
14
15
  ]
15
16
  : []),
@@ -17,30 +18,39 @@ export const SETTINGS_ROUTES_EE = [
17
18
  ...(window.strapi.features.isEnabled(window.strapi.features.REVIEW_WORKFLOWS)
18
19
  ? [
19
20
  {
20
- component: React.lazy(() =>
21
- import(
21
+ async Component() {
22
+ const component = await import(
22
23
  /* webpackChunkName: "review-workflows-settings-list-view" */ './pages/ReviewWorkflows/pages/ListView'
23
- )
24
- ),
25
- path: '/settings/review-workflows',
24
+ );
25
+
26
+ return component;
27
+ },
28
+ to: '/settings/review-workflows',
29
+ exact: true,
26
30
  },
27
31
 
28
32
  {
29
- component: React.lazy(() =>
30
- import(
33
+ async Component() {
34
+ const component = await import(
31
35
  /* webpackChunkName: "review-workflows-settings-create-view" */ './pages/ReviewWorkflows/pages/CreateView'
32
- )
33
- ),
34
- path: '/settings/review-workflows/create',
36
+ );
37
+
38
+ return component;
39
+ },
40
+ to: '/settings/review-workflows/create',
41
+ exact: true,
35
42
  },
36
43
 
37
44
  {
38
- component: React.lazy(() =>
39
- import(
45
+ async Component() {
46
+ const component = await import(
40
47
  /* webpackChunkName: "review-workflows-settings-edit-view" */ './pages/ReviewWorkflows/pages/EditView'
41
- )
42
- ),
43
- path: '/settings/review-workflows/:workflowId',
48
+ );
49
+
50
+ return component;
51
+ },
52
+ to: '/settings/review-workflows/:workflowId',
53
+ exact: true,
44
54
  },
45
55
  ]
46
56
  : []),
@@ -48,10 +58,15 @@ export const SETTINGS_ROUTES_EE = [
48
58
  ...(window.strapi.features.isEnabled(window.strapi.features.SSO)
49
59
  ? [
50
60
  {
51
- component: React.lazy(() =>
52
- import(/* webpackChunkName: "sso-settings-page" */ './pages/SingleSignOn')
53
- ),
54
- path: '/settings/single-sign-on',
61
+ async Component() {
62
+ const component = await import(
63
+ /* webpackChunkName: "sso-settings-page" */ './pages/SingleSignOn'
64
+ );
65
+
66
+ return component;
67
+ },
68
+ to: '/settings/single-sign-on',
69
+ exact: true,
55
70
  },
56
71
  ]
57
72
  : []),
@@ -6,6 +6,7 @@ module.exports = {
6
6
  STAGE_MODEL_UID: 'admin::workflow-stage',
7
7
  STAGE_DEFAULT_COLOR: '#4945FF',
8
8
  ENTITY_STAGE_ATTRIBUTE: 'strapi_stage',
9
+ ENTITY_ASSIGNEE_ATTRIBUTE: 'strapi_assignee',
9
10
  MAX_WORKFLOWS: 200,
10
11
  MAX_STAGES_PER_WORKFLOW: 200,
11
12
  ERRORS: {
@@ -8,4 +8,5 @@ module.exports = {
8
8
  admin: require('./admin'),
9
9
  workflows: require('./workflows'),
10
10
  stages: require('./workflows/stages'),
11
+ assignees: require('./workflows/assignees'),
11
12
  };
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ const { getService } = require('../../../utils');
4
+ const { validateUpdateAssigneeOnEntity } = require('../../../validation/review-workflows');
5
+
6
+ module.exports = {
7
+ /**
8
+ * Updates an entity's assignee.
9
+ * @async
10
+ * @param {Object} ctx - The Koa context object.
11
+ * @param {Object} ctx.params - An object containing the parameters from the request URL.
12
+ * @param {string} ctx.params.model_uid - The model UID of the entity.
13
+ * @param {string} ctx.params.id - The ID of the entity to update.
14
+ * @param {Object} ctx.request.body.data - Optional data object containing the new assignee ID for the entity.
15
+ * @param {string} ctx.request.body.data.id - The ID of the new assignee for the entity.
16
+ * @throws {ApplicationError} If review workflows is not activated on the specified model UID.
17
+ * @throws {ValidationError} If the `data` object in the request body fails to pass validation.
18
+ * @returns {Promise<void>} A promise that resolves when the entity's assignee has been updated.
19
+ */
20
+ async updateEntity(ctx) {
21
+ const assigneeService = getService('assignees');
22
+ const workflowService = getService('workflows');
23
+
24
+ const { model_uid: model, id } = ctx.params;
25
+
26
+ const { sanitizeOutput } = strapi
27
+ .plugin('content-manager')
28
+ .service('permission-checker')
29
+ .create({ userAbility: ctx.state.userAbility, model });
30
+
31
+ // TODO: check if user has update permission on the entity
32
+
33
+ const { id: assigneeId } = await validateUpdateAssigneeOnEntity(
34
+ ctx.request?.body?.data,
35
+ 'You should pass a valid id to the body of the put request.'
36
+ );
37
+
38
+ await workflowService.assertContentTypeBelongsToWorkflow(model);
39
+
40
+ const entity = await assigneeService.updateEntityAssignee(id, model, assigneeId);
41
+
42
+ ctx.body = { data: await sanitizeOutput(entity) };
43
+ },
44
+ };
@@ -142,5 +142,22 @@ module.exports = {
142
142
  ],
143
143
  },
144
144
  },
145
+ {
146
+ method: 'PUT',
147
+ path: '/content-manager/(collection|single)-types/:model_uid/:id/assignee',
148
+ handler: 'assignees.updateEntity',
149
+ config: {
150
+ middlewares: [enableFeatureMiddleware('review-workflows')],
151
+ policies: [
152
+ 'admin::isAuthenticatedAdmin',
153
+ {
154
+ name: 'admin::hasPermissions',
155
+ config: {
156
+ actions: ['admin::users.read', 'admin::review-workflows.read'],
157
+ },
158
+ },
159
+ ],
160
+ },
161
+ },
145
162
  ],
146
163
  };
@@ -8,6 +8,7 @@ module.exports = {
8
8
  'seat-enforcement': require('./seat-enforcement'),
9
9
  workflows: require('./review-workflows/workflows'),
10
10
  stages: require('./review-workflows/stages'),
11
+ assignees: require('./review-workflows/assignees'),
11
12
  'review-workflows': require('./review-workflows/review-workflows'),
12
13
  'review-workflows-validation': require('./review-workflows/validation'),
13
14
  'review-workflows-decorator': require('./review-workflows/entity-service-decorator'),
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const { ApplicationError } = require('@strapi/utils').errors;
4
+ const { isNil } = require('lodash/fp');
5
+ const { ENTITY_ASSIGNEE_ATTRIBUTE } = require('../../constants/workflows');
6
+ const { getService } = require('../../utils');
7
+
8
+ module.exports = ({ strapi }) => {
9
+ const metrics = getService('review-workflows-metrics', { strapi });
10
+
11
+ return {
12
+ async findEntityAssigneeId(id, model) {
13
+ const entity = await strapi.entityService.findOne(model, id, {
14
+ populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
15
+ fields: [],
16
+ });
17
+
18
+ return entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;
19
+ },
20
+
21
+ /**
22
+ * Update the assignee of an entity
23
+ */
24
+ async updateEntityAssignee(id, model, assigneeId) {
25
+ if (isNil(assigneeId)) {
26
+ return this.deleteEntityAssignee(id, model);
27
+ }
28
+
29
+ const userExists = await getService('user', { strapi }).exists({ id: assigneeId });
30
+
31
+ if (!userExists) {
32
+ throw new ApplicationError(`Selected user does not exist`);
33
+ }
34
+
35
+ metrics.sendDidEditAssignee(await this.findEntityAssigneeId(id, model), assigneeId);
36
+
37
+ return strapi.entityService.update(model, id, {
38
+ data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId },
39
+ populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
40
+ fields: [],
41
+ });
42
+ },
43
+
44
+ async deleteEntityAssignee(id, model) {
45
+ metrics.sendDidEditAssignee(await this.findEntityAssigneeId(id, model), null);
46
+
47
+ return strapi.entityService.update(model, id, {
48
+ data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: null },
49
+ populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
50
+ fields: [],
51
+ });
52
+ },
53
+ };
54
+ };
@@ -24,6 +24,10 @@ const sendDidEditWorkflow = async () => {
24
24
  strapi.telemetry.send('didEditWorkflow', {});
25
25
  };
26
26
 
27
+ const sendDidEditAssignee = async (fromId, toId) => {
28
+ strapi.telemetry.send('didEditAssignee', { from: fromId, to: toId });
29
+ };
30
+
27
31
  const sendDidSendReviewWorkflowPropertiesOnceAWeek = async (
28
32
  numberOfActiveWorkflows,
29
33
  avgStagesCount,
@@ -48,4 +52,5 @@ module.exports = {
48
52
  sendDidCreateWorkflow,
49
53
  sendDidEditWorkflow,
50
54
  sendDidSendReviewWorkflowPropertiesOnceAWeek,
55
+ sendDidEditAssignee,
51
56
  };