@strapi/admin 4.12.6 → 4.12.7

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/index.js +118 -0
  3. package/admin/src/components/AuthenticatedApp/utils/api.js +85 -0
  4. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +11 -0
  5. package/admin/src/components/GuidedTour/Modal/index.js +3 -1
  6. package/admin/src/components/PluginsInitializer/index.js +68 -0
  7. package/admin/src/components/PluginsInitializer/init.js +11 -0
  8. package/admin/src/components/PluginsInitializer/reducer.js +22 -0
  9. package/admin/src/content-manager/pages/App/index.js +16 -5
  10. package/admin/src/content-manager/pages/EditView/Information/index.js +1 -1
  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/hooks/useSettingsForm/index.js +3 -14
  14. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  15. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +3 -1
  16. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +3 -1
  17. package/admin/src/index.js +1 -1
  18. package/admin/src/layouts/AppLayout/index.js +33 -0
  19. package/admin/src/pages/Admin/Onboarding/index.js +3 -1
  20. package/admin/src/pages/Admin/index.js +74 -80
  21. package/admin/src/pages/App/constants.js +1 -1
  22. package/admin/src/pages/App/index.js +122 -160
  23. package/admin/src/pages/AuthPage/index.js +4 -2
  24. package/admin/src/pages/HomePage/index.js +3 -1
  25. package/admin/src/pages/InstalledPluginsPage/index.js +3 -1
  26. package/admin/src/pages/{InternalErrorPage.js → InternalErrorPage/index.js} +4 -3
  27. package/admin/src/pages/{NotFoundPage.js → NotFoundPage/index.js} +3 -1
  28. package/admin/src/pages/ProfilePage/index.js +4 -2
  29. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +3 -3
  30. package/admin/src/pages/SettingsPage/constants.js +132 -67
  31. package/admin/src/pages/SettingsPage/index.js +36 -31
  32. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  33. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +35 -69
  34. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +23 -0
  35. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +17 -0
  36. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  37. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +1 -2
  38. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  39. package/admin/src/pages/SettingsPage/utils/createSectionsRoutes.js +11 -0
  40. package/admin/src/pages/SettingsPage/utils/getSectionsToDisplay.js +5 -0
  41. package/admin/src/pages/SettingsPage/utils/index.js +2 -0
  42. package/admin/src/pages/UseCasePage/index.js +175 -0
  43. package/admin/src/utils/checkFormValidity.js +15 -0
  44. package/admin/src/utils/createRoute.js +7 -5
  45. package/admin/src/utils/formatAPIErrors.js +3 -1
  46. package/admin/src/utils/getAttributesToDisplay.js +19 -0
  47. package/admin/src/utils/getExistingActions.js +32 -0
  48. package/admin/src/utils/getFullName.js +1 -1
  49. package/admin/src/utils/index.js +9 -0
  50. package/admin/src/utils/makeUniqueRoutes.js +6 -0
  51. package/admin/src/utils/sortLinks.js +3 -1
  52. package/admin/src/utils/uniqueAdminHash.js +9 -2
  53. package/build/{1049.9d69d231.chunk.js → 1049.f76cb14b.chunk.js} +1 -1
  54. package/build/1386.879bcd90.chunk.js +7 -0
  55. package/build/2225.c6244756.chunk.js +79 -0
  56. package/build/2379.f1641312.chunk.js +1 -0
  57. package/build/2395.46f8d0c1.chunk.js +26 -0
  58. package/build/2801.5cef5ec8.chunk.js +1 -0
  59. package/build/3483.03c24f96.chunk.js +1 -0
  60. package/build/3739.63e352f1.chunk.js +103 -0
  61. package/build/3929.5632f24d.chunk.js +114 -0
  62. package/build/448.829e1344.chunk.js +1 -0
  63. package/build/502.8ae8ef60.chunk.js +1 -0
  64. package/build/5483.6dd2e776.chunk.js +6 -0
  65. package/build/5542.2415a393.chunk.js +63 -0
  66. package/build/6691.4985ef22.chunk.js +105 -0
  67. package/build/7464.3e64a1d5.chunk.js +1 -0
  68. package/build/8276.10a3f883.chunk.js +26 -0
  69. package/build/{2747.d1442a90.chunk.js → 9806.5d5a0e8d.chunk.js} +64 -72
  70. package/build/9944.7af075a5.chunk.js +26 -0
  71. package/build/Admin-authenticatedApp.31497f74.chunk.js +79 -0
  72. package/build/Admin_InternalErrorPage.f45f2462.chunk.js +1 -0
  73. package/build/Admin_homePage.ac9dfb86.chunk.js +81 -0
  74. package/build/Admin_marketplace.c94239f6.chunk.js +55 -0
  75. package/build/Admin_pluginsPage.bbe79434.chunk.js +6 -0
  76. package/build/Admin_profilePage.192edc52.chunk.js +13 -0
  77. package/build/Admin_settingsPage.97cb9d41.chunk.js +111 -0
  78. package/build/admin-app.91898385.chunk.js +36 -0
  79. package/build/{admin-edit-roles-page.24bdf746.chunk.js → admin-edit-roles-page.6d567273.chunk.js} +1 -1
  80. package/build/admin-edit-users.acfd4128.chunk.js +10 -0
  81. package/build/{admin-users.2b3e4305.chunk.js → admin-users.00e20017.chunk.js} +2 -2
  82. package/build/{content-manager.fb0833bd.chunk.js → content-manager.b40f79c0.chunk.js} +78 -78
  83. package/build/{content-type-builder.66066281.chunk.js → content-type-builder.cd999f6e.chunk.js} +18 -18
  84. package/build/email-settings-page.d494d1eb.chunk.js +11 -0
  85. package/build/index.html +1 -1
  86. package/build/main.9dbe4579.js +2859 -0
  87. package/build/review-workflows-settings-create-view.cb08cfa2.chunk.js +1 -0
  88. package/build/review-workflows-settings-edit-view.3c7cbe63.chunk.js +1 -0
  89. package/build/review-workflows-settings-list-view.1611dc1f.chunk.js +56 -0
  90. package/build/runtime~main.d515c521.js +2 -0
  91. package/build/{sso-settings-page.4dba0670.chunk.js → sso-settings-page.12b6d8ae.chunk.js} +1 -1
  92. package/build/users-advanced-settings-page.f0760eb8.chunk.js +9 -0
  93. package/build/users-email-settings-page.ff4b32f3.chunk.js +9 -0
  94. package/build/users-providers-settings-page.48de0306.chunk.js +14 -0
  95. package/build/users-roles-settings-page.9d9a1eff.chunk.js +30 -0
  96. package/build/webhook-edit-page.6cb479ff.chunk.js +33 -0
  97. package/ee/admin/hooks/index.js +4 -0
  98. package/ee/admin/hooks/useAuthProviders/index.js +50 -0
  99. package/ee/admin/hooks/useAuthProviders/reducer.js +26 -0
  100. package/ee/admin/hooks/{useLicenseLimitNotification.js → useLicenseLimitNotification/index.js} +4 -2
  101. package/ee/admin/hooks/useLicenseLimits/index.js +1 -0
  102. package/ee/admin/hooks/{useLicenseLimits.js → useLicenseLimits/useLicenseLimits.js} +1 -4
  103. package/ee/admin/pages/App/constants.js +5 -6
  104. package/ee/admin/pages/AuthPage/components/Login/index.js +4 -8
  105. package/ee/admin/pages/AuthPage/components/Providers/index.js +5 -8
  106. package/ee/admin/pages/HomePage/index.js +1 -1
  107. package/ee/admin/pages/SettingsPage/constants.js +42 -27
  108. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/CreateView.js +1 -1
  109. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/EditView.js +1 -1
  110. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/ListView.js +1 -1
  111. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +1 -1
  112. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
  113. package/package.json +8 -8
  114. package/admin/src/components/AuthenticatedApp.js +0 -229
  115. package/admin/src/pages/UseCasePage.js +0 -174
  116. package/build/1504.eff012f7.chunk.js +0 -95
  117. package/build/2166.c837469a.chunk.js +0 -1
  118. package/build/2225.33287e1b.chunk.js +0 -79
  119. package/build/2237.03792b63.chunk.js +0 -114
  120. package/build/2379.401f56f3.chunk.js +0 -1
  121. package/build/2395.e6a79fbb.chunk.js +0 -26
  122. package/build/2801.31393ffe.chunk.js +0 -1
  123. package/build/3483.8517171f.chunk.js +0 -1
  124. package/build/502.8dd074ff.chunk.js +0 -1
  125. package/build/5483.5bfbb00d.chunk.js +0 -6
  126. package/build/7464.592a9295.chunk.js +0 -1
  127. package/build/748.fd2e5afd.chunk.js +0 -105
  128. package/build/773.6381d62d.chunk.js +0 -18
  129. package/build/7826.399afe81.chunk.js +0 -103
  130. package/build/8261.2525d35c.chunk.js +0 -7
  131. package/build/8276.e519a707.chunk.js +0 -26
  132. package/build/8299.62b67c72.chunk.js +0 -1
  133. package/build/Admin-AuthPage.90d64342.chunk.js +0 -35
  134. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +0 -24
  135. package/build/Admin-UseCasePage.1f757db5.chunk.js +0 -13
  136. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +0 -12
  137. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +0 -9
  138. package/build/Admin_NotFoundPage.21620424.chunk.js +0 -9
  139. package/build/Admin_Onboarding.dbfa32f6.chunk.js +0 -43
  140. package/build/Admin_homePage.2000cbe9.chunk.js +0 -86
  141. package/build/Admin_marketplace.ec80e29b.chunk.js +0 -63
  142. package/build/Admin_pluginsPage.0c6851f8.chunk.js +0 -14
  143. package/build/Admin_profilePage.78cd8495.chunk.js +0 -21
  144. package/build/Admin_settingsPage.1760c3ce.chunk.js +0 -119
  145. package/build/StrapiApp.221fac30.chunk.js +0 -5
  146. package/build/admin-edit-users.5d10d444.chunk.js +0 -10
  147. package/build/email-settings-page.2f7e35c0.chunk.js +0 -11
  148. package/build/main.ee3c1938.js +0 -2859
  149. package/build/review-workflows-settings-create-view.d24a32b9.chunk.js +0 -1
  150. package/build/review-workflows-settings-edit-view.6044b022.chunk.js +0 -1
  151. package/build/review-workflows-settings-list-view.3f0ef4bc.chunk.js +0 -56
  152. package/build/runtime~main.397ee447.js +0 -2
  153. package/build/users-advanced-settings-page.17052d72.chunk.js +0 -9
  154. package/build/users-email-settings-page.3de8ea50.chunk.js +0 -9
  155. package/build/users-providers-settings-page.0eaa916d.chunk.js +0 -14
  156. package/build/users-roles-settings-page.957ad48b.chunk.js +0 -55
  157. package/build/webhook-edit-page.665210af.chunk.js +0 -33
  158. package/ee/admin/hooks/useAuthProviders.js +0 -25
  159. /package/ee/admin/hooks/{__mocks__/useLicenseLimits.js → useLicenseLimits/__mocks__/index.js} +0 -0
@@ -1,10 +1,9 @@
1
- import * as React from 'react';
1
+ import { AuthResponse } from '../AuthResponse';
2
2
 
3
- export const AUTH_ROUTES_EE = [
3
+ export const ROUTES_EE = [
4
4
  {
5
- component: React.lazy(() =>
6
- import('../AuthResponse').then((module) => ({ default: module.AuthResponse }))
7
- ),
8
- path: '/auth/login/:authResponse',
5
+ Component: () => ({ default: AuthResponse }),
6
+ to: '/auth/login/:authResponse',
7
+ exact: true,
9
8
  },
10
9
  ];
@@ -7,7 +7,7 @@ import styled from 'styled-components';
7
7
 
8
8
  import UnauthenticatedLayout from '../../../../../../admin/src/layouts/UnauthenticatedLayout';
9
9
  import BaseLogin from '../../../../../../admin/src/pages/AuthPage/components/Login/BaseLogin';
10
- import { useAuthProviders } from '../../../../hooks/useAuthProviders';
10
+ import { useAuthProviders } from '../../../../hooks';
11
11
  import SSOProviders from '../Providers/SSOProviders';
12
12
 
13
13
  const DividerFull = styled(Divider)`
@@ -15,15 +15,11 @@ const DividerFull = styled(Divider)`
15
15
  `;
16
16
 
17
17
  export const LoginEE = (loginProps) => {
18
+ const ssoEnabled = window.strapi.features.isEnabled(window.strapi.features.SSO);
19
+ const { isLoading, data: providers } = useAuthProviders({ ssoEnabled });
18
20
  const { formatMessage } = useIntl();
19
- const { isLoading, providers } = useAuthProviders({
20
- enabled: window.strapi.features.isEnabled(window.strapi.features.SSO),
21
- });
22
21
 
23
- if (
24
- !window.strapi.features.isEnabled(window.strapi.features.SSO) ||
25
- (!isLoading && providers.length === 0)
26
- ) {
22
+ if (!ssoEnabled || (!isLoading && providers.length === 0)) {
27
23
  return (
28
24
  <UnauthenticatedLayout>
29
25
  <BaseLogin {...loginProps} />
@@ -11,7 +11,7 @@ import UnauthenticatedLayout, {
11
11
  Column,
12
12
  LayoutContent,
13
13
  } from '../../../../../../admin/src/layouts/UnauthenticatedLayout';
14
- import { useAuthProviders } from '../../../../hooks/useAuthProviders';
14
+ import { useAuthProviders } from '../../../../hooks';
15
15
 
16
16
  import SSOProviders from './SSOProviders';
17
17
 
@@ -20,20 +20,17 @@ const DividerFull = styled(Divider)`
20
20
  `;
21
21
 
22
22
  const Providers = () => {
23
+ const ssoEnabled = window.strapi.features.isEnabled(window.strapi.features.SSO);
24
+
23
25
  const { push } = useHistory();
24
26
  const { formatMessage } = useIntl();
25
- const { isLoading, providers } = useAuthProviders({
26
- enabled: window.strapi.features.isEnabled(window.strapi.features.SSO),
27
- });
27
+ const { isLoading, data: providers } = useAuthProviders({ ssoEnabled });
28
28
 
29
29
  const handleClick = () => {
30
30
  push('/auth/login');
31
31
  };
32
32
 
33
- if (
34
- !window.strapi.features.isEnabled(window.strapi.features.SSO) ||
35
- (!isLoading && providers.length === 0)
36
- ) {
33
+ if (!ssoEnabled || (!isLoading && providers.length === 0)) {
37
34
  return <Redirect to="/auth/login" />;
38
35
  }
39
36
 
@@ -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/useLicenseLimitNotification';
5
+ import { useLicenseLimitNotification } from '../../hooks';
6
6
 
7
7
  export function HomePageEE() {
8
8
  useLicenseLimitNotification();
@@ -1,15 +1,16 @@
1
- import * as React from 'react';
2
-
3
- export const SETTINGS_ROUTES_EE = [
1
+ export const ROUTES_EE = [
4
2
  ...(window.strapi.features.isEnabled(window.strapi.features.AUDIT_LOGS)
5
3
  ? [
6
4
  {
7
- component: React.lazy(() =>
8
- import(
5
+ async Component() {
6
+ const component = await import(
9
7
  /* webpackChunkName: "audit-logs-settings-page" */ './pages/AuditLogs/ProtectedListPage'
10
- )
11
- ),
12
- path: '/settings/audit-logs',
8
+ );
9
+
10
+ return component;
11
+ },
12
+ to: '/settings/audit-logs',
13
+ exact: true,
13
14
  },
14
15
  ]
15
16
  : []),
@@ -17,30 +18,39 @@ export const SETTINGS_ROUTES_EE = [
17
18
  ...(window.strapi.features.isEnabled(window.strapi.features.REVIEW_WORKFLOWS)
18
19
  ? [
19
20
  {
20
- component: React.lazy(() =>
21
- import(
21
+ async Component() {
22
+ const component = await import(
22
23
  /* webpackChunkName: "review-workflows-settings-list-view" */ './pages/ReviewWorkflows/pages/ListView'
23
- )
24
- ),
25
- path: '/settings/review-workflows',
24
+ );
25
+
26
+ return component;
27
+ },
28
+ to: '/settings/review-workflows',
29
+ exact: true,
26
30
  },
27
31
 
28
32
  {
29
- component: React.lazy(() =>
30
- import(
33
+ async Component() {
34
+ const component = await import(
31
35
  /* webpackChunkName: "review-workflows-settings-create-view" */ './pages/ReviewWorkflows/pages/CreateView'
32
- )
33
- ),
34
- path: '/settings/review-workflows/create',
36
+ );
37
+
38
+ return component;
39
+ },
40
+ to: '/settings/review-workflows/create',
41
+ exact: true,
35
42
  },
36
43
 
37
44
  {
38
- component: React.lazy(() =>
39
- import(
45
+ async Component() {
46
+ const component = await import(
40
47
  /* webpackChunkName: "review-workflows-settings-edit-view" */ './pages/ReviewWorkflows/pages/EditView'
41
- )
42
- ),
43
- path: '/settings/review-workflows/:workflowId',
48
+ );
49
+
50
+ return component;
51
+ },
52
+ to: '/settings/review-workflows/:workflowId',
53
+ exact: true,
44
54
  },
45
55
  ]
46
56
  : []),
@@ -48,10 +58,15 @@ export const SETTINGS_ROUTES_EE = [
48
58
  ...(window.strapi.features.isEnabled(window.strapi.features.SSO)
49
59
  ? [
50
60
  {
51
- component: React.lazy(() =>
52
- import(/* webpackChunkName: "sso-settings-page" */ './pages/SingleSignOn')
53
- ),
54
- path: '/settings/single-sign-on',
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,
55
70
  },
56
71
  ]
57
72
  : []),
@@ -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/useLicenseLimits';
20
+ import { useLicenseLimits } from '../../../../../../hooks';
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/useLicenseLimits';
22
+ import { useLicenseLimits } from '../../../../../../hooks';
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/useLicenseLimits';
38
+ import { useLicenseLimits } from '../../../../../../hooks';
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/useLicenseLimits';
9
+ import { useLicenseLimits } from '../../../../../../hooks';
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/useLicenseLimitNotification';
5
+ import { useLicenseLimitNotification } from '../../../../../hooks';
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.6",
3
+ "version": "4.12.7",
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.6",
45
+ "@strapi/data-transfer": "4.12.7",
46
46
  "@strapi/design-system": "1.9.0",
47
- "@strapi/helper-plugin": "4.12.6",
47
+ "@strapi/helper-plugin": "4.12.7",
48
48
  "@strapi/icons": "1.9.0",
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",
49
+ "@strapi/permissions": "4.12.7",
50
+ "@strapi/provider-audit-logs-local": "4.12.7",
51
+ "@strapi/typescript-utils": "4.12.7",
52
+ "@strapi/utils": "4.12.7",
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": "9bb6ba1e0d07c65423e99075438262540a042d76"
157
+ "gitHead": "fefc4a24acc60a59c00049e67a99ec1069be2add"
158
158
  }
@@ -1,229 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import {
4
- AppInfoProvider,
5
- auth,
6
- LoadingIndicatorPage,
7
- useFetchClient,
8
- useGuidedTour,
9
- useNotification,
10
- useStrapiApp,
11
- } from '@strapi/helper-plugin';
12
- import { useQueries } from 'react-query';
13
- import { valid, lt } from 'semver';
14
-
15
- import packageJSON from '../../../package.json';
16
- import { useConfigurations } from '../hooks';
17
- import { Admin } from '../pages/Admin';
18
- import { getFullName } from '../utils/getFullName';
19
- import { hashAdminUserEmail } from '../utils/uniqueAdminHash';
20
-
21
- import RBACProvider from './RBACProvider';
22
-
23
- const strapiVersion = packageJSON.version;
24
-
25
- const checkLatestStrapiVersion = (currentPackageVersion, latestPublishedVersion) => {
26
- if (!valid(currentPackageVersion) || !valid(latestPublishedVersion)) {
27
- return false;
28
- }
29
-
30
- return lt(currentPackageVersion, latestPublishedVersion);
31
- };
32
-
33
- export const AuthenticatedApp = () => {
34
- const { setGuidedTourVisibility } = useGuidedTour();
35
- const toggleNotification = useNotification();
36
- const userInfo = auth.getUserInfo();
37
- const { get } = useFetchClient();
38
- // TODO: replace with getDisplayName()
39
- const [userDisplayName, setUserDisplayName] = React.useState(
40
- userInfo?.userName ?? getFullName(userInfo.firstname, userInfo.lastname)
41
- );
42
- const [userId, setUserId] = React.useState(null);
43
- const { showReleaseNotification } = useConfigurations();
44
- const { plugins: appPlugins = {} } = useStrapiApp();
45
- const [plugins, setPlugins] = React.useState(appPlugins);
46
- const [
47
- { data: appInfos, isLoading: isLoadingAppInfos },
48
- { data: tagName },
49
- { data: permissions, isLoading: isLoadingPermissions, refetch },
50
- { data: userRoles },
51
- ] = useQueries([
52
- {
53
- queryKey: 'information',
54
- async queryFn() {
55
- const {
56
- data: { data },
57
- } = await get('/admin/information');
58
-
59
- return data;
60
- },
61
- },
62
-
63
- {
64
- queryKey: 'strapi-release',
65
- async queryFn() {
66
- const res = await fetch('https://api.github.com/repos/strapi/strapi/releases/latest');
67
-
68
- if (!res.ok) {
69
- throw new Error('Failed to fetch latest Strapi version.');
70
- }
71
-
72
- const { tag_name } = await res.json();
73
-
74
- return tag_name;
75
- },
76
- enabled: showReleaseNotification,
77
- initialData: strapiVersion,
78
- onSuccess(data) {
79
- const shouldUpdateStrapi = checkLatestStrapiVersion(strapiVersion, data.tag_name);
80
-
81
- if (shouldUpdateStrapi && !JSON.parse(localStorage.getItem('STRAPI_UPDATE_NOTIF'))) {
82
- toggleNotification({
83
- type: 'info',
84
- message: { id: 'notification.version.update.message' },
85
- link: {
86
- url: `https://github.com/strapi/strapi/releases/tag/${data.tag_name}`,
87
- label: {
88
- id: 'global.see-more',
89
- },
90
- },
91
- blockTransition: true,
92
- onClose: () => localStorage.setItem('STRAPI_UPDATE_NOTIF', true),
93
- });
94
- }
95
- },
96
- retry: false,
97
- },
98
- {
99
- queryKey: ['users', 'me', 'permissions'],
100
- async queryFn() {
101
- const {
102
- data: { data },
103
- } = await get('/admin/users/me/permissions');
104
-
105
- return data;
106
- },
107
- initialData: [],
108
- },
109
-
110
- {
111
- queryKey: ['users', 'me'],
112
- async queryFn() {
113
- const {
114
- data: {
115
- data: { roles },
116
- },
117
- } = await get('/admin/users/me');
118
-
119
- return roles;
120
- },
121
- },
122
- ]);
123
-
124
- // Display the guided tour conditionally for super admins in development mode
125
- React.useEffect(() => {
126
- if (userRoles) {
127
- const isUserSuperAdmin = userRoles.find(({ code }) => code === 'strapi-super-admin');
128
-
129
- if (isUserSuperAdmin && appInfos?.currentEnvironment === 'development') {
130
- setGuidedTourVisibility(true);
131
- }
132
- }
133
- }, [userRoles, appInfos, setGuidedTourVisibility]);
134
-
135
- // Create a hash of the users email adress and use it as ID for tracking
136
- React.useEffect(() => {
137
- const generateUserId = async (userInfo) => {
138
- const userId = await hashAdminUserEmail(userInfo);
139
- setUserId(userId);
140
- };
141
-
142
- if (userInfo) {
143
- generateUserId(userInfo);
144
- }
145
- }, [userInfo]);
146
-
147
- /**
148
- *
149
- * I have spent some time trying to understand what is happening here, and wanted to
150
- * leave that knowledge for my future me:
151
- *
152
- * `initializer` is an undocumented property of the `registerPlugin` API. At the time
153
- * of writing it seems only to be used by the i18n plugin.
154
- *
155
- * How does it work?
156
- *
157
- * Every plugin that has an `initializer` component defined, receives the
158
- * `setPlugin` function as a component prop. In the case of i18n the plugin fetches locales
159
- * first and calls `setPlugin` with `pluginId` once they are loaded, which then triggers the
160
- * reducer of the admin app defined above.
161
- *
162
- * Once all plugins are set to `isReady: true` the app renders.
163
- *
164
- * This API is used to block rendering of the admin app. We should remove that in v5 completely
165
- * and make sure plugins can inject data into the global store before they are initialized, to avoid
166
- * having a new prop-callback based communication channel between plugins and the core admin app.
167
- *
168
- */
169
-
170
- const hasApluginNotReady = Object.values(plugins).some((plugin) => plugin.isReady === false);
171
-
172
- if (
173
- !userDisplayName ||
174
- !userId ||
175
- isLoadingAppInfos ||
176
- isLoadingPermissions ||
177
- hasApluginNotReady
178
- ) {
179
- const initializers = Object.keys(plugins).reduce((acc, current) => {
180
- const InitializerComponent = plugins[current].initializer;
181
-
182
- if (InitializerComponent) {
183
- const key = plugins[current].pluginId;
184
-
185
- acc.push(
186
- <InitializerComponent
187
- key={key}
188
- setPlugin={(pluginId) => {
189
- setPlugins((prev) => ({
190
- ...prev,
191
- [pluginId]: {
192
- ...prev[pluginId],
193
- isReady: true,
194
- },
195
- }));
196
- }}
197
- />
198
- );
199
- }
200
-
201
- return acc;
202
- }, []);
203
-
204
- return (
205
- <>
206
- {initializers}
207
- <LoadingIndicatorPage />
208
- </>
209
- );
210
- }
211
-
212
- return (
213
- <AppInfoProvider
214
- {...appInfos}
215
- userId={userId}
216
- latestStrapiReleaseTag={tagName}
217
- // TODO: setUserDisplayName should not exist and be removed, as it is only used
218
- // to update the displayName immediately, in case a user updates their profile.
219
- // This information should be derived from the state.
220
- setUserDisplayName={setUserDisplayName}
221
- shouldUpdateStrapi={checkLatestStrapiVersion(strapiVersion, tagName)}
222
- userDisplayName={userDisplayName}
223
- >
224
- <RBACProvider permissions={permissions} refetchPermissions={refetch}>
225
- <Admin />
226
- </RBACProvider>
227
- </AppInfoProvider>
228
- );
229
- };
@@ -1,174 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import {
4
- Button,
5
- Flex,
6
- Main,
7
- Option,
8
- Select,
9
- TextButton,
10
- TextInput,
11
- Typography,
12
- } from '@strapi/design-system';
13
- import { auth, useNotification } from '@strapi/helper-plugin';
14
- import { parse } from 'qs';
15
- import { useIntl } from 'react-intl';
16
- import { useHistory } from 'react-router-dom';
17
-
18
- import Logo from '../components/UnauthenticatedLogo';
19
- import UnauthenticatedLayout, { LayoutContent } from '../layouts/UnauthenticatedLayout';
20
-
21
- export const options = [
22
- {
23
- intlLabel: {
24
- id: 'Usecase.front-end',
25
- defaultMessage: 'Front-end developer',
26
- },
27
- value: 'front_end_developer',
28
- },
29
- {
30
- intlLabel: {
31
- id: 'Usecase.back-end',
32
- defaultMessage: 'Back-end developer',
33
- },
34
- value: 'back_end_developer',
35
- },
36
- {
37
- intlLabel: {
38
- id: 'Usecase.full-stack',
39
- defaultMessage: 'Full-stack developer',
40
- },
41
- value: 'full_stack_developer',
42
- },
43
- {
44
- intlLabel: {
45
- id: 'global.content-manager',
46
- defaultMessage: 'Content Manager',
47
- },
48
- value: 'content_manager',
49
- },
50
- {
51
- intlLabel: {
52
- id: 'Usecase.content-creator',
53
- defaultMessage: 'Content Creator',
54
- },
55
- value: 'content_creator',
56
- },
57
- {
58
- intlLabel: {
59
- id: 'Usecase.other',
60
- defaultMessage: 'Other',
61
- },
62
- value: 'other',
63
- },
64
- ];
65
-
66
- export const UseCasePage = () => {
67
- const toggleNotification = useNotification();
68
- const { push, location } = useHistory();
69
- const { formatMessage } = useIntl();
70
- const [role, setRole] = React.useState();
71
- const [otherRole, setOtherRole] = React.useState('');
72
-
73
- const { firstname, email } = auth.getUserInfo();
74
- const { hasAdmin } = parse(location?.search, { ignoreQueryPrefix: true });
75
-
76
- const handleSubmit = async (event) => {
77
- event.preventDefault();
78
-
79
- const shouldSkip = event.nativeEvent?.submitter?.name === 'skip';
80
-
81
- await fetch('https://analytics.strapi.io/register', {
82
- body: JSON.stringify({
83
- email,
84
- username: firstname,
85
- firstAdmin: Boolean(!hasAdmin),
86
- persona: {
87
- role: shouldSkip ? undefined : role,
88
- otherRole: shouldSkip ? undefined : otherRole,
89
- },
90
- }),
91
-
92
- headers: {
93
- 'Content-Type': 'application/json',
94
- },
95
-
96
- method: 'POST',
97
- });
98
-
99
- toggleNotification({
100
- type: 'success',
101
- message: {
102
- id: 'Usecase.notification.success.project-created',
103
- defaultMessage: 'Project has been successfully created',
104
- },
105
- });
106
-
107
- push('/');
108
- };
109
-
110
- return (
111
- <UnauthenticatedLayout>
112
- <Main labelledBy="usecase-title">
113
- <form onSubmit={handleSubmit}>
114
- <LayoutContent>
115
- <Flex direction="column" alignItems="stretch" gap={7}>
116
- <Flex direction="column" gap={6}>
117
- <Logo />
118
-
119
- <Typography textAlign="center" variant="alpha" as="h1" id="usecase-title">
120
- {formatMessage({
121
- id: 'Usecase.title',
122
- defaultMessage: 'Tell us a bit more about yourself',
123
- })}
124
- </Typography>
125
- </Flex>
126
-
127
- <Flex direction="column" alignItems="stretch" gap={6}>
128
- <Select
129
- id="usecase"
130
- data-testid="usecase"
131
- label={formatMessage({
132
- id: 'Usecase.input.work-type',
133
- defaultMessage: 'What type of work do you do?',
134
- })}
135
- onChange={setRole}
136
- value={role}
137
- >
138
- {options.map(({ intlLabel, value }) => (
139
- <Option key={value} value={value}>
140
- {formatMessage(intlLabel)}
141
- </Option>
142
- ))}
143
- </Select>
144
-
145
- {role === 'other' && (
146
- <TextInput
147
- name="other"
148
- label={formatMessage({ id: 'Usecase.other', defaultMessage: 'Other' })}
149
- value={otherRole}
150
- onChange={(e) => setOtherRole(e.target.value)}
151
- data-testid="other"
152
- />
153
- )}
154
-
155
- <Button type="submit" size="L" fullWidth disabled={!role}>
156
- {formatMessage({ id: 'global.finish', defaultMessage: 'Finish' })}
157
- </Button>
158
- </Flex>
159
- </Flex>
160
- </LayoutContent>
161
-
162
- <Flex justifyContent="center" paddingTop={4}>
163
- <TextButton type="submit" name="skip">
164
- {formatMessage({
165
- id: 'Usecase.button.skip',
166
- defaultMessage: 'Skip this question',
167
- })}
168
- </TextButton>
169
- </Flex>
170
- </form>
171
- </Main>
172
- </UnauthenticatedLayout>
173
- );
174
- };