@strapi/admin 4.10.0-beta.0 → 4.10.0-beta.1

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 (193) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +14 -0
  3. package/admin/src/components/LanguageProvider/index.js +1 -1
  4. package/admin/src/components/LocalesProvider/__mocks__/useLocalesProvider.js +7 -0
  5. package/admin/src/components/LocalesProvider/index.js +2 -3
  6. package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +3 -6
  7. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn.js +2 -0
  8. package/admin/src/content-manager/components/DynamicTable/index.js +11 -29
  9. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +12 -6
  10. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/findAllAndReplace.js +10 -3
  11. package/admin/src/content-manager/components/InputUID/endActionStyle.js +4 -13
  12. package/admin/src/content-manager/components/InputUID/index.js +95 -72
  13. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +4 -8
  14. package/admin/src/content-manager/pages/App/LeftMenu/index.js +56 -35
  15. package/admin/src/content-manager/pages/App/actions.js +19 -7
  16. package/admin/src/content-manager/pages/App/constants.js +3 -3
  17. package/admin/src/content-manager/pages/App/index.js +5 -4
  18. package/admin/src/content-manager/pages/App/reducer.js +7 -6
  19. package/admin/src/content-manager/pages/App/selectors.js +3 -0
  20. package/admin/src/content-manager/pages/App/{useModels.js → useContentManagerInitData.js} +29 -28
  21. package/admin/src/content-manager/pages/App/utils/generateModelsLinks.js +2 -2
  22. package/admin/src/content-manager/pages/App/utils/getContentTypeLinks.js +17 -15
  23. package/admin/src/content-manager/pages/EditSettingsView/components/ModalForm.js +4 -5
  24. package/admin/src/content-manager/pages/EditSettingsView/index.js +4 -0
  25. package/admin/src/content-manager/pages/EditSettingsView/reducer.js +6 -7
  26. package/admin/src/content-manager/pages/EditSettingsView/utils/layout.js +1 -30
  27. package/admin/src/content-manager/pages/EditView/DeleteLink/index.js +5 -11
  28. package/admin/src/content-manager/pages/EditView/index.js +2 -7
  29. package/admin/src/content-manager/pages/ListSettingsView/index.js +1 -0
  30. package/admin/src/content-manager/sharedReducers/crudReducer/actions.js +6 -0
  31. package/admin/src/content-manager/sharedReducers/crudReducer/constants.js +1 -0
  32. package/admin/src/content-manager/sharedReducers/crudReducer/reducer.js +5 -0
  33. package/admin/src/hooks/useConfigurations/__mocks__/index.js +7 -0
  34. package/admin/src/hooks/useFetchMarketplacePlugins/utils/api.js +7 -8
  35. package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +5 -0
  36. package/admin/src/hooks/useRegenerate/index.js +12 -7
  37. package/admin/src/pages/AuthPage/components/Register/index.js +46 -38
  38. package/admin/src/pages/HomePage/SocialLinks.js +1 -1
  39. package/admin/src/pages/MarketplacePage/components/EmptyNpmPackageSearch/index.js +3 -3
  40. package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +42 -9
  41. package/admin/src/pages/MarketplacePage/components/NpmPackagesPagination/index.js +26 -0
  42. package/admin/src/pages/MarketplacePage/components/OfflineLayout/index.js +45 -0
  43. package/admin/src/pages/MarketplacePage/index.js +80 -175
  44. package/admin/src/pages/MarketplacePage/utils/useMarketplaceData.js +85 -0
  45. package/admin/src/pages/SettingsPage/components/Tokens/FormHead/index.js +4 -0
  46. package/admin/src/pages/SettingsPage/components/Tokens/Regenerate/index.js +5 -3
  47. package/admin/src/pages/SettingsPage/components/Tokens/TokenTypeSelect/index.js +7 -5
  48. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/components/RoleRow/index.js +12 -4
  49. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +21 -2
  50. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/FormTransferTokenContainer/index.js +41 -0
  51. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +53 -9
  52. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/schema.js +1 -0
  53. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +27 -5
  54. package/admin/src/translations/en.json +51 -49
  55. package/admin/src/translations/ru.json +51 -19
  56. package/build/1387.84b454d3.chunk.js +1 -0
  57. package/build/1657.45231968.chunk.js +168 -0
  58. package/build/3081.bcf9a12f.chunk.js +108 -0
  59. package/build/462.8fff7f3b.chunk.js +71 -0
  60. package/build/4628.20631dd1.chunk.js +1 -0
  61. package/build/5542.b8240e3f.chunk.js +70 -0
  62. package/build/5563.905daa13.chunk.js +79 -0
  63. package/build/6404.68405699.chunk.js +100 -0
  64. package/build/7259.b7d00cea.chunk.js +1 -0
  65. package/build/8694.6522968d.chunk.js +247 -0
  66. package/build/Admin-authenticatedApp.52c88751.chunk.js +79 -0
  67. package/build/Admin_InternalErrorPage.15c6bf07.chunk.js +1 -0
  68. package/build/Admin_homePage.f9309c6d.chunk.js +73 -0
  69. package/build/Admin_marketplace.56bc1008.chunk.js +31 -0
  70. package/build/Admin_pluginsPage.f6b52ee9.chunk.js +6 -0
  71. package/build/Admin_profilePage.9112cffc.chunk.js +15 -0
  72. package/build/Admin_settingsPage.257b3477.chunk.js +79 -0
  73. package/build/Upload_ConfigureTheView.eaaec495.chunk.js +1 -0
  74. package/build/admin-app.dfaeea5d.chunk.js +110 -0
  75. package/build/admin-edit-roles-page.4f1858e9.chunk.js +280 -0
  76. package/build/admin-edit-users.7e14d85f.chunk.js +10 -0
  77. package/build/admin-roles-list.329c1f63.chunk.js +31 -0
  78. package/build/admin-users.d02de059.chunk.js +34 -0
  79. package/build/api-tokens-create-page.97595e12.chunk.js +1 -0
  80. package/build/api-tokens-edit-page.cd36e30e.chunk.js +1 -0
  81. package/build/api-tokens-list-page.6757c7b9.chunk.js +16 -0
  82. package/build/audit-logs-settings-page.19d90bda.chunk.js +76 -0
  83. package/build/content-manager.def692c2.chunk.js +1130 -0
  84. package/build/content-type-builder-list-view.9c2c020c.chunk.js +214 -0
  85. package/build/content-type-builder-translation-en-json.510e88ca.chunk.js +1 -0
  86. package/build/content-type-builder.5e1f4afc.chunk.js +126 -0
  87. package/build/email-settings-page.1095e1ab.chunk.js +10 -0
  88. package/build/en-json.08303b37.chunk.js +1 -0
  89. package/build/{highlight.js.26ef649f.chunk.js → highlight.js.28a1547e.chunk.js} +2 -2
  90. package/build/i18n-settings-page.7d80aae0.chunk.js +60 -0
  91. package/build/index.html +1 -1
  92. package/build/main.120be100.js +2280 -0
  93. package/build/review-workflows-settings.9092ed72.chunk.js +106 -0
  94. package/build/ru-json.e0662702.chunk.js +1 -0
  95. package/build/{runtime~main.5a95bee6.js → runtime~main.112b3101.js} +2 -2
  96. package/build/sso-settings-page.1dd4886e.chunk.js +1 -0
  97. package/build/transfer-tokens-create-page.ec2ca215.chunk.js +1 -0
  98. package/build/transfer-tokens-edit-page.22bf28e5.chunk.js +1 -0
  99. package/build/transfer-tokens-list-page.cf8c77f2.chunk.js +16 -0
  100. package/build/upload-settings.945fdcfa.chunk.js +13 -0
  101. package/build/{upload-translation-th-json.3847dae0.chunk.js → upload-translation-th-json.98d35574.chunk.js} +1 -1
  102. package/build/upload.a86b1054.chunk.js +33 -0
  103. package/build/users-advanced-settings-page.5b5a9baa.chunk.js +8 -0
  104. package/build/users-email-settings-page.e5506eb4.chunk.js +23 -0
  105. package/build/users-providers-settings-page.e32089c2.chunk.js +28 -0
  106. package/build/users-roles-settings-page.2f85dcec.chunk.js +30 -0
  107. package/build/webhook-edit-page.213f0075.chunk.js +75 -0
  108. package/build/webhook-list-page.5beb2a5c.chunk.js +71 -0
  109. package/{admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/ReviewWorkflowsStage.js → ee/admin/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/ReviewWorkflowsStageEE.js} +2 -2
  110. package/ee/admin/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn.js +45 -0
  111. package/ee/admin/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/index.js +3 -0
  112. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +61 -18
  113. package/ee/admin/hooks/useLicenseLimitNotification/index.js +1 -1
  114. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useAuditLogsData.js +6 -3
  115. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/index.js +15 -5
  116. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/utils/getDisplayedFilters.js +52 -45
  117. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +8 -4
  118. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/Stage.js +2 -2
  119. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +2 -2
  120. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/reducer/index.js +2 -1
  121. package/ee/server/content-types/workflow/index.js +0 -3
  122. package/ee/server/content-types/workflow-stage/index.js +0 -5
  123. package/ee/server/controllers/workflows/stages/index.js +8 -1
  124. package/ee/server/register.js +3 -1
  125. package/ee/server/services/audit-logs.js +75 -16
  126. package/ee/server/services/review-workflows/entity-service-decorator.js +17 -5
  127. package/ee/server/services/review-workflows/review-workflows.js +27 -91
  128. package/ee/server/services/review-workflows/stages.js +108 -7
  129. package/ee/server/utils/persisted-tables.js +114 -22
  130. package/ee/server/utils/review-workflows.js +9 -0
  131. package/jest.config.front.js +1 -6
  132. package/package.json +24 -22
  133. package/server/controllers/transfer/runner.js +4 -2
  134. package/server/middlewares/data-transfer.js +4 -1
  135. package/server/routes/transfer.js +13 -4
  136. package/server/services/constants.js +4 -0
  137. package/server/services/transfer/permission.js +1 -1
  138. package/server/services/transfer/token.js +33 -31
  139. package/server/validation/transfer/token.js +10 -2
  140. package/webpack.config.js +6 -2
  141. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/index.js +0 -1
  142. package/admin/src/content-manager/pages/App/LeftMenu/utils/index.js +0 -1
  143. package/admin/src/content-manager/pages/App/LeftMenu/utils/matchByTitle.js +0 -24
  144. package/build/2263.4c5916f9.chunk.js +0 -98
  145. package/build/4049.64715f20.chunk.js +0 -1
  146. package/build/4649.213b8a3b.chunk.js +0 -30
  147. package/build/6985.66cca29c.chunk.js +0 -1
  148. package/build/7259.aefb51e8.chunk.js +0 -1
  149. package/build/8469.853c822b.chunk.js +0 -1
  150. package/build/9505.dbe702ab.chunk.js +0 -14
  151. package/build/9816.01ee964f.chunk.js +0 -2
  152. package/build/Admin-authenticatedApp.f50ad423.chunk.js +0 -79
  153. package/build/Admin_InternalErrorPage.4ad8b0df.chunk.js +0 -1
  154. package/build/Admin_homePage.1411fb7c.chunk.js +0 -68
  155. package/build/Admin_marketplace.02608d56.chunk.js +0 -22
  156. package/build/Admin_pluginsPage.15e3b0fd.chunk.js +0 -1
  157. package/build/Admin_profilePage.76afeca0.chunk.js +0 -15
  158. package/build/Admin_settingsPage.147755cd.chunk.js +0 -9
  159. package/build/Upload_ConfigureTheView.34dde278.chunk.js +0 -1
  160. package/build/admin-app.55dd7921.chunk.js +0 -112
  161. package/build/admin-edit-roles-page.cf543488.chunk.js +0 -216
  162. package/build/admin-edit-users.31c20712.chunk.js +0 -10
  163. package/build/admin-roles-list.489c501f.chunk.js +0 -2
  164. package/build/admin-users.3e111a7d.chunk.js +0 -11
  165. package/build/api-tokens-create-page.4328b852.chunk.js +0 -1
  166. package/build/api-tokens-edit-page.bce5050f.chunk.js +0 -1
  167. package/build/api-tokens-list-page.93f24348.chunk.js +0 -16
  168. package/build/audit-logs-settings-page.7be97e82.chunk.js +0 -1
  169. package/build/content-manager.4480ae88.chunk.js +0 -1137
  170. package/build/content-type-builder-list-view.cf38fe2f.chunk.js +0 -191
  171. package/build/content-type-builder-translation-en-json.7961593e.chunk.js +0 -1
  172. package/build/content-type-builder.af9abf1e.chunk.js +0 -126
  173. package/build/email-settings-page.4bdbef9a.chunk.js +0 -3
  174. package/build/en-json.697b4bcf.chunk.js +0 -1
  175. package/build/i18n-settings-page.2bb5be96.chunk.js +0 -1
  176. package/build/main.af8c0f31.js +0 -3790
  177. package/build/review-workflows-settings.7a7dc773.chunk.js +0 -57
  178. package/build/ru-json.6a01cea6.chunk.js +0 -1
  179. package/build/sso-settings-page.272b87c8.chunk.js +0 -1
  180. package/build/transfer-tokens-create-page.a1f14bb1.chunk.js +0 -1
  181. package/build/transfer-tokens-edit-page.00ee1c74.chunk.js +0 -1
  182. package/build/transfer-tokens-list-page.ce37354b.chunk.js +0 -16
  183. package/build/upload-settings.0875e973.chunk.js +0 -1
  184. package/build/upload.c7da1611.chunk.js +0 -13
  185. package/build/users-advanced-settings-page.1d3c14c7.chunk.js +0 -1
  186. package/build/users-email-settings-page.e8db68c4.chunk.js +0 -1
  187. package/build/users-providers-settings-page.14cac425.chunk.js +0 -1
  188. package/build/users-roles-settings-page.2ea4de84.chunk.js +0 -30
  189. package/build/webhook-edit-page.329141a5.chunk.js +0 -23
  190. package/build/webhook-list-page.029957a4.chunk.js +0 -1
  191. package/ee/server/migrations/review-workflows.js +0 -39
  192. package/ee/server/utils/test.js +0 -11
  193. /package/admin/src/{content-manager/components/InputUID/useDebounce.js → hooks/useDebounce/index.js} +0 -0
@@ -1,49 +1,141 @@
1
1
  'use strict';
2
2
 
3
+ const { differenceWith, isEqual } = require('lodash/fp');
4
+
3
5
  /**
4
- * Finds all tables in the database that start with a prefix
5
- * @param {string} prefix
6
- * @returns {Array}
6
+ * Transform table name to the object format
7
+ * @param {Array<string|{ table: string; dependsOn?: Array<{ table: string;}> }>} table
8
+ * @returns Array<{ table: string; dependsOn?: Array<{ table: string;}> }>
7
9
  */
8
- const findTablesThatStartWithPrefix = async (prefix) => {
9
- const tables = await strapi.db.dialect.schemaInspector.getTables();
10
- return tables.filter((tableName) => tableName.startsWith(prefix));
10
+ const transformTableName = (table) => {
11
+ if (typeof table === 'string') {
12
+ return { name: table };
13
+ }
14
+ return table;
11
15
  };
12
16
 
13
17
  /**
14
- * Get all reserved table names from the core store
15
- * @returns {Array}
18
+ * Finds all tables in the database matching the regular expression
19
+ * @param {Object} ctx
20
+ * @param {Strapi} ctx.strapi
21
+ * @param {RegExp} regex
22
+ * @returns {Promise<string[]>}
16
23
  */
17
- const getPersistedTables = async () =>
18
- (await strapi.store.get({
24
+ async function findTables({ strapi }, regex) {
25
+ const tables = await strapi.db.dialect.schemaInspector.getTables();
26
+ return tables.filter((tableName) => regex.test(tableName));
27
+ }
28
+
29
+ /**
30
+ * Add tables name to the reserved tables in core store
31
+ * @param {Object} ctx
32
+ * @param {Strapi} ctx.strapi
33
+ * @param {Array<string|{ table: string; dependsOn?: Array<{ table: string;}> }>} tableNames
34
+ * @return {Promise<void>}
35
+ */
36
+ async function addPersistTables({ strapi }, tableNames) {
37
+ const persistedTables = await getPersistedTables({ strapi });
38
+ const tables = tableNames.map(transformTableName);
39
+
40
+ // Get new tables to be persisted, remove tables if they already were persisted
41
+ const notPersistedTableNames = differenceWith(isEqual, tables, persistedTables);
42
+ // Remove tables that are going to be changed
43
+ const tablesToPersist = differenceWith(
44
+ (t1, t2) => t1.name === t2.name,
45
+ persistedTables,
46
+ notPersistedTableNames
47
+ );
48
+
49
+ if (!notPersistedTableNames.length) {
50
+ return;
51
+ }
52
+
53
+ tablesToPersist.push(...notPersistedTableNames);
54
+ await strapi.store.set({
19
55
  type: 'core',
20
56
  key: 'persisted_tables',
21
- })) ?? [];
57
+ value: tablesToPersist,
58
+ });
59
+ }
22
60
 
23
61
  /**
24
- * Add all table names that start with a prefix to the reserved tables in
25
- * core store
26
- * @param {string} tableNamePrefix
62
+ * Remove tables name from the reserved tables in core store
63
+ * @param {Object} ctx
64
+ * @param {Strapi} ctx.strapi
65
+ * @param {Array<string>} tableNames
66
+ * @return {Promise<void>}
27
67
  */
68
+ async function removePersistedTables({ strapi }, tableNames) {
69
+ const persistedTables = await getPersistedTables({ strapi });
28
70
 
29
- const persistTablesWithPrefix = async (tableNamePrefix) => {
30
- const persistedTables = await getPersistedTables();
31
- const tableNames = await findTablesThatStartWithPrefix(tableNamePrefix);
32
- const notReservedTableNames = tableNames.filter((name) => !persistedTables.includes(name));
71
+ // Get new tables to be persisted, remove tables if they already were persisted
72
+ const newPersistedTables = differenceWith(
73
+ (t1, t2) => t1.name === t2,
74
+ persistedTables,
75
+ tableNames
76
+ );
33
77
 
34
- if (!notReservedTableNames.length) {
78
+ if (newPersistedTables.length === persistedTables.length) {
35
79
  return;
36
80
  }
37
81
 
38
- persistedTables.push(...notReservedTableNames);
39
82
  await strapi.store.set({
40
83
  type: 'core',
41
84
  key: 'persisted_tables',
42
- value: persistedTables,
85
+ value: newPersistedTables,
43
86
  });
87
+ }
88
+
89
+ /**
90
+ * Get all reserved table names from the core store
91
+ * @param {Object} ctx
92
+ * @param {Strapi} ctx.strapi
93
+ * @returns {Promise<string[]>}
94
+ */
95
+
96
+ async function getPersistedTables({ strapi }) {
97
+ const persistedTables = await strapi.store.get({
98
+ type: 'core',
99
+ key: 'persisted_tables',
100
+ });
101
+
102
+ return (persistedTables || []).map(transformTableName);
103
+ }
104
+
105
+ /**
106
+ * Add all table names that start with a prefix to the reserved tables in
107
+ * core store
108
+ * @param {string} tableNamePrefix
109
+ * @return {Promise<void>}
110
+ */
111
+
112
+ const persistTablesWithPrefix = async (tableNamePrefix) => {
113
+ const tableNameRegex = new RegExp(`^${tableNamePrefix}.*`);
114
+ const tableNames = await findTables({ strapi }, tableNameRegex);
115
+
116
+ await addPersistTables({ strapi }, tableNames);
117
+ };
118
+
119
+ /**
120
+ * Remove all table names that end with a suffix from the reserved tables in core store
121
+ * @param {string} tableNameSuffix
122
+ * @return {Promise<void>}
123
+ */
124
+ const removePersistedTablesWithSuffix = async (tableNameSuffix) => {
125
+ const tableNameRegex = new RegExp(`.*${tableNameSuffix}$`);
126
+ const tableNames = await findTables({ strapi }, tableNameRegex);
127
+ await removePersistedTables({ strapi }, tableNames);
128
+ };
129
+
130
+ const persistTable = async (tableName, dependsOn) => {
131
+ await addPersistTables({ strapi }, [
132
+ { name: tableName, dependsOn: dependsOn?.map((depTableName) => ({ name: depTableName })) },
133
+ ]);
44
134
  };
45
135
 
46
136
  module.exports = {
47
137
  persistTablesWithPrefix,
48
- findTablesThatStartWithPrefix,
138
+ removePersistedTablesWithSuffix,
139
+ persistTable,
140
+ findTables,
49
141
  };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const { get, keys, pickBy, pipe } = require('lodash/fp');
3
4
  const { WORKFLOW_MODEL_UID } = require('../constants/workflows');
4
5
 
5
6
  /**
@@ -19,7 +20,15 @@ function hasReviewWorkflow({ strapi }, contentType) {
19
20
  const getDefaultWorkflow = async ({ strapi }) =>
20
21
  strapi.query(WORKFLOW_MODEL_UID).findOne({ populate: ['stages'] });
21
22
 
23
+ const getContentTypeUIDsWithActivatedReviewWorkflows = pipe([
24
+ // Pick only content-types with reviewWorkflows options set to true
25
+ pickBy(get('options.reviewWorkflows')),
26
+ // Get UIDs
27
+ keys,
28
+ ]);
29
+
22
30
  module.exports = {
23
31
  hasReviewWorkflow,
24
32
  getDefaultWorkflow,
33
+ getContentTypeUIDsWithActivatedReviewWorkflows,
25
34
  };
@@ -1,11 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const baseConfig = require('../../../jest.base-config.front');
4
- const pkg = require('./package.json');
5
-
6
3
  module.exports = {
7
- ...baseConfig,
8
- displayName: (pkg.strapi && pkg.strapi.name) || pkg.name,
9
- roots: [__dirname],
4
+ preset: '../../../jest-preset.front.js',
10
5
  collectCoverageFrom: ['<rootDir>/packages/core/admin/admin/**/*.js'],
11
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "4.10.0-beta.0",
3
+ "version": "4.10.0-beta.1",
4
4
  "description": "Strapi Admin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,14 +28,16 @@
28
28
  "develop:webpack": "cross-env NODE_ENV=development webpack serve --config webpack.config.dev.js --progress profile",
29
29
  "prepublishOnly": "yarn build",
30
30
  "build": "rimraf build && node ./scripts/build.js",
31
- "build:mesure": "rimraf build && cross-env MESURE_BUILD_SPEED=true node ./scripts/build.js",
31
+ "build:measure": "rimraf build && cross-env MEASURE_BUILD_SPEED=true node ./scripts/build.js",
32
32
  "test": "echo \"no tests yet\"",
33
- "test:unit": "jest --verbose",
34
- "test:front": "cross-env IS_EE=true jest --config ./jest.config.front.js",
35
- "test:front:watch": "cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
36
- "test:front:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js",
37
- "test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
38
- "test:front:ce:cov": "cross-env IS_EE=false jest --config ./jest.config.front.js --coverage"
33
+ "test:unit": "run -T jest",
34
+ "test:unit:watch": "run -T jest --watch",
35
+ "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
36
+ "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
37
+ "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
38
+ "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
39
+ "test:front:ce:cov": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --coverage",
40
+ "lint": "run -T eslint ."
39
41
  },
40
42
  "dependencies": {
41
43
  "@babel/core": "^7.20.12",
@@ -46,19 +48,20 @@
46
48
  "@casl/ability": "^5.4.3",
47
49
  "@fingerprintjs/fingerprintjs": "3.3.6",
48
50
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
49
- "@strapi/babel-plugin-switch-ee-ce": "4.10.0-beta.0",
50
- "@strapi/data-transfer": "4.10.0-beta.0",
51
+ "@strapi/babel-plugin-switch-ee-ce": "4.10.0-beta.1",
52
+ "@strapi/data-transfer": "4.10.0-beta.1",
51
53
  "@strapi/design-system": "1.6.6",
52
- "@strapi/helper-plugin": "4.10.0-beta.0",
54
+ "@strapi/helper-plugin": "4.10.0-beta.1",
53
55
  "@strapi/icons": "1.6.6",
54
- "@strapi/permissions": "4.10.0-beta.0",
55
- "@strapi/provider-audit-logs-local": "4.10.0-beta.0",
56
- "@strapi/typescript-utils": "4.10.0-beta.0",
57
- "@strapi/utils": "4.10.0-beta.0",
56
+ "@strapi/permissions": "4.10.0-beta.1",
57
+ "@strapi/provider-audit-logs-local": "4.10.0-beta.1",
58
+ "@strapi/typescript-utils": "4.10.0-beta.1",
59
+ "@strapi/utils": "4.10.0-beta.1",
58
60
  "axios": "1.3.4",
59
61
  "babel-loader": "^9.1.2",
60
62
  "babel-plugin-styled-components": "2.0.2",
61
63
  "bcryptjs": "2.4.3",
64
+ "browserslist": "^4.17.3",
62
65
  "browserslist-to-esbuild": "1.2.0",
63
66
  "chalk": "^4.1.2",
64
67
  "chokidar": "^3.5.1",
@@ -99,18 +102,17 @@
99
102
  "markdown-it-mark": "^3.0.1",
100
103
  "markdown-it-sub": "^1.0.0",
101
104
  "markdown-it-sup": "1.0.0",
102
- "match-sorter": "^4.0.2",
103
105
  "mini-css-extract-plugin": "2.7.2",
104
106
  "node-schedule": "2.1.0",
105
107
  "p-map": "4.0.0",
106
108
  "passport-local": "1.0.0",
107
109
  "pluralize": "8.0.0",
108
110
  "prop-types": "^15.7.2",
109
- "qs": "6.11.0",
111
+ "qs": "6.11.1",
110
112
  "react": "^17.0.2",
111
113
  "react-copy-to-clipboard": "^5.1.0",
112
114
  "react-dnd": "15.1.2",
113
- "react-dnd-html5-backend": "15.1.2",
115
+ "react-dnd-html5-backend": "15.1.3",
114
116
  "react-dom": "^17.0.2",
115
117
  "react-error-boundary": "3.1.4",
116
118
  "react-fast-compare": "^3.2.0",
@@ -122,13 +124,13 @@
122
124
  "react-refresh": "0.14.0",
123
125
  "react-router-dom": "5.3.4",
124
126
  "react-select": "5.7.0",
125
- "react-window": "1.8.7",
127
+ "react-window": "1.8.8",
126
128
  "redux": "^4.2.1",
127
129
  "reselect": "^4.1.7",
128
130
  "rimraf": "3.0.2",
129
- "sanitize-html": "2.7.3",
131
+ "sanitize-html": "2.10.0",
130
132
  "semver": "7.3.8",
131
- "sift": "16.0.0",
133
+ "sift": "16.0.1",
132
134
  "style-loader": "3.3.1",
133
135
  "styled-components": "5.3.3",
134
136
  "typescript": "4.6.2",
@@ -166,5 +168,5 @@
166
168
  }
167
169
  }
168
170
  },
169
- "gitHead": "1519ef0e56d27b738f24fc88223797651ad47aaf"
171
+ "gitHead": "95d581b31bee464af42e5d8db408fa578d8532c7"
170
172
  }
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { createTransferHandler } = require('@strapi/data-transfer').strapi.remote.handlers;
3
+ const { createPushController, createPullController } =
4
+ require('@strapi/data-transfer').strapi.remote.handlers;
4
5
  const {
5
6
  errors: { UnauthorizedError },
6
7
  } = require('@strapi/utils');
@@ -22,5 +23,6 @@ const verify = async (ctx, scope) => {
22
23
  };
23
24
 
24
25
  module.exports = {
25
- connect: createTransferHandler({ verify }),
26
+ push: createPushController({ verify }),
27
+ pull: createPullController({ verify }),
26
28
  };
@@ -13,7 +13,10 @@ module.exports = () => async (ctx, next) => {
13
13
 
14
14
  if (!hasValidTokenSalt()) {
15
15
  return ctx.notImplemented(
16
- 'The server configuration for data transfer is invalid. Please contact your server administrator.'
16
+ 'The server configuration for data transfer is invalid. Please contact your server administrator.',
17
+ {
18
+ code: 'INVALID_TOKEN_SALT',
19
+ }
17
20
  );
18
21
  }
19
22
 
@@ -3,17 +3,26 @@
3
3
  const dataTransferAuthStrategy = require('../strategies/data-transfer');
4
4
 
5
5
  module.exports = [
6
- // Transfer route
6
+ // Transfer Push
7
7
  {
8
8
  method: 'GET',
9
- path: '/transfer/runner/connect',
10
- handler: 'transfer.runner-connect',
9
+ path: '/transfer/runner/push',
10
+ handler: 'transfer.runner-push',
11
11
  config: {
12
12
  middlewares: ['admin::data-transfer'],
13
- // TODO: Allow not passing any scope <> Add a way to prevent assigning one by default
14
13
  auth: { strategies: [dataTransferAuthStrategy], scope: ['push'] },
15
14
  },
16
15
  },
16
+ // Transfer Pull
17
+ {
18
+ method: 'GET',
19
+ path: '/transfer/runner/pull',
20
+ handler: 'transfer.runner-pull',
21
+ config: {
22
+ middlewares: ['admin::data-transfer'],
23
+ auth: { strategies: [dataTransferAuthStrategy], scope: ['pull'] },
24
+ },
25
+ },
17
26
  // Transfer Tokens
18
27
  {
19
28
  method: 'POST',
@@ -24,6 +24,10 @@ module.exports = {
24
24
  DAYS_30: 30 * DAY_IN_MS,
25
25
  DAYS_90: 90 * DAY_IN_MS,
26
26
  },
27
+ TRANSFER_TOKEN_TYPE: {
28
+ PUSH: 'push',
29
+ PULL: 'pull',
30
+ },
27
31
  TRANSFER_TOKEN_LIFESPANS: {
28
32
  UNLIMITED: null,
29
33
  DAYS_7: 7 * DAY_IN_MS,
@@ -3,7 +3,7 @@
3
3
  const permissions = require('@strapi/permissions');
4
4
  const { providerFactory } = require('@strapi/utils');
5
5
 
6
- const DEFAULT_TRANSFER_ACTIONS = ['push'];
6
+ const DEFAULT_TRANSFER_ACTIONS = ['push', 'pull'];
7
7
 
8
8
  const providers = {
9
9
  action: providerFactory(),
@@ -149,37 +149,39 @@ const update = async (id, attributes) => {
149
149
  },
150
150
  });
151
151
 
152
- const currentPermissionsResult = await strapi.entityService.load(
153
- TRANSFER_TOKEN_UID,
154
- updatedToken,
155
- 'permissions'
156
- );
157
-
158
- const currentPermissions = map('action', currentPermissionsResult || []);
159
- const newPermissions = uniq(attributes.permissions);
160
-
161
- const actionsToDelete = difference(currentPermissions, newPermissions);
162
- const actionsToAdd = difference(newPermissions, currentPermissions);
163
-
164
- // TODO: improve efficiency here
165
- // method using a loop -- works but very inefficient
166
- await Promise.all(
167
- actionsToDelete.map((action) =>
168
- strapi.query(TRANSFER_TOKEN_PERMISSION_UID).delete({
169
- where: { action, token: id },
170
- })
171
- )
172
- );
173
-
174
- // TODO: improve efficiency here
175
- // using a loop -- works but very inefficient
176
- await Promise.all(
177
- actionsToAdd.map((action) =>
178
- strapi.query(TRANSFER_TOKEN_PERMISSION_UID).create({
179
- data: { action, token: id },
180
- })
181
- )
182
- );
152
+ if (attributes.permissions) {
153
+ const currentPermissionsResult = await strapi.entityService.load(
154
+ TRANSFER_TOKEN_UID,
155
+ updatedToken,
156
+ 'permissions'
157
+ );
158
+
159
+ const currentPermissions = map('action', currentPermissionsResult || []);
160
+ const newPermissions = uniq(attributes.permissions);
161
+
162
+ const actionsToDelete = difference(currentPermissions, newPermissions);
163
+ const actionsToAdd = difference(newPermissions, currentPermissions);
164
+
165
+ // TODO: improve efficiency here
166
+ // method using a loop -- works but very inefficient
167
+ await Promise.all(
168
+ actionsToDelete.map((action) =>
169
+ strapi.query(TRANSFER_TOKEN_PERMISSION_UID).delete({
170
+ where: { action, token: id },
171
+ })
172
+ )
173
+ );
174
+
175
+ // TODO: improve efficiency here
176
+ // using a loop -- works but very inefficient
177
+ await Promise.all(
178
+ actionsToAdd.map((action) =>
179
+ strapi.query(TRANSFER_TOKEN_PERMISSION_UID).create({
180
+ data: { action, token: id },
181
+ })
182
+ )
183
+ );
184
+ }
183
185
 
184
186
  // retrieve permissions
185
187
  const permissionsFromDb = await strapi.entityService.load(
@@ -8,7 +8,11 @@ const transferTokenCreationSchema = yup
8
8
  .shape({
9
9
  name: yup.string().min(1).required(),
10
10
  description: yup.string().optional(),
11
- permissions: yup.array().of(yup.string()).nullable(),
11
+ permissions: yup
12
+ .array()
13
+ .min(1)
14
+ .of(yup.string().oneOf(Object.values(constants.TRANSFER_TOKEN_TYPE)))
15
+ .required(),
12
16
  lifespan: yup
13
17
  .number()
14
18
  .min(1)
@@ -23,7 +27,11 @@ const transferTokenUpdateSchema = yup
23
27
  .shape({
24
28
  name: yup.string().min(1).notNull(),
25
29
  description: yup.string().nullable(),
26
- permissions: yup.array().of(yup.string()).nullable(),
30
+ permissions: yup
31
+ .array()
32
+ .min(1)
33
+ .of(yup.string().oneOf(Object.values(constants.TRANSFER_TOKEN_TYPE)))
34
+ .nullable(),
27
35
  })
28
36
  .noUnknown()
29
37
  .strict();
package/webpack.config.js CHANGED
@@ -9,6 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
9
9
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
10
10
  const WebpackBar = require('webpackbar');
11
11
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
12
+ const browserslist = require('browserslist');
12
13
  const browserslistToEsbuild = require('browserslist-to-esbuild');
13
14
 
14
15
  const alias = require('./webpack.alias');
@@ -52,7 +53,10 @@ module.exports = ({
52
53
 
53
54
  const excludeRegex = createPluginsExcludePath(pluginsPath);
54
55
 
55
- const buildTarget = browserslistToEsbuild();
56
+ // Ensure we use the config in this directory, even if run with a different
57
+ // working directory
58
+ const browserslistConfig = browserslist.loadConfig({ path: __dirname });
59
+ const buildTarget = browserslistToEsbuild(browserslistConfig);
56
60
 
57
61
  return {
58
62
  mode: isProduction ? 'production' : 'development',
@@ -221,7 +225,7 @@ module.exports = ({
221
225
  alias,
222
226
  symlinks: false,
223
227
  extensions: ['.js', '.jsx', '.react.js', '.ts', '.tsx'],
224
- mainFields: ['browser', 'jsnext:main', 'main'],
228
+ mainFields: ['browser', 'module', 'jsnext:main', 'main'],
225
229
  modules: ['node_modules', path.resolve(__dirname, 'node_modules')],
226
230
  },
227
231
  plugins: [
@@ -1 +0,0 @@
1
- export * from './ReviewWorkflowsStage';
@@ -1 +0,0 @@
1
- export { default as matchByTitle } from './matchByTitle';
@@ -1,24 +0,0 @@
1
- import matchSorter from 'match-sorter';
2
- import camelCase from 'lodash/camelCase';
3
-
4
- /**
5
- * @type {(links: array, search? : string) => array }
6
- */
7
- const matchByTitle = (links, search) =>
8
- search
9
- ? matchSorter(links, search.toLowerCase(), { keys: [(item) => item.title.toLowerCase()] })
10
- : links.sort((link, nextLink) => {
11
- const title = camelCase(link.title);
12
- const nextTitle = camelCase(nextLink.title);
13
-
14
- if (title < nextTitle) {
15
- return -1;
16
- }
17
- if (title > nextTitle) {
18
- return 1;
19
- }
20
-
21
- return 0;
22
- });
23
-
24
- export default matchByTitle;