@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,167 +1,102 @@
1
- export const ROUTES_CE = [
2
- {
3
- async Component() {
4
- const component = await import(
5
- /* webpackChunkName: "admin-roles-list" */ './pages/Roles/ProtectedListPage'
6
- );
1
+ import * as React from 'react';
7
2
 
8
- return component;
9
- },
10
- to: '/settings/roles',
11
- exact: true,
3
+ export const SETTINGS_ROUTES_CE = [
4
+ {
5
+ component: React.lazy(() =>
6
+ import(/* webpackChunkName: "admin-roles-list" */ './pages/Roles/ProtectedListPage')
7
+ ),
8
+ path: '/settings/roles',
12
9
  },
13
10
  {
14
- async Component() {
15
- const component = await import(
16
- /* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/CreatePage'
17
- );
18
-
19
- return component;
20
- },
21
- to: '/settings/roles/duplicate/:id',
22
- exact: true,
11
+ component: React.lazy(() =>
12
+ import(/* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/CreatePage')
13
+ ),
14
+ path: '/settings/roles/duplicate/:id',
23
15
  },
24
16
  {
25
- async Component() {
26
- const component = await import(
27
- /* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/CreatePage'
28
- );
29
-
30
- return component;
31
- },
32
- to: '/settings/roles/new',
33
- exact: true,
17
+ component: React.lazy(() =>
18
+ import(/* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/CreatePage')
19
+ ),
20
+ path: '/settings/roles/new',
34
21
  },
35
22
  {
36
- async Component() {
37
- const component = await import(
38
- /* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/ProtectedEditPage'
39
- );
40
-
41
- return component;
42
- },
43
- to: '/settings/roles/:id',
44
- exact: true,
23
+ component: React.lazy(() =>
24
+ import(/* webpackChunkName: "admin-edit-roles-page" */ './pages/Roles/ProtectedEditPage')
25
+ ),
26
+ path: '/settings/roles/:id',
45
27
  },
46
28
  {
47
- async Component() {
48
- const component = await import(
49
- /* webpackChunkName: "admin-users" */ './pages/Users/ProtectedListPage'
50
- );
51
-
52
- return component;
53
- },
54
- to: '/settings/users',
55
- exact: true,
29
+ component: React.lazy(() =>
30
+ import(/* webpackChunkName: "admin-users" */ './pages/Users/ProtectedListPage')
31
+ ),
32
+ path: '/settings/users',
56
33
  },
57
34
  {
58
- async Component() {
59
- const component = await import(
60
- /* webpackChunkName: "admin-edit-users" */ './pages/Users/ProtectedEditPage'
61
- );
62
-
63
- return component;
64
- },
65
- to: '/settings/users/:id',
66
- exact: true,
35
+ component: React.lazy(() =>
36
+ import(/* webpackChunkName: "admin-edit-users" */ './pages/Users/ProtectedEditPage')
37
+ ),
38
+ path: '/settings/users/:id',
67
39
  },
68
40
  {
69
- async Component() {
70
- const component = await import(
71
- /* webpackChunkName: "webhook-edit-page" */ './pages/Webhooks/ProtectedCreateView'
72
- );
73
-
74
- return component;
75
- },
76
- to: '/settings/webhooks/create',
77
- exact: true,
41
+ component: React.lazy(() =>
42
+ import(/* webpackChunkName: "webhook-edit-page" */ './pages/Webhooks/ProtectedCreateView')
43
+ ),
44
+ path: '/settings/webhooks/create',
78
45
  },
79
46
  {
80
- async Component() {
81
- const component = await import(
82
- /* webpackChunkName: "webhook-edit-page" */ './pages/Webhooks/ProtectedEditView'
83
- );
84
-
85
- return component;
86
- },
87
- to: '/settings/webhooks/:id',
88
- exact: true,
47
+ component: React.lazy(() =>
48
+ import(/* webpackChunkName: "webhook-edit-page" */ './pages/Webhooks/ProtectedEditView')
49
+ ),
50
+ path: '/settings/webhooks/:id',
89
51
  },
90
52
  {
91
- async Component() {
92
- const component = await import(
93
- /* webpackChunkName: "webhook-list-page" */ './pages/Webhooks/ProtectedListView'
94
- );
95
-
96
- return component;
97
- },
98
- to: '/settings/webhooks',
99
- exact: true,
53
+ component: React.lazy(() =>
54
+ import(/* webpackChunkName: "webhook-list-page" */ './pages/Webhooks/ProtectedListView')
55
+ ),
56
+ path: '/settings/webhooks',
100
57
  },
101
58
  {
102
- async Component() {
103
- const component = await import(
104
- /* webpackChunkName: "api-tokens-list-page" */ './pages/ApiTokens/ProtectedListView'
105
- );
106
-
107
- return component;
108
- },
109
- to: '/settings/api-tokens',
110
- exact: true,
59
+ component: React.lazy(() =>
60
+ import(/* webpackChunkName: "api-tokens-list-page" */ './pages/ApiTokens/ProtectedListView')
61
+ ),
62
+ path: '/settings/api-tokens',
111
63
  },
112
64
  {
113
- async Component() {
114
- const component = await import(
65
+ component: React.lazy(() =>
66
+ import(
115
67
  /* webpackChunkName: "api-tokens-create-page" */ './pages/ApiTokens/ProtectedCreateView'
116
- );
117
-
118
- return component;
119
- },
120
- to: '/settings/api-tokens/create',
121
- exact: true,
68
+ )
69
+ ),
70
+ path: '/settings/api-tokens/create',
122
71
  },
123
72
  {
124
- async Component() {
125
- const component = await import(
126
- /* webpackChunkName: "api-tokens-edit-page" */ './pages/ApiTokens/ProtectedEditView'
127
- );
128
-
129
- return component;
130
- },
131
- to: '/settings/api-tokens/:id',
132
- exact: true,
73
+ component: React.lazy(() =>
74
+ import(/* webpackChunkName: "api-tokens-edit-page" */ './pages/ApiTokens/ProtectedEditView')
75
+ ),
76
+ path: '/settings/api-tokens/:id',
133
77
  },
134
78
  {
135
- async Component() {
136
- const component = await import(
79
+ component: React.lazy(() =>
80
+ import(
137
81
  /* webpackChunkName: "transfer-tokens-create-page" */ './pages/TransferTokens/ProtectedCreateView'
138
- );
139
-
140
- return component;
141
- },
142
- to: '/settings/transfer-tokens/create',
143
- exact: true,
82
+ )
83
+ ),
84
+ path: '/settings/transfer-tokens/create',
144
85
  },
145
86
  {
146
- async Component() {
147
- const component = await import(
87
+ component: React.lazy(() =>
88
+ import(
148
89
  /* webpackChunkName: "transfer-tokens-list-page" */ './pages/TransferTokens/ProtectedListView'
149
- );
150
-
151
- return component;
152
- },
153
- to: '/settings/transfer-tokens',
154
- exact: true,
90
+ )
91
+ ),
92
+ path: '/settings/transfer-tokens',
155
93
  },
156
94
  {
157
- async Component() {
158
- const component = await import(
95
+ component: React.lazy(() =>
96
+ import(
159
97
  /* webpackChunkName: "transfer-tokens-edit-page" */ './pages/TransferTokens/ProtectedEditView'
160
- );
161
-
162
- return component;
163
- },
164
- to: '/settings/transfer-tokens/:id',
165
- exact: true,
98
+ )
99
+ ),
100
+ path: '/settings/transfer-tokens/:id',
166
101
  },
167
102
  ];
@@ -1,15 +1,4 @@
1
- /**
2
- *
3
- * SettingsPage
4
- *
5
- */
6
-
7
- // NOTE TO PLUGINS DEVELOPERS:
8
- // If you modify this file you also need to update the documentation accordingly
9
- // Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-settings-api.md
10
- // IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
11
-
12
- import React, { memo, useMemo } from 'react';
1
+ import * as React from 'react';
13
2
 
14
3
  import { Layout } from '@strapi/design-system';
15
4
  import { LoadingIndicatorPage, useStrapiApp } from '@strapi/helper-plugin';
@@ -19,21 +8,21 @@ import { Redirect, Route, Switch, useParams } from 'react-router-dom';
19
8
 
20
9
  import { useSettingsMenu } from '../../hooks';
21
10
  import { useEnterprise } from '../../hooks/useEnterprise';
22
- import { createRoute, makeUniqueRoutes } from '../../utils';
11
+ import { createRoute } from '../../utils/createRoute';
23
12
 
24
13
  import SettingsNav from './components/SettingsNav';
25
- import { ROUTES_CE } from './constants';
14
+ import { SETTINGS_ROUTES_CE } from './constants';
26
15
  import ApplicationInfosPage from './pages/ApplicationInfosPage';
27
- import { createSectionsRoutes } from './utils';
28
16
 
29
- function SettingsPage() {
17
+ export function SettingsPage() {
30
18
  const { settingId } = useParams();
31
19
  const { settings } = useStrapiApp();
32
20
  const { formatMessage } = useIntl();
33
21
  const { isLoading, menu } = useSettingsMenu();
34
22
  const routes = useEnterprise(
35
- ROUTES_CE,
36
- async () => (await import('../../../../ee/admin/pages/SettingsPage/constants')).ROUTES_EE,
23
+ SETTINGS_ROUTES_CE,
24
+ async () =>
25
+ (await import('../../../../ee/admin/pages/SettingsPage/constants')).SETTINGS_ROUTES_EE,
37
26
  {
38
27
  combine(ceRoutes, eeRoutes) {
39
28
  return [...ceRoutes, ...eeRoutes];
@@ -42,14 +31,19 @@ function SettingsPage() {
42
31
  }
43
32
  );
44
33
 
45
- // Creates the admin routes
46
- const adminRoutes = useMemo(() => {
47
- return makeUniqueRoutes(
48
- routes.map(({ to, Component, exact }) => createRoute(Component, to, exact))
49
- );
50
- }, [routes]);
34
+ /**
35
+ * `Component` is an async function, which is passed as property of the
36
+ * addSettingsLink() API during the plugin bootstrap step.
37
+ *
38
+ * Because of that we can't just render <Route component={Component} />,
39
+ * but have to await the function.
40
+ *
41
+ * This isn't a good React pattern and should be reconsidered.
42
+ */
51
43
 
52
- const pluginsRoutes = createSectionsRoutes(settings);
44
+ const pluginSettingsRoutes = Object.values(settings).flatMap((section) =>
45
+ section.links.map((link) => createRoute(link.Component, link.to, link.exact || false))
46
+ );
53
47
 
54
48
  // Since the useSettingsMenu hook can make API calls in order to check the links permissions
55
49
  // We need to add a loading state to prevent redirecting the user while permissions are being checked
@@ -61,23 +55,24 @@ function SettingsPage() {
61
55
  return <Redirect to="/settings/application-infos" />;
62
56
  }
63
57
 
64
- const settingTitle = formatMessage({
65
- id: 'global.settings',
66
- defaultMessage: 'Settings',
67
- });
68
-
69
58
  return (
70
59
  <Layout sideNav={<SettingsNav menu={menu} />}>
71
- <Helmet title={settingTitle} />
60
+ <Helmet
61
+ title={formatMessage({
62
+ id: 'global.settings',
63
+ defaultMessage: 'Settings',
64
+ })}
65
+ />
72
66
 
73
67
  <Switch>
74
68
  <Route path="/settings/application-infos" component={ApplicationInfosPage} exact />
75
- {adminRoutes}
76
- {pluginsRoutes}
69
+
70
+ {routes.map(({ path, component }) => (
71
+ <Route key={path} path={path} component={component} exact />
72
+ ))}
73
+
74
+ {pluginSettingsRoutes}
77
75
  </Switch>
78
76
  </Layout>
79
77
  );
80
78
  }
81
-
82
- export default memo(SettingsPage);
83
- export { SettingsPage };
@@ -19,7 +19,7 @@ import { useSelector } from 'react-redux';
19
19
  import { useHistory, useRouteMatch } from 'react-router-dom';
20
20
 
21
21
  import { ApiTokenPermissionsContextProvider } from '../../../../../contexts/ApiTokenPermissions';
22
- import { formatAPIErrors } from '../../../../../utils';
22
+ import { formatAPIErrors } from '../../../../../utils/formatAPIErrors';
23
23
  import { selectAdminPermissions } from '../../../../App/selectors';
24
24
  import { API_TOKEN_TYPE } from '../../../components/Tokens/constants';
25
25
  import FormHead from '../../../components/Tokens/FormHead';
@@ -1,4 +1,4 @@
1
- import React, { useRef } from 'react';
1
+ import * as React from 'react';
2
2
 
3
3
  import {
4
4
  Button,
@@ -14,8 +14,11 @@ import {
14
14
  Typography,
15
15
  } from '@strapi/design-system';
16
16
  import {
17
+ prefixFileUrlWithBackendUrl,
17
18
  SettingsPageTitle,
19
+ useAPIErrorHandler,
18
20
  useAppInfo,
21
+ useFetchClient,
19
22
  useFocusWhenNavigate,
20
23
  useNotification,
21
24
  useRBAC,
@@ -23,7 +26,7 @@ import {
23
26
  } from '@strapi/helper-plugin';
24
27
  import { Check, ExternalLink } from '@strapi/icons';
25
28
  import { useIntl } from 'react-intl';
26
- import { useMutation, useQuery, useQueryClient } from 'react-query';
29
+ import { useMutation, useQuery } from 'react-query';
27
30
  import { useSelector } from 'react-redux';
28
31
 
29
32
  import { useConfigurations } from '../../../../hooks';
@@ -31,18 +34,20 @@ import { useEnterprise } from '../../../../hooks/useEnterprise';
31
34
  import { selectAdminPermissions } from '../../../App/selectors';
32
35
 
33
36
  import CustomizationInfos from './components/CustomizationInfos';
34
- import { fetchProjectSettings, postProjectSettings } from './utils/api';
35
37
  import getFormData from './utils/getFormData';
36
38
 
37
39
  const AdminSeatInfoCE = () => null;
38
40
 
39
41
  const ApplicationInfosPage = () => {
40
- const inputsRef = useRef();
42
+ const inputsRef = React.useRef();
41
43
  const toggleNotification = useNotification();
42
44
  const { trackUsage } = useTracking();
43
45
  const { formatMessage } = useIntl();
44
- const queryClient = useQueryClient();
45
- useFocusWhenNavigate();
46
+ const { get, post } = useFetchClient();
47
+ const { updateProjectSettings } = useConfigurations();
48
+ const permissions = useSelector(selectAdminPermissions);
49
+ const { formatAPIError } = useAPIErrorHandler();
50
+
46
51
  const {
47
52
  communityEdition,
48
53
  latestStrapiReleaseTag,
@@ -50,8 +55,7 @@ const ApplicationInfosPage = () => {
50
55
  shouldUpdateStrapi,
51
56
  strapiVersion,
52
57
  } = useAppInfo();
53
- const { updateProjectSettings } = useConfigurations();
54
- const permissions = useSelector(selectAdminPermissions);
58
+
55
59
  const AdminSeatInfo = useEnterprise(
56
60
  AdminSeatInfoCE,
57
61
  async () =>
@@ -65,38 +69,68 @@ const ApplicationInfosPage = () => {
65
69
  const {
66
70
  allowedActions: { canRead, canUpdate },
67
71
  } = useRBAC(permissions.settings['project-settings']);
68
- const canSubmit = canRead && canUpdate;
69
72
 
70
- const { data, isLoading } = useQuery('project-settings', fetchProjectSettings, {
71
- enabled: canRead,
72
- });
73
+ useFocusWhenNavigate();
73
74
 
74
- const submitMutation = useMutation((body) => postProjectSettings(body), {
75
- async onSuccess({ menuLogo, authLogo }) {
76
- await queryClient.invalidateQueries('project-settings', { refetchActive: true });
77
- updateProjectSettings({ menuLogo: menuLogo?.url, authLogo: authLogo?.url });
75
+ const { data, isLoading } = useQuery(
76
+ ['project-settings'],
77
+ async () => {
78
+ const { data } = await get('/admin/project-settings');
79
+
80
+ return data;
78
81
  },
79
- });
82
+ {
83
+ cacheTime: 0,
84
+ enabled: canRead,
85
+ select(data) {
86
+ return {
87
+ ...data,
80
88
 
81
- const handleSubmit = (e) => {
82
- e.preventDefault();
89
+ authLogo: data.authLogo
90
+ ? {
91
+ ...data.authLogo,
92
+ url: prefixFileUrlWithBackendUrl(data.authLogo.url),
93
+ }
94
+ : data.authLogo,
83
95
 
84
- if (!canUpdate) return;
96
+ menuLogo: data.menuLogo
97
+ ? {
98
+ ...data.menuLogo,
99
+ url: prefixFileUrlWithBackendUrl(data.menuLogo.url),
100
+ }
101
+ : data.menuLogo,
102
+ };
103
+ },
104
+ }
105
+ );
85
106
 
86
- const inputValues = inputsRef.current.getValues();
87
- const formData = getFormData(inputValues);
107
+ const submitMutation = useMutation(
108
+ (body) =>
109
+ post('/admin/project-settings', body, {
110
+ headers: {
111
+ 'Content-Type': 'multipart/form-data',
112
+ },
113
+ }),
114
+ {
115
+ onError(error) {
116
+ toggleNotification({
117
+ type: 'warning',
118
+ message: formatAPIError(error),
119
+ });
120
+ },
88
121
 
89
- submitMutation.mutate(formData, {
90
- onSuccess() {
91
- const { menuLogo, authLogo } = inputValues;
122
+ async onSuccess(data) {
123
+ const { menuLogo, authLogo } = data;
92
124
 
93
- if (menuLogo.rawFile) {
125
+ updateProjectSettings({ menuLogo: menuLogo?.url, authLogo: authLogo?.url });
126
+
127
+ if (menuLogo?.rawFile) {
94
128
  trackUsage('didChangeLogo', {
95
129
  logo: 'menu',
96
130
  });
97
131
  }
98
132
 
99
- if (authLogo.rawFile) {
133
+ if (authLogo?.rawFile) {
100
134
  trackUsage('didChangeLogo', {
101
135
  logo: 'auth',
102
136
  });
@@ -107,13 +141,13 @@ const ApplicationInfosPage = () => {
107
141
  message: formatMessage({ id: 'app', defaultMessage: 'Saved' }),
108
142
  });
109
143
  },
110
- onError() {
111
- toggleNotification({
112
- type: 'warning',
113
- message: { id: 'notification.error', defaultMessage: 'An error occurred' },
114
- });
115
- },
116
- });
144
+ }
145
+ );
146
+
147
+ const handleSubmit = (e) => {
148
+ e.preventDefault();
149
+
150
+ submitMutation.mutate(getFormData(inputsRef.current.getValues()));
117
151
  };
118
152
 
119
153
  // block rendering until the EE component is fully loaded
@@ -145,7 +179,7 @@ const ApplicationInfosPage = () => {
145
179
  defaultMessage: 'Administration panel’s global information',
146
180
  })}
147
181
  primaryAction={
148
- canSubmit && (
182
+ canUpdate && (
149
183
  <Button type="submit" startIcon={<Check />}>
150
184
  {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
151
185
  </Button>
@@ -19,7 +19,7 @@ import { useQuery } from 'react-query';
19
19
  import { useSelector } from 'react-redux';
20
20
  import { useHistory, useRouteMatch } from 'react-router-dom';
21
21
 
22
- import { formatAPIErrors } from '../../../../../utils';
22
+ import { formatAPIErrors } from '../../../../../utils/formatAPIErrors';
23
23
  import { selectAdminPermissions } from '../../../../App/selectors';
24
24
  import { TRANSFER_TOKEN_TYPE } from '../../../components/Tokens/constants';
25
25
  import FormHead from '../../../components/Tokens/FormHead';
@@ -34,7 +34,8 @@ import { useHistory, useRouteMatch } from 'react-router-dom';
34
34
 
35
35
  import { useAdminUsers } from '../../../../../hooks/useAdminUsers';
36
36
  import { useEnterprise } from '../../../../../hooks/useEnterprise';
37
- import { formatAPIErrors, getFullName } from '../../../../../utils';
37
+ import { formatAPIErrors } from '../../../../../utils/formatAPIErrors';
38
+ import { getFullName } from '../../../../../utils/getFullName';
38
39
  import { MagicLinkCE } from '../components/MagicLink';
39
40
  import SelectRoles from '../components/SelectRoles';
40
41
  import { editValidation } from '../utils/validations/users';
@@ -16,7 +16,7 @@ import PropTypes from 'prop-types';
16
16
  import { useIntl } from 'react-intl';
17
17
  import { useHistory } from 'react-router-dom';
18
18
 
19
- import { getFullName } from '../../../../../../../utils';
19
+ import { getFullName } from '../../../../../../../utils/getFullName';
20
20
 
21
21
  const TableRows = ({
22
22
  canDelete,