@strapi/admin 4.12.5 → 4.12.6

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 (159) hide show
  1. package/admin/src/StrapiApp.js +1 -1
  2. package/admin/src/components/AuthenticatedApp.js +229 -0
  3. package/admin/src/components/GuidedTour/Modal/index.js +1 -3
  4. package/admin/src/content-manager/pages/App/index.js +5 -16
  5. package/admin/src/content-manager/pages/EditView/Information/index.js +1 -1
  6. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  7. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  8. package/admin/src/hooks/useSettingsForm/index.js +14 -3
  9. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  10. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +1 -3
  11. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +1 -3
  12. package/admin/src/index.js +1 -1
  13. package/admin/src/pages/Admin/Onboarding/index.js +1 -3
  14. package/admin/src/pages/Admin/index.js +80 -74
  15. package/admin/src/pages/App/constants.js +1 -1
  16. package/admin/src/pages/App/index.js +160 -122
  17. package/admin/src/pages/AuthPage/index.js +2 -4
  18. package/admin/src/pages/HomePage/index.js +1 -3
  19. package/admin/src/pages/InstalledPluginsPage/index.js +1 -3
  20. package/admin/src/pages/{InternalErrorPage/index.js → InternalErrorPage.js} +3 -4
  21. package/admin/src/pages/{NotFoundPage/index.js → NotFoundPage.js} +1 -3
  22. package/admin/src/pages/ProfilePage/index.js +2 -4
  23. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +3 -3
  24. package/admin/src/pages/SettingsPage/constants.js +67 -132
  25. package/admin/src/pages/SettingsPage/index.js +31 -36
  26. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  27. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +69 -35
  28. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  29. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +2 -1
  30. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  31. package/admin/src/pages/UseCasePage.js +174 -0
  32. package/admin/src/utils/createRoute.js +5 -7
  33. package/admin/src/utils/formatAPIErrors.js +1 -3
  34. package/admin/src/utils/getFullName.js +1 -1
  35. package/admin/src/utils/sortLinks.js +1 -3
  36. package/admin/src/utils/uniqueAdminHash.js +2 -9
  37. package/build/{1049.f76cb14b.chunk.js → 1049.9d69d231.chunk.js} +1 -1
  38. package/build/1504.eff012f7.chunk.js +95 -0
  39. package/build/2166.c837469a.chunk.js +1 -0
  40. package/build/2225.33287e1b.chunk.js +79 -0
  41. package/build/2237.03792b63.chunk.js +114 -0
  42. package/build/2379.401f56f3.chunk.js +1 -0
  43. package/build/2395.e6a79fbb.chunk.js +26 -0
  44. package/build/{9806.5d5a0e8d.chunk.js → 2747.d1442a90.chunk.js} +72 -64
  45. package/build/2801.31393ffe.chunk.js +1 -0
  46. package/build/3483.8517171f.chunk.js +1 -0
  47. package/build/502.8dd074ff.chunk.js +1 -0
  48. package/build/5483.5bfbb00d.chunk.js +6 -0
  49. package/build/7464.592a9295.chunk.js +1 -0
  50. package/build/748.fd2e5afd.chunk.js +105 -0
  51. package/build/773.6381d62d.chunk.js +18 -0
  52. package/build/7826.399afe81.chunk.js +103 -0
  53. package/build/8261.2525d35c.chunk.js +7 -0
  54. package/build/8276.e519a707.chunk.js +26 -0
  55. package/build/8299.62b67c72.chunk.js +1 -0
  56. package/build/Admin-AuthPage.90d64342.chunk.js +35 -0
  57. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +24 -0
  58. package/build/Admin-UseCasePage.1f757db5.chunk.js +13 -0
  59. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +12 -0
  60. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +9 -0
  61. package/build/Admin_NotFoundPage.21620424.chunk.js +9 -0
  62. package/build/Admin_Onboarding.dbfa32f6.chunk.js +43 -0
  63. package/build/Admin_homePage.2000cbe9.chunk.js +86 -0
  64. package/build/Admin_marketplace.ec80e29b.chunk.js +63 -0
  65. package/build/Admin_pluginsPage.0c6851f8.chunk.js +14 -0
  66. package/build/Admin_profilePage.78cd8495.chunk.js +21 -0
  67. package/build/Admin_settingsPage.1760c3ce.chunk.js +119 -0
  68. package/build/StrapiApp.221fac30.chunk.js +5 -0
  69. package/build/{admin-edit-roles-page.6d567273.chunk.js → admin-edit-roles-page.24bdf746.chunk.js} +1 -1
  70. package/build/admin-edit-users.5d10d444.chunk.js +10 -0
  71. package/build/{admin-users.00e20017.chunk.js → admin-users.2b3e4305.chunk.js} +2 -2
  72. package/build/{content-manager.b40f79c0.chunk.js → content-manager.fb0833bd.chunk.js} +78 -78
  73. package/build/{content-type-builder.cd999f6e.chunk.js → content-type-builder.66066281.chunk.js} +18 -18
  74. package/build/email-settings-page.2f7e35c0.chunk.js +11 -0
  75. package/build/index.html +1 -1
  76. package/build/main.ee3c1938.js +2859 -0
  77. package/build/review-workflows-settings-create-view.d24a32b9.chunk.js +1 -0
  78. package/build/review-workflows-settings-edit-view.6044b022.chunk.js +1 -0
  79. package/build/review-workflows-settings-list-view.3f0ef4bc.chunk.js +56 -0
  80. package/build/runtime~main.397ee447.js +2 -0
  81. package/build/{sso-settings-page.12b6d8ae.chunk.js → sso-settings-page.4dba0670.chunk.js} +1 -1
  82. package/build/users-advanced-settings-page.17052d72.chunk.js +9 -0
  83. package/build/users-email-settings-page.3de8ea50.chunk.js +9 -0
  84. package/build/users-providers-settings-page.0eaa916d.chunk.js +14 -0
  85. package/build/users-roles-settings-page.957ad48b.chunk.js +55 -0
  86. package/build/webhook-edit-page.665210af.chunk.js +33 -0
  87. package/ee/admin/hooks/useAuthProviders.js +25 -0
  88. package/ee/admin/hooks/{useLicenseLimitNotification/index.js → useLicenseLimitNotification.js} +2 -4
  89. package/ee/admin/hooks/{useLicenseLimits/useLicenseLimits.js → useLicenseLimits.js} +4 -1
  90. package/ee/admin/pages/App/constants.js +6 -5
  91. package/ee/admin/pages/AuthPage/components/Login/index.js +8 -4
  92. package/ee/admin/pages/AuthPage/components/Providers/index.js +8 -5
  93. package/ee/admin/pages/HomePage/index.js +1 -1
  94. package/ee/admin/pages/SettingsPage/constants.js +27 -42
  95. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/CreateView.js +1 -1
  96. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/EditView.js +1 -1
  97. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/ListView.js +1 -1
  98. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +1 -1
  99. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
  100. package/package.json +8 -8
  101. package/admin/src/components/AuthenticatedApp/index.js +0 -118
  102. package/admin/src/components/AuthenticatedApp/utils/api.js +0 -85
  103. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +0 -11
  104. package/admin/src/components/PluginsInitializer/index.js +0 -68
  105. package/admin/src/components/PluginsInitializer/init.js +0 -11
  106. package/admin/src/components/PluginsInitializer/reducer.js +0 -22
  107. package/admin/src/layouts/AppLayout/index.js +0 -33
  108. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +0 -23
  109. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +0 -17
  110. package/admin/src/pages/SettingsPage/utils/createSectionsRoutes.js +0 -11
  111. package/admin/src/pages/SettingsPage/utils/getSectionsToDisplay.js +0 -5
  112. package/admin/src/pages/SettingsPage/utils/index.js +0 -2
  113. package/admin/src/pages/UseCasePage/index.js +0 -175
  114. package/admin/src/utils/checkFormValidity.js +0 -15
  115. package/admin/src/utils/getAttributesToDisplay.js +0 -19
  116. package/admin/src/utils/getExistingActions.js +0 -32
  117. package/admin/src/utils/index.js +0 -9
  118. package/admin/src/utils/makeUniqueRoutes.js +0 -6
  119. package/build/1386.879bcd90.chunk.js +0 -7
  120. package/build/2225.c6244756.chunk.js +0 -79
  121. package/build/2379.f1641312.chunk.js +0 -1
  122. package/build/2395.46f8d0c1.chunk.js +0 -26
  123. package/build/2801.5cef5ec8.chunk.js +0 -1
  124. package/build/3483.03c24f96.chunk.js +0 -1
  125. package/build/3739.63e352f1.chunk.js +0 -103
  126. package/build/3929.5632f24d.chunk.js +0 -114
  127. package/build/448.829e1344.chunk.js +0 -1
  128. package/build/502.8ae8ef60.chunk.js +0 -1
  129. package/build/5483.6dd2e776.chunk.js +0 -6
  130. package/build/5542.2415a393.chunk.js +0 -63
  131. package/build/6691.4985ef22.chunk.js +0 -105
  132. package/build/7464.3e64a1d5.chunk.js +0 -1
  133. package/build/8276.10a3f883.chunk.js +0 -26
  134. package/build/9944.7af075a5.chunk.js +0 -26
  135. package/build/Admin-authenticatedApp.01fc56de.chunk.js +0 -79
  136. package/build/Admin_InternalErrorPage.f45f2462.chunk.js +0 -1
  137. package/build/Admin_homePage.ac9dfb86.chunk.js +0 -81
  138. package/build/Admin_marketplace.c94239f6.chunk.js +0 -55
  139. package/build/Admin_pluginsPage.bbe79434.chunk.js +0 -6
  140. package/build/Admin_profilePage.192edc52.chunk.js +0 -13
  141. package/build/Admin_settingsPage.97cb9d41.chunk.js +0 -111
  142. package/build/admin-app.91898385.chunk.js +0 -36
  143. package/build/admin-edit-users.acfd4128.chunk.js +0 -10
  144. package/build/email-settings-page.d494d1eb.chunk.js +0 -11
  145. package/build/main.9dbe4579.js +0 -2859
  146. package/build/review-workflows-settings-create-view.cb08cfa2.chunk.js +0 -1
  147. package/build/review-workflows-settings-edit-view.3c7cbe63.chunk.js +0 -1
  148. package/build/review-workflows-settings-list-view.1611dc1f.chunk.js +0 -56
  149. package/build/runtime~main.46a609e9.js +0 -2
  150. package/build/users-advanced-settings-page.f0760eb8.chunk.js +0 -9
  151. package/build/users-email-settings-page.ff4b32f3.chunk.js +0 -9
  152. package/build/users-providers-settings-page.48de0306.chunk.js +0 -14
  153. package/build/users-roles-settings-page.9d9a1eff.chunk.js +0 -30
  154. package/build/webhook-edit-page.6cb479ff.chunk.js +0 -33
  155. package/ee/admin/hooks/index.js +0 -4
  156. package/ee/admin/hooks/useAuthProviders/index.js +0 -50
  157. package/ee/admin/hooks/useAuthProviders/reducer.js +0 -26
  158. package/ee/admin/hooks/useLicenseLimits/index.js +0 -1
  159. /package/ee/admin/hooks/{useLicenseLimits/__mocks__/index.js → __mocks__/useLicenseLimits.js} +0 -0
@@ -1,10 +1,4 @@
1
- /**
2
- *
3
- * App.js
4
- *
5
- */
6
-
7
- import React, { lazy, Suspense, useEffect, useMemo, useState } from 'react';
1
+ import * as React from 'react';
8
2
 
9
3
  import { SkipToContent } from '@strapi/design-system';
10
4
  import {
@@ -12,31 +6,57 @@ import {
12
6
  LoadingIndicatorPage,
13
7
  prefixFileUrlWithBackendUrl,
14
8
  TrackingProvider,
15
- useAppInfo,
16
9
  useFetchClient,
17
- useNotification,
18
10
  } from '@strapi/helper-plugin';
19
11
  import merge from 'lodash/merge';
20
12
  import { useIntl } from 'react-intl';
13
+ import { useQueries } from 'react-query';
21
14
  import { useDispatch } from 'react-redux';
22
15
  import { Route, Switch } from 'react-router-dom';
23
16
 
24
17
  import PrivateRoute from '../../components/PrivateRoute';
25
18
  import { ADMIN_PERMISSIONS_CE } from '../../constants';
26
- import { useConfigurations } from '../../hooks';
19
+ import useConfigurations from '../../hooks/useConfigurations';
27
20
  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';
32
21
 
33
- import { ROUTES_CE, SET_ADMIN_PERMISSIONS } from './constants';
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
+ );
34
35
 
35
- const AuthenticatedApp = lazy(() =>
36
- import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp')
36
+ const UseCasePage = React.lazy(() =>
37
+ import(/* webpackChunkName: "Admin-UseCasePage" */ '../UseCasePage').then((module) => ({
38
+ default: module.UseCasePage,
39
+ }))
37
40
  );
38
41
 
39
- function App() {
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
+
40
60
  const adminPermissions = useEnterprise(
41
61
  ADMIN_PERMISSIONS_CE,
42
62
  async () => (await import('../../../../ee/admin/constants')).ADMIN_PERMISSIONS_EE,
@@ -49,155 +69,173 @@ function App() {
49
69
  defaultValue: ADMIN_PERMISSIONS_CE,
50
70
  }
51
71
  );
52
- const routes = useEnterprise(
53
- ROUTES_CE,
54
- async () => (await import('../../../../ee/admin/pages/App/constants')).ROUTES_EE,
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,
55
77
  {
56
78
  defaultValue: [],
57
79
  }
58
80
  );
59
- const toggleNotification = useNotification();
60
- const { updateProjectSettings } = useConfigurations();
61
- const { formatMessage } = useIntl();
62
- const [{ isLoading, hasAdmin, uuid, deviceId }, setState] = useState({
63
- isLoading: true,
81
+
82
+ // TODO: this should be moved to redux
83
+ const [{ hasAdmin, uuid }, setState] = React.useState({
64
84
  hasAdmin: false,
85
+ uuid: undefined,
65
86
  });
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);
77
87
 
78
- useEffect(() => {
88
+ // Store permissions in redux
89
+ React.useEffect(() => {
79
90
  dispatch({ type: SET_ADMIN_PERMISSIONS, payload: adminPermissions });
80
91
  }, [adminPermissions, dispatch]);
81
92
 
82
- useEffect(() => {
83
- const currentToken = auth.getToken();
84
-
85
- const renewToken = async () => {
86
- try {
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() {
87
101
  const {
88
102
  data: {
89
103
  data: { token },
90
104
  },
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]);
105
+ } = await post('/admin/renew-token', { token: auth.getToken() });
106
+
107
+ return token;
108
+ },
109
+
110
+ enabled: !!auth.getToken(),
111
+ },
104
112
 
105
- useEffect(() => {
106
- const getData = async () => {
107
- try {
113
+ {
114
+ queryKey: 'init',
115
+ async queryFn() {
108
116
  const {
109
- data: {
110
- data: { hasAdmin, uuid, menuLogo, authLogo },
111
- },
117
+ data: { data },
112
118
  } = await get(`/admin/init`);
113
119
 
114
- updateProjectSettings({
115
- menuLogo: prefixFileUrlWithBackendUrl(menuLogo),
116
- authLogo: prefixFileUrlWithBackendUrl(authLogo),
117
- });
120
+ return data;
121
+ },
122
+ },
118
123
 
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' },
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,
158
133
  });
159
- }
160
- };
161
134
 
162
- getData();
163
- // eslint-disable-next-line react-hooks/exhaustive-deps
164
- }, [toggleNotification, updateProjectSettings]);
135
+ return data;
136
+ },
137
+
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
+ }
165
194
 
166
- const setHasAdmin = (hasAdmin) => setState((prev) => ({ ...prev, hasAdmin }));
195
+ if (uuid) {
196
+ trackInitEvent();
197
+ }
198
+ }, [telemetryProperties, uuid]);
167
199
 
168
- const trackingInfo = useMemo(
200
+ const trackingContext = React.useMemo(
169
201
  () => ({
170
202
  uuid,
171
203
  telemetryProperties,
172
- deviceId,
173
204
  }),
174
- [uuid, telemetryProperties, deviceId]
205
+ [uuid, telemetryProperties]
175
206
  );
176
207
 
177
- if (isLoading) {
208
+ if (isLoadingInit) {
178
209
  return <LoadingIndicatorPage />;
179
210
  }
180
211
 
181
212
  return (
182
- <Suspense fallback={<LoadingIndicatorPage />}>
213
+ <React.Suspense fallback={<LoadingIndicatorPage />}>
183
214
  <SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent>
184
- <TrackingProvider value={trackingInfo}>
215
+ <TrackingProvider value={trackingContext}>
185
216
  <Switch>
186
- {authRoutes}
217
+ {authRoutes.map(({ path, component }) => (
218
+ <Route key={path} path={path} component={component} exact />
219
+ ))}
220
+
187
221
  <Route
188
222
  path="/auth/:authType"
189
223
  render={(routerProps) => (
190
- <AuthPage {...routerProps} setHasAdmin={setHasAdmin} hasAdmin={hasAdmin} />
224
+ <AuthPage
225
+ {...routerProps}
226
+ setHasAdmin={(hasAdmin) => setState((prev) => ({ ...prev, hasAdmin }))}
227
+ hasAdmin={hasAdmin}
228
+ />
191
229
  )}
192
230
  exact
193
231
  />
194
232
  <PrivateRoute path="/usecase" component={UseCasePage} />
195
233
  <PrivateRoute path="/" component={AuthenticatedApp} />
234
+ <Route path="/404" component={NotFoundPage} />
235
+ <Route path="/500" component={InternalErrorPage} />
196
236
  <Route path="" component={NotFoundPage} />
197
237
  </Switch>
198
238
  </TrackingProvider>
199
- </Suspense>
239
+ </React.Suspense>
200
240
  );
201
241
  }
202
-
203
- export default App;
@@ -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
- const AuthPage = ({ hasAdmin, setHasAdmin }) => {
21
+ export const AuthPage = ({ hasAdmin, setHasAdmin }) => {
22
22
  const {
23
23
  push,
24
24
  location: { search },
@@ -315,5 +315,3 @@ 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
- function HomePageSwitch() {
92
+ export function HomePage() {
93
93
  const HomePage = useEnterprise(
94
94
  HomePageCE,
95
95
  // eslint-disable-next-line import/no-cycle
@@ -103,5 +103,3 @@ function HomePageSwitch() {
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
- const InstalledPluginsPage = () => {
12
+ export const PluginsPage = () => {
13
13
  const { formatMessage } = useIntl();
14
14
  const permissions = useSelector(selectAdminPermissions);
15
15
 
@@ -25,5 +25,3 @@ const InstalledPluginsPage = () => {
25
25
  </CheckPagePermissions>
26
26
  );
27
27
  };
28
-
29
- export default InstalledPluginsPage;
@@ -4,15 +4,16 @@
4
4
  * This is the page we show when the user gets a 500 error
5
5
  *
6
6
  */
7
- import React from 'react';
7
+ import * as 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
- const InternalErrorPage = () => {
14
+ export const InternalErrorPage = () => {
15
15
  const { formatMessage } = useIntl();
16
+
16
17
  useFocusWhenNavigate();
17
18
 
18
19
  return (
@@ -46,5 +47,3 @@ const InternalErrorPage = () => {
46
47
  </Main>
47
48
  );
48
49
  };
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
- const NoContentType = () => {
14
+ export const NotFoundPage = () => {
15
15
  const { formatMessage } = useIntl();
16
16
  useFocusWhenNavigate();
17
17
 
@@ -46,5 +46,3 @@ const NoContentType = () => {
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';
31
+ import { getFullName } from '../../utils/getFullName';
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
- const ProfilePage = () => {
38
+ export const ProfilePage = () => {
39
39
  const { changeLocale, localeNames } = useLocalesProvider();
40
40
  const { setUserDisplayName } = useAppInfo();
41
41
  const queryClient = useQueryClient();
@@ -231,5 +231,3 @@ const ProfilePage = () => {
231
231
  </Main>
232
232
  );
233
233
  };
234
-
235
- export default ProfilePage;
@@ -12,14 +12,14 @@ import PropTypes from 'prop-types';
12
12
  import { useIntl } from 'react-intl';
13
13
  import { NavLink, useLocation } from 'react-router-dom';
14
14
 
15
- import { getSectionsToDisplay } from '../../utils';
16
-
17
15
  const SettingsNav = ({ menu }) => {
18
16
  const { formatMessage } = useIntl();
19
17
  const { trackUsage } = useTracking();
20
18
  const { pathname } = useLocation();
21
19
 
22
- const filteredMenu = getSectionsToDisplay(menu);
20
+ const filteredMenu = menu.filter(
21
+ (section) => !section.links.every((link) => link.isDisplayed === false)
22
+ );
23
23
 
24
24
  const sections = filteredMenu.map((section) => {
25
25
  return {