@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
@@ -11,7 +11,7 @@ import UnauthenticatedLayout, {
11
11
  Column,
12
12
  LayoutContent,
13
13
  } from '../../../../../../admin/src/layouts/UnauthenticatedLayout';
14
- import { useAuthProviders } from '../../../../hooks';
14
+ import { useAuthProviders } from '../../../../hooks/useAuthProviders';
15
15
 
16
16
  import SSOProviders from './SSOProviders';
17
17
 
@@ -20,17 +20,20 @@ const DividerFull = styled(Divider)`
20
20
  `;
21
21
 
22
22
  const Providers = () => {
23
- const ssoEnabled = window.strapi.features.isEnabled(window.strapi.features.SSO);
24
-
25
23
  const { push } = useHistory();
26
24
  const { formatMessage } = useIntl();
27
- const { isLoading, data: providers } = useAuthProviders({ ssoEnabled });
25
+ const { isLoading, providers } = useAuthProviders({
26
+ enabled: window.strapi.features.isEnabled(window.strapi.features.SSO),
27
+ });
28
28
 
29
29
  const handleClick = () => {
30
30
  push('/auth/login');
31
31
  };
32
32
 
33
- if (!ssoEnabled || (!isLoading && providers.length === 0)) {
33
+ if (
34
+ !window.strapi.features.isEnabled(window.strapi.features.SSO) ||
35
+ (!isLoading && providers.length === 0)
36
+ ) {
34
37
  return <Redirect to="/auth/login" />;
35
38
  }
36
39
 
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
 
3
3
  // eslint-disable-next-line import/no-cycle
4
4
  import { HomePageCE } from '../../../../admin/src/pages/HomePage';
5
- import { useLicenseLimitNotification } from '../../hooks';
5
+ import { useLicenseLimitNotification } from '../../hooks/useLicenseLimitNotification';
6
6
 
7
7
  export function HomePageEE() {
8
8
  useLicenseLimitNotification();
@@ -1,16 +1,15 @@
1
- export const ROUTES_EE = [
1
+ import * as React from 'react';
2
+
3
+ export const SETTINGS_ROUTES_EE = [
2
4
  ...(window.strapi.features.isEnabled(window.strapi.features.AUDIT_LOGS)
3
5
  ? [
4
6
  {
5
- async Component() {
6
- const component = await import(
7
+ component: React.lazy(() =>
8
+ import(
7
9
  /* webpackChunkName: "audit-logs-settings-page" */ './pages/AuditLogs/ProtectedListPage'
8
- );
9
-
10
- return component;
11
- },
12
- to: '/settings/audit-logs',
13
- exact: true,
10
+ )
11
+ ),
12
+ path: '/settings/audit-logs',
14
13
  },
15
14
  ]
16
15
  : []),
@@ -18,39 +17,30 @@ export const ROUTES_EE = [
18
17
  ...(window.strapi.features.isEnabled(window.strapi.features.REVIEW_WORKFLOWS)
19
18
  ? [
20
19
  {
21
- async Component() {
22
- const component = await import(
20
+ component: React.lazy(() =>
21
+ import(
23
22
  /* webpackChunkName: "review-workflows-settings-list-view" */ './pages/ReviewWorkflows/pages/ListView'
24
- );
25
-
26
- return component;
27
- },
28
- to: '/settings/review-workflows',
29
- exact: true,
23
+ )
24
+ ),
25
+ path: '/settings/review-workflows',
30
26
  },
31
27
 
32
28
  {
33
- async Component() {
34
- const component = await import(
29
+ component: React.lazy(() =>
30
+ import(
35
31
  /* webpackChunkName: "review-workflows-settings-create-view" */ './pages/ReviewWorkflows/pages/CreateView'
36
- );
37
-
38
- return component;
39
- },
40
- to: '/settings/review-workflows/create',
41
- exact: true,
32
+ )
33
+ ),
34
+ path: '/settings/review-workflows/create',
42
35
  },
43
36
 
44
37
  {
45
- async Component() {
46
- const component = await import(
38
+ component: React.lazy(() =>
39
+ import(
47
40
  /* webpackChunkName: "review-workflows-settings-edit-view" */ './pages/ReviewWorkflows/pages/EditView'
48
- );
49
-
50
- return component;
51
- },
52
- to: '/settings/review-workflows/:workflowId',
53
- exact: true,
41
+ )
42
+ ),
43
+ path: '/settings/review-workflows/:workflowId',
54
44
  },
55
45
  ]
56
46
  : []),
@@ -58,15 +48,10 @@ export const ROUTES_EE = [
58
48
  ...(window.strapi.features.isEnabled(window.strapi.features.SSO)
59
49
  ? [
60
50
  {
61
- async Component() {
62
- const component = await import(
63
- /* webpackChunkName: "sso-settings-page" */ './pages/SingleSignOn'
64
- );
65
-
66
- return component;
67
- },
68
- to: '/settings/single-sign-on',
69
- exact: true,
51
+ component: React.lazy(() =>
52
+ import(/* webpackChunkName: "sso-settings-page" */ './pages/SingleSignOn')
53
+ ),
54
+ path: '/settings/single-sign-on',
70
55
  },
71
56
  ]
72
57
  : []),
@@ -17,7 +17,7 @@ import { useHistory } from 'react-router-dom';
17
17
 
18
18
  import { useContentTypes } from '../../../../../../../../admin/src/hooks/useContentTypes';
19
19
  import { useInjectReducer } from '../../../../../../../../admin/src/hooks/useInjectReducer';
20
- import { useLicenseLimits } from '../../../../../../hooks';
20
+ import { useLicenseLimits } from '../../../../../../hooks/useLicenseLimits';
21
21
  import { addStage, resetWorkflow } from '../../actions';
22
22
  import * as Layout from '../../components/Layout';
23
23
  import * as LimitsModal from '../../components/LimitsModal';
@@ -19,7 +19,7 @@ import { useParams } from 'react-router-dom';
19
19
  import { useContentTypes } from '../../../../../../../../admin/src/hooks/useContentTypes';
20
20
  import { useInjectReducer } from '../../../../../../../../admin/src/hooks/useInjectReducer';
21
21
  import { selectAdminPermissions } from '../../../../../../../../admin/src/pages/App/selectors';
22
- import { useLicenseLimits } from '../../../../../../hooks';
22
+ import { useLicenseLimits } from '../../../../../../hooks/useLicenseLimits';
23
23
  import { resetWorkflow, setWorkflow } from '../../actions';
24
24
  import * as Layout from '../../components/Layout';
25
25
  import * as LimitsModal from '../../components/LimitsModal';
@@ -35,7 +35,7 @@ import styled from 'styled-components';
35
35
 
36
36
  import { useContentTypes } from '../../../../../../../../admin/src/hooks/useContentTypes';
37
37
  import { selectAdminPermissions } from '../../../../../../../../admin/src/pages/App/selectors';
38
- import { useLicenseLimits } from '../../../../../../hooks';
38
+ import { useLicenseLimits } from '../../../../../../hooks/useLicenseLimits';
39
39
  import * as Layout from '../../components/Layout';
40
40
  import * as LimitsModal from '../../components/LimitsModal';
41
41
  import { CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME } from '../../constants';
@@ -6,7 +6,7 @@ import isNil from 'lodash/isNil';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useIntl } from 'react-intl';
8
8
 
9
- import { useLicenseLimits } from '../../../../../../hooks';
9
+ import { useLicenseLimits } from '../../../../../../hooks/useLicenseLimits';
10
10
 
11
11
  export const CreateActionEE = ({ onClick }) => {
12
12
  const { formatMessage } = useIntl();
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
 
3
3
  // eslint-disable-next-line import/no-cycle
4
4
  import { UserListPageCE } from '../../../../../../../admin/src/pages/SettingsPage/pages/Users/ListPage';
5
- import { useLicenseLimitNotification } from '../../../../../hooks';
5
+ import { useLicenseLimitNotification } from '../../../../../hooks/useLicenseLimitNotification';
6
6
 
7
7
  function UserListPageEE() {
8
8
  useLicenseLimitNotification();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "4.12.5",
3
+ "version": "4.12.6",
4
4
  "description": "Strapi Admin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,14 +42,14 @@
42
42
  "dependencies": {
43
43
  "@casl/ability": "^5.4.3",
44
44
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
45
- "@strapi/data-transfer": "4.12.5",
45
+ "@strapi/data-transfer": "4.12.6",
46
46
  "@strapi/design-system": "1.9.0",
47
- "@strapi/helper-plugin": "4.12.5",
47
+ "@strapi/helper-plugin": "4.12.6",
48
48
  "@strapi/icons": "1.9.0",
49
- "@strapi/permissions": "4.12.5",
50
- "@strapi/provider-audit-logs-local": "4.12.5",
51
- "@strapi/typescript-utils": "4.12.5",
52
- "@strapi/utils": "4.12.5",
49
+ "@strapi/permissions": "4.12.6",
50
+ "@strapi/provider-audit-logs-local": "4.12.6",
51
+ "@strapi/typescript-utils": "4.12.6",
52
+ "@strapi/utils": "4.12.6",
53
53
  "axios": "1.4.0",
54
54
  "bcryptjs": "2.4.3",
55
55
  "browserslist": "^4.17.3",
@@ -154,5 +154,5 @@
154
154
  }
155
155
  }
156
156
  },
157
- "gitHead": "c1935e70041b440f2a78178c4a9fda79b722d1ab"
157
+ "gitHead": "9bb6ba1e0d07c65423e99075438262540a042d76"
158
158
  }
@@ -1,118 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
-
3
- import {
4
- AppInfoProvider,
5
- auth,
6
- LoadingIndicatorPage,
7
- useGuidedTour,
8
- useNotification,
9
- } from '@strapi/helper-plugin';
10
- import get from 'lodash/get';
11
- import { useQueries } from 'react-query';
12
- // TODO: DS add loader
13
-
14
- import packageJSON from '../../../../package.json';
15
- import { useConfigurations } from '../../hooks';
16
- import { getFullName, hashAdminUserEmail } from '../../utils';
17
- import PluginsInitializer from '../PluginsInitializer';
18
- import RBACProvider from '../RBACProvider';
19
-
20
- import {
21
- fetchAppInfo,
22
- fetchCurrentUserPermissions,
23
- fetchStrapiLatestRelease,
24
- fetchUserRoles,
25
- } from './utils/api';
26
- import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
27
-
28
- const strapiVersion = packageJSON.version;
29
-
30
- const AuthenticatedApp = () => {
31
- const { setGuidedTourVisibility } = useGuidedTour();
32
- const toggleNotification = useNotification();
33
- const userInfo = auth.getUserInfo();
34
- const userName = get(userInfo, 'username') || getFullName(userInfo.firstname, userInfo.lastname);
35
- const [userDisplayName, setUserDisplayName] = useState(userName);
36
- const [userId, setUserId] = useState(null);
37
- const { showReleaseNotification } = useConfigurations();
38
- const [
39
- { data: appInfos, status },
40
- { data: tagName, isLoading },
41
- { data: permissions, status: fetchPermissionsStatus, refetch, isFetching },
42
- { data: userRoles },
43
- ] = useQueries([
44
- { queryKey: 'app-infos', queryFn: fetchAppInfo },
45
- {
46
- queryKey: 'strapi-release',
47
- queryFn: () => fetchStrapiLatestRelease(toggleNotification),
48
- enabled: showReleaseNotification,
49
- initialData: strapiVersion,
50
- },
51
- {
52
- queryKey: 'admin-users-permission',
53
- queryFn: fetchCurrentUserPermissions,
54
- initialData: [],
55
- },
56
- {
57
- queryKey: 'user-roles',
58
- queryFn: fetchUserRoles,
59
- },
60
- ]);
61
-
62
- const shouldUpdateStrapi = checkLatestStrapiVersion(strapiVersion, tagName);
63
-
64
- /**
65
- * TODO: does this actually need to be an effect?
66
- */
67
- useEffect(() => {
68
- if (userRoles) {
69
- const isUserSuperAdmin = userRoles.find(({ code }) => code === 'strapi-super-admin');
70
-
71
- if (isUserSuperAdmin && appInfos?.autoReload) {
72
- setGuidedTourVisibility(true);
73
- }
74
- }
75
- }, [userRoles, appInfos, setGuidedTourVisibility]);
76
-
77
- useEffect(() => {
78
- const getUserId = async () => {
79
- const userId = await hashAdminUserEmail(userInfo);
80
- setUserId(userId);
81
- };
82
-
83
- getUserId();
84
- }, [userInfo]);
85
-
86
- // We don't need to wait for the release query to be fetched before rendering the plugins
87
- // however, we need the appInfos and the permissions
88
- const shouldShowNotDependentQueriesLoader =
89
- isFetching || status === 'loading' || fetchPermissionsStatus === 'loading';
90
-
91
- const shouldShowLoader = isLoading || shouldShowNotDependentQueriesLoader;
92
-
93
- if (shouldShowLoader) {
94
- return <LoadingIndicatorPage />;
95
- }
96
-
97
- // TODO: add error state
98
- if (status === 'error') {
99
- return <div>error...</div>;
100
- }
101
-
102
- return (
103
- <AppInfoProvider
104
- {...appInfos}
105
- userId={userId}
106
- latestStrapiReleaseTag={tagName}
107
- setUserDisplayName={setUserDisplayName}
108
- shouldUpdateStrapi={shouldUpdateStrapi}
109
- userDisplayName={userDisplayName}
110
- >
111
- <RBACProvider permissions={permissions} refetchPermissions={refetch}>
112
- <PluginsInitializer />
113
- </RBACProvider>
114
- </AppInfoProvider>
115
- );
116
- };
117
-
118
- export default AuthenticatedApp;
@@ -1,85 +0,0 @@
1
- import { getFetchClient } from '@strapi/helper-plugin';
2
-
3
- import packageJSON from '../../../../../package.json';
4
-
5
- import checkLatestStrapiVersion from './checkLatestStrapiVersion';
6
-
7
- const strapiVersion = packageJSON.version;
8
- const showUpdateNotif = !JSON.parse(localStorage.getItem('STRAPI_UPDATE_NOTIF'));
9
- const { get } = getFetchClient();
10
-
11
- const fetchStrapiLatestRelease = async (toggleNotification) => {
12
- try {
13
- const res = await fetch('https://api.github.com/repos/strapi/strapi/releases/latest');
14
-
15
- if (!res.ok) {
16
- throw new Error('Failed to fetch latest Strapi version.');
17
- }
18
- const { tag_name } = await res.json();
19
- const shouldUpdateStrapi = checkLatestStrapiVersion(strapiVersion, tag_name);
20
-
21
- if (shouldUpdateStrapi && showUpdateNotif) {
22
- toggleNotification({
23
- type: 'info',
24
- message: { id: 'notification.version.update.message' },
25
- link: {
26
- url: `https://github.com/strapi/strapi/releases/tag/${tag_name}`,
27
- label: {
28
- id: 'global.see-more',
29
- },
30
- },
31
- blockTransition: true,
32
- onClose: () => localStorage.setItem('STRAPI_UPDATE_NOTIF', true),
33
- });
34
- }
35
-
36
- return tag_name;
37
- } catch (err) {
38
- // Don't throw an error
39
- return strapiVersion;
40
- }
41
- };
42
-
43
- const fetchAppInfo = async () => {
44
- try {
45
- const { data, headers } = await get('/admin/information');
46
-
47
- if (!headers['content-type'].includes('application/json')) {
48
- throw new Error('Not found');
49
- }
50
-
51
- return data.data;
52
- } catch (error) {
53
- throw new Error(error);
54
- }
55
- };
56
-
57
- const fetchCurrentUserPermissions = async () => {
58
- try {
59
- const { data, headers } = await get('/admin/users/me/permissions');
60
-
61
- if (!headers['content-type'].includes('application/json')) {
62
- throw new Error('Not found');
63
- }
64
-
65
- return data.data;
66
- } catch (err) {
67
- throw new Error(err);
68
- }
69
- };
70
-
71
- const fetchUserRoles = async () => {
72
- try {
73
- const {
74
- data: {
75
- data: { roles },
76
- },
77
- } = await get('/admin/users/me');
78
-
79
- return roles;
80
- } catch (err) {
81
- throw new Error(err);
82
- }
83
- };
84
-
85
- export { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease, fetchUserRoles };
@@ -1,11 +0,0 @@
1
- import semver from 'semver';
2
-
3
- const checkLatestStrapiVersion = (currentPackageVersion, latestPublishedVersion) => {
4
- if (!semver.valid(currentPackageVersion) || !semver.valid(latestPublishedVersion)) {
5
- return false;
6
- }
7
-
8
- return semver.lt(currentPackageVersion, latestPublishedVersion);
9
- };
10
-
11
- export default checkLatestStrapiVersion;
@@ -1,68 +0,0 @@
1
- import React, { useReducer, useRef } from 'react';
2
-
3
- import { LoadingIndicatorPage, useStrapiApp } from '@strapi/helper-plugin';
4
-
5
- import Admin from '../../pages/Admin';
6
-
7
- import init from './init';
8
- import reducer, { initialState } from './reducer';
9
-
10
- const PluginsInitializer = () => {
11
- const { plugins: appPlugins } = useStrapiApp();
12
- const [{ plugins }, dispatch] = useReducer(reducer, initialState, () => init(appPlugins));
13
- const setPlugin = useRef((pluginId) => {
14
- dispatch({ type: 'SET_PLUGIN_READY', pluginId });
15
- });
16
-
17
- const hasApluginNotReady = Object.keys(plugins).some(
18
- (plugin) => plugins[plugin].isReady === false
19
- );
20
-
21
- /**
22
- *
23
- * I have spent some time trying to understand what is happening here, and wanted to
24
- * leave that knowledge for my future me:
25
- *
26
- * `initializer` is an undocumented property of the `registerPlugin` API. At the time
27
- * of writing it seems only to be used by the i18n plugin.
28
- *
29
- * How does it work?
30
- *
31
- * Every plugin that has an `initializer` component defined, receives the
32
- * `setPlugin` function as a component prop. In the case of i18n the plugin fetches locales
33
- * first and calls `setPlugin` with `pluginId` once they are loaded, which then triggers the
34
- * reducer of the admin app defined above.
35
- *
36
- * Once all plugins are set to `isReady: true` the app renders.
37
- *
38
- * This API is used to block rendering of the admin app. We should remove that in v5 completely
39
- * and make sure plugins can inject data into the global store before they are initialized, to avoid
40
- * having a new prop-callback based communication channel between plugins and the core admin app.
41
- *
42
- */
43
-
44
- if (hasApluginNotReady) {
45
- const initializers = Object.keys(plugins).reduce((acc, current) => {
46
- const InitializerComponent = plugins[current].initializer;
47
-
48
- if (InitializerComponent) {
49
- const key = plugins[current].pluginId;
50
-
51
- acc.push(<InitializerComponent key={key} setPlugin={setPlugin.current} />);
52
- }
53
-
54
- return acc;
55
- }, []);
56
-
57
- return (
58
- <>
59
- {initializers}
60
- <LoadingIndicatorPage />
61
- </>
62
- );
63
- }
64
-
65
- return <Admin />;
66
- };
67
-
68
- export default PluginsInitializer;
@@ -1,11 +0,0 @@
1
- const init = (plugins) => {
2
- return {
3
- plugins: Object.keys(plugins).reduce((acc, current) => {
4
- acc[current] = { ...plugins[current] };
5
-
6
- return acc;
7
- }, {}),
8
- };
9
- };
10
-
11
- export default init;
@@ -1,22 +0,0 @@
1
- import produce from 'immer';
2
- import set from 'lodash/set';
3
-
4
- const initialState = {
5
- plugins: null,
6
- };
7
-
8
- const reducer = (state = initialState, action) =>
9
- /* eslint-disable-next-line consistent-return */
10
- produce(state, (draftState) => {
11
- switch (action.type) {
12
- case 'SET_PLUGIN_READY': {
13
- set(draftState, ['plugins', action.pluginId, 'isReady'], true);
14
- break;
15
- }
16
- default:
17
- return draftState;
18
- }
19
- });
20
-
21
- export { initialState };
22
- export default reducer;
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Box, Flex, SkipToContent } from '@strapi/design-system';
4
- import PropTypes from 'prop-types';
5
- import { useIntl } from 'react-intl';
6
- import styled from 'styled-components';
7
-
8
- const FlexBox = styled(Box)`
9
- flex: 1;
10
- `;
11
-
12
- const AppLayout = ({ children, sideNav }) => {
13
- const { formatMessage } = useIntl();
14
-
15
- return (
16
- <Box background="neutral100">
17
- <SkipToContent>
18
- {formatMessage({ id: 'skipToContent', defaultMessage: 'Skip to content' })}
19
- </SkipToContent>
20
- <Flex alignItems="flex-start">
21
- {sideNav}
22
- <FlexBox>{children}</FlexBox>
23
- </Flex>
24
- </Box>
25
- );
26
- };
27
-
28
- AppLayout.propTypes = {
29
- children: PropTypes.node.isRequired,
30
- sideNav: PropTypes.node.isRequired,
31
- };
32
-
33
- export default AppLayout;
@@ -1,23 +0,0 @@
1
- import { getFetchClient } from '@strapi/helper-plugin';
2
-
3
- import prefixAllUrls from './prefixAllUrls';
4
-
5
- const fetchProjectSettings = async () => {
6
- const { get } = getFetchClient();
7
- const { data } = await get('/admin/project-settings');
8
-
9
- return prefixAllUrls(data);
10
- };
11
-
12
- const postProjectSettings = async (body) => {
13
- const { post } = getFetchClient();
14
- const { data } = await post('/admin/project-settings', body, {
15
- headers: {
16
- 'Content-Type': 'multipart/form-data',
17
- },
18
- });
19
-
20
- return prefixAllUrls(data);
21
- };
22
-
23
- export { fetchProjectSettings, postProjectSettings };
@@ -1,17 +0,0 @@
1
- import { prefixFileUrlWithBackendUrl } from '@strapi/helper-plugin';
2
- import transform from 'lodash/transform';
3
-
4
- const prefixAllUrls = (data) =>
5
- transform(
6
- data,
7
- (result, value, key) => {
8
- if (value && value.url) {
9
- result[key] = { ...value, url: prefixFileUrlWithBackendUrl(value.url) };
10
- } else {
11
- result[key] = value;
12
- }
13
- },
14
- {}
15
- );
16
-
17
- export default prefixAllUrls;
@@ -1,11 +0,0 @@
1
- import flatMap from 'lodash/flatMap';
2
-
3
- import { createRoute } from '../../../utils';
4
-
5
- const createSectionsRoutes = (settings) => {
6
- const allLinks = flatMap(settings, (section) => section.links);
7
-
8
- return allLinks.map((link) => createRoute(link.Component, link.to, link.exact || false));
9
- };
10
-
11
- export default createSectionsRoutes;
@@ -1,5 +0,0 @@
1
- const getSectionsToDisplay = (menu) => {
2
- return menu.filter((section) => !section.links.every((link) => link.isDisplayed === false));
3
- };
4
-
5
- export default getSectionsToDisplay;
@@ -1,2 +0,0 @@
1
- export { default as createSectionsRoutes } from './createSectionsRoutes';
2
- export { default as getSectionsToDisplay } from './getSectionsToDisplay';