@strapi/admin 4.7.0-beta.0 → 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 (257) hide show
  1. package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +6 -14
  2. package/admin/src/content-manager/components/DynamicTable/CellContent/RelationMultiple/index.js +1 -1
  3. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +2 -0
  4. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +39 -9
  5. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +9 -15
  6. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +4 -12
  7. package/admin/src/content-manager/pages/EditView/DeleteLink/index.js +6 -8
  8. package/admin/src/content-manager/pages/ListView/index.js +6 -11
  9. package/admin/src/hooks/useRegenerate/index.js +2 -2
  10. package/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js +0 -7
  11. package/admin/src/index.js +1 -0
  12. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +15 -2
  13. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +3 -5
  14. package/admin/src/pages/SettingsPage/{components/Tokens/TokenBox → pages/ApiTokens/EditView/components/ContentBox}/index.js +17 -17
  15. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormApiTokenContainer/index.js +142 -52
  16. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormBody/index.js +78 -0
  17. package/admin/src/pages/SettingsPage/{components/Tokens → pages/ApiTokens/EditView/components}/FormHead/index.js +19 -36
  18. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Regenerate/index.js +1 -5
  19. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +14 -37
  20. package/admin/src/pages/SettingsPage/{components/Tokens/Table → pages/ApiTokens/ListView/DynamicTable}/DefaultButton/index.js +1 -1
  21. package/admin/src/pages/SettingsPage/{components/Tokens/Table → pages/ApiTokens/ListView/DynamicTable}/DeleteButton/index.js +1 -1
  22. package/admin/src/pages/SettingsPage/{components/Tokens/Table → pages/ApiTokens/ListView/DynamicTable}/ReadButton/index.js +0 -0
  23. package/admin/src/pages/SettingsPage/{components/Tokens/Table → pages/ApiTokens/ListView/DynamicTable}/UpdateButton/index.js +0 -0
  24. package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/index.js +112 -0
  25. package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +13 -5
  26. package/admin/src/pages/SettingsPage/pages/Users/components/MagicLink/MagicLinkWrapper.js +3 -20
  27. package/admin/src/pages/SettingsPage/utils/defaultRoutes.js +0 -33
  28. package/admin/src/permissions/defaultPermissions.js +2 -23
  29. package/admin/src/translations/ar.json +4 -4
  30. package/admin/src/translations/ca.json +4 -4
  31. package/admin/src/translations/cs.json +4 -4
  32. package/admin/src/translations/de.json +4 -4
  33. package/admin/src/translations/dk.json +4 -4
  34. package/admin/src/translations/en.json +9 -17
  35. package/admin/src/translations/es.json +4 -4
  36. package/admin/src/translations/eu.json +4 -4
  37. package/admin/src/translations/fr.json +4 -4
  38. package/admin/src/translations/gu.json +4 -4
  39. package/admin/src/translations/he.json +4 -4
  40. package/admin/src/translations/hi.json +4 -4
  41. package/admin/src/translations/hu.json +4 -4
  42. package/admin/src/translations/id.json +4 -4
  43. package/admin/src/translations/it.json +4 -4
  44. package/admin/src/translations/ja.json +4 -4
  45. package/admin/src/translations/ko.json +4 -4
  46. package/admin/src/translations/ml.json +4 -4
  47. package/admin/src/translations/ms.json +4 -4
  48. package/admin/src/translations/nl.json +4 -4
  49. package/admin/src/translations/no.json +4 -4
  50. package/admin/src/translations/pl.json +4 -4
  51. package/admin/src/translations/pt-BR.json +4 -4
  52. package/admin/src/translations/pt.json +4 -4
  53. package/admin/src/translations/ru.json +785 -789
  54. package/admin/src/translations/sa.json +4 -4
  55. package/admin/src/translations/sk.json +4 -4
  56. package/admin/src/translations/sv.json +4 -4
  57. package/admin/src/translations/th.json +4 -4
  58. package/admin/src/translations/tr.json +4 -4
  59. package/admin/src/translations/uk.json +4 -4
  60. package/admin/src/translations/vi.json +4 -4
  61. package/admin/src/translations/zh-Hans.json +4 -4
  62. package/admin/src/translations/zh.json +4 -4
  63. package/build/1683.d59d0f23.chunk.js +268 -0
  64. package/build/{4855.bd092921.chunk.js → 2223.1bfea951.chunk.js} +88 -88
  65. package/build/2743.646a1015.chunk.js +45 -0
  66. package/build/3075.3ee481f1.chunk.js +108 -0
  67. package/build/3632.2e378cf8.chunk.js +138 -0
  68. package/build/4318.cd55ce02.chunk.js +30 -0
  69. package/build/8633.00ccd382.chunk.js +1 -0
  70. package/build/9707.b36ed71e.chunk.js +96 -0
  71. package/build/{Admin-authenticatedApp.f29f6021.chunk.js → Admin-authenticatedApp.a73577e1.chunk.js} +2 -2
  72. package/build/{Admin_InternalErrorPage.157152a8.chunk.js → Admin_InternalErrorPage.178ddb90.chunk.js} +1 -1
  73. package/build/{Admin_homePage.b1730882.chunk.js → Admin_homePage.c2f5f27d.chunk.js} +2 -2
  74. package/build/{Admin_marketplace.ea0316c2.chunk.js → Admin_marketplace.1df49c42.chunk.js} +1 -1
  75. package/build/{Admin_pluginsPage.5c24f963.chunk.js → Admin_pluginsPage.8d824408.chunk.js} +2 -2
  76. package/build/{Admin_profilePage.59af1978.chunk.js → Admin_profilePage.cb667bc5.chunk.js} +2 -2
  77. package/build/Admin_settingsPage.f90615fb.chunk.js +178 -0
  78. package/build/{Upload_ConfigureTheView.3f2b6e6a.chunk.js → Upload_ConfigureTheView.d306009d.chunk.js} +1 -1
  79. package/build/admin-app.06f07029.chunk.js +112 -0
  80. package/build/admin-edit-roles-page.35199b9d.chunk.js +1 -0
  81. package/build/admin-edit-users.9e48b00d.chunk.js +10 -0
  82. package/build/admin-users.cf7b4151.chunk.js +11 -0
  83. package/build/{api-tokens-create-page.0db3aec1.chunk.js → api-tokens-create-page.a31c7fba.chunk.js} +1 -1
  84. package/build/{api-tokens-edit-page.671e0e26.chunk.js → api-tokens-edit-page.64fef287.chunk.js} +1 -1
  85. package/build/api-tokens-list-page.e600ad3e.chunk.js +16 -0
  86. package/build/ar-json.39e54aba.chunk.js +1 -0
  87. package/build/{audit-logs-settings-page.c3dce30d.chunk.js → audit-logs-settings-page.d4da4579.chunk.js} +1 -1
  88. package/build/{ca-json.f6a0f472.chunk.js → ca-json.4d999055.chunk.js} +1 -1
  89. package/build/content-manager.255c3a59.chunk.js +1139 -0
  90. package/build/{content-type-builder-list-view.79e84b36.chunk.js → content-type-builder-list-view.8d7a3d68.chunk.js} +5 -5
  91. package/build/content-type-builder.3c8558a5.chunk.js +126 -0
  92. package/build/cs-json.4b44411c.chunk.js +1 -0
  93. package/build/{de-json.30e1f35b.chunk.js → de-json.866f8a28.chunk.js} +1 -1
  94. package/build/{dk-json.e6d9ffa4.chunk.js → dk-json.10f7b1d1.chunk.js} +1 -1
  95. package/build/email-settings-page.b19f2eb2.chunk.js +10 -0
  96. package/build/en-json.1997583c.chunk.js +1 -0
  97. package/build/es-json.ea15c957.chunk.js +1 -0
  98. package/build/{eu-json.fceecd8b.chunk.js → eu-json.3bc24d60.chunk.js} +1 -1
  99. package/build/{fr-json.78545ef8.chunk.js → fr-json.e88fbdfd.chunk.js} +1 -1
  100. package/build/{gu-json.676518f2.chunk.js → gu-json.94f0d242.chunk.js} +1 -1
  101. package/build/{he-json.ad22e8cc.chunk.js → he-json.f0de8cdb.chunk.js} +1 -1
  102. package/build/{hi-json.19b51c09.chunk.js → hi-json.df3a7be2.chunk.js} +1 -1
  103. package/build/{hu-json.f947088f.chunk.js → hu-json.680e6eef.chunk.js} +1 -1
  104. package/build/{i18n-settings-page.b8d8753e.chunk.js → i18n-settings-page.a6b49eac.chunk.js} +1 -1
  105. package/build/{id-json.504daa84.chunk.js → id-json.e0d83d41.chunk.js} +1 -1
  106. package/build/index.html +1 -1
  107. package/build/{it-json.2fd90f4d.chunk.js → it-json.8be59205.chunk.js} +1 -1
  108. package/build/{ja-json.c9f12d0b.chunk.js → ja-json.97ee41ba.chunk.js} +1 -1
  109. package/build/{ko-json.ef463065.chunk.js → ko-json.4cbbf4f2.chunk.js} +1 -1
  110. package/build/main.7f308c20.js +4322 -0
  111. package/build/{ml-json.490f666c.chunk.js → ml-json.e3747091.chunk.js} +1 -1
  112. package/build/ms-json.0eddffd9.chunk.js +1 -0
  113. package/build/{nl-json.c416295a.chunk.js → nl-json.371a15ee.chunk.js} +1 -1
  114. package/build/{no-json.1a2258ba.chunk.js → no-json.9b3cd181.chunk.js} +1 -1
  115. package/build/{pl-json.8cf0c871.chunk.js → pl-json.e535cbce.chunk.js} +1 -1
  116. package/build/{pt-BR-json.51fab8d0.chunk.js → pt-BR-json.e5fafa46.chunk.js} +1 -1
  117. package/build/pt-json.ee554a41.chunk.js +1 -0
  118. package/build/review-workflows-settings.7b4be1b0.chunk.js +63 -0
  119. package/build/{ru-json.aa5cd123.chunk.js → ru-json.866f0ff1.chunk.js} +1 -1
  120. package/build/runtime~main.bf374148.js +2 -0
  121. package/build/{sa-json.f3fa5407.chunk.js → sa-json.7efeb257.chunk.js} +1 -1
  122. package/build/{sk-json.9ec60d9f.chunk.js → sk-json.7bbeb0af.chunk.js} +1 -1
  123. package/build/{sso-settings-page.b85ad080.chunk.js → sso-settings-page.ad2143dd.chunk.js} +1 -1
  124. package/build/{sv-json.c6b0c237.chunk.js → sv-json.dc40951f.chunk.js} +1 -1
  125. package/build/{th-json.6e68155c.chunk.js → th-json.f664b96d.chunk.js} +1 -1
  126. package/build/{tr-json.9f41dc08.chunk.js → tr-json.b79eae31.chunk.js} +1 -1
  127. package/build/uk-json.b7e38370.chunk.js +1 -0
  128. package/build/upload-settings.eb1a7908.chunk.js +84 -0
  129. package/build/upload.700e2c84.chunk.js +33 -0
  130. package/build/{users-advanced-settings-page.fce9908e.chunk.js → users-advanced-settings-page.aae212f2.chunk.js} +1 -1
  131. package/build/{users-email-settings-page.343d0ad2.chunk.js → users-email-settings-page.8a9b0da1.chunk.js} +1 -1
  132. package/build/{users-providers-settings-page.e5a9a3f1.chunk.js → users-providers-settings-page.e6be909d.chunk.js} +10 -10
  133. package/build/{users-roles-settings-page.66312f31.chunk.js → users-roles-settings-page.97d06a80.chunk.js} +3 -3
  134. package/build/vi-json.ee4c5537.chunk.js +1 -0
  135. package/build/webhook-edit-page.9eb0f789.chunk.js +75 -0
  136. package/build/webhook-list-page.66082323.chunk.js +42 -0
  137. package/build/{zh-Hans-json.9c0eac99.chunk.js → zh-Hans-json.30a18940.chunk.js} +1 -1
  138. package/build/{zh-json.f88f563d.chunk.js → zh-json.49d84433.chunk.js} +1 -1
  139. package/ee/admin/hooks/useSettingsMenu/utils/customAdminLinks.js +12 -12
  140. package/ee/admin/hooks/useSettingsMenu/utils/customGlobalLinks.js +21 -13
  141. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +137 -0
  142. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/actions/index.js +42 -0
  143. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/AddStage.js +87 -0
  144. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/index.js +1 -0
  145. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/Stage.js +90 -0
  146. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/index.js +1 -0
  147. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stages.js +77 -0
  148. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/index.js +1 -0
  149. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/constants.js +6 -0
  150. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +63 -0
  151. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/index.js +3 -0
  152. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/reducer/index.js +102 -0
  153. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/utils/getWorkflowValidationSchema.js +25 -0
  154. package/ee/admin/pages/SettingsPage/utils/customRoutes.js +16 -2
  155. package/ee/admin/permissions/customPermissions.js +7 -0
  156. package/ee/server/bootstrap.js +7 -1
  157. package/ee/server/config/admin-actions.js +10 -0
  158. package/ee/server/constants/default-stages.json +14 -0
  159. package/ee/server/constants/default-workflow.json +1 -0
  160. package/ee/server/constants/workflows.js +7 -0
  161. package/ee/server/content-types/index.js +9 -0
  162. package/ee/server/content-types/workflow/index.js +34 -0
  163. package/ee/server/content-types/workflow-stage/index.js +36 -0
  164. package/ee/server/controllers/index.js +2 -0
  165. package/ee/server/controllers/workflows/index.js +36 -0
  166. package/ee/server/controllers/workflows/stages/index.js +57 -0
  167. package/ee/server/index.js +1 -0
  168. package/ee/server/routes/index.js +87 -0
  169. package/ee/server/services/index.js +3 -0
  170. package/ee/server/services/review-workflows/review-workflows.js +54 -0
  171. package/ee/server/services/review-workflows/stages.js +133 -0
  172. package/ee/server/services/review-workflows/workflows.js +25 -0
  173. package/ee/server/utils/index.js +8 -0
  174. package/ee/server/utils/test.js +11 -0
  175. package/ee/server/validation/review-workflows.js +17 -0
  176. package/package.json +13 -13
  177. package/server/bootstrap.js +0 -2
  178. package/server/config/admin-actions.js +0 -64
  179. package/server/content-types/index.js +0 -2
  180. package/server/controllers/admin.js +0 -55
  181. package/server/controllers/api-token.js +5 -4
  182. package/server/controllers/index.js +0 -1
  183. package/server/register.js +9 -2
  184. package/server/routes/admin.js +0 -28
  185. package/server/routes/index.js +0 -2
  186. package/server/services/api-token.js +3 -2
  187. package/server/services/constants.js +0 -6
  188. package/server/services/index.js +0 -1
  189. package/server/strategies/api-token.js +2 -4
  190. package/server/strategies/index.js +0 -1
  191. package/server/utils/index.d.ts +0 -2
  192. package/server/validation/api-tokens.js +6 -1
  193. package/webpack.config.js +0 -3
  194. package/admin/src/pages/SettingsPage/components/Tokens/FormiTokenContainer/LifeSpanInput.js +0 -96
  195. package/admin/src/pages/SettingsPage/components/Tokens/LifeSpanInput/index.js +0 -98
  196. package/admin/src/pages/SettingsPage/components/Tokens/Regenerate/index.js +0 -73
  197. package/admin/src/pages/SettingsPage/components/Tokens/Table/index.js +0 -135
  198. package/admin/src/pages/SettingsPage/components/Tokens/TokenDescription/index.js +0 -51
  199. package/admin/src/pages/SettingsPage/components/Tokens/TokenName/index.js +0 -46
  200. package/admin/src/pages/SettingsPage/components/Tokens/TokenTypeSelect/index.js +0 -69
  201. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/FormTransferTokenContainer/index.js +0 -105
  202. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/LoadingView/index.js +0 -50
  203. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +0 -201
  204. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/getDateOfExpiration.js +0 -16
  205. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/index.js +0 -4
  206. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/schema.js +0 -10
  207. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +0 -182
  208. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/utils/tableHeaders.js +0 -48
  209. package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedCreateView/index.js +0 -14
  210. package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedEditView/index.js +0 -14
  211. package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedListView/index.js +0 -12
  212. package/build/1683.c8aa7b7c.chunk.js +0 -268
  213. package/build/2743.6d1632f9.chunk.js +0 -45
  214. package/build/3075.dc3894fe.chunk.js +0 -108
  215. package/build/3632.0317b618.chunk.js +0 -138
  216. package/build/4649.15cc0afe.chunk.js +0 -30
  217. package/build/7259.aa68d808.chunk.js +0 -1
  218. package/build/7407.883fb1f5.chunk.js +0 -1
  219. package/build/9707.7290fd92.chunk.js +0 -96
  220. package/build/Admin_settingsPage.178dc6e3.chunk.js +0 -178
  221. package/build/admin-app.77a50e1f.chunk.js +0 -112
  222. package/build/admin-edit-roles-page.446b69dc.chunk.js +0 -1
  223. package/build/admin-edit-users.2ed69bfd.chunk.js +0 -10
  224. package/build/admin-users.fc003b10.chunk.js +0 -11
  225. package/build/api-tokens-list-page.7387102c.chunk.js +0 -16
  226. package/build/ar-json.932794f7.chunk.js +0 -1
  227. package/build/content-manager.42b24d46.chunk.js +0 -1139
  228. package/build/content-type-builder.855db321.chunk.js +0 -126
  229. package/build/cs-json.79879fb6.chunk.js +0 -1
  230. package/build/email-settings-page.d1fcc7a3.chunk.js +0 -10
  231. package/build/en-json.b0748970.chunk.js +0 -1
  232. package/build/es-json.e275481d.chunk.js +0 -1
  233. package/build/main.1022ed01.js +0 -4393
  234. package/build/ms-json.db87d8d3.chunk.js +0 -1
  235. package/build/pt-json.62927d1e.chunk.js +0 -1
  236. package/build/runtime~main.84941a97.js +0 -2
  237. package/build/transfer-tokens-create-page.16e23791.chunk.js +0 -1
  238. package/build/transfer-tokens-edit-page.3886c973.chunk.js +0 -1
  239. package/build/transfer-tokens-list-page.e8010a89.chunk.js +0 -16
  240. package/build/uk-json.b2fcd567.chunk.js +0 -1
  241. package/build/upload-settings.ef64bbf9.chunk.js +0 -84
  242. package/build/upload.c5730dfa.chunk.js +0 -33
  243. package/build/vi-json.f08d7d03.chunk.js +0 -1
  244. package/build/webhook-edit-page.73e51e64.chunk.js +0 -75
  245. package/build/webhook-list-page.1134f130.chunk.js +0 -42
  246. package/server/content-types/transfer-token-permission.js +0 -36
  247. package/server/content-types/transfer-token.js +0 -66
  248. package/server/controllers/transfer/index.js +0 -13
  249. package/server/controllers/transfer/runner.js +0 -24
  250. package/server/controllers/transfer/token.js +0 -131
  251. package/server/routes/transfer.js +0 -95
  252. package/server/services/transfer/index.js +0 -6
  253. package/server/services/transfer/permission.js +0 -22
  254. package/server/services/transfer/token.js +0 -409
  255. package/server/strategies/data-transfer.js +0 -107
  256. package/server/validation/transfer/index.js +0 -5
  257. package/server/validation/transfer/token.js +0 -34
@@ -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.7.0-beta.0",
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.7.0-beta.0",
50
- "@strapi/data-transfer": "4.7.0-beta.0",
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.7.0-beta.0",
52
+ "@strapi/helper-plugin": "4.9.0-alpha.0",
53
53
  "@strapi/icons": "1.6.3",
54
- "@strapi/permissions": "4.7.0-beta.0",
55
- "@strapi/provider-audit-logs-local": "4.7.0-beta.0",
56
- "@strapi/typescript-utils": "4.7.0-beta.0",
57
- "@strapi/utils": "4.7.0-beta.0",
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,7 +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
- "node-polyfill-webpack-plugin": "2.0.1",
104
104
  "node-schedule": "2.1.0",
105
105
  "p-map": "4.0.0",
106
106
  "passport-local": "1.0.0",
@@ -114,7 +114,7 @@
114
114
  "react-error-boundary": "3.1.4",
115
115
  "react-fast-compare": "^3.2.0",
116
116
  "react-helmet": "^6.1.0",
117
- "react-intl": "6.2.7",
117
+ "react-intl": "6.2.8",
118
118
  "react-is": "^17.0.2",
119
119
  "react-query": "3.24.3",
120
120
  "react-redux": "8.0.5",
@@ -144,10 +144,10 @@
144
144
  "@testing-library/user-event": "14.4.3",
145
145
  "duplicate-dependencies-webpack-plugin": "^1.0.2",
146
146
  "glob": "8.0.3",
147
- "msw": "1.0.0",
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": "880ba7af867ad43c4cc45b47467b76a9b5606b6e"
168
+ "gitHead": "35f783d0dc07db101e7e62cb4d682f751551f452"
169
169
  }
@@ -78,7 +78,6 @@ module.exports = async () => {
78
78
  const userService = getService('user');
79
79
  const roleService = getService('role');
80
80
  const apiTokenService = getService('api-token');
81
- const transferService = getService('transfer');
82
81
  const tokenService = getService('token');
83
82
 
84
83
  await roleService.createRolesIfNoneExist();
@@ -94,6 +93,5 @@ module.exports = async () => {
94
93
  await syncAPITokensPermissions();
95
94
 
96
95
  apiTokenService.checkSaltIsDefined();
97
- transferService.token.checkSaltIsDefined();
98
96
  tokenService.checkSecretIsDefined();
99
97
  };
@@ -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',
@@ -180,53 +164,5 @@ module.exports = {
180
164
  section: 'settings',
181
165
  category: 'project',
182
166
  },
183
- {
184
- uid: 'transfer.tokens.access',
185
- displayName: 'Access the transfer tokens settings page',
186
- pluginName: 'admin',
187
- section: 'settings',
188
- category: 'transfer tokens',
189
- subCategory: 'transfer tokens',
190
- },
191
- {
192
- uid: 'transfer.tokens.create',
193
- displayName: 'Create (generate)',
194
- pluginName: 'admin',
195
- section: 'settings',
196
- category: 'transfer tokens',
197
- subCategory: 'general',
198
- },
199
- {
200
- uid: 'transfer.tokens.read',
201
- displayName: 'Read',
202
- pluginName: 'admin',
203
- section: 'settings',
204
- category: 'transfer tokens',
205
- subCategory: 'general',
206
- },
207
- {
208
- uid: 'transfer.tokens.update',
209
- displayName: 'Update',
210
- pluginName: 'admin',
211
- section: 'settings',
212
- category: 'transfer tokens',
213
- subCategory: 'general',
214
- },
215
- {
216
- uid: 'transfer.tokens.regenerate',
217
- displayName: 'Regenerate',
218
- pluginName: 'admin',
219
- section: 'settings',
220
- category: 'transfer tokens',
221
- subCategory: 'general',
222
- },
223
- {
224
- uid: 'transfer.tokens.delete',
225
- displayName: 'Delete (revoke)',
226
- pluginName: 'admin',
227
- section: 'settings',
228
- category: 'transfer tokens',
229
- subCategory: 'general',
230
- },
231
167
  ],
232
168
  };
@@ -6,6 +6,4 @@ module.exports = {
6
6
  role: { schema: require('./Role') },
7
7
  'api-token': { schema: require('./api-token') },
8
8
  'api-token-permission': { schema: require('./api-token-permission') },
9
- 'transfer-token': { schema: require('./transfer-token') },
10
- 'transfer-token-permission': { schema: require('./transfer-token-permission') },
11
9
  };