@strapi/admin 4.12.4 → 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 (187) 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/components/Wysiwyg/WysiwygNav.js +7 -30
  5. package/admin/src/content-manager/hooks/useSyncRbac/index.js +10 -2
  6. package/admin/src/content-manager/pages/App/index.js +5 -16
  7. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +1 -1
  8. package/admin/src/content-manager/pages/EditView/Information/index.js +1 -1
  9. package/admin/src/content-manager/pages/EditViewLayoutManager/index.js +2 -2
  10. package/admin/src/content-manager/pages/ListSettingsView/index.js +16 -41
  11. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  12. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  13. package/admin/src/content-manager/pages/ListView/index.js +27 -1
  14. package/admin/src/content-manager/pages/ListViewLayoutManager/index.js +2 -2
  15. package/admin/src/hooks/useSettingsForm/index.js +14 -3
  16. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  17. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +1 -3
  18. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +1 -3
  19. package/admin/src/index.js +1 -1
  20. package/admin/src/pages/Admin/Onboarding/index.js +1 -3
  21. package/admin/src/pages/Admin/index.js +80 -74
  22. package/admin/src/pages/App/constants.js +1 -1
  23. package/admin/src/pages/App/index.js +160 -122
  24. package/admin/src/pages/AuthPage/index.js +2 -4
  25. package/admin/src/pages/HomePage/index.js +1 -3
  26. package/admin/src/pages/InstalledPluginsPage/index.js +1 -3
  27. package/admin/src/pages/{InternalErrorPage/index.js → InternalErrorPage.js} +3 -4
  28. package/admin/src/pages/MarketplacePage/index.js +0 -1
  29. package/admin/src/pages/{NotFoundPage/index.js → NotFoundPage.js} +1 -3
  30. package/admin/src/pages/ProfilePage/index.js +2 -4
  31. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +3 -3
  32. package/admin/src/pages/SettingsPage/constants.js +67 -132
  33. package/admin/src/pages/SettingsPage/index.js +31 -36
  34. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  35. package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +24 -31
  36. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +69 -35
  37. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  38. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +11 -6
  39. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +4 -1
  40. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  41. package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +1 -0
  42. package/admin/src/pages/UseCasePage.js +174 -0
  43. package/admin/src/translations/zh-Hans.json +918 -902
  44. package/admin/src/utils/createRoute.js +5 -7
  45. package/admin/src/utils/formatAPIErrors.js +1 -3
  46. package/admin/src/utils/getFullName.js +1 -1
  47. package/admin/src/utils/sortLinks.js +1 -3
  48. package/admin/src/utils/uniqueAdminHash.js +2 -9
  49. package/build/{1049.f76cb14b.chunk.js → 1049.9d69d231.chunk.js} +1 -1
  50. package/build/1504.eff012f7.chunk.js +95 -0
  51. package/build/2166.c837469a.chunk.js +1 -0
  52. package/build/2225.33287e1b.chunk.js +79 -0
  53. package/build/2237.03792b63.chunk.js +114 -0
  54. package/build/2379.401f56f3.chunk.js +1 -0
  55. package/build/2395.e6a79fbb.chunk.js +26 -0
  56. package/build/{9806.3392505e.chunk.js → 2747.d1442a90.chunk.js} +78 -70
  57. package/build/2801.31393ffe.chunk.js +1 -0
  58. package/build/3483.8517171f.chunk.js +1 -0
  59. package/build/4546.7a3c0d03.chunk.js +1 -0
  60. package/build/502.8dd074ff.chunk.js +1 -0
  61. package/build/5483.5bfbb00d.chunk.js +6 -0
  62. package/build/7464.592a9295.chunk.js +1 -0
  63. package/build/748.fd2e5afd.chunk.js +105 -0
  64. package/build/773.6381d62d.chunk.js +18 -0
  65. package/build/7826.399afe81.chunk.js +103 -0
  66. package/build/8261.2525d35c.chunk.js +7 -0
  67. package/build/8276.e519a707.chunk.js +26 -0
  68. package/build/8299.62b67c72.chunk.js +1 -0
  69. package/build/Admin-AuthPage.90d64342.chunk.js +35 -0
  70. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +24 -0
  71. package/build/Admin-UseCasePage.1f757db5.chunk.js +13 -0
  72. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +12 -0
  73. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +9 -0
  74. package/build/Admin_NotFoundPage.21620424.chunk.js +9 -0
  75. package/build/Admin_Onboarding.dbfa32f6.chunk.js +43 -0
  76. package/build/Admin_homePage.2000cbe9.chunk.js +86 -0
  77. package/build/Admin_marketplace.ec80e29b.chunk.js +63 -0
  78. package/build/Admin_pluginsPage.0c6851f8.chunk.js +14 -0
  79. package/build/Admin_profilePage.78cd8495.chunk.js +21 -0
  80. package/build/Admin_settingsPage.1760c3ce.chunk.js +119 -0
  81. package/build/StrapiApp.221fac30.chunk.js +5 -0
  82. package/build/{admin-edit-roles-page.6d567273.chunk.js → admin-edit-roles-page.24bdf746.chunk.js} +1 -1
  83. package/build/admin-edit-users.5d10d444.chunk.js +10 -0
  84. package/build/admin-users.2b3e4305.chunk.js +11 -0
  85. package/build/api-tokens-list-page.0af7d431.chunk.js +16 -0
  86. package/build/audit-logs-settings-page.0f73ccf8.chunk.js +1 -0
  87. package/build/content-manager.fb0833bd.chunk.js +1099 -0
  88. package/build/{content-type-builder.40534de5.chunk.js → content-type-builder.66066281.chunk.js} +18 -18
  89. package/build/email-settings-page.2f7e35c0.chunk.js +11 -0
  90. package/build/i18n-translation-ru-json.a3dbc125.chunk.js +1 -0
  91. package/build/index.html +1 -1
  92. package/build/main.ee3c1938.js +2859 -0
  93. package/build/review-workflows-settings-create-view.d24a32b9.chunk.js +1 -0
  94. package/build/review-workflows-settings-edit-view.6044b022.chunk.js +1 -0
  95. package/build/review-workflows-settings-list-view.3f0ef4bc.chunk.js +56 -0
  96. package/build/runtime~main.397ee447.js +2 -0
  97. package/build/{sso-settings-page.12b6d8ae.chunk.js → sso-settings-page.4dba0670.chunk.js} +1 -1
  98. package/build/transfer-tokens-list-page.d6986b03.chunk.js +16 -0
  99. package/build/users-advanced-settings-page.17052d72.chunk.js +9 -0
  100. package/build/users-email-settings-page.3de8ea50.chunk.js +9 -0
  101. package/build/users-permissions-translation-zh-Hans-json.8d82c809.chunk.js +1 -0
  102. package/build/users-providers-settings-page.0eaa916d.chunk.js +14 -0
  103. package/build/users-roles-settings-page.957ad48b.chunk.js +55 -0
  104. package/build/webhook-edit-page.665210af.chunk.js +33 -0
  105. package/build/zh-Hans-json.97efd015.chunk.js +1 -0
  106. package/ee/admin/hooks/useAuthProviders.js +25 -0
  107. package/ee/admin/hooks/{useLicenseLimitNotification/index.js → useLicenseLimitNotification.js} +2 -4
  108. package/ee/admin/hooks/{useLicenseLimits/useLicenseLimits.js → useLicenseLimits.js} +4 -1
  109. package/ee/admin/pages/App/constants.js +6 -5
  110. package/ee/admin/pages/AuthPage/components/Login/index.js +8 -4
  111. package/ee/admin/pages/AuthPage/components/Providers/index.js +8 -5
  112. package/ee/admin/pages/HomePage/index.js +1 -1
  113. package/ee/admin/pages/SettingsPage/constants.js +27 -42
  114. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/CreateView.js +1 -1
  115. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/EditView.js +1 -1
  116. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/ListView.js +1 -1
  117. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +1 -1
  118. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
  119. package/package.json +10 -10
  120. package/admin/src/components/AuthenticatedApp/index.js +0 -118
  121. package/admin/src/components/AuthenticatedApp/utils/api.js +0 -85
  122. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +0 -11
  123. package/admin/src/components/PluginsInitializer/index.js +0 -68
  124. package/admin/src/components/PluginsInitializer/init.js +0 -11
  125. package/admin/src/components/PluginsInitializer/reducer.js +0 -22
  126. package/admin/src/layouts/AppLayout/index.js +0 -33
  127. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +0 -23
  128. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +0 -17
  129. package/admin/src/pages/SettingsPage/utils/createSectionsRoutes.js +0 -11
  130. package/admin/src/pages/SettingsPage/utils/getSectionsToDisplay.js +0 -5
  131. package/admin/src/pages/SettingsPage/utils/index.js +0 -2
  132. package/admin/src/pages/UseCasePage/index.js +0 -175
  133. package/admin/src/utils/checkFormValidity.js +0 -15
  134. package/admin/src/utils/getAttributesToDisplay.js +0 -19
  135. package/admin/src/utils/getExistingActions.js +0 -32
  136. package/admin/src/utils/index.js +0 -9
  137. package/admin/src/utils/makeUniqueRoutes.js +0 -6
  138. package/build/1386.879bcd90.chunk.js +0 -7
  139. package/build/2225.c6244756.chunk.js +0 -79
  140. package/build/2379.f1641312.chunk.js +0 -1
  141. package/build/2395.46f8d0c1.chunk.js +0 -26
  142. package/build/2801.5cef5ec8.chunk.js +0 -1
  143. package/build/3483.03c24f96.chunk.js +0 -1
  144. package/build/3739.63e352f1.chunk.js +0 -103
  145. package/build/3929.5632f24d.chunk.js +0 -114
  146. package/build/448.829e1344.chunk.js +0 -1
  147. package/build/4546.cfafae68.chunk.js +0 -1
  148. package/build/502.8ae8ef60.chunk.js +0 -1
  149. package/build/5483.6dd2e776.chunk.js +0 -6
  150. package/build/5542.2415a393.chunk.js +0 -63
  151. package/build/6691.4985ef22.chunk.js +0 -105
  152. package/build/7464.3e64a1d5.chunk.js +0 -1
  153. package/build/8276.10a3f883.chunk.js +0 -26
  154. package/build/9944.7af075a5.chunk.js +0 -26
  155. package/build/Admin-authenticatedApp.f5ece8ff.chunk.js +0 -79
  156. package/build/Admin_InternalErrorPage.f45f2462.chunk.js +0 -1
  157. package/build/Admin_homePage.ac9dfb86.chunk.js +0 -81
  158. package/build/Admin_marketplace.dde9c148.chunk.js +0 -55
  159. package/build/Admin_pluginsPage.bbe79434.chunk.js +0 -6
  160. package/build/Admin_profilePage.192edc52.chunk.js +0 -13
  161. package/build/Admin_settingsPage.97cb9d41.chunk.js +0 -111
  162. package/build/admin-app.91898385.chunk.js +0 -36
  163. package/build/admin-edit-users.79eeb125.chunk.js +0 -10
  164. package/build/admin-users.123aa08e.chunk.js +0 -11
  165. package/build/api-tokens-list-page.505bf7e0.chunk.js +0 -16
  166. package/build/audit-logs-settings-page.4b422831.chunk.js +0 -1
  167. package/build/content-manager.2af15f57.chunk.js +0 -1099
  168. package/build/email-settings-page.d494d1eb.chunk.js +0 -11
  169. package/build/i18n-translation-ru-json.401bc498.chunk.js +0 -1
  170. package/build/main.f13fc96c.js +0 -2856
  171. package/build/review-workflows-settings-create-view.cb08cfa2.chunk.js +0 -1
  172. package/build/review-workflows-settings-edit-view.3c7cbe63.chunk.js +0 -1
  173. package/build/review-workflows-settings-list-view.1611dc1f.chunk.js +0 -56
  174. package/build/runtime~main.bb4efc54.js +0 -2
  175. package/build/transfer-tokens-list-page.22147d2c.chunk.js +0 -16
  176. package/build/users-advanced-settings-page.f0760eb8.chunk.js +0 -9
  177. package/build/users-email-settings-page.ff4b32f3.chunk.js +0 -9
  178. package/build/users-permissions-translation-zh-Hans-json.6ab714ee.chunk.js +0 -1
  179. package/build/users-providers-settings-page.48de0306.chunk.js +0 -14
  180. package/build/users-roles-settings-page.3f9f063e.chunk.js +0 -30
  181. package/build/webhook-edit-page.6cb479ff.chunk.js +0 -33
  182. package/build/zh-Hans-json.937b395b.chunk.js +0 -1
  183. package/ee/admin/hooks/index.js +0 -4
  184. package/ee/admin/hooks/useAuthProviders/index.js +0 -50
  185. package/ee/admin/hooks/useAuthProviders/reducer.js +0 -26
  186. package/ee/admin/hooks/useLicenseLimits/index.js +0 -1
  187. /package/ee/admin/hooks/{useLicenseLimits/__mocks__/index.js → __mocks__/useLicenseLimits.js} +0 -0
@@ -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;
@@ -70,7 +70,6 @@ const MarketPlacePage = () => {
70
70
  id: 'admin.pages.MarketPlacePage.production',
71
71
  defaultMessage: 'Manage plugins from the development environment',
72
72
  },
73
- blockTransition: true,
74
73
  });
75
74
  }
76
75
  }, [toggleNotification, isInDevelopmentMode]);
@@ -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 {
@@ -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,11 +1,12 @@
1
- import React, { useEffect, useRef } from 'react';
1
+ import * as React from 'react';
2
2
 
3
- import { Button, ContentLayout, HeaderLayout, Main } from '@strapi/design-system';
3
+ import { ContentLayout, HeaderLayout, Main } from '@strapi/design-system';
4
4
  import {
5
5
  LinkButton,
6
6
  NoContent,
7
7
  NoPermissions,
8
8
  SettingsPageTitle,
9
+ useAPIErrorHandler,
9
10
  useFetchClient,
10
11
  useFocusWhenNavigate,
11
12
  useGuidedTour,
@@ -38,16 +39,17 @@ const ApiTokenListView = () => {
38
39
  const { push } = useHistory();
39
40
  const { trackUsage } = useTracking();
40
41
  const { startSection } = useGuidedTour();
41
- const startSectionRef = useRef(startSection);
42
+ const startSectionRef = React.useRef(startSection);
42
43
  const { get, del } = useFetchClient();
44
+ const { formatAPIError } = useAPIErrorHandler();
43
45
 
44
- useEffect(() => {
46
+ React.useEffect(() => {
45
47
  if (startSectionRef.current) {
46
48
  startSectionRef.current('apiTokens');
47
49
  }
48
50
  }, []);
49
51
 
50
- useEffect(() => {
52
+ React.useEffect(() => {
51
53
  push({ search: qs.stringify({ sort: 'name:ASC' }, { encode: false }) });
52
54
  }, [push]);
53
55
 
@@ -59,16 +61,13 @@ const ApiTokenListView = () => {
59
61
  },
60
62
  }));
61
63
 
62
- const {
63
- data: apiTokens,
64
- status,
65
- isFetching,
66
- } = useQuery(
64
+ const { data: apiTokens, isLoading: isLoadingTokens } = useQuery(
67
65
  ['api-tokens'],
68
66
  async () => {
69
67
  trackUsage('willAccessTokenList', {
70
68
  tokenType: API_TOKEN_TYPE,
71
69
  });
70
+
72
71
  const {
73
72
  data: { data },
74
73
  } = await get(`/admin/api-tokens`);
@@ -78,19 +77,18 @@ const ApiTokenListView = () => {
78
77
  return data;
79
78
  },
80
79
  {
80
+ cacheTime: 0,
81
81
  enabled: canRead,
82
- onError() {
82
+ onError(error) {
83
83
  toggleNotification({
84
84
  type: 'warning',
85
- message: { id: 'notification.error', defaultMessage: 'An error occured' },
85
+ message: formatAPIError(error),
86
86
  });
87
87
  },
88
88
  }
89
89
  );
90
90
 
91
- const isLoading =
92
- canRead &&
93
- ((status !== 'success' && status !== 'error') || (status === 'success' && isFetching));
91
+ const isLoading = isLoadingTokens;
94
92
 
95
93
  const deleteMutation = useMutation(
96
94
  async (id) => {
@@ -101,25 +99,20 @@ const ApiTokenListView = () => {
101
99
  await queryClient.invalidateQueries(['api-tokens']);
102
100
  trackUsage('didDeleteToken');
103
101
  },
104
- onError(err) {
105
- if (err?.response?.data?.data) {
106
- toggleNotification({ type: 'warning', message: err.response.data.data });
107
- } else {
108
- toggleNotification({
109
- type: 'warning',
110
- message: { id: 'notification.error', defaultMessage: 'An error occured' },
111
- });
112
- }
102
+ onError(error) {
103
+ toggleNotification({ type: 'warning', message: formatAPIError(error) });
113
104
  },
114
105
  }
115
106
  );
116
107
 
117
- const shouldDisplayDynamicTable = canRead && apiTokens;
118
- const shouldDisplayNoContent = canRead && !apiTokens && !canCreate;
119
- const shouldDisplayNoContentWithCreationButton = canRead && !apiTokens && canCreate;
108
+ const hasApiTokens = apiTokens && apiTokens.length > 0;
109
+ const shouldDisplayDynamicTable = canRead && hasApiTokens;
110
+ const shouldDisplayNoContent = canRead && !hasApiTokens && !canCreate;
111
+ const shouldDisplayNoContentWithCreationButton = canRead && !hasApiTokens && canCreate;
120
112
 
121
113
  return (
122
114
  <Main aria-busy={isLoading}>
115
+ {/* TODO: this needs to be translated */}
123
116
  <SettingsPageTitle name="API Tokens" />
124
117
  <HeaderLayout
125
118
  title={formatMessage({ id: 'Settings.apiTokens.title', defaultMessage: 'API Tokens' })}
@@ -128,7 +121,7 @@ const ApiTokenListView = () => {
128
121
  defaultMessage: 'List of generated tokens to consume the API',
129
122
  })}
130
123
  primaryAction={
131
- canCreate ? (
124
+ canCreate && (
132
125
  <LinkButton
133
126
  data-testid="create-api-token-button"
134
127
  startIcon={<Plus />}
@@ -145,7 +138,7 @@ const ApiTokenListView = () => {
145
138
  defaultMessage: 'Create new API Token',
146
139
  })}
147
140
  </LinkButton>
148
- ) : undefined
141
+ )
149
142
  }
150
143
  />
151
144
  <ContentLayout>
@@ -169,12 +162,12 @@ const ApiTokenListView = () => {
169
162
  defaultMessage: 'Add your first API Token',
170
163
  }}
171
164
  action={
172
- <Button variant="secondary" startIcon={<Plus />}>
165
+ <LinkButton variant="secondary" startIcon={<Plus />} to="/settings/api-tokens/create">
173
166
  {formatMessage({
174
167
  id: 'Settings.apiTokens.addNewToken',
175
168
  defaultMessage: 'Add new API Token',
176
169
  })}
177
- </Button>
170
+ </LinkButton>
178
171
  }
179
172
  />
180
173
  )}