@strapi/admin 4.12.6 → 4.13.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/admin/src/StrapiApp.js +1 -1
  2. package/admin/src/components/AuthenticatedApp/index.js +118 -0
  3. package/admin/src/components/AuthenticatedApp/utils/api.js +85 -0
  4. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +11 -0
  5. package/admin/src/components/GuidedTour/Modal/index.js +3 -1
  6. package/admin/src/components/NpsSurvey/hooks/useNpsSurveySettings.js +17 -0
  7. package/admin/src/components/NpsSurvey/index.js +365 -0
  8. package/admin/src/components/PluginsInitializer/index.js +68 -0
  9. package/admin/src/components/PluginsInitializer/init.js +11 -0
  10. package/admin/src/components/PluginsInitializer/reducer.js +22 -0
  11. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumns.js +2 -0
  12. package/admin/src/content-manager/components/DynamicZone/components/DynamicZoneLabel.js +1 -1
  13. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +8 -1
  14. package/admin/src/content-manager/components/Filter/CustomInputs/AdminUsersFilter.js +42 -0
  15. package/admin/src/content-manager/components/Filter/Filter.js +54 -0
  16. package/admin/src/content-manager/components/Filter/index.js +1 -0
  17. package/admin/src/content-manager/components/InputUID/index.js +222 -216
  18. package/admin/src/content-manager/components/RelationInput/RelationInput.js +4 -0
  19. package/admin/src/content-manager/components/RepeatableComponent/index.js +32 -2
  20. package/admin/src/content-manager/components/Wysiwyg/Editor.js +432 -68
  21. package/admin/src/content-manager/components/Wysiwyg/WysiwygStyles.js +0 -7
  22. package/admin/src/content-manager/components/Wysiwyg/index.js +147 -152
  23. package/admin/src/content-manager/hooks/useAllowedAttributes.js +47 -0
  24. package/admin/src/content-manager/pages/App/index.js +16 -5
  25. package/admin/src/content-manager/pages/EditView/Information/index.js +9 -8
  26. package/admin/src/content-manager/pages/ListSettingsView/components/Settings.js +40 -7
  27. package/admin/src/content-manager/pages/ListSettingsView/index.js +6 -2
  28. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  29. package/admin/src/content-manager/pages/ListView/components/FieldPicker/index.js +67 -69
  30. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  31. package/admin/src/content-manager/pages/ListView/components/ViewSettingsMenu/index.js +80 -0
  32. package/admin/src/content-manager/pages/ListView/index.js +236 -67
  33. package/admin/src/content-manager/utils/getDisplayName.js +33 -0
  34. package/admin/src/content-manager/utils/index.js +1 -0
  35. package/admin/src/hooks/useSettingsForm/index.js +3 -14
  36. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  37. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +3 -1
  38. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +3 -1
  39. package/admin/src/index.js +1 -1
  40. package/admin/src/layouts/AppLayout/index.js +33 -0
  41. package/admin/src/pages/Admin/Onboarding/index.js +3 -1
  42. package/admin/src/pages/Admin/index.js +73 -77
  43. package/admin/src/pages/App/constants.js +1 -1
  44. package/admin/src/pages/App/index.js +122 -160
  45. package/admin/src/pages/AuthPage/components/Register/index.js +5 -0
  46. package/admin/src/pages/AuthPage/index.js +4 -2
  47. package/admin/src/pages/HomePage/index.js +3 -1
  48. package/admin/src/pages/InstalledPluginsPage/index.js +3 -1
  49. package/admin/src/pages/{InternalErrorPage.js → InternalErrorPage/index.js} +4 -3
  50. package/admin/src/pages/{NotFoundPage.js → NotFoundPage/index.js} +3 -1
  51. package/admin/src/pages/ProfilePage/index.js +4 -2
  52. package/admin/src/pages/SettingsPage/constants.js +132 -67
  53. package/admin/src/pages/SettingsPage/index.js +18 -23
  54. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  55. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  56. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +1 -2
  57. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  58. package/admin/src/pages/UseCasePage/index.js +175 -0
  59. package/admin/src/plugins.js +7 -8
  60. package/admin/src/translations/en.json +10 -1
  61. package/admin/src/utils/checkFormValidity.js +15 -0
  62. package/admin/src/utils/createRoute.js +7 -5
  63. package/admin/src/utils/formatAPIErrors.js +3 -1
  64. package/admin/src/utils/getAttributesToDisplay.js +19 -0
  65. package/admin/src/utils/getExistingActions.js +32 -0
  66. package/admin/src/utils/getFullName.js +1 -1
  67. package/admin/src/utils/index.js +9 -0
  68. package/admin/src/utils/makeUniqueRoutes.js +6 -0
  69. package/admin/src/utils/sortLinks.js +3 -1
  70. package/admin/src/utils/uniqueAdminHash.js +9 -2
  71. package/build/{1049.9d69d231.chunk.js → 1049.ec69f5e0.chunk.js} +1 -1
  72. package/build/1227.9f37e1dc.chunk.js +1 -0
  73. package/build/1386.ea73b677.chunk.js +7 -0
  74. package/build/{2225.33287e1b.chunk.js → 2225.649fb7bc.chunk.js} +2 -2
  75. package/build/{2237.03792b63.chunk.js → 2237.b832ae6e.chunk.js} +4 -4
  76. package/build/{2379.401f56f3.chunk.js → 2379.1f98a31a.chunk.js} +1 -1
  77. package/build/{2395.e6a79fbb.chunk.js → 2395.0e5e8ded.chunk.js} +1 -1
  78. package/build/{2801.31393ffe.chunk.js → 2801.8e1aa82a.chunk.js} +1 -1
  79. package/build/3483.19381b40.chunk.js +1 -0
  80. package/build/3739.63e352f1.chunk.js +103 -0
  81. package/build/4174.f1f39e40.chunk.js +1 -0
  82. package/build/448.829e1344.chunk.js +1 -0
  83. package/build/4546.a5946d22.chunk.js +1 -0
  84. package/build/4724.aea5c8c1.chunk.js +6 -0
  85. package/build/{502.8dd074ff.chunk.js → 502.7bba43b1.chunk.js} +1 -1
  86. package/build/6158.c3c13c20.chunk.js +1 -0
  87. package/build/6691.4985ef22.chunk.js +105 -0
  88. package/build/{7464.592a9295.chunk.js → 7464.eb057bec.chunk.js} +1 -1
  89. package/build/78.dcc6df5c.chunk.js +1 -0
  90. package/build/{8276.e519a707.chunk.js → 8276.be3ed581.chunk.js} +2 -2
  91. package/build/{2747.d1442a90.chunk.js → 9806.5d5a0e8d.chunk.js} +64 -72
  92. package/build/9944.7af075a5.chunk.js +26 -0
  93. package/build/Admin-authenticatedApp.43b6ec9a.chunk.js +79 -0
  94. package/build/Admin_InternalErrorPage.38155af3.chunk.js +1 -0
  95. package/build/Admin_homePage.6f128523.chunk.js +81 -0
  96. package/build/Admin_marketplace.061a6e5a.chunk.js +55 -0
  97. package/build/Admin_pluginsPage.16f837b8.chunk.js +6 -0
  98. package/build/Admin_profilePage.678bce24.chunk.js +13 -0
  99. package/build/Admin_settingsPage.af7309e4.chunk.js +111 -0
  100. package/build/{Upload_ConfigureTheView.345ac1e0.chunk.js → Upload_ConfigureTheView.3fc1c100.chunk.js} +1 -1
  101. package/build/admin-app.d63bd229.chunk.js +36 -0
  102. package/build/{admin-edit-roles-page.24bdf746.chunk.js → admin-edit-roles-page.38a6c863.chunk.js} +3 -3
  103. package/build/admin-edit-users.545fc882.chunk.js +10 -0
  104. package/build/{admin-roles-list.23ddff26.chunk.js → admin-roles-list.1e2e814d.chunk.js} +1 -1
  105. package/build/admin-users.b8ea5677.chunk.js +11 -0
  106. package/build/{api-tokens-create-page.46c2ea84.chunk.js → api-tokens-create-page.e0c15627.chunk.js} +1 -1
  107. package/build/{api-tokens-edit-page.58139df9.chunk.js → api-tokens-edit-page.9f2dce47.chunk.js} +1 -1
  108. package/build/{api-tokens-list-page.0af7d431.chunk.js → api-tokens-list-page.d747051c.chunk.js} +2 -2
  109. package/build/{audit-logs-settings-page.0f73ccf8.chunk.js → audit-logs-settings-page.96f9d608.chunk.js} +1 -1
  110. package/build/content-manager.ccff1078.chunk.js +1097 -0
  111. package/build/{content-type-builder-list-view.bf9be456.chunk.js → content-type-builder-list-view.b71cf240.chunk.js} +1 -1
  112. package/build/{content-type-builder.66066281.chunk.js → content-type-builder.e5669749.chunk.js} +18 -18
  113. package/build/{email-settings-page.2f7e35c0.chunk.js → email-settings-page.2809f0bf.chunk.js} +1 -1
  114. package/build/en-json.e12fd5fc.chunk.js +1 -0
  115. package/build/{i18n-settings-page.47f78016.chunk.js → i18n-settings-page.5f716172.chunk.js} +1 -1
  116. package/build/index.html +1 -1
  117. package/build/main.c6c9e04c.js +2859 -0
  118. package/build/{review-workflows-settings-create-view.d24a32b9.chunk.js → review-workflows-settings-create-view.4a156a19.chunk.js} +1 -1
  119. package/build/{review-workflows-settings-edit-view.6044b022.chunk.js → review-workflows-settings-edit-view.ce984d1f.chunk.js} +1 -1
  120. package/build/{review-workflows-settings-list-view.3f0ef4bc.chunk.js → review-workflows-settings-list-view.419b8deb.chunk.js} +2 -2
  121. package/build/runtime~main.dcf1cb45.js +2 -0
  122. package/build/{sso-settings-page.4dba0670.chunk.js → sso-settings-page.45153df5.chunk.js} +1 -1
  123. package/build/{transfer-tokens-create-page.1597e6ab.chunk.js → transfer-tokens-create-page.ebba16d8.chunk.js} +1 -1
  124. package/build/{transfer-tokens-edit-page.8741529f.chunk.js → transfer-tokens-edit-page.d7bb2b3e.chunk.js} +1 -1
  125. package/build/{transfer-tokens-list-page.d6986b03.chunk.js → transfer-tokens-list-page.cfe1736c.chunk.js} +2 -2
  126. package/build/{upload-settings.7f93d4c0.chunk.js → upload-settings.cc5ad813.chunk.js} +1 -1
  127. package/build/{upload.37488080.chunk.js → upload.756efc28.chunk.js} +1 -1
  128. package/build/{users-advanced-settings-page.17052d72.chunk.js → users-advanced-settings-page.818d84eb.chunk.js} +1 -1
  129. package/build/{users-email-settings-page.3de8ea50.chunk.js → users-email-settings-page.c1967c09.chunk.js} +1 -1
  130. package/build/{users-providers-settings-page.0eaa916d.chunk.js → users-providers-settings-page.11893e08.chunk.js} +1 -1
  131. package/build/{users-roles-settings-page.957ad48b.chunk.js → users-roles-settings-page.2b051e6a.chunk.js} +1 -1
  132. package/build/webhook-edit-page.de45c635.chunk.js +33 -0
  133. package/build/{webhook-list-page.65e1b5bb.chunk.js → webhook-list-page.ca91df8b.chunk.js} +1 -1
  134. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/AssigneeFilter.js +42 -0
  135. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/StageFilter.js +70 -0
  136. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/constants.js +71 -0
  137. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +9 -217
  138. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/AssigneeSelect.js +147 -0
  139. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/index.js +1 -0
  140. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/StageSelect.js +243 -0
  141. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/index.js +1 -0
  142. package/ee/admin/content-manager/pages/EditView/InformationBox/constants.js +2 -0
  143. package/ee/admin/content-manager/pages/ListSettingsView/constants.js +7 -0
  144. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/ReviewWorkflowsAssigneeEE.js +21 -0
  145. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants.js +44 -17
  146. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/index.js +1 -0
  147. package/ee/admin/pages/App/constants.js +5 -6
  148. package/ee/admin/pages/SettingsPage/constants.js +42 -27
  149. package/ee/server/constants/workflows.js +1 -0
  150. package/ee/server/controllers/index.js +1 -0
  151. package/ee/server/controllers/workflows/assignees/index.js +44 -0
  152. package/ee/server/routes/review-workflows.js +17 -0
  153. package/ee/server/services/index.js +1 -0
  154. package/ee/server/services/review-workflows/assignees.js +54 -0
  155. package/ee/server/services/review-workflows/metrics/index.js +5 -0
  156. package/ee/server/services/review-workflows/review-workflows.js +20 -11
  157. package/ee/server/validation/review-workflows.js +8 -0
  158. package/index.js +2 -6
  159. package/package.json +9 -9
  160. package/scripts/build.js +15 -15
  161. package/scripts/create-dev-plugins-file.js +5 -38
  162. package/server/controllers/role.js +2 -0
  163. package/server/controllers/user.js +2 -0
  164. package/server/services/permission/permissions-manager/index.js +3 -1
  165. package/server/services/permission/permissions-manager/sanitize.js +19 -7
  166. package/server/services/permission/permissions-manager/validate.js +218 -0
  167. package/utils/create-cache-dir.js +62 -16
  168. package/utils/create-plugins-exclude-path.js +3 -23
  169. package/utils/get-plugins.js +110 -0
  170. package/utils/index.js +1 -1
  171. package/webpack.config.js +10 -13
  172. package/admin/src/components/AuthenticatedApp.js +0 -229
  173. package/admin/src/content-manager/components/AttributeFilter/Filters.js +0 -58
  174. package/admin/src/content-manager/components/AttributeFilter/hooks/useAllowedAttributes.js +0 -42
  175. package/admin/src/content-manager/components/AttributeFilter/index.js +0 -40
  176. package/admin/src/content-manager/components/Wysiwyg/EditorStylesContainer.js +0 -344
  177. package/admin/src/pages/UseCasePage.js +0 -174
  178. package/build/2166.c837469a.chunk.js +0 -1
  179. package/build/3483.8517171f.chunk.js +0 -1
  180. package/build/3984.dda474f7.chunk.js +0 -1
  181. package/build/4546.7a3c0d03.chunk.js +0 -1
  182. package/build/5483.5bfbb00d.chunk.js +0 -6
  183. package/build/6158.c974fd83.chunk.js +0 -1
  184. package/build/748.fd2e5afd.chunk.js +0 -105
  185. package/build/773.6381d62d.chunk.js +0 -18
  186. package/build/7826.399afe81.chunk.js +0 -103
  187. package/build/8261.2525d35c.chunk.js +0 -7
  188. package/build/8299.62b67c72.chunk.js +0 -1
  189. package/build/Admin-AuthPage.90d64342.chunk.js +0 -35
  190. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +0 -24
  191. package/build/Admin-UseCasePage.1f757db5.chunk.js +0 -13
  192. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +0 -12
  193. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +0 -9
  194. package/build/Admin_NotFoundPage.21620424.chunk.js +0 -9
  195. package/build/Admin_Onboarding.dbfa32f6.chunk.js +0 -43
  196. package/build/Admin_homePage.2000cbe9.chunk.js +0 -86
  197. package/build/Admin_marketplace.ec80e29b.chunk.js +0 -63
  198. package/build/Admin_pluginsPage.0c6851f8.chunk.js +0 -14
  199. package/build/Admin_profilePage.78cd8495.chunk.js +0 -21
  200. package/build/Admin_settingsPage.1760c3ce.chunk.js +0 -119
  201. package/build/StrapiApp.221fac30.chunk.js +0 -5
  202. package/build/admin-edit-users.5d10d444.chunk.js +0 -10
  203. package/build/admin-users.2b3e4305.chunk.js +0 -11
  204. package/build/content-manager.fb0833bd.chunk.js +0 -1099
  205. package/build/en-json.08c05fcf.chunk.js +0 -1
  206. package/build/main.ee3c1938.js +0 -2859
  207. package/build/runtime~main.397ee447.js +0 -2
  208. package/build/webhook-edit-page.665210af.chunk.js +0 -33
  209. package/scripts/create-plugins-file.js +0 -92
  210. package/utils/get-plugins-path.js +0 -41
  211. /package/server/services/permission/permissions-manager/{query-builers.js → query-builders.js} +0 -0
@@ -1,4 +1,10 @@
1
- import * as React from 'react';
1
+ /**
2
+ *
3
+ * App.js
4
+ *
5
+ */
6
+
7
+ import React, { lazy, Suspense, useEffect, useMemo, useState } from 'react';
2
8
 
3
9
  import { SkipToContent } from '@strapi/design-system';
4
10
  import {
@@ -6,57 +12,31 @@ import {
6
12
  LoadingIndicatorPage,
7
13
  prefixFileUrlWithBackendUrl,
8
14
  TrackingProvider,
15
+ useAppInfo,
9
16
  useFetchClient,
17
+ useNotification,
10
18
  } from '@strapi/helper-plugin';
11
19
  import merge from 'lodash/merge';
12
20
  import { useIntl } from 'react-intl';
13
- import { useQueries } from 'react-query';
14
21
  import { useDispatch } from 'react-redux';
15
22
  import { Route, Switch } from 'react-router-dom';
16
23
 
17
24
  import PrivateRoute from '../../components/PrivateRoute';
18
25
  import { ADMIN_PERMISSIONS_CE } from '../../constants';
19
- import useConfigurations from '../../hooks/useConfigurations';
26
+ import { useConfigurations } from '../../hooks';
20
27
  import { useEnterprise } from '../../hooks/useEnterprise';
28
+ import { createRoute, makeUniqueRoutes } from '../../utils';
29
+ import AuthPage from '../AuthPage';
30
+ import NotFoundPage from '../NotFoundPage';
31
+ import UseCasePage from '../UseCasePage';
21
32
 
22
- import { AUTH_ROUTES_CE, SET_ADMIN_PERMISSIONS } from './constants';
23
-
24
- const AuthPage = React.lazy(() =>
25
- import(/* webpackChunkName: "Admin-AuthPage" */ '../AuthPage').then((module) => ({
26
- default: module.AuthPage,
27
- }))
28
- );
29
-
30
- const AuthenticatedApp = React.lazy(() =>
31
- import(/* webpackChunkName: "Admin-AuthenticatedApp" */ '../../components/AuthenticatedApp').then(
32
- (module) => ({ default: module.AuthenticatedApp })
33
- )
34
- );
33
+ import { ROUTES_CE, SET_ADMIN_PERMISSIONS } from './constants';
35
34
 
36
- const UseCasePage = React.lazy(() =>
37
- import(/* webpackChunkName: "Admin-UseCasePage" */ '../UseCasePage').then((module) => ({
38
- default: module.UseCasePage,
39
- }))
35
+ const AuthenticatedApp = lazy(() =>
36
+ import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp')
40
37
  );
41
38
 
42
- const NotFoundPage = React.lazy(() =>
43
- import(/* webpackChunkName: "Admin_NotFoundPage" */ '../NotFoundPage').then((module) => ({
44
- default: module.NotFoundPage,
45
- }))
46
- );
47
-
48
- const InternalErrorPage = React.lazy(() =>
49
- import(/* webpackChunkName: "Admin_InternalErrorPage" */ '../InternalErrorPage').then(
50
- (module) => ({ default: module.InternalErrorPage })
51
- )
52
- );
53
-
54
- export function App() {
55
- const { updateProjectSettings } = useConfigurations();
56
- const { formatMessage } = useIntl();
57
- const dispatch = useDispatch();
58
- const { get, post } = useFetchClient();
59
-
39
+ function App() {
60
40
  const adminPermissions = useEnterprise(
61
41
  ADMIN_PERMISSIONS_CE,
62
42
  async () => (await import('../../../../ee/admin/constants')).ADMIN_PERMISSIONS_EE,
@@ -69,173 +49,155 @@ export function App() {
69
49
  defaultValue: ADMIN_PERMISSIONS_CE,
70
50
  }
71
51
  );
72
-
73
- // Load authentication routes for CE and EE (SSO)
74
- const authRoutes = useEnterprise(
75
- AUTH_ROUTES_CE,
76
- async () => (await import('../../../../ee/admin/pages/App/constants')).AUTH_ROUTES_EE,
52
+ const routes = useEnterprise(
53
+ ROUTES_CE,
54
+ async () => (await import('../../../../ee/admin/pages/App/constants')).ROUTES_EE,
77
55
  {
78
56
  defaultValue: [],
79
57
  }
80
58
  );
81
-
82
- // TODO: this should be moved to redux
83
- const [{ hasAdmin, uuid }, setState] = React.useState({
59
+ const toggleNotification = useNotification();
60
+ const { updateProjectSettings } = useConfigurations();
61
+ const { formatMessage } = useIntl();
62
+ const [{ isLoading, hasAdmin, uuid, deviceId }, setState] = useState({
63
+ isLoading: true,
84
64
  hasAdmin: false,
85
- uuid: undefined,
86
65
  });
66
+ const dispatch = useDispatch();
67
+ const appInfo = useAppInfo();
68
+ const { get, post } = useFetchClient();
69
+
70
+ const authRoutes = useMemo(() => {
71
+ return makeUniqueRoutes(
72
+ routes.map(({ to, Component, exact }) => createRoute(Component, to, exact))
73
+ );
74
+ }, [routes]);
75
+
76
+ const [telemetryProperties, setTelemetryProperties] = useState(null);
87
77
 
88
- // Store permissions in redux
89
- React.useEffect(() => {
78
+ useEffect(() => {
90
79
  dispatch({ type: SET_ADMIN_PERMISSIONS, payload: adminPermissions });
91
80
  }, [adminPermissions, dispatch]);
92
81
 
93
- const [
94
- { data: token, error: errorRenewToken },
95
- { data: initData, isLoading: isLoadingInit },
96
- { data: telemetryProperties },
97
- ] = useQueries([
98
- {
99
- queryKey: 'renew-token',
100
- async queryFn() {
82
+ useEffect(() => {
83
+ const currentToken = auth.getToken();
84
+
85
+ const renewToken = async () => {
86
+ try {
101
87
  const {
102
88
  data: {
103
89
  data: { token },
104
90
  },
105
- } = await post('/admin/renew-token', { token: auth.getToken() });
106
-
107
- return token;
108
- },
109
-
110
- enabled: !!auth.getToken(),
111
- },
91
+ } = await post('/admin/renew-token', { token: currentToken });
92
+ auth.updateToken(token);
93
+ } catch (err) {
94
+ // Refresh app
95
+ auth.clearAppStorage();
96
+ window.location.reload();
97
+ }
98
+ };
99
+
100
+ if (currentToken) {
101
+ renewToken();
102
+ }
103
+ }, [post]);
112
104
 
113
- {
114
- queryKey: 'init',
115
- async queryFn() {
105
+ useEffect(() => {
106
+ const getData = async () => {
107
+ try {
116
108
  const {
117
- data: { data },
109
+ data: {
110
+ data: { hasAdmin, uuid, menuLogo, authLogo },
111
+ },
118
112
  } = await get(`/admin/init`);
119
113
 
120
- return data;
121
- },
122
- },
123
-
124
- {
125
- queryKey: 'telemetry-properties',
126
- async queryFn() {
127
- const {
128
- data: { data },
129
- } = await get(`/admin/telemetry-properties`, {
130
- // NOTE: needed because the interceptors of the fetchClient redirect to /login when receive a
131
- // 401 and it would end up in an infinite loop when the user doesn't have a session.
132
- validateStatus: (status) => status < 500,
114
+ updateProjectSettings({
115
+ menuLogo: prefixFileUrlWithBackendUrl(menuLogo),
116
+ authLogo: prefixFileUrlWithBackendUrl(authLogo),
133
117
  });
134
118
 
135
- return data;
136
- },
119
+ if (uuid) {
120
+ const {
121
+ data: { data: properties },
122
+ } = await get(`/admin/telemetry-properties`, {
123
+ // NOTE: needed because the interceptors of the fetchClient redirect to /login when receive a 401 and it would end up in an infinite loop when the user doesn't have a session.
124
+ validateStatus: (status) => status < 500,
125
+ });
126
+
127
+ setTelemetryProperties(properties);
128
+
129
+ try {
130
+ const event = 'didInitializeAdministration';
131
+ await post(
132
+ 'https://analytics.strapi.io/api/v2/track',
133
+ {
134
+ // This event is anonymous
135
+ event,
136
+ userId: '',
137
+ deviceId,
138
+ eventPropeties: {},
139
+ userProperties: { environment: appInfo.currentEnvironment },
140
+ groupProperties: { ...properties, projectId: uuid },
141
+ },
142
+ {
143
+ headers: {
144
+ 'X-Strapi-Event': event,
145
+ },
146
+ }
147
+ );
148
+ } catch (e) {
149
+ // Silent.
150
+ }
151
+ }
152
+
153
+ setState({ isLoading: false, hasAdmin, uuid, deviceId });
154
+ } catch (err) {
155
+ toggleNotification({
156
+ type: 'warning',
157
+ message: { id: 'app.containers.App.notification.error.init' },
158
+ });
159
+ }
160
+ };
137
161
 
138
- enabled: !!auth.getToken(),
139
- },
140
- ]);
141
-
142
- React.useEffect(() => {
143
- // If the renew token could not be fetched, logout the user
144
- if (errorRenewToken) {
145
- auth.clearAppStorage();
146
- window.location.reload();
147
- } else if (token) {
148
- auth.updateToken(token);
149
- }
150
- }, [errorRenewToken, token]);
151
-
152
- // Store the fetched project settings (e.g. logos)
153
- // TODO: this should be moved to redux
154
- React.useEffect(() => {
155
- if (!isLoadingInit && initData) {
156
- updateProjectSettings({
157
- menuLogo: prefixFileUrlWithBackendUrl(initData.menuLogo),
158
- authLogo: prefixFileUrlWithBackendUrl(initData.authLogo),
159
- });
160
-
161
- // TODO: this should be stored in redux
162
- setState((prev) => ({
163
- ...prev,
164
- hasAdmin: initData.hasAdmin,
165
- uuid: initData.uuid,
166
- }));
167
- }
168
- }, [initData, isLoadingInit, updateProjectSettings]);
169
-
170
- // We can't use useTracking here, because `App` is not wrapped in the tracking provider
171
- // context, which we can't do because the context values contain data that can only be
172
- // accessed when a user is logged in.
173
- // This should not use `useFetchClient`, because it does not communicate to the admin API.
174
- React.useEffect(() => {
175
- async function trackInitEvent() {
176
- await fetch('https://analytics.strapi.io/api/v2/track', {
177
- body: JSON.stringify({
178
- event: 'didInitializeAdministration',
179
- // This event is anonymous
180
- userId: '',
181
- eventPropeties: {},
182
- userProperties: {},
183
- groupProperties: { ...telemetryProperties, projectId: uuid },
184
- }),
185
-
186
- headers: {
187
- 'Content-Type': 'application/json',
188
- 'X-Strapi-Event': 'didInitializeAdministration',
189
- },
190
-
191
- method: 'POST',
192
- });
193
- }
162
+ getData();
163
+ // eslint-disable-next-line react-hooks/exhaustive-deps
164
+ }, [toggleNotification, updateProjectSettings]);
194
165
 
195
- if (uuid) {
196
- trackInitEvent();
197
- }
198
- }, [telemetryProperties, uuid]);
166
+ const setHasAdmin = (hasAdmin) => setState((prev) => ({ ...prev, hasAdmin }));
199
167
 
200
- const trackingContext = React.useMemo(
168
+ const trackingInfo = useMemo(
201
169
  () => ({
202
170
  uuid,
203
171
  telemetryProperties,
172
+ deviceId,
204
173
  }),
205
- [uuid, telemetryProperties]
174
+ [uuid, telemetryProperties, deviceId]
206
175
  );
207
176
 
208
- if (isLoadingInit) {
177
+ if (isLoading) {
209
178
  return <LoadingIndicatorPage />;
210
179
  }
211
180
 
212
181
  return (
213
- <React.Suspense fallback={<LoadingIndicatorPage />}>
182
+ <Suspense fallback={<LoadingIndicatorPage />}>
214
183
  <SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent>
215
- <TrackingProvider value={trackingContext}>
184
+ <TrackingProvider value={trackingInfo}>
216
185
  <Switch>
217
- {authRoutes.map(({ path, component }) => (
218
- <Route key={path} path={path} component={component} exact />
219
- ))}
220
-
186
+ {authRoutes}
221
187
  <Route
222
188
  path="/auth/:authType"
223
189
  render={(routerProps) => (
224
- <AuthPage
225
- {...routerProps}
226
- setHasAdmin={(hasAdmin) => setState((prev) => ({ ...prev, hasAdmin }))}
227
- hasAdmin={hasAdmin}
228
- />
190
+ <AuthPage {...routerProps} setHasAdmin={setHasAdmin} hasAdmin={hasAdmin} />
229
191
  )}
230
192
  exact
231
193
  />
232
194
  <PrivateRoute path="/usecase" component={UseCasePage} />
233
195
  <PrivateRoute path="/" component={AuthenticatedApp} />
234
- <Route path="/404" component={NotFoundPage} />
235
- <Route path="/500" component={InternalErrorPage} />
236
196
  <Route path="" component={NotFoundPage} />
237
197
  </Switch>
238
198
  </TrackingProvider>
239
- </React.Suspense>
199
+ </Suspense>
240
200
  );
241
201
  }
202
+
203
+ export default App;
@@ -29,6 +29,7 @@ import { useIntl } from 'react-intl';
29
29
  import { useHistory } from 'react-router-dom';
30
30
  import styled from 'styled-components';
31
31
 
32
+ import { useNpsSurveySettings } from '../../../../components/NpsSurvey/hooks/useNpsSurveySettings';
32
33
  import Logo from '../../../../components/UnauthenticatedLogo';
33
34
  import UnauthenticatedLayout, { LayoutContent } from '../../../../layouts/UnauthenticatedLayout';
34
35
  import FieldActionWrapper from '../FieldActionWrapper';
@@ -55,6 +56,7 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
55
56
  const query = useQuery();
56
57
  const { formatAPIError } = useAPIErrorHandler();
57
58
  const { get } = useFetchClient();
59
+ const { setNpsSurveySettings } = useNpsSurveySettings();
58
60
 
59
61
  const registrationToken = query.get('registrationToken');
60
62
 
@@ -143,6 +145,9 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
143
145
  } else {
144
146
  onSubmit(normalizedData, formik);
145
147
  }
148
+
149
+ // Only enable EE survey if user accepted the newsletter
150
+ setNpsSurveySettings({ enabled: data.news });
146
151
  } catch (err) {
147
152
  const errors = getYupInnerErrors(err);
148
153
  setSubmitCount(submitCount + 1);
@@ -11,14 +11,14 @@ import { Redirect, useHistory, useRouteMatch } from 'react-router-dom';
11
11
  import persistStateToLocaleStorage from '../../components/GuidedTour/utils/persistStateToLocaleStorage';
12
12
  import useLocalesProvider from '../../components/LocalesProvider/useLocalesProvider';
13
13
  import { useEnterprise } from '../../hooks/useEnterprise';
14
- import { formatAPIErrors } from '../../utils/formatAPIErrors';
14
+ import formatAPIErrors from '../../utils/formatAPIErrors';
15
15
 
16
16
  import { LoginCE } from './components/Login';
17
17
  import { FORMS } from './constants';
18
18
  import init from './init';
19
19
  import { initialState, reducer } from './reducer';
20
20
 
21
- export const AuthPage = ({ hasAdmin, setHasAdmin }) => {
21
+ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
22
22
  const {
23
23
  push,
24
24
  location: { search },
@@ -315,3 +315,5 @@ AuthPage.propTypes = {
315
315
  hasAdmin: PropTypes.bool,
316
316
  setHasAdmin: PropTypes.func.isRequired,
317
317
  };
318
+
319
+ export default AuthPage;
@@ -89,7 +89,7 @@ export const HomePageCE = () => {
89
89
  );
90
90
  };
91
91
 
92
- export function HomePage() {
92
+ function HomePageSwitch() {
93
93
  const HomePage = useEnterprise(
94
94
  HomePageCE,
95
95
  // eslint-disable-next-line import/no-cycle
@@ -103,3 +103,5 @@ export function HomePage() {
103
103
 
104
104
  return <HomePage />;
105
105
  }
106
+
107
+ export default HomePageSwitch;
@@ -9,7 +9,7 @@ import { selectAdminPermissions } from '../App/selectors';
9
9
 
10
10
  import Plugins from './Plugins';
11
11
 
12
- export const PluginsPage = () => {
12
+ const InstalledPluginsPage = () => {
13
13
  const { formatMessage } = useIntl();
14
14
  const permissions = useSelector(selectAdminPermissions);
15
15
 
@@ -25,3 +25,5 @@ export const PluginsPage = () => {
25
25
  </CheckPagePermissions>
26
26
  );
27
27
  };
28
+
29
+ export default InstalledPluginsPage;
@@ -4,16 +4,15 @@
4
4
  * This is the page we show when the user gets a 500 error
5
5
  *
6
6
  */
7
- import * as React from 'react';
7
+ import React from 'react';
8
8
 
9
9
  import { ContentLayout, EmptyStateLayout, HeaderLayout, Main } from '@strapi/design-system';
10
10
  import { LinkButton, useFocusWhenNavigate } from '@strapi/helper-plugin';
11
11
  import { ArrowRight, EmptyPictures } from '@strapi/icons';
12
12
  import { useIntl } from 'react-intl';
13
13
 
14
- export const InternalErrorPage = () => {
14
+ const InternalErrorPage = () => {
15
15
  const { formatMessage } = useIntl();
16
-
17
16
  useFocusWhenNavigate();
18
17
 
19
18
  return (
@@ -47,3 +46,5 @@ export const InternalErrorPage = () => {
47
46
  </Main>
48
47
  );
49
48
  };
49
+
50
+ export default InternalErrorPage;
@@ -11,7 +11,7 @@ import { LinkButton, useFocusWhenNavigate } from '@strapi/helper-plugin';
11
11
  import { ArrowRight, EmptyPictures } from '@strapi/icons';
12
12
  import { useIntl } from 'react-intl';
13
13
 
14
- export const NotFoundPage = () => {
14
+ const NoContentType = () => {
15
15
  const { formatMessage } = useIntl();
16
16
  useFocusWhenNavigate();
17
17
 
@@ -46,3 +46,5 @@ export const NotFoundPage = () => {
46
46
  </Main>
47
47
  );
48
48
  };
49
+
50
+ export default NoContentType;
@@ -28,14 +28,14 @@ import { useMutation, useQuery, useQueryClient } from 'react-query';
28
28
 
29
29
  import useLocalesProvider from '../../components/LocalesProvider/useLocalesProvider';
30
30
  import { useThemeToggle } from '../../hooks';
31
- import { getFullName } from '../../utils/getFullName';
31
+ import { getFullName } from '../../utils';
32
32
 
33
33
  import Password from './components/Password';
34
34
  import Preferences from './components/Preferences';
35
35
  import UserInfo from './components/UserInfo';
36
36
  import schema from './utils/schema';
37
37
 
38
- export const ProfilePage = () => {
38
+ const ProfilePage = () => {
39
39
  const { changeLocale, localeNames } = useLocalesProvider();
40
40
  const { setUserDisplayName } = useAppInfo();
41
41
  const queryClient = useQueryClient();
@@ -231,3 +231,5 @@ export const ProfilePage = () => {
231
231
  </Main>
232
232
  );
233
233
  };
234
+
235
+ export default ProfilePage;