@strapi/admin 4.12.6 → 4.13.0-alpha.0

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 (211) 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/NpsSurvey/hooks/useNpsSurveySettings.js +17 -0
  7. package/admin/src/components/NpsSurvey/index.js +365 -0
  8. package/admin/src/components/PluginsInitializer/index.js +68 -0
  9. package/admin/src/components/PluginsInitializer/init.js +11 -0
  10. package/admin/src/components/PluginsInitializer/reducer.js +22 -0
  11. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumns.js +2 -0
  12. package/admin/src/content-manager/components/DynamicZone/components/DynamicZoneLabel.js +1 -1
  13. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +8 -1
  14. package/admin/src/content-manager/components/Filter/CustomInputs/AdminUsersFilter.js +42 -0
  15. package/admin/src/content-manager/components/Filter/Filter.js +54 -0
  16. package/admin/src/content-manager/components/Filter/index.js +1 -0
  17. package/admin/src/content-manager/components/InputUID/index.js +222 -216
  18. package/admin/src/content-manager/components/RelationInput/RelationInput.js +4 -0
  19. package/admin/src/content-manager/components/RepeatableComponent/index.js +32 -2
  20. package/admin/src/content-manager/components/Wysiwyg/Editor.js +432 -68
  21. package/admin/src/content-manager/components/Wysiwyg/WysiwygStyles.js +0 -7
  22. package/admin/src/content-manager/components/Wysiwyg/index.js +147 -152
  23. package/admin/src/content-manager/hooks/useAllowedAttributes.js +47 -0
  24. package/admin/src/content-manager/pages/App/index.js +16 -5
  25. package/admin/src/content-manager/pages/EditView/Information/index.js +9 -8
  26. package/admin/src/content-manager/pages/ListSettingsView/components/Settings.js +40 -7
  27. package/admin/src/content-manager/pages/ListSettingsView/index.js +6 -2
  28. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  29. package/admin/src/content-manager/pages/ListView/components/FieldPicker/index.js +67 -69
  30. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  31. package/admin/src/content-manager/pages/ListView/components/ViewSettingsMenu/index.js +80 -0
  32. package/admin/src/content-manager/pages/ListView/index.js +236 -67
  33. package/admin/src/content-manager/utils/getDisplayName.js +33 -0
  34. package/admin/src/content-manager/utils/index.js +1 -0
  35. package/admin/src/hooks/useSettingsForm/index.js +3 -14
  36. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  37. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +3 -1
  38. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +3 -1
  39. package/admin/src/index.js +1 -1
  40. package/admin/src/layouts/AppLayout/index.js +33 -0
  41. package/admin/src/pages/Admin/Onboarding/index.js +3 -1
  42. package/admin/src/pages/Admin/index.js +73 -77
  43. package/admin/src/pages/App/constants.js +1 -1
  44. package/admin/src/pages/App/index.js +122 -160
  45. package/admin/src/pages/AuthPage/components/Register/index.js +5 -0
  46. package/admin/src/pages/AuthPage/index.js +4 -2
  47. package/admin/src/pages/HomePage/index.js +3 -1
  48. package/admin/src/pages/InstalledPluginsPage/index.js +3 -1
  49. package/admin/src/pages/{InternalErrorPage.js → InternalErrorPage/index.js} +4 -3
  50. package/admin/src/pages/{NotFoundPage.js → NotFoundPage/index.js} +3 -1
  51. package/admin/src/pages/ProfilePage/index.js +4 -2
  52. package/admin/src/pages/SettingsPage/constants.js +132 -67
  53. package/admin/src/pages/SettingsPage/index.js +18 -23
  54. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  55. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  56. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +1 -2
  57. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  58. package/admin/src/pages/UseCasePage/index.js +175 -0
  59. package/admin/src/plugins.js +7 -8
  60. package/admin/src/translations/en.json +10 -1
  61. package/admin/src/utils/checkFormValidity.js +15 -0
  62. package/admin/src/utils/createRoute.js +7 -5
  63. package/admin/src/utils/formatAPIErrors.js +3 -1
  64. package/admin/src/utils/getAttributesToDisplay.js +19 -0
  65. package/admin/src/utils/getExistingActions.js +32 -0
  66. package/admin/src/utils/getFullName.js +1 -1
  67. package/admin/src/utils/index.js +9 -0
  68. package/admin/src/utils/makeUniqueRoutes.js +6 -0
  69. package/admin/src/utils/sortLinks.js +3 -1
  70. package/admin/src/utils/uniqueAdminHash.js +9 -2
  71. package/build/{1049.9d69d231.chunk.js → 1049.ec69f5e0.chunk.js} +1 -1
  72. package/build/1227.9f37e1dc.chunk.js +1 -0
  73. package/build/1386.ea73b677.chunk.js +7 -0
  74. package/build/{2225.33287e1b.chunk.js → 2225.649fb7bc.chunk.js} +2 -2
  75. package/build/{2237.03792b63.chunk.js → 2237.b832ae6e.chunk.js} +4 -4
  76. package/build/{2379.401f56f3.chunk.js → 2379.1f98a31a.chunk.js} +1 -1
  77. package/build/{2395.e6a79fbb.chunk.js → 2395.0e5e8ded.chunk.js} +1 -1
  78. package/build/{2801.31393ffe.chunk.js → 2801.8e1aa82a.chunk.js} +1 -1
  79. package/build/3483.19381b40.chunk.js +1 -0
  80. package/build/3739.63e352f1.chunk.js +103 -0
  81. package/build/4174.f1f39e40.chunk.js +1 -0
  82. package/build/448.829e1344.chunk.js +1 -0
  83. package/build/4546.a5946d22.chunk.js +1 -0
  84. package/build/4724.aea5c8c1.chunk.js +6 -0
  85. package/build/{502.8dd074ff.chunk.js → 502.7bba43b1.chunk.js} +1 -1
  86. package/build/6158.c3c13c20.chunk.js +1 -0
  87. package/build/6691.4985ef22.chunk.js +105 -0
  88. package/build/{7464.592a9295.chunk.js → 7464.eb057bec.chunk.js} +1 -1
  89. package/build/78.dcc6df5c.chunk.js +1 -0
  90. package/build/{8276.e519a707.chunk.js → 8276.be3ed581.chunk.js} +2 -2
  91. package/build/{2747.d1442a90.chunk.js → 9806.5d5a0e8d.chunk.js} +64 -72
  92. package/build/9944.7af075a5.chunk.js +26 -0
  93. package/build/Admin-authenticatedApp.43b6ec9a.chunk.js +79 -0
  94. package/build/Admin_InternalErrorPage.38155af3.chunk.js +1 -0
  95. package/build/Admin_homePage.6f128523.chunk.js +81 -0
  96. package/build/Admin_marketplace.061a6e5a.chunk.js +55 -0
  97. package/build/Admin_pluginsPage.16f837b8.chunk.js +6 -0
  98. package/build/Admin_profilePage.678bce24.chunk.js +13 -0
  99. package/build/Admin_settingsPage.af7309e4.chunk.js +111 -0
  100. package/build/{Upload_ConfigureTheView.345ac1e0.chunk.js → Upload_ConfigureTheView.3fc1c100.chunk.js} +1 -1
  101. package/build/admin-app.d63bd229.chunk.js +36 -0
  102. package/build/{admin-edit-roles-page.24bdf746.chunk.js → admin-edit-roles-page.38a6c863.chunk.js} +3 -3
  103. package/build/admin-edit-users.545fc882.chunk.js +10 -0
  104. package/build/{admin-roles-list.23ddff26.chunk.js → admin-roles-list.1e2e814d.chunk.js} +1 -1
  105. package/build/admin-users.b8ea5677.chunk.js +11 -0
  106. package/build/{api-tokens-create-page.46c2ea84.chunk.js → api-tokens-create-page.e0c15627.chunk.js} +1 -1
  107. package/build/{api-tokens-edit-page.58139df9.chunk.js → api-tokens-edit-page.9f2dce47.chunk.js} +1 -1
  108. package/build/{api-tokens-list-page.0af7d431.chunk.js → api-tokens-list-page.d747051c.chunk.js} +2 -2
  109. package/build/{audit-logs-settings-page.0f73ccf8.chunk.js → audit-logs-settings-page.96f9d608.chunk.js} +1 -1
  110. package/build/content-manager.ccff1078.chunk.js +1097 -0
  111. package/build/{content-type-builder-list-view.bf9be456.chunk.js → content-type-builder-list-view.b71cf240.chunk.js} +1 -1
  112. package/build/{content-type-builder.66066281.chunk.js → content-type-builder.e5669749.chunk.js} +18 -18
  113. package/build/{email-settings-page.2f7e35c0.chunk.js → email-settings-page.2809f0bf.chunk.js} +1 -1
  114. package/build/en-json.e12fd5fc.chunk.js +1 -0
  115. package/build/{i18n-settings-page.47f78016.chunk.js → i18n-settings-page.5f716172.chunk.js} +1 -1
  116. package/build/index.html +1 -1
  117. package/build/main.c6c9e04c.js +2859 -0
  118. package/build/{review-workflows-settings-create-view.d24a32b9.chunk.js → review-workflows-settings-create-view.4a156a19.chunk.js} +1 -1
  119. package/build/{review-workflows-settings-edit-view.6044b022.chunk.js → review-workflows-settings-edit-view.ce984d1f.chunk.js} +1 -1
  120. package/build/{review-workflows-settings-list-view.3f0ef4bc.chunk.js → review-workflows-settings-list-view.419b8deb.chunk.js} +2 -2
  121. package/build/runtime~main.dcf1cb45.js +2 -0
  122. package/build/{sso-settings-page.4dba0670.chunk.js → sso-settings-page.45153df5.chunk.js} +1 -1
  123. package/build/{transfer-tokens-create-page.1597e6ab.chunk.js → transfer-tokens-create-page.ebba16d8.chunk.js} +1 -1
  124. package/build/{transfer-tokens-edit-page.8741529f.chunk.js → transfer-tokens-edit-page.d7bb2b3e.chunk.js} +1 -1
  125. package/build/{transfer-tokens-list-page.d6986b03.chunk.js → transfer-tokens-list-page.cfe1736c.chunk.js} +2 -2
  126. package/build/{upload-settings.7f93d4c0.chunk.js → upload-settings.cc5ad813.chunk.js} +1 -1
  127. package/build/{upload.37488080.chunk.js → upload.756efc28.chunk.js} +1 -1
  128. package/build/{users-advanced-settings-page.17052d72.chunk.js → users-advanced-settings-page.818d84eb.chunk.js} +1 -1
  129. package/build/{users-email-settings-page.3de8ea50.chunk.js → users-email-settings-page.c1967c09.chunk.js} +1 -1
  130. package/build/{users-providers-settings-page.0eaa916d.chunk.js → users-providers-settings-page.11893e08.chunk.js} +1 -1
  131. package/build/{users-roles-settings-page.957ad48b.chunk.js → users-roles-settings-page.2b051e6a.chunk.js} +1 -1
  132. package/build/webhook-edit-page.de45c635.chunk.js +33 -0
  133. package/build/{webhook-list-page.65e1b5bb.chunk.js → webhook-list-page.ca91df8b.chunk.js} +1 -1
  134. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/AssigneeFilter.js +42 -0
  135. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/StageFilter.js +70 -0
  136. package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/constants.js +71 -0
  137. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +9 -217
  138. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/AssigneeSelect.js +147 -0
  139. package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/index.js +1 -0
  140. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/StageSelect.js +243 -0
  141. package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/index.js +1 -0
  142. package/ee/admin/content-manager/pages/EditView/InformationBox/constants.js +2 -0
  143. package/ee/admin/content-manager/pages/ListSettingsView/constants.js +7 -0
  144. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/ReviewWorkflowsAssigneeEE.js +21 -0
  145. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants.js +44 -17
  146. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/index.js +1 -0
  147. package/ee/admin/pages/App/constants.js +5 -6
  148. package/ee/admin/pages/SettingsPage/constants.js +42 -27
  149. package/ee/server/constants/workflows.js +1 -0
  150. package/ee/server/controllers/index.js +1 -0
  151. package/ee/server/controllers/workflows/assignees/index.js +44 -0
  152. package/ee/server/routes/review-workflows.js +17 -0
  153. package/ee/server/services/index.js +1 -0
  154. package/ee/server/services/review-workflows/assignees.js +54 -0
  155. package/ee/server/services/review-workflows/metrics/index.js +5 -0
  156. package/ee/server/services/review-workflows/review-workflows.js +20 -11
  157. package/ee/server/validation/review-workflows.js +8 -0
  158. package/index.js +2 -6
  159. package/package.json +9 -9
  160. package/scripts/build.js +15 -15
  161. package/scripts/create-dev-plugins-file.js +5 -38
  162. package/server/controllers/role.js +2 -0
  163. package/server/controllers/user.js +2 -0
  164. package/server/services/permission/permissions-manager/index.js +3 -1
  165. package/server/services/permission/permissions-manager/sanitize.js +19 -7
  166. package/server/services/permission/permissions-manager/validate.js +218 -0
  167. package/utils/create-cache-dir.js +62 -16
  168. package/utils/create-plugins-exclude-path.js +3 -23
  169. package/utils/get-plugins.js +110 -0
  170. package/utils/index.js +1 -1
  171. package/webpack.config.js +10 -13
  172. package/admin/src/components/AuthenticatedApp.js +0 -229
  173. package/admin/src/content-manager/components/AttributeFilter/Filters.js +0 -58
  174. package/admin/src/content-manager/components/AttributeFilter/hooks/useAllowedAttributes.js +0 -42
  175. package/admin/src/content-manager/components/AttributeFilter/index.js +0 -40
  176. package/admin/src/content-manager/components/Wysiwyg/EditorStylesContainer.js +0 -344
  177. package/admin/src/pages/UseCasePage.js +0 -174
  178. package/build/2166.c837469a.chunk.js +0 -1
  179. package/build/3483.8517171f.chunk.js +0 -1
  180. package/build/3984.dda474f7.chunk.js +0 -1
  181. package/build/4546.7a3c0d03.chunk.js +0 -1
  182. package/build/5483.5bfbb00d.chunk.js +0 -6
  183. package/build/6158.c974fd83.chunk.js +0 -1
  184. package/build/748.fd2e5afd.chunk.js +0 -105
  185. package/build/773.6381d62d.chunk.js +0 -18
  186. package/build/7826.399afe81.chunk.js +0 -103
  187. package/build/8261.2525d35c.chunk.js +0 -7
  188. package/build/8299.62b67c72.chunk.js +0 -1
  189. package/build/Admin-AuthPage.90d64342.chunk.js +0 -35
  190. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +0 -24
  191. package/build/Admin-UseCasePage.1f757db5.chunk.js +0 -13
  192. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +0 -12
  193. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +0 -9
  194. package/build/Admin_NotFoundPage.21620424.chunk.js +0 -9
  195. package/build/Admin_Onboarding.dbfa32f6.chunk.js +0 -43
  196. package/build/Admin_homePage.2000cbe9.chunk.js +0 -86
  197. package/build/Admin_marketplace.ec80e29b.chunk.js +0 -63
  198. package/build/Admin_pluginsPage.0c6851f8.chunk.js +0 -14
  199. package/build/Admin_profilePage.78cd8495.chunk.js +0 -21
  200. package/build/Admin_settingsPage.1760c3ce.chunk.js +0 -119
  201. package/build/StrapiApp.221fac30.chunk.js +0 -5
  202. package/build/admin-edit-users.5d10d444.chunk.js +0 -10
  203. package/build/admin-users.2b3e4305.chunk.js +0 -11
  204. package/build/content-manager.fb0833bd.chunk.js +0 -1099
  205. package/build/en-json.08c05fcf.chunk.js +0 -1
  206. package/build/main.ee3c1938.js +0 -2859
  207. package/build/runtime~main.397ee447.js +0 -2
  208. package/build/webhook-edit-page.665210af.chunk.js +0 -33
  209. package/scripts/create-plugins-file.js +0 -92
  210. package/utils/get-plugins-path.js +0 -41
  211. /package/server/services/permission/permissions-manager/{query-builers.js → query-builders.js} +0 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Retrieves the display name of an admin panel user
3
+ * @typedef AdminUserNamesAttributes
4
+ * @property {string} firstname
5
+ * @property {string} lastname
6
+ * @property {string} username
7
+ * @property {string} email
8
+ *
9
+ * @type {(user: AdminUserNamesAttributes, formatMessage: import('react-intl').formatMessage) => string}
10
+ */
11
+ const getDisplayName = ({ firstname, lastname, username, email }, formatMessage) => {
12
+ if (username) {
13
+ return username;
14
+ }
15
+
16
+ // firstname is not required if the user is created with a username
17
+ if (firstname) {
18
+ return formatMessage(
19
+ {
20
+ id: 'global.fullname',
21
+ defaultMessage: '{firstname} {lastname}',
22
+ },
23
+ {
24
+ firstname,
25
+ lastname,
26
+ }
27
+ ).trim();
28
+ }
29
+
30
+ return email;
31
+ };
32
+
33
+ export { getDisplayName };
@@ -12,3 +12,4 @@ export { default as mergeMetasWithSchema } from './mergeMetasWithSchema';
12
12
  export { default as removeKeyInObject } from './removeKeyInObject';
13
13
  export { default as removePasswordFieldsFromData } from './removePasswordFieldsFromData';
14
14
  export { default as createYupSchema } from './schema';
15
+ export { getDisplayName } from './getDisplayName';
@@ -1,14 +1,9 @@
1
1
  import { useEffect, useReducer } from 'react';
2
2
 
3
- import {
4
- getYupInnerErrors,
5
- useFetchClient,
6
- useNotification,
7
- useOverlayBlocker,
8
- } from '@strapi/helper-plugin';
3
+ import { useFetchClient, useNotification, useOverlayBlocker } from '@strapi/helper-plugin';
9
4
  import omit from 'lodash/omit';
10
5
 
11
- import { formatAPIErrors } from '../../utils/formatAPIErrors';
6
+ import { checkFormValidity, formatAPIErrors } from '../../utils';
12
7
 
13
8
  import init from './init';
14
9
  import { initialState, reducer } from './reducer';
@@ -81,13 +76,7 @@ const useSettingsForm = (endPoint, schema, cbSuccess, fieldsToPick) => {
81
76
  const handleSubmit = async (e) => {
82
77
  e.preventDefault();
83
78
 
84
- let errors = null;
85
-
86
- try {
87
- await schema.validate(modifiedData, { abortEarly: false });
88
- } catch (err) {
89
- errors = getYupInnerErrors(err);
90
- }
79
+ const errors = await checkFormValidity(modifiedData, schema);
91
80
 
92
81
  dispatch({
93
82
  type: 'SET_ERRORS',
@@ -7,8 +7,8 @@ import { selectAdminPermissions } from '../../pages/App/selectors';
7
7
  import { useEnterprise } from '../useEnterprise';
8
8
 
9
9
  import { LINKS_CE } from './constants';
10
- import { formatLinks } from './utils/formatLinks';
11
- import { sortLinks } from './utils/sortLinks';
10
+ import formatLinks from './utils/formatLinks';
11
+ import sortLinks from './utils/sortLinks';
12
12
 
13
13
  const useSettingsMenu = () => {
14
14
  const [{ isLoading, menu }, setData] = useState({
@@ -1,4 +1,4 @@
1
- export const formatLinks = (menu) => {
1
+ const formatLinks = (menu) => {
2
2
  return menu.map((menuSection) => {
3
3
  const formattedLinks = menuSection.links.map((link) => ({
4
4
  ...link,
@@ -8,3 +8,5 @@ export const formatLinks = (menu) => {
8
8
  return { ...menuSection, links: formattedLinks };
9
9
  });
10
10
  };
11
+
12
+ export default formatLinks;
@@ -1,3 +1,5 @@
1
1
  import sortBy from 'lodash/sortBy';
2
2
 
3
- export const sortLinks = (links) => sortBy(links, (link) => link.id);
3
+ const sortLinks = (links) => sortBy(links, (link) => link.id);
4
+
5
+ export default sortLinks;
@@ -52,7 +52,7 @@ const run = async () => {
52
52
 
53
53
  // We need to make sure to fetch the project type before importing the StrapiApp
54
54
  // otherwise the strapi-babel-plugin does not work correctly
55
- const StrapiApp = await import(/* webpackChunkName: "StrapiApp" */ './StrapiApp');
55
+ const StrapiApp = await import(/* webpackChunkName: "admin-app" */ './StrapiApp');
56
56
 
57
57
  const app = StrapiApp.default({
58
58
  appPlugins: plugins,
@@ -0,0 +1,33 @@
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;
@@ -75,7 +75,7 @@ const TextLink = styled(TypographyLineHeight)`
75
75
  }
76
76
  `;
77
77
 
78
- export const Onboarding = () => {
78
+ const Onboarding = () => {
79
79
  const triggerRef = useRef();
80
80
  const [isOpen, setIsOpen] = useState(false);
81
81
  const { formatMessage } = useIntl();
@@ -222,3 +222,5 @@ export const Onboarding = () => {
222
222
  </Box>
223
223
  );
224
224
  };
225
+
226
+ export default Onboarding;
@@ -4,92 +4,82 @@
4
4
  *
5
5
  */
6
6
 
7
- import * as React from 'react';
7
+ import React, { lazy, Suspense, useEffect, useMemo } from 'react';
8
8
 
9
- import { Box, Flex } from '@strapi/design-system';
10
9
  import { LoadingIndicatorPage, useStrapiApp, useTracking } from '@strapi/helper-plugin';
11
10
  import { DndProvider } from 'react-dnd';
12
11
  import { HTML5Backend } from 'react-dnd-html5-backend';
13
12
  import { useDispatch, useSelector } from 'react-redux';
14
13
  import { Route, Switch } from 'react-router-dom';
15
14
 
15
+ import GuidedTourModal from '../../components/GuidedTour/Modal';
16
16
  import LeftMenu from '../../components/LeftMenu';
17
- import useConfigurations from '../../hooks/useConfigurations';
18
- import useMenu from '../../hooks/useMenu';
19
- import { createRoute } from '../../utils/createRoute';
17
+ import { useConfigurations, useMenu } from '../../hooks';
18
+ import AppLayout from '../../layouts/AppLayout';
19
+ import { createRoute } from '../../utils';
20
20
  import { SET_APP_RUNTIME_STATUS } from '../App/constants';
21
21
 
22
- const CM = React.lazy(() =>
23
- import(/* webpackChunkName: "content-manager" */ '../../content-manager/pages/App').then(
24
- (module) => ({ default: module.ContentManger })
25
- )
26
- );
27
- const GuidedTourModal = React.lazy(() =>
28
- import(/* webpackChunkName: "Admin_GuidedTourModal" */ '../../components/GuidedTour/Modal').then(
29
- (module) => ({ default: module.GuidedTourModal })
30
- )
31
- );
32
- const HomePage = React.lazy(() =>
33
- import(/* webpackChunkName: "Admin_homePage" */ '../HomePage').then((module) => ({
34
- default: module.HomePage,
35
- }))
22
+ import Onboarding from './Onboarding';
23
+
24
+ const CM = lazy(() =>
25
+ import(/* webpackChunkName: "content-manager" */ '../../content-manager/pages/App')
36
26
  );
37
- const InstalledPluginsPage = React.lazy(() =>
38
- import(/* webpackChunkName: "Admin_pluginsPage" */ '../InstalledPluginsPage').then((module) => ({
39
- default: module.PluginsPage,
40
- }))
27
+ const HomePage = lazy(() => import(/* webpackChunkName: "Admin_homePage" */ '../HomePage'));
28
+ const InstalledPluginsPage = lazy(() =>
29
+ import(/* webpackChunkName: "Admin_pluginsPage" */ '../InstalledPluginsPage')
41
30
  );
42
- const MarketplacePage = React.lazy(() =>
31
+ const MarketplacePage = lazy(() =>
43
32
  import(/* webpackChunkName: "Admin_marketplace" */ '../MarketplacePage')
44
33
  );
45
- const Onboarding = React.lazy(() =>
46
- import(/* webpackChunkName: "Admin_Onboarding" */ './Onboarding').then((module) => ({
47
- default: module.Onboarding,
48
- }))
34
+ const NotFoundPage = lazy(() =>
35
+ import(/* webpackChunkName: "Admin_NotFoundPage" */ '../NotFoundPage')
49
36
  );
50
- const ProfilePage = React.lazy(() =>
51
- import(/* webpackChunkName: "Admin_profilePage" */ '../ProfilePage').then((module) => ({
52
- default: module.ProfilePage,
53
- }))
37
+ const InternalErrorPage = lazy(() =>
38
+ import(/* webpackChunkName: "Admin_InternalErrorPage" */ '../InternalErrorPage')
39
+ );
40
+
41
+ const ProfilePage = lazy(() =>
42
+ import(/* webpackChunkName: "Admin_profilePage" */ '../ProfilePage')
54
43
  );
55
- const SettingsPage = React.lazy(() =>
44
+ const SettingsPage = lazy(() =>
56
45
  import(/* webpackChunkName: "Admin_settingsPage" */ '../SettingsPage').then((module) => ({
57
46
  default: module.SettingsPage,
58
47
  }))
59
48
  );
60
49
 
61
- export const Admin = () => {
62
- const { isLoading, generalSectionLinks, pluginsSectionLinks } = useMenu();
63
- const { menu } = useStrapiApp();
64
- const { showTutorials } = useConfigurations();
50
+ // Simple hook easier for testing
51
+ /**
52
+ * TODO: remove this, it's bad.
53
+ */
54
+ const useTrackUsage = () => {
65
55
  const { trackUsage } = useTracking();
66
56
  const dispatch = useDispatch();
67
57
  const appStatus = useSelector((state) => state.admin_app.status);
68
58
 
69
- React.useEffect(() => {
59
+ useEffect(() => {
70
60
  // Make sure the event is only send once after accessing the admin panel
71
61
  // and not at runtime for example when regenerating the permissions with the ctb
72
62
  // or with i18n
73
63
  if (appStatus === 'init') {
74
64
  trackUsage('didAccessAuthenticatedAdministration');
65
+
75
66
  dispatch({ type: SET_APP_RUNTIME_STATUS });
76
67
  }
77
- }, [appStatus, dispatch, trackUsage]);
78
-
79
- const routes = menu
80
- .filter((link) => link.Component)
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, [appStatus]);
70
+ };
81
71
 
82
- /**
83
- * `Component` is an async function, which is passed as property of the
84
- * addMenuLink() API during the plugin registration step.
85
- *
86
- * Because of that we can't just render <Route component={Component} />,
87
- * but have to await the function.
88
- *
89
- * This isn't a good React pattern and should be reconsidered.
90
- */
72
+ const Admin = () => {
73
+ useTrackUsage();
74
+ const { isLoading, generalSectionLinks, pluginsSectionLinks } = useMenu();
75
+ const { menu } = useStrapiApp();
76
+ const { showTutorials } = useConfigurations();
91
77
 
92
- .map(({ to, Component, exact }) => createRoute(Component, to, exact));
78
+ const routes = useMemo(() => {
79
+ return menu
80
+ .filter((link) => link.Component)
81
+ .map(({ to, Component, exact }) => createRoute(Component, to, exact));
82
+ }, [menu]);
93
83
 
94
84
  if (isLoading) {
95
85
  return <LoadingIndicatorPage />;
@@ -97,34 +87,40 @@ export const Admin = () => {
97
87
 
98
88
  return (
99
89
  <DndProvider backend={HTML5Backend}>
100
- <Flex alignItems="stretch">
101
- <LeftMenu
102
- generalSectionLinks={generalSectionLinks}
103
- pluginsSectionLinks={pluginsSectionLinks}
104
- />
105
-
106
- <Box flex="1">
107
- <React.Suspense fallback={<LoadingIndicatorPage />}>
108
- <Switch>
109
- <Route path="/" component={HomePage} exact />
110
- <Route path="/me" component={ProfilePage} exact />
111
- <Route path="/content-manager" component={CM} />
112
- {routes}
113
- <Route path="/settings/:settingId" component={SettingsPage} />
114
- <Route path="/settings" component={SettingsPage} exact />
115
- <Route path="/marketplace" component={MarketplacePage} />
116
- <Route path="/list-plugins" component={InstalledPluginsPage} exact />
117
- </Switch>
118
- </React.Suspense>
119
- </Box>
120
-
121
- {/* TODO: we should move the logic to determine whether the guided tour is displayed
122
- or not out of the component, to make the code-splitting more effective
123
- */}
90
+ <AppLayout
91
+ sideNav={
92
+ <LeftMenu
93
+ generalSectionLinks={generalSectionLinks}
94
+ pluginsSectionLinks={pluginsSectionLinks}
95
+ />
96
+ }
97
+ >
98
+ <Suspense fallback={<LoadingIndicatorPage />}>
99
+ <Switch>
100
+ <Route path="/" component={HomePage} exact />
101
+ <Route path="/me" component={ProfilePage} exact />
102
+ <Route path="/content-manager" component={CM} />
103
+ {routes}
104
+ <Route path="/settings/:settingId" component={SettingsPage} />
105
+ <Route path="/settings" component={SettingsPage} exact />
106
+ <Route path="/marketplace">
107
+ <MarketplacePage />
108
+ </Route>
109
+ <Route path="/list-plugins" exact>
110
+ <InstalledPluginsPage />
111
+ </Route>
112
+ <Route path="/404" component={NotFoundPage} />
113
+ <Route path="/500" component={InternalErrorPage} />
114
+ <Route path="" component={NotFoundPage} />
115
+ </Switch>
116
+ </Suspense>
124
117
  <GuidedTourModal />
125
118
 
126
119
  {showTutorials && <Onboarding />}
127
- </Flex>
120
+ </AppLayout>
128
121
  </DndProvider>
129
122
  );
130
123
  };
124
+
125
+ export default Admin;
126
+ export { useTrackUsage };
@@ -1,4 +1,4 @@
1
1
  export const SET_APP_RUNTIME_STATUS = 'StrapiAdmin/APP/SET_APP_RUNTIME_STATUS';
2
2
  export const SET_ADMIN_PERMISSIONS = 'StrapiAdmin/App/SET_ADMIN_PERMISSIONS';
3
3
 
4
- export const AUTH_ROUTES_CE = [];
4
+ export const ROUTES_CE = [];