@strapi/admin 4.2.0-beta.3 → 4.3.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 (177) hide show
  1. package/admin/src/components/ConfigurationsProvider/index.js +51 -0
  2. package/admin/src/components/ConfigurationsProvider/reducer.js +28 -0
  3. package/admin/src/components/LeftMenu/index.js +12 -2
  4. package/admin/src/components/Providers/index.js +8 -4
  5. package/admin/src/components/UnauthenticatedLogo/index.js +4 -2
  6. package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +3 -3
  7. package/admin/src/content-manager/components/SelectMany/index.js +2 -4
  8. package/admin/src/content-manager/components/SelectWrapper/index.js +1 -13
  9. package/admin/src/hooks/useFetchMarketplaceProviders/index.js +23 -0
  10. package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +11 -0
  11. package/admin/src/pages/App/index.js +7 -2
  12. package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch/EmptyPluginGrid.js → EmptyNpmPackageSearch/EmptyNpmPackageGrid.js} +1 -1
  13. package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch → EmptyNpmPackageSearch}/index.js +6 -4
  14. package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/InstallPluginButton.js +0 -0
  15. package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/index.js +22 -10
  16. package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +42 -0
  17. package/admin/src/pages/MarketplacePage/components/PageHeader/index.js +12 -5
  18. package/admin/src/pages/MarketplacePage/index.js +99 -37
  19. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/index.js +85 -0
  20. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/init.js +13 -0
  21. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/reducer.js +43 -0
  22. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoInput/index.js +118 -0
  23. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoInput/reducer.js +28 -0
  24. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoInput/stepper.js +25 -0
  25. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/AddLogoDialog.js +67 -0
  26. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromComputerForm.js +176 -0
  27. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromUrlForm.js +86 -0
  28. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/ImageCardAsset.js +51 -0
  29. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/PendingLogoDialog.js +97 -0
  30. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/index.js +85 -0
  31. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/reducer.js +28 -0
  32. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +153 -91
  33. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +16 -0
  34. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/constants.js +3 -0
  35. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/getFormData.js +17 -0
  36. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/parseFileMetadatas.js +76 -0
  37. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +17 -0
  38. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/urlToFile.js +21 -0
  39. package/admin/src/translations/en.json +33 -3
  40. package/admin/src/translations/pl.json +264 -12
  41. package/admin/src/translations/vi.json +17 -17
  42. package/admin/src/tsconfig.json +1 -1
  43. package/build/1820.ca954075.chunk.js +503 -0
  44. package/build/1856.6a94980b.chunk.js +172 -0
  45. package/build/20.9e5a98b6.chunk.js +308 -0
  46. package/build/2077.5456ccd1.chunk.js +194 -0
  47. package/build/3531.231e0eb6.chunk.js +10 -0
  48. package/build/{4073.41ac1235.chunk.js → 4073.e144a91a.chunk.js} +1 -1
  49. package/build/413.d5986568.chunk.js +284 -0
  50. package/build/4715.4588fdf5.chunk.js +385 -0
  51. package/build/{210.014495c1.chunk.js → 472.d43be8bb.chunk.js} +58 -58
  52. package/build/4800.d3ebc81d.chunk.js +1 -0
  53. package/build/5250.24040688.chunk.js +11 -0
  54. package/build/6229.53b33cf0.chunk.js +194 -0
  55. package/build/7418.6db737ce.chunk.js +112 -0
  56. package/build/8773.54a26ded.chunk.js +327 -0
  57. package/build/9066.2847fdff.chunk.js +101 -0
  58. package/build/9262.25aa12a5.chunk.js +1 -0
  59. package/build/9420.ba035f29.chunk.js +508 -0
  60. package/build/Admin-authenticatedApp.52f3c150.chunk.js +80 -0
  61. package/build/{Admin_homePage.f157e33e.chunk.js → Admin_homePage.0ac648e8.chunk.js} +2 -2
  62. package/build/Admin_marketplace.71c66b49.chunk.js +11 -0
  63. package/build/{Admin_profilePage.62c203ad.chunk.js → Admin_profilePage.27191ed2.chunk.js} +1 -1
  64. package/build/Admin_settingsPage.021da806.chunk.js +178 -0
  65. package/build/{admin-edit-roles-page.94e1403b.chunk.js → admin-edit-roles-page.fb374555.chunk.js} +1 -1
  66. package/build/admin-edit-users.a360deaf.chunk.js +10 -0
  67. package/build/admin-users.47d06d24.chunk.js +11 -0
  68. package/build/api-tokens-create-page.698f132d.chunk.js +1 -0
  69. package/build/api-tokens-edit-page.afece2fe.chunk.js +1 -0
  70. package/build/{api-tokens-list-page.340750a6.chunk.js → api-tokens-list-page.46d96dee.chunk.js} +1 -1
  71. package/build/content-manager.afcc3624.chunk.js +1182 -0
  72. package/build/email-settings-page.8871dfe8.chunk.js +103 -0
  73. package/build/en-json.0a5ba154.chunk.js +1 -0
  74. package/build/i18n-settings-page.dfb4eb01.chunk.js +101 -0
  75. package/build/index.html +1 -1
  76. package/build/main.ca3856ed.js +8640 -0
  77. package/build/pl-json.f65302c2.chunk.js +1 -0
  78. package/build/{runtime~main.e7611418.js → runtime~main.48a46dd2.js} +1 -1
  79. package/build/{sso-settings-page.e9034e22.chunk.js → sso-settings-page.dfb0b917.chunk.js} +1 -1
  80. package/build/upload-settings.8d8c672a.chunk.js +101 -0
  81. package/build/upload-translation-de-json.745613c0.chunk.js +1 -0
  82. package/build/upload-translation-dk-json.cb25dcf0.chunk.js +1 -0
  83. package/build/upload-translation-en-json.e78688a0.chunk.js +1 -0
  84. package/build/upload-translation-es-json.1f344b53.chunk.js +1 -0
  85. package/build/upload-translation-fr-json.e21c0c7a.chunk.js +1 -0
  86. package/build/upload-translation-he-json.4ce77b7b.chunk.js +1 -0
  87. package/build/upload-translation-it-json.5ce11e0b.chunk.js +1 -0
  88. package/build/upload-translation-ja-json.22afae44.chunk.js +1 -0
  89. package/build/upload-translation-ko-json.9a2c21cb.chunk.js +1 -0
  90. package/build/upload-translation-ms-json.0605d6da.chunk.js +1 -0
  91. package/build/upload-translation-pl-json.e534b676.chunk.js +1 -0
  92. package/build/upload-translation-pt-BR-json.95686cfb.chunk.js +1 -0
  93. package/build/upload-translation-ru-json.37bd1546.chunk.js +1 -0
  94. package/build/upload-translation-sk-json.b03d4904.chunk.js +1 -0
  95. package/build/upload-translation-th-json.64dd70ce.chunk.js +1 -0
  96. package/build/upload-translation-uk-json.1328cb3e.chunk.js +1 -0
  97. package/build/{upload-translation-zh-Hans-json.c9622577.chunk.js → upload-translation-zh-Hans-json.6832ff81.chunk.js} +1 -1
  98. package/build/upload-translation-zh-json.ee8fba96.chunk.js +1 -0
  99. package/build/upload.5622b777.chunk.js +7 -0
  100. package/build/users-advanced-settings-page.4af9e241.chunk.js +101 -0
  101. package/build/users-email-settings-page.d69c0d87.chunk.js +101 -0
  102. package/build/users-providers-settings-page.fc1fda6d.chunk.js +101 -0
  103. package/build/vi-json.bf3424be.chunk.js +1 -0
  104. package/build/webhook-edit-page.a7ae6e3b.chunk.js +23 -0
  105. package/build/webhook-list-page.057f396c.chunk.js +133 -0
  106. package/index.js +2 -8
  107. package/package.json +10 -9
  108. package/scripts/build.js +3 -1
  109. package/server/config/admin-actions.js +14 -0
  110. package/server/controllers/admin.js +40 -2
  111. package/server/routes/admin.js +28 -1
  112. package/server/services/index.js +1 -0
  113. package/server/services/project-settings.js +173 -0
  114. package/server/utils/index.d.ts +2 -0
  115. package/server/validation/project-settings.js +39 -0
  116. package/utils/create-cache-dir.js +6 -36
  117. package/utils/get-custom-app-config-file.js +7 -2
  118. package/utils/get-plugins-path.js +1 -1
  119. package/admin/src/content-manager/components/SelectWrapper/ClearIndicator.js +0 -18
  120. package/admin/src/content-manager/components/SelectWrapper/DropdownIndicator.js +0 -24
  121. package/admin/src/content-manager/components/SelectWrapper/IconBox.js +0 -20
  122. package/admin/src/content-manager/components/SelectWrapper/IndicatorSeparator.js +0 -3
  123. package/admin/src/content-manager/components/SelectWrapper/utils/getSelectStyles.js +0 -92
  124. package/build/1709.ceed0e18.chunk.js +0 -503
  125. package/build/1856.521a99fd.chunk.js +0 -172
  126. package/build/20.cf744c35.chunk.js +0 -308
  127. package/build/2077.51485bfb.chunk.js +0 -194
  128. package/build/2135.95ee6de1.chunk.js +0 -162
  129. package/build/2524.688d0355.chunk.js +0 -1
  130. package/build/2912.79c2b3c8.chunk.js +0 -253
  131. package/build/4715.77e04177.chunk.js +0 -385
  132. package/build/4761.3eabdf46.chunk.js +0 -101
  133. package/build/6229.a5cca9f2.chunk.js +0 -194
  134. package/build/6281.f10a7e3a.chunk.js +0 -1
  135. package/build/7009.79fce86d.chunk.js +0 -164
  136. package/build/7191.3bde3cbf.chunk.js +0 -335
  137. package/build/7841.f0e7d629.chunk.js +0 -253
  138. package/build/7863.bc7a8f3a.chunk.js +0 -112
  139. package/build/9420.cb0b75e8.chunk.js +0 -508
  140. package/build/Admin-authenticatedApp.4ce8d292.chunk.js +0 -80
  141. package/build/Admin_marketplace.1e3393c9.chunk.js +0 -11
  142. package/build/Admin_settingsPage.924a7816.chunk.js +0 -170
  143. package/build/admin-edit-users.6c2bf718.chunk.js +0 -10
  144. package/build/admin-users.e03db115.chunk.js +0 -11
  145. package/build/api-tokens-create-page.787ab302.chunk.js +0 -1
  146. package/build/api-tokens-edit-page.e4010c0c.chunk.js +0 -1
  147. package/build/content-manager.6cdcfb6e.chunk.js +0 -1204
  148. package/build/email-settings-page.f67d13b2.chunk.js +0 -103
  149. package/build/en-json.3e1a222e.chunk.js +0 -1
  150. package/build/i18n-settings-page.6b67cb75.chunk.js +0 -101
  151. package/build/main.45472ea9.js +0 -8404
  152. package/build/pl-json.94f05d2c.chunk.js +0 -1
  153. package/build/upload-settings.3db55de0.chunk.js +0 -101
  154. package/build/upload-translation-de-json.b642da08.chunk.js +0 -1
  155. package/build/upload-translation-dk-json.fc61df13.chunk.js +0 -1
  156. package/build/upload-translation-en-json.59269508.chunk.js +0 -1
  157. package/build/upload-translation-es-json.8ec935ef.chunk.js +0 -1
  158. package/build/upload-translation-fr-json.eb9b4f84.chunk.js +0 -1
  159. package/build/upload-translation-he-json.c226f2dc.chunk.js +0 -1
  160. package/build/upload-translation-it-json.8e58456e.chunk.js +0 -1
  161. package/build/upload-translation-ja-json.1378a2e7.chunk.js +0 -1
  162. package/build/upload-translation-ko-json.5e06e112.chunk.js +0 -1
  163. package/build/upload-translation-ms-json.dc3bf0d7.chunk.js +0 -1
  164. package/build/upload-translation-pl-json.6071e38c.chunk.js +0 -1
  165. package/build/upload-translation-pt-BR-json.7e8d9550.chunk.js +0 -1
  166. package/build/upload-translation-ru-json.da2529f3.chunk.js +0 -1
  167. package/build/upload-translation-sk-json.bfdf4f09.chunk.js +0 -1
  168. package/build/upload-translation-th-json.6a48b826.chunk.js +0 -1
  169. package/build/upload-translation-uk-json.6fb09148.chunk.js +0 -1
  170. package/build/upload-translation-zh-json.711f804b.chunk.js +0 -1
  171. package/build/upload.070c189b.chunk.js +0 -105
  172. package/build/users-advanced-settings-page.a23cda17.chunk.js +0 -101
  173. package/build/users-email-settings-page.0a096388.chunk.js +0 -1
  174. package/build/users-providers-settings-page.bfe7755a.chunk.js +0 -1
  175. package/build/vi-json.3d14e91e.chunk.js +0 -1
  176. package/build/webhook-edit-page.2fa94db3.chunk.js +0 -23
  177. package/build/webhook-list-page.b594db49.chunk.js +0 -133
@@ -7,6 +7,34 @@ module.exports = [
7
7
  handler: 'admin.init',
8
8
  config: { auth: false },
9
9
  },
10
+ {
11
+ method: 'GET',
12
+ path: '/project-settings',
13
+ handler: 'admin.getProjectSettings',
14
+ config: {
15
+ policies: [
16
+ 'admin::isAuthenticatedAdmin',
17
+ {
18
+ name: 'admin::hasPermissions',
19
+ config: { actions: ['admin::project-settings.read'] },
20
+ },
21
+ ],
22
+ },
23
+ },
24
+ {
25
+ method: 'POST',
26
+ path: '/project-settings',
27
+ handler: 'admin.updateProjectSettings',
28
+ config: {
29
+ policies: [
30
+ 'admin::isAuthenticatedAdmin',
31
+ {
32
+ name: 'admin::hasPermissions',
33
+ config: { actions: ['admin::project-settings.update'] },
34
+ },
35
+ ],
36
+ },
37
+ },
10
38
  {
11
39
  method: 'GET',
12
40
  path: '/project-type',
@@ -27,7 +55,6 @@ module.exports = [
27
55
  handler: 'admin.telemetryProperties',
28
56
  config: {
29
57
  auth: false,
30
- policies: ['admin::isTelemetryEnabled'],
31
58
  },
32
59
  },
33
60
  {
@@ -13,4 +13,5 @@ module.exports = {
13
13
  auth: require('./auth'),
14
14
  action: require('./action'),
15
15
  'api-token': require('./api-token'),
16
+ 'project-settings': require('./project-settings'),
16
17
  };
@@ -0,0 +1,173 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const { pick } = require('lodash');
5
+
6
+ const PROJECT_SETTINGS_FILE_INPUTS = ['menuLogo'];
7
+ const DEFAULT_PROJECT_SETTINGS = {
8
+ menuLogo: null,
9
+ };
10
+
11
+ const parseFilesData = async files => {
12
+ const formatedFilesData = {};
13
+
14
+ await Promise.all(
15
+ PROJECT_SETTINGS_FILE_INPUTS.map(async inputName => {
16
+ const file = files[inputName];
17
+
18
+ // Skip empty file inputs
19
+ if (!file) {
20
+ return;
21
+ }
22
+
23
+ const getStream = () => fs.createReadStream(file.path);
24
+
25
+ // Add formated data for the upload provider
26
+ formatedFilesData[inputName] = strapi
27
+ .plugin('upload')
28
+ .service('upload')
29
+ .formatFileInfo({
30
+ filename: file.name,
31
+ type: file.type,
32
+ size: file.size,
33
+ });
34
+
35
+ // Add image dimensions
36
+ Object.assign(
37
+ formatedFilesData[inputName],
38
+ await strapi
39
+ .plugin('upload')
40
+ .service('image-manipulation')
41
+ .getDimensions({ getStream })
42
+ );
43
+
44
+ // Add file path, and stream
45
+ Object.assign(formatedFilesData[inputName], {
46
+ stream: getStream(),
47
+ tmpPath: file.path,
48
+ provider: strapi.config.get('plugin.upload').provider,
49
+ });
50
+ })
51
+ );
52
+
53
+ return formatedFilesData;
54
+ };
55
+
56
+ const getProjectSettings = async () => {
57
+ const store = strapi.store({ type: 'core', name: 'admin' });
58
+ const projectSettings = {
59
+ ...DEFAULT_PROJECT_SETTINGS,
60
+ ...(await store.get({ key: 'project-settings' })),
61
+ };
62
+
63
+ // Filter file input fields
64
+ PROJECT_SETTINGS_FILE_INPUTS.forEach(inputName => {
65
+ if (!projectSettings[inputName]) {
66
+ return;
67
+ }
68
+
69
+ projectSettings[inputName] = pick(projectSettings[inputName], [
70
+ 'name',
71
+ 'url',
72
+ 'width',
73
+ 'height',
74
+ 'ext',
75
+ 'size',
76
+ ]);
77
+ });
78
+
79
+ return projectSettings;
80
+ };
81
+
82
+ const uploadFiles = async (files = {}) => {
83
+ // Call the provider upload function for each file
84
+ return Promise.all(
85
+ Object.values(files)
86
+ .filter(file => file.stream instanceof fs.ReadStream)
87
+ .map(file => strapi.plugin('upload').provider.uploadStream(file))
88
+ );
89
+ };
90
+
91
+ const deleteOldFiles = async ({ previousSettings, newSettings }) => {
92
+ return Promise.all(
93
+ PROJECT_SETTINGS_FILE_INPUTS.map(async inputName => {
94
+ // Skip if the store doesn't contain project settings
95
+ if (!previousSettings) {
96
+ return;
97
+ }
98
+
99
+ // Skip if there was no previous file
100
+ if (!previousSettings[inputName]) {
101
+ return;
102
+ }
103
+
104
+ // Skip if the file was not changed
105
+ if (
106
+ newSettings[inputName] &&
107
+ previousSettings[inputName].hash === newSettings[inputName].hash
108
+ ) {
109
+ return;
110
+ }
111
+
112
+ // Skip if the file was not uploaded with the current provider
113
+ if (strapi.config.get('plugin.upload').provider !== previousSettings[inputName].provider) {
114
+ return;
115
+ }
116
+
117
+ // There was a previous file and an new file was uploaded
118
+ // Remove the previous file
119
+ strapi.plugin('upload').provider.delete(previousSettings[inputName]);
120
+ })
121
+ );
122
+ };
123
+
124
+ const updateProjectSettings = async newSettings => {
125
+ const store = strapi.store({ type: 'core', name: 'admin' });
126
+ const previousSettings = await store.get({ key: 'project-settings' });
127
+ const files = pick(newSettings, PROJECT_SETTINGS_FILE_INPUTS);
128
+
129
+ await uploadFiles(files);
130
+
131
+ PROJECT_SETTINGS_FILE_INPUTS.forEach(inputName => {
132
+ // If the user input exists but is not a formdata "file" remove it
133
+ if (newSettings[inputName] !== undefined && !(typeof newSettings[inputName] === 'object')) {
134
+ newSettings[inputName] = null;
135
+ return;
136
+ }
137
+
138
+ // If the user input is undefined reuse previous setting (do not update field)
139
+ if (!newSettings[inputName]) {
140
+ newSettings[inputName] = previousSettings[inputName];
141
+ return;
142
+ }
143
+
144
+ // Update the file
145
+ newSettings[inputName] = pick(newSettings[inputName], [
146
+ 'name',
147
+ 'hash',
148
+ 'url',
149
+ 'width',
150
+ 'height',
151
+ 'ext',
152
+ 'size',
153
+ 'provider',
154
+ ]);
155
+ });
156
+
157
+ // No await to proceed asynchronously
158
+ deleteOldFiles({ previousSettings, newSettings });
159
+
160
+ await store.set({
161
+ key: 'project-settings',
162
+ value: { ...previousSettings, ...newSettings },
163
+ });
164
+
165
+ return getProjectSettings();
166
+ };
167
+
168
+ module.exports = {
169
+ deleteOldFiles,
170
+ parseFilesData,
171
+ getProjectSettings,
172
+ updateProjectSettings,
173
+ };
@@ -6,6 +6,7 @@ import * as metrics from '../services/metrics';
6
6
  import * as token from '../services/token';
7
7
  import * as auth from '../services/auth';
8
8
  import * as apiToken from '../services/api-token';
9
+ import * as projectSettings from '../services/project-settings';
9
10
 
10
11
  type S = {
11
12
  role: typeof role;
@@ -16,6 +17,7 @@ type S = {
16
17
  auth: typeof auth;
17
18
  metrics: typeof metrics;
18
19
  'api-token': typeof apiToken;
20
+ 'project-settings': typeof projectSettings;
19
21
  };
20
22
 
21
23
  export function getService<T extends keyof S>(name: T): S[T];
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ const { yup, validateYupSchemaSync } = require('@strapi/utils');
4
+
5
+ const MAX_IMAGE_WIDTH = 750;
6
+ const MAX_IMAGE_HEIGHT = MAX_IMAGE_WIDTH;
7
+ const MAX_IMAGE_FILE_SIZE = 1024 * 1024; // 1Mo
8
+ const ALLOWED_IMAGE_FILE_TYPES = ['image/jpeg', 'image/png', 'image/svg+xml'];
9
+
10
+ const updateProjectSettings = yup
11
+ .object({
12
+ menuLogo: yup.string(),
13
+ })
14
+ .noUnknown();
15
+
16
+ const updateProjectSettingsFiles = yup
17
+ .object({
18
+ menuLogo: yup.object({
19
+ name: yup.string(),
20
+ type: yup.string().oneOf(ALLOWED_IMAGE_FILE_TYPES),
21
+ size: yup.number().max(MAX_IMAGE_FILE_SIZE),
22
+ }),
23
+ })
24
+ .noUnknown();
25
+
26
+ const updateProjectSettingsImagesDimensions = yup.object({
27
+ menuLogo: yup.object({
28
+ width: yup.number().max(MAX_IMAGE_WIDTH),
29
+ height: yup.number().max(MAX_IMAGE_HEIGHT),
30
+ }),
31
+ });
32
+
33
+ module.exports = {
34
+ validateUpdateProjectSettings: validateYupSchemaSync(updateProjectSettings),
35
+ validateUpdateProjectSettingsFiles: validateYupSchemaSync(updateProjectSettingsFiles),
36
+ validateUpdateProjectSettingsImagesDimensions: validateYupSchemaSync(
37
+ updateProjectSettingsImagesDimensions
38
+ ),
39
+ };
@@ -3,7 +3,7 @@
3
3
  const path = require('path');
4
4
  const _ = require('lodash');
5
5
  const fs = require('fs-extra');
6
- const { isUsingTypeScript } = require('@strapi/typescript-utils');
6
+ const tsUtils = require('@strapi/typescript-utils');
7
7
  const getCustomAppConfigFile = require('./get-custom-app-config-file');
8
8
 
9
9
  const getPkgPath = name => path.dirname(require.resolve(`${name}/package.json`));
@@ -71,7 +71,10 @@ async function copyAdmin(dest) {
71
71
  async function createCacheDir({ appDir, plugins }) {
72
72
  const cacheDir = path.resolve(appDir, '.cache');
73
73
 
74
- const useTypeScript = await isUsingTypeScript(path.join(appDir, 'src', 'admin'), 'tsconfig.json');
74
+ const useTypeScript = await tsUtils.isUsingTypeScript(
75
+ path.join(appDir, 'src', 'admin'),
76
+ 'tsconfig.json'
77
+ );
75
78
 
76
79
  const pluginsWithFront = Object.keys(plugins)
77
80
  .filter(pluginName => {
@@ -121,40 +124,7 @@ async function createCacheDir({ appDir, plugins }) {
121
124
 
122
125
  // create the tsconfig.json file so we can develop plugins in ts while being in a JS project
123
126
  if (!useTypeScript) {
124
- await createTSConfigFile(cacheDir);
125
- }
126
- }
127
-
128
- async function createTSConfigFile(dest) {
129
- const tsConfig = {
130
- compilerOptions: {
131
- lib: ['es2019', 'es2020.promise', 'es2020.bigint', 'es2020.string', 'DOM'],
132
- noImplicitAny: false,
133
- module: 'es2020',
134
- target: 'es5',
135
- jsx: 'react',
136
- allowJs: true,
137
- strict: true,
138
- moduleResolution: 'node',
139
- skipLibCheck: true,
140
- esModuleInterop: true,
141
- allowSyntheticDefaultImports: true,
142
- resolveJsonModule: true,
143
- noEmit: false,
144
- incremental: true,
145
- },
146
- include: ['../../../src/admin/*', '../../../src/**/**/admin/src/*'],
147
- exclude: ['node_modules', '**/*.test.js', '*.js'],
148
- };
149
-
150
- const filePath = path.join(dest, 'admin', 'src', 'tsconfig.json');
151
-
152
- try {
153
- await fs.ensureFile(filePath);
154
-
155
- await fs.writeJSON(filePath, tsConfig, { spaces: 2 });
156
- } catch (err) {
157
- console.log(err);
127
+ await tsUtils.admin.createTSConfigFile(cacheDir);
158
128
  }
159
129
  }
160
130
 
@@ -15,9 +15,14 @@ const getCustomAppConfigFile = async dir => {
15
15
 
16
16
  const files = await fse.readdir(adminSrcPath);
17
17
 
18
- const appRegex = new RegExp(`app.${useTypeScript ? 't' : 'j'}sx?$`);
18
+ const appJsx = files.find(file => /^app.jsx?$/.test(file));
19
+ const appTsx = files.find(file => /^app.tsx?$/.test(file));
19
20
 
20
- return files.find(file => file.match(appRegex));
21
+ if (useTypeScript) {
22
+ return appTsx || appJsx;
23
+ }
24
+
25
+ return appJsx;
21
26
  };
22
27
 
23
28
  module.exports = getCustomAppConfigFile;
@@ -2,9 +2,9 @@
2
2
 
3
3
  const { join, resolve } = require('path');
4
4
  const fs = require('fs-extra');
5
- // eslint-disable-next-line node/no-extraneous-require
6
5
  const glob = require('glob');
7
6
 
7
+ // Only for dev environement
8
8
  const getPluginsPath = () => {
9
9
  const rootPath = resolve(__dirname, '..', join('..', '..', '..', 'packages'));
10
10
  const corePath = join(rootPath, 'core', '*');
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { components } from 'react-select';
3
- import Cross from '@strapi/icons/Cross';
4
- import IconBox from './IconBox';
5
-
6
- const ClearIndicator = props => {
7
- const Component = components.ClearIndicator;
8
-
9
- return (
10
- <Component {...props}>
11
- <IconBox as="button" type="button">
12
- <Cross />
13
- </IconBox>
14
- </Component>
15
- );
16
- };
17
-
18
- export default ClearIndicator;
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import CarretDown from '@strapi/icons/CarretDown';
4
- import IconBox from './IconBox';
5
-
6
- export const CarretBox = styled(IconBox)`
7
- display: flex;
8
- background: none;
9
- border: none;
10
-
11
- svg {
12
- width: ${6 / 16}rem;
13
- }
14
- `;
15
-
16
- const DropdownIndicator = () => {
17
- return (
18
- <CarretBox as="button" type="button" paddingRight={3}>
19
- <CarretDown />
20
- </CarretBox>
21
- );
22
- };
23
-
24
- export default DropdownIndicator;
@@ -1,20 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Box } from '@strapi/design-system/Box';
3
-
4
- export const IconBox = styled(Box)`
5
- background: transparent;
6
- border: none;
7
- position: relative;
8
- z-index: 1;
9
-
10
- svg {
11
- height: ${11 / 16}rem;
12
- width: ${11 / 16}rem;
13
- }
14
-
15
- svg path {
16
- fill: ${({ theme }) => theme.colors.neutral600};
17
- }
18
- `;
19
-
20
- export default IconBox;
@@ -1,3 +0,0 @@
1
- const IndicatorSeparator = () => null;
2
-
3
- export default IndicatorSeparator;
@@ -1,92 +0,0 @@
1
- const getSelectStyles = theme => {
2
- return {
3
- clearIndicator: base => ({ ...base, padding: 0, paddingRight: theme.spaces[3] }),
4
- container: base => ({
5
- ...base,
6
- background: theme.colors.neutral0,
7
- fontFamily: 'Arial',
8
- lineHeight: 'normal',
9
- }),
10
- control: (base, state) => {
11
- let border;
12
- let borderBottom;
13
- let backgroundColor;
14
-
15
- if (state.isFocused) {
16
- border = `1px solid ${theme.colors.primary600} !important`;
17
- } else {
18
- border = `1px solid ${theme.colors.neutral200} !important`;
19
- }
20
-
21
- if (state.menuIsOpen === true) {
22
- borderBottom = `1px solid ${theme.colors.primary600} !important`;
23
- }
24
-
25
- if (state.isDisabled) {
26
- backgroundColor = '#fafafb !important';
27
- }
28
-
29
- return {
30
- ...base,
31
- fontSize: 14,
32
- height: 40,
33
- border,
34
- outline: 0,
35
- boxShadow: 0,
36
- borderRadius: '2px !important',
37
- borderBottom,
38
- backgroundColor,
39
- borderTopLeftRadius: '4px !important',
40
- borderTopRightRadius: '4px !important',
41
- borderBottomLeftRadius: '4px !important',
42
- borderBottomRightRadius: '4px !important',
43
- };
44
- },
45
- indicatorContainer: base => ({ ...base, padding: 0, paddingRight: theme.spaces[3] }),
46
- input: base => ({ ...base, margin: 0, padding: 0, color: theme.colors.neutral800 }),
47
- menu: base => {
48
- return {
49
- ...base,
50
- width: '100%',
51
- marginTop: theme.spaces[1],
52
- backgroundColor: theme.colors.neutral0,
53
- color: theme.colors.neutral800,
54
- borderRadius: '4px !important',
55
- borderTopLeftRadius: '4px !important',
56
- borderTopRightRadius: '4px !important',
57
- border: `1px solid ${theme.colors.neutral200} !important`,
58
- boxShadow: 0,
59
- fontSize: '14px',
60
- fontFamily: 'Arial',
61
- zIndex: 2,
62
- };
63
- },
64
- menuList: base => ({
65
- ...base,
66
- paddingLeft: theme.spaces[1],
67
- paddingTop: theme.spaces[1],
68
- paddingRight: theme.spaces[1],
69
- paddingBottom: theme.spaces[1],
70
- }),
71
- option: (base, state) => {
72
- let backgroundColor = base.backgroundColor;
73
-
74
- if (state.isFocused) {
75
- backgroundColor = theme.colors.primary100;
76
- }
77
-
78
- return { ...base, lineHeight: theme.spaces[5], backgroundColor, borderRadius: 4 };
79
- },
80
- placeholder: base => ({ ...base, marginLeft: 0 }),
81
- singleValue: base => ({ ...base, marginLeft: 0, color: theme.colors.neutral800 }),
82
- valueContainer: base => ({
83
- ...base,
84
- padding: 0,
85
- paddingLeft: theme.spaces[4],
86
- marginLeft: 0,
87
- marginRight: 0,
88
- }),
89
- };
90
- };
91
-
92
- export default getSelectStyles;