@strapi/admin 4.6.1 → 4.9.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 (196) hide show
  1. package/admin/src/assets/images/onboarding-preview.png +0 -0
  2. package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +4 -14
  3. package/admin/src/content-manager/components/DynamicTable/CellContent/RelationMultiple/index.js +1 -1
  4. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +2 -0
  5. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +39 -9
  6. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +9 -15
  7. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +4 -12
  8. package/admin/src/content-manager/pages/EditView/DeleteLink/index.js +6 -8
  9. package/admin/src/content-manager/pages/ListView/index.js +6 -11
  10. package/admin/src/index.js +1 -0
  11. package/admin/src/pages/Admin/Onboarding/constants.js +46 -0
  12. package/admin/src/pages/Admin/Onboarding/index.js +161 -89
  13. package/admin/src/pages/Admin/index.js +5 -2
  14. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +15 -2
  15. package/admin/src/pages/SettingsPage/pages/Users/components/MagicLink/MagicLinkWrapper.js +3 -20
  16. package/admin/src/permissions/defaultPermissions.js +2 -15
  17. package/admin/src/translations/ar.json +4 -4
  18. package/admin/src/translations/ca.json +4 -4
  19. package/admin/src/translations/cs.json +4 -4
  20. package/admin/src/translations/de.json +4 -4
  21. package/admin/src/translations/dk.json +4 -4
  22. package/admin/src/translations/en.json +14 -5
  23. package/admin/src/translations/es.json +4 -4
  24. package/admin/src/translations/eu.json +4 -4
  25. package/admin/src/translations/fr.json +4 -4
  26. package/admin/src/translations/gu.json +4 -4
  27. package/admin/src/translations/he.json +4 -4
  28. package/admin/src/translations/hi.json +4 -4
  29. package/admin/src/translations/hu.json +4 -4
  30. package/admin/src/translations/id.json +4 -4
  31. package/admin/src/translations/it.json +4 -4
  32. package/admin/src/translations/ja.json +4 -4
  33. package/admin/src/translations/ko.json +4 -4
  34. package/admin/src/translations/ml.json +4 -4
  35. package/admin/src/translations/ms.json +4 -4
  36. package/admin/src/translations/nl.json +4 -4
  37. package/admin/src/translations/no.json +4 -4
  38. package/admin/src/translations/pl.json +4 -4
  39. package/admin/src/translations/pt-BR.json +4 -4
  40. package/admin/src/translations/pt.json +4 -4
  41. package/admin/src/translations/ru.json +785 -789
  42. package/admin/src/translations/sa.json +4 -4
  43. package/admin/src/translations/sk.json +4 -4
  44. package/admin/src/translations/sv.json +4 -4
  45. package/admin/src/translations/th.json +4 -4
  46. package/admin/src/translations/tr.json +4 -4
  47. package/admin/src/translations/uk.json +4 -4
  48. package/admin/src/translations/vi.json +4 -4
  49. package/admin/src/translations/zh-Hans.json +4 -4
  50. package/admin/src/translations/zh.json +4 -4
  51. package/build/1683.d59d0f23.chunk.js +268 -0
  52. package/build/19eb2dfcf2603eb55733.png +0 -0
  53. package/build/{4855.bd092921.chunk.js → 2223.1bfea951.chunk.js} +88 -88
  54. package/build/2743.646a1015.chunk.js +45 -0
  55. package/build/3075.3ee481f1.chunk.js +108 -0
  56. package/build/3632.2e378cf8.chunk.js +138 -0
  57. package/build/{4318.f96a9d4d.chunk.js → 4318.cd55ce02.chunk.js} +1 -1
  58. package/build/9707.b36ed71e.chunk.js +96 -0
  59. package/build/Admin-authenticatedApp.a73577e1.chunk.js +79 -0
  60. package/build/{Admin_InternalErrorPage.157152a8.chunk.js → Admin_InternalErrorPage.178ddb90.chunk.js} +1 -1
  61. package/build/{Admin_homePage.b1730882.chunk.js → Admin_homePage.c2f5f27d.chunk.js} +2 -2
  62. package/build/{Admin_marketplace.ea0316c2.chunk.js → Admin_marketplace.1df49c42.chunk.js} +1 -1
  63. package/build/{Admin_pluginsPage.5c24f963.chunk.js → Admin_pluginsPage.8d824408.chunk.js} +2 -2
  64. package/build/{Admin_profilePage.59af1978.chunk.js → Admin_profilePage.cb667bc5.chunk.js} +2 -2
  65. package/build/Admin_settingsPage.f90615fb.chunk.js +178 -0
  66. package/build/{Upload_ConfigureTheView.3f2b6e6a.chunk.js → Upload_ConfigureTheView.d306009d.chunk.js} +1 -1
  67. package/build/admin-app.06f07029.chunk.js +112 -0
  68. package/build/admin-edit-roles-page.35199b9d.chunk.js +1 -0
  69. package/build/admin-edit-users.9e48b00d.chunk.js +10 -0
  70. package/build/admin-users.cf7b4151.chunk.js +11 -0
  71. package/build/{api-tokens-create-page.d248362d.chunk.js → api-tokens-create-page.a31c7fba.chunk.js} +1 -1
  72. package/build/{api-tokens-edit-page.8516fa20.chunk.js → api-tokens-edit-page.64fef287.chunk.js} +1 -1
  73. package/build/{api-tokens-list-page.44a79fda.chunk.js → api-tokens-list-page.e600ad3e.chunk.js} +2 -2
  74. package/build/ar-json.39e54aba.chunk.js +1 -0
  75. package/build/{audit-logs-settings-page.c3dce30d.chunk.js → audit-logs-settings-page.d4da4579.chunk.js} +1 -1
  76. package/build/{ca-json.f6a0f472.chunk.js → ca-json.4d999055.chunk.js} +1 -1
  77. package/build/content-manager.255c3a59.chunk.js +1139 -0
  78. package/build/{content-type-builder-list-view.79e84b36.chunk.js → content-type-builder-list-view.8d7a3d68.chunk.js} +5 -5
  79. package/build/content-type-builder.3c8558a5.chunk.js +126 -0
  80. package/build/cs-json.4b44411c.chunk.js +1 -0
  81. package/build/{de-json.30e1f35b.chunk.js → de-json.866f8a28.chunk.js} +1 -1
  82. package/build/{dk-json.e6d9ffa4.chunk.js → dk-json.10f7b1d1.chunk.js} +1 -1
  83. package/build/email-settings-page.b19f2eb2.chunk.js +10 -0
  84. package/build/en-json.1997583c.chunk.js +1 -0
  85. package/build/es-json.ea15c957.chunk.js +1 -0
  86. package/build/{eu-json.fceecd8b.chunk.js → eu-json.3bc24d60.chunk.js} +1 -1
  87. package/build/{fr-json.78545ef8.chunk.js → fr-json.e88fbdfd.chunk.js} +1 -1
  88. package/build/{gu-json.676518f2.chunk.js → gu-json.94f0d242.chunk.js} +1 -1
  89. package/build/{he-json.ad22e8cc.chunk.js → he-json.f0de8cdb.chunk.js} +1 -1
  90. package/build/{hi-json.19b51c09.chunk.js → hi-json.df3a7be2.chunk.js} +1 -1
  91. package/build/{hu-json.f947088f.chunk.js → hu-json.680e6eef.chunk.js} +1 -1
  92. package/build/{i18n-settings-page.b8d8753e.chunk.js → i18n-settings-page.a6b49eac.chunk.js} +1 -1
  93. package/build/{id-json.504daa84.chunk.js → id-json.e0d83d41.chunk.js} +1 -1
  94. package/build/index.html +1 -1
  95. package/build/{it-json.2fd90f4d.chunk.js → it-json.8be59205.chunk.js} +1 -1
  96. package/build/{ja-json.c9f12d0b.chunk.js → ja-json.97ee41ba.chunk.js} +1 -1
  97. package/build/{ko-json.ef463065.chunk.js → ko-json.4cbbf4f2.chunk.js} +1 -1
  98. package/build/main.7f308c20.js +4322 -0
  99. package/build/{ml-json.490f666c.chunk.js → ml-json.e3747091.chunk.js} +1 -1
  100. package/build/ms-json.0eddffd9.chunk.js +1 -0
  101. package/build/{nl-json.c416295a.chunk.js → nl-json.371a15ee.chunk.js} +1 -1
  102. package/build/{no-json.1a2258ba.chunk.js → no-json.9b3cd181.chunk.js} +1 -1
  103. package/build/{pl-json.8cf0c871.chunk.js → pl-json.e535cbce.chunk.js} +1 -1
  104. package/build/{pt-BR-json.51fab8d0.chunk.js → pt-BR-json.e5fafa46.chunk.js} +1 -1
  105. package/build/pt-json.ee554a41.chunk.js +1 -0
  106. package/build/review-workflows-settings.7b4be1b0.chunk.js +63 -0
  107. package/build/{ru-json.aa5cd123.chunk.js → ru-json.866f0ff1.chunk.js} +1 -1
  108. package/build/runtime~main.bf374148.js +2 -0
  109. package/build/{sa-json.f3fa5407.chunk.js → sa-json.7efeb257.chunk.js} +1 -1
  110. package/build/{sk-json.9ec60d9f.chunk.js → sk-json.7bbeb0af.chunk.js} +1 -1
  111. package/build/{sso-settings-page.b85ad080.chunk.js → sso-settings-page.ad2143dd.chunk.js} +1 -1
  112. package/build/{sv-json.c6b0c237.chunk.js → sv-json.dc40951f.chunk.js} +1 -1
  113. package/build/{th-json.6e68155c.chunk.js → th-json.f664b96d.chunk.js} +1 -1
  114. package/build/{tr-json.9f41dc08.chunk.js → tr-json.b79eae31.chunk.js} +1 -1
  115. package/build/uk-json.b7e38370.chunk.js +1 -0
  116. package/build/upload-settings.eb1a7908.chunk.js +84 -0
  117. package/build/upload.700e2c84.chunk.js +33 -0
  118. package/build/{users-advanced-settings-page.fce9908e.chunk.js → users-advanced-settings-page.aae212f2.chunk.js} +1 -1
  119. package/build/{users-email-settings-page.343d0ad2.chunk.js → users-email-settings-page.8a9b0da1.chunk.js} +1 -1
  120. package/build/{users-providers-settings-page.e5a9a3f1.chunk.js → users-providers-settings-page.e6be909d.chunk.js} +10 -10
  121. package/build/{users-roles-settings-page.66312f31.chunk.js → users-roles-settings-page.97d06a80.chunk.js} +3 -3
  122. package/build/vi-json.ee4c5537.chunk.js +1 -0
  123. package/build/webhook-edit-page.9eb0f789.chunk.js +75 -0
  124. package/build/webhook-list-page.66082323.chunk.js +42 -0
  125. package/build/{zh-Hans-json.9c0eac99.chunk.js → zh-Hans-json.30a18940.chunk.js} +1 -1
  126. package/build/{zh-json.f88f563d.chunk.js → zh-json.49d84433.chunk.js} +1 -1
  127. package/ee/admin/hooks/useSettingsMenu/utils/customAdminLinks.js +12 -12
  128. package/ee/admin/hooks/useSettingsMenu/utils/customGlobalLinks.js +21 -13
  129. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +137 -0
  130. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/actions/index.js +42 -0
  131. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/AddStage.js +87 -0
  132. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/index.js +1 -0
  133. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/Stage.js +90 -0
  134. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/index.js +1 -0
  135. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stages.js +77 -0
  136. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/index.js +1 -0
  137. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/constants.js +6 -0
  138. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +63 -0
  139. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/index.js +3 -0
  140. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/reducer/index.js +102 -0
  141. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/utils/getWorkflowValidationSchema.js +25 -0
  142. package/ee/admin/pages/SettingsPage/utils/customRoutes.js +16 -2
  143. package/ee/admin/permissions/customPermissions.js +7 -0
  144. package/ee/server/bootstrap.js +7 -1
  145. package/ee/server/config/admin-actions.js +10 -0
  146. package/ee/server/constants/default-stages.json +14 -0
  147. package/ee/server/constants/default-workflow.json +1 -0
  148. package/ee/server/constants/workflows.js +7 -0
  149. package/ee/server/content-types/index.js +9 -0
  150. package/ee/server/content-types/workflow/index.js +34 -0
  151. package/ee/server/content-types/workflow-stage/index.js +36 -0
  152. package/ee/server/controllers/index.js +2 -0
  153. package/ee/server/controllers/workflows/index.js +36 -0
  154. package/ee/server/controllers/workflows/stages/index.js +57 -0
  155. package/ee/server/index.js +1 -0
  156. package/ee/server/routes/index.js +87 -0
  157. package/ee/server/services/index.js +3 -0
  158. package/ee/server/services/review-workflows/review-workflows.js +54 -0
  159. package/ee/server/services/review-workflows/stages.js +133 -0
  160. package/ee/server/services/review-workflows/workflows.js +25 -0
  161. package/ee/server/utils/index.js +8 -0
  162. package/ee/server/utils/test.js +11 -0
  163. package/ee/server/validation/review-workflows.js +17 -0
  164. package/package.json +15 -15
  165. package/server/config/admin-actions.js +0 -16
  166. package/server/controllers/admin.js +0 -55
  167. package/server/routes/admin.js +0 -28
  168. package/webpack.config.js +0 -3
  169. package/build/1683.c8aa7b7c.chunk.js +0 -268
  170. package/build/2743.6d1632f9.chunk.js +0 -45
  171. package/build/3075.dc3894fe.chunk.js +0 -108
  172. package/build/3632.0317b618.chunk.js +0 -138
  173. package/build/9707.7290fd92.chunk.js +0 -96
  174. package/build/Admin-authenticatedApp.ce646f66.chunk.js +0 -75
  175. package/build/Admin_settingsPage.d1493824.chunk.js +0 -178
  176. package/build/admin-app.25934eaa.chunk.js +0 -112
  177. package/build/admin-edit-roles-page.446b69dc.chunk.js +0 -1
  178. package/build/admin-edit-users.2ed69bfd.chunk.js +0 -10
  179. package/build/admin-users.fc003b10.chunk.js +0 -11
  180. package/build/ar-json.932794f7.chunk.js +0 -1
  181. package/build/content-manager.35ff9726.chunk.js +0 -1139
  182. package/build/content-type-builder.855db321.chunk.js +0 -126
  183. package/build/cs-json.79879fb6.chunk.js +0 -1
  184. package/build/email-settings-page.d1fcc7a3.chunk.js +0 -10
  185. package/build/en-json.1f137a90.chunk.js +0 -1
  186. package/build/es-json.e275481d.chunk.js +0 -1
  187. package/build/main.7b151630.js +0 -4377
  188. package/build/ms-json.db87d8d3.chunk.js +0 -1
  189. package/build/pt-json.62927d1e.chunk.js +0 -1
  190. package/build/runtime~main.a20d633b.js +0 -2
  191. package/build/uk-json.b2fcd567.chunk.js +0 -1
  192. package/build/upload-settings.ef64bbf9.chunk.js +0 -84
  193. package/build/upload.c5730dfa.chunk.js +0 -33
  194. package/build/vi-json.f08d7d03.chunk.js +0 -1
  195. package/build/webhook-edit-page.73e51e64.chunk.js +0 -75
  196. package/build/webhook-list-page.1134f130.chunk.js +0 -42
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ schema: {
5
+ collectionName: 'strapi_workflows_stages',
6
+ info: {
7
+ name: 'Workflow Stage',
8
+ description: '',
9
+ singularName: 'workflow-stage',
10
+ pluralName: 'workflow-stages',
11
+ displayName: 'Stages',
12
+ },
13
+ options: {},
14
+ pluginOptions: {
15
+ 'content-manager': {
16
+ visible: false,
17
+ },
18
+ 'content-type-builder': {
19
+ visible: false,
20
+ },
21
+ },
22
+ attributes: {
23
+ name: {
24
+ type: 'string',
25
+ configurable: false,
26
+ },
27
+ workflow: {
28
+ type: 'relation',
29
+ target: 'admin::workflow',
30
+ relation: 'manyToOne',
31
+ inversedBy: 'stages',
32
+ configurable: false,
33
+ },
34
+ },
35
+ },
36
+ };
@@ -6,4 +6,6 @@ module.exports = {
6
6
  role: require('./role'),
7
7
  user: require('./user'),
8
8
  auditLogs: require('./audit-logs'),
9
+ workflows: require('./workflows'),
10
+ stages: require('./workflows/stages'),
9
11
  };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const { getService } = require('../../utils');
4
+
5
+ module.exports = {
6
+ /**
7
+ * List all workflows
8
+ * @param {import('koa').BaseContext} ctx - koa context
9
+ */
10
+ async find(ctx) {
11
+ const { populate } = ctx.query;
12
+ const workflowService = getService('workflows');
13
+ const data = await workflowService.find({
14
+ populate,
15
+ });
16
+
17
+ ctx.body = {
18
+ data,
19
+ };
20
+ },
21
+ /**
22
+ * Get one workflow based on its id contained in request parameters
23
+ * @param {import('koa').BaseContext} ctx - koa context
24
+ */
25
+ async findById(ctx) {
26
+ const { id } = ctx.params;
27
+ const { populate } = ctx.query;
28
+
29
+ const workflowService = getService('workflows');
30
+ const data = await workflowService.findById(id, { populate });
31
+
32
+ ctx.body = {
33
+ data,
34
+ };
35
+ },
36
+ };
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ const { getService } = require('../../../utils');
4
+ const { validateUpdateStages } = require('../../../validation/review-workflows');
5
+
6
+ module.exports = {
7
+ /**
8
+ * List all stages
9
+ * @param {import('koa').BaseContext} ctx - koa context
10
+ */
11
+ async find(ctx) {
12
+ const { workflow_id: workflowId } = ctx.params;
13
+ const { populate } = ctx.query;
14
+ const stagesService = getService('stages');
15
+
16
+ const data = await stagesService.find({
17
+ workflowId,
18
+ populate,
19
+ });
20
+
21
+ ctx.body = {
22
+ data,
23
+ };
24
+ },
25
+ /**
26
+ * Get one stage
27
+ * @param {import('koa').BaseContext} ctx - koa context
28
+ */
29
+ async findById(ctx) {
30
+ const { id, workflow_id: workflowId } = ctx.params;
31
+ const { populate } = ctx.query;
32
+ const stagesService = getService('stages');
33
+
34
+ const data = await stagesService.findById(id, {
35
+ workflowId,
36
+ populate,
37
+ });
38
+
39
+ ctx.body = {
40
+ data,
41
+ };
42
+ },
43
+
44
+ async replace(ctx) {
45
+ const { workflow_id: workflowId } = ctx.params;
46
+ const stagesService = getService('stages');
47
+ const {
48
+ body: { data: stages },
49
+ } = ctx.request;
50
+
51
+ const stagesValidated = await validateUpdateStages(stages);
52
+
53
+ const data = await stagesService.replaceWorkflowStages(workflowId, stagesValidated);
54
+
55
+ ctx.body = { data };
56
+ },
57
+ };
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports = {
4
4
  register: require('./register'),
5
+ contentTypes: require('./content-types'),
5
6
  bootstrap: require('./bootstrap'),
6
7
  destroy: require('./destroy'),
7
8
  routes: require('./routes'),
@@ -148,4 +148,91 @@ module.exports = [
148
148
  ],
149
149
  },
150
150
  },
151
+
152
+ // Review workflow
153
+ {
154
+ method: 'GET',
155
+ path: '/review-workflows/workflows',
156
+ handler: 'workflows.find',
157
+ config: {
158
+ middlewares: [enableFeatureMiddleware('review-workflows')],
159
+ policies: [
160
+ 'admin::isAuthenticatedAdmin',
161
+ {
162
+ name: 'admin::hasPermissions',
163
+ config: {
164
+ actions: ['admin::review-workflows.read'],
165
+ },
166
+ },
167
+ ],
168
+ },
169
+ },
170
+ {
171
+ method: 'GET',
172
+ path: '/review-workflows/workflows/:id',
173
+ handler: 'workflows.findById',
174
+ config: {
175
+ middlewares: [enableFeatureMiddleware('review-workflows')],
176
+ policies: [
177
+ 'admin::isAuthenticatedAdmin',
178
+ {
179
+ name: 'admin::hasPermissions',
180
+ config: {
181
+ actions: ['admin::review-workflows.read'],
182
+ },
183
+ },
184
+ ],
185
+ },
186
+ },
187
+ {
188
+ method: 'GET',
189
+ path: '/review-workflows/workflows/:workflow_id/stages',
190
+ handler: 'stages.find',
191
+ config: {
192
+ middlewares: [enableFeatureMiddleware('review-workflows')],
193
+ policies: [
194
+ 'admin::isAuthenticatedAdmin',
195
+ {
196
+ name: 'admin::hasPermissions',
197
+ config: {
198
+ actions: ['admin::review-workflows.read'],
199
+ },
200
+ },
201
+ ],
202
+ },
203
+ },
204
+ {
205
+ method: 'PUT',
206
+ path: '/review-workflows/workflows/:workflow_id/stages',
207
+ handler: 'stages.replace',
208
+ config: {
209
+ middlewares: [enableFeatureMiddleware('review-workflows')],
210
+ policies: [
211
+ 'admin::isAuthenticatedAdmin',
212
+ {
213
+ name: 'admin::hasPermissions',
214
+ config: {
215
+ actions: ['admin::review-workflows.read'],
216
+ },
217
+ },
218
+ ],
219
+ },
220
+ },
221
+ {
222
+ method: 'GET',
223
+ path: '/review-workflows/workflows/:workflow_id/stages/:id',
224
+ handler: 'stages.findById',
225
+ config: {
226
+ middlewares: [enableFeatureMiddleware('review-workflows')],
227
+ policies: [
228
+ 'admin::isAuthenticatedAdmin',
229
+ {
230
+ name: 'admin::hasPermissions',
231
+ config: {
232
+ actions: ['admin::review-workflows.read'],
233
+ },
234
+ },
235
+ ],
236
+ },
237
+ },
151
238
  ];
@@ -3,4 +3,7 @@
3
3
  module.exports = {
4
4
  passport: require('./passport'),
5
5
  role: require('./role'),
6
+ workflows: require('./review-workflows/workflows'),
7
+ stages: require('./review-workflows/stages'),
8
+ 'review-workflows': require('./review-workflows/review-workflows'),
6
9
  };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const { getService } = require('../../utils');
4
+
5
+ /**
6
+ * Map every stage in the array to be ordered in the relation
7
+ * @param {Object[]} stages
8
+ * @param {number} stages.id
9
+ * @return {Object[]}
10
+ */
11
+ function buildStagesConnectArray(stages) {
12
+ return stages.map((stage, index) => {
13
+ const connect = {
14
+ id: stage.id,
15
+ position: {},
16
+ };
17
+
18
+ if (index === 0) {
19
+ connect.position.start = true;
20
+ } else {
21
+ connect.position.after = stages[index - 1].id;
22
+ }
23
+ return connect;
24
+ });
25
+ }
26
+
27
+ module.exports = ({ strapi }) => {
28
+ const workflowsService = getService('workflows', { strapi });
29
+ const stagesService = getService('stages', { strapi });
30
+
31
+ return {
32
+ async bootstrap() {
33
+ const wfCount = await workflowsService.count();
34
+ const stagesCount = await stagesService.count();
35
+
36
+ // Check if there is nothing about review-workflow in DB
37
+ // If any, the feature has already been initialized with a workflow and stages
38
+ if (wfCount === 0 && stagesCount === 0) {
39
+ const defaultStages = require('../../constants/default-stages.json');
40
+ const defaultWorkflow = require('../../constants/default-workflow.json');
41
+
42
+ const stages = await stagesService.createMany(defaultStages, { fields: ['id'] });
43
+ const workflow = {
44
+ ...defaultWorkflow,
45
+ stages: {
46
+ connect: buildStagesConnectArray(stages),
47
+ },
48
+ };
49
+
50
+ await workflowsService.create(workflow);
51
+ }
52
+ },
53
+ };
54
+ };
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ mapAsync,
5
+ errors: { ApplicationError },
6
+ } = require('@strapi/utils');
7
+
8
+ const { STAGE_MODEL_UID } = require('../../constants/workflows');
9
+ const { getService } = require('../../utils');
10
+
11
+ module.exports = ({ strapi }) => {
12
+ const workflowsService = getService('workflows', { strapi });
13
+
14
+ return {
15
+ find({ workflowId, populate }) {
16
+ const params = {
17
+ filters: { workflow: workflowId },
18
+ populate,
19
+ };
20
+ return strapi.entityService.findMany(STAGE_MODEL_UID, params);
21
+ },
22
+
23
+ findById(id, { workflowId, populate }) {
24
+ const params = {
25
+ filters: { workflow: workflowId },
26
+ populate,
27
+ };
28
+ return strapi.entityService.findOne(STAGE_MODEL_UID, id, params);
29
+ },
30
+
31
+ createMany(stagesList, { fields }) {
32
+ const params = {
33
+ select: fields,
34
+ };
35
+ return Promise.all(
36
+ stagesList.map((stage) =>
37
+ strapi.entityService.create(STAGE_MODEL_UID, { data: stage, ...params })
38
+ )
39
+ );
40
+ },
41
+
42
+ update(stageId, stageData) {
43
+ return strapi.entityService.update(STAGE_MODEL_UID, stageId, { data: stageData });
44
+ },
45
+
46
+ delete(stageId) {
47
+ return strapi.entityService.delete(STAGE_MODEL_UID, stageId);
48
+ },
49
+
50
+ count() {
51
+ return strapi.entityService.count(STAGE_MODEL_UID);
52
+ },
53
+
54
+ async replaceWorkflowStages(workflowId, stages) {
55
+ const workflow = await workflowsService.findById(workflowId, { populate: ['stages'] });
56
+
57
+ const { created, updated, deleted } = getDiffBetweenStages(workflow.stages, stages);
58
+
59
+ assertAtLeastOneStageRemain(workflow.stages, { created, deleted });
60
+
61
+ return strapi.db.transaction(async () => {
62
+ const newStages = await this.createMany(created, { fields: ['id'] });
63
+ const stagesIds = stages.map((stage) => stage.id ?? newStages.shift().id);
64
+
65
+ await mapAsync(updated, (stage) => this.update(stage.id, stage));
66
+ await mapAsync(deleted, (stage) => this.delete(stage.id));
67
+ return workflowsService.update(workflowId, {
68
+ stages: stagesIds,
69
+ });
70
+ });
71
+ },
72
+ };
73
+ };
74
+
75
+ /**
76
+ * Compares two arrays of stages and returns an object indicating the differences.
77
+ *
78
+ * The function compares the `id` properties of each stage in `sourceStages` and `comparisonStages` to determine if the stage is present in both arrays.
79
+ * If a stage with the same `id` is found in both arrays but the `name` property is different, the stage is considered updated.
80
+ * If a stage with a particular `id` is only found in `comparisonStages`, it is considered created.
81
+ * If a stage with a particular `id` is only found in `sourceStages`, it is considered deleted.
82
+ *
83
+ * @typedef {{id: Number, name: String, workflow: Number}} Stage
84
+ * @typedef {{created: Stage[], updated: Stage[], deleted: Stage[]}} DiffStages
85
+ *
86
+ * The DiffStages object has three properties: `created`, `updated`, and `deleted`.
87
+ * `created` is an array of stages that are in `comparisonStages` but not in `sourceStages`.
88
+ * `updated` is an array of stages that have different names in `comparisonStages` and `sourceStages`.
89
+ * `deleted` is an array of stages that are in `sourceStages` but not in `comparisonStages`.
90
+ *
91
+ * @param {Stage[]} sourceStages
92
+ * @param {Stage[]} comparisonStages
93
+ * @returns { DiffStages }
94
+ */
95
+ function getDiffBetweenStages(sourceStages, comparisonStages) {
96
+ const result = comparisonStages.reduce(
97
+ (acc, stageToCompare) => {
98
+ const srcStage = sourceStages.find((stage) => stage.id === stageToCompare.id);
99
+
100
+ if (!srcStage) {
101
+ acc.created.push(stageToCompare);
102
+ } else if (srcStage.name !== stageToCompare.name) {
103
+ acc.updated.push(stageToCompare);
104
+ }
105
+ return acc;
106
+ },
107
+ { created: [], updated: [] }
108
+ );
109
+
110
+ result.deleted = sourceStages.filter(
111
+ (srcStage) => !comparisonStages.some((cmpStage) => cmpStage.id === srcStage.id)
112
+ );
113
+
114
+ return result;
115
+ }
116
+
117
+ /**
118
+ * Asserts that at least one stage remains in the workflow after applying deletions and additions.
119
+ *
120
+ * @param {Array} workflowStages - An array of stages in the current workflow.
121
+ * @param {Object} diffStages - An object containing the stages to be deleted and created.
122
+ * @param {Array} diffStages.deleted - An array of stages that are planned to be deleted from the workflow.
123
+ * @param {Array} diffStages.created - An array of stages that are planned to be created in the workflow.
124
+ *
125
+ * @throws {ApplicationError} If the number of remaining stages in the workflow after applying deletions and additions is less than 1.
126
+ */
127
+ function assertAtLeastOneStageRemain(workflowStages, diffStages) {
128
+ const remainingStagesCount =
129
+ workflowStages.length - diffStages.deleted.length + diffStages.created.length;
130
+ if (remainingStagesCount < 1) {
131
+ throw new ApplicationError('At least one stage must remain in the workflow.');
132
+ }
133
+ }
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const { WORKFLOW_MODEL_UID } = require('../../constants/workflows');
4
+
5
+ module.exports = ({ strapi }) => ({
6
+ find(opts) {
7
+ return strapi.entityService.findMany(WORKFLOW_MODEL_UID, opts);
8
+ },
9
+
10
+ findById(id, opts) {
11
+ return strapi.entityService.findOne(WORKFLOW_MODEL_UID, id, opts);
12
+ },
13
+
14
+ create(workflowData) {
15
+ return strapi.entityService.create(WORKFLOW_MODEL_UID, { data: workflowData });
16
+ },
17
+
18
+ count() {
19
+ return strapi.entityService.count(WORKFLOW_MODEL_UID);
20
+ },
21
+
22
+ update(id, workflowData) {
23
+ return strapi.entityService.update(WORKFLOW_MODEL_UID, id, { data: workflowData });
24
+ },
25
+ });
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const getService = (name, { strapi } = { strapi: global.strapi }) => {
4
+ return strapi.service(`admin::${name}`);
5
+ };
6
+ module.exports = {
7
+ getService,
8
+ };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Execute a test suite only if the condition is true
5
+ * @return Jest.Describe
6
+ */
7
+ const describeOnCondition = (bool) => (bool ? describe : describe.skip);
8
+
9
+ module.exports = {
10
+ describeOnCondition,
11
+ };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const { yup, validateYupSchema } = require('@strapi/utils');
4
+
5
+ const stageObject = yup.object().shape({
6
+ id: yup.number().integer().min(1),
7
+ name: yup.string().max(255).required(),
8
+ });
9
+
10
+ const validateUpdateStagesSchema = yup.array().of(stageObject).required();
11
+
12
+ module.exports = {
13
+ validateUpdateStages: validateYupSchema(validateUpdateStagesSchema, {
14
+ strict: false,
15
+ stripUnknown: true,
16
+ }),
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "4.6.1",
3
+ "version": "4.9.0-alpha.0",
4
4
  "description": "Strapi Admin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,15 +46,15 @@
46
46
  "@casl/ability": "^5.4.3",
47
47
  "@fingerprintjs/fingerprintjs": "3.3.6",
48
48
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
49
- "@strapi/babel-plugin-switch-ee-ce": "4.6.1",
50
- "@strapi/data-transfer": "4.6.1",
49
+ "@strapi/babel-plugin-switch-ee-ce": "4.9.0-alpha.0",
50
+ "@strapi/data-transfer": "4.9.0-alpha.0",
51
51
  "@strapi/design-system": "1.6.3",
52
- "@strapi/helper-plugin": "4.6.1",
52
+ "@strapi/helper-plugin": "4.9.0-alpha.0",
53
53
  "@strapi/icons": "1.6.3",
54
- "@strapi/permissions": "4.6.1",
55
- "@strapi/provider-audit-logs-local": "4.6.1",
56
- "@strapi/typescript-utils": "4.6.1",
57
- "@strapi/utils": "4.6.1",
54
+ "@strapi/permissions": "4.9.0-alpha.0",
55
+ "@strapi/provider-audit-logs-local": "4.9.0-alpha.0",
56
+ "@strapi/typescript-utils": "4.9.0-alpha.0",
57
+ "@strapi/utils": "4.9.0-alpha.0",
58
58
  "axios": "1.2.2",
59
59
  "babel-loader": "^9.1.2",
60
60
  "babel-plugin-styled-components": "2.0.2",
@@ -73,6 +73,7 @@
73
73
  "find-root": "1.1.0",
74
74
  "fork-ts-checker-webpack-plugin": "7.2.1",
75
75
  "formik": "^2.2.6",
76
+ "fractional-indexing": "3.2.0",
76
77
  "fs-extra": "10.0.0",
77
78
  "highlight.js": "^10.4.1",
78
79
  "history": "^4.9.0",
@@ -100,8 +101,6 @@
100
101
  "markdown-it-sup": "1.0.0",
101
102
  "match-sorter": "^4.0.2",
102
103
  "mini-css-extract-plugin": "2.7.2",
103
- "msw": "0.49.1",
104
- "node-polyfill-webpack-plugin": "2.0.1",
105
104
  "node-schedule": "2.1.0",
106
105
  "p-map": "4.0.0",
107
106
  "passport-local": "1.0.0",
@@ -115,15 +114,15 @@
115
114
  "react-error-boundary": "3.1.4",
116
115
  "react-fast-compare": "^3.2.0",
117
116
  "react-helmet": "^6.1.0",
118
- "react-intl": "6.2.7",
117
+ "react-intl": "6.2.8",
119
118
  "react-is": "^17.0.2",
120
119
  "react-query": "3.24.3",
121
- "react-redux": "7.2.8",
120
+ "react-redux": "8.0.5",
122
121
  "react-refresh": "0.14.0",
123
122
  "react-router": "5.2.0",
124
123
  "react-router-dom": "5.3.4",
125
124
  "react-window": "1.8.7",
126
- "redux": "^4.0.1",
125
+ "redux": "^4.2.1",
127
126
  "reselect": "^4.0.0",
128
127
  "rimraf": "3.0.2",
129
128
  "sanitize-html": "2.7.3",
@@ -145,9 +144,10 @@
145
144
  "@testing-library/user-event": "14.4.3",
146
145
  "duplicate-dependencies-webpack-plugin": "^1.0.2",
147
146
  "glob": "8.0.3",
147
+ "msw": "1.0.1",
148
148
  "react-test-renderer": "^17.0.2",
149
149
  "speed-measure-webpack-plugin": "1.5.0",
150
- "webpack-bundle-analyzer": "^4.7.0"
150
+ "webpack-bundle-analyzer": "^4.8.0"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "@strapi/strapi": "^4.3.4"
@@ -165,5 +165,5 @@
165
165
  }
166
166
  }
167
167
  },
168
- "gitHead": "17a7845e3d453ea2e7911bda6ec25ed196dd5f16"
168
+ "gitHead": "35f783d0dc07db101e7e62cb4d682f751551f452"
169
169
  }
@@ -10,22 +10,6 @@ module.exports = {
10
10
  category: 'plugins and marketplace',
11
11
  subCategory: 'marketplace',
12
12
  },
13
- {
14
- uid: 'marketplace.plugins.install',
15
- displayName: 'Install (only for dev env)',
16
- pluginName: 'admin',
17
- section: 'settings',
18
- category: 'plugins and marketplace',
19
- subCategory: 'plugins',
20
- },
21
- {
22
- uid: 'marketplace.plugins.uninstall',
23
- displayName: 'Uninstall (only for dev env)',
24
- pluginName: 'admin',
25
- section: 'settings',
26
- category: 'plugins and marketplace',
27
- subCategory: 'plugins',
28
- },
29
13
  {
30
14
  uid: 'webhooks.create',
31
15
  displayName: 'Create',