@strapi/admin 4.12.4 → 4.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/admin/src/StrapiApp.js +1 -1
  2. package/admin/src/components/AuthenticatedApp.js +229 -0
  3. package/admin/src/components/GuidedTour/Modal/index.js +1 -3
  4. package/admin/src/content-manager/components/Wysiwyg/WysiwygNav.js +7 -30
  5. package/admin/src/content-manager/hooks/useSyncRbac/index.js +10 -2
  6. package/admin/src/content-manager/pages/App/index.js +5 -16
  7. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +1 -1
  8. package/admin/src/content-manager/pages/EditView/Information/index.js +1 -1
  9. package/admin/src/content-manager/pages/EditViewLayoutManager/index.js +2 -2
  10. package/admin/src/content-manager/pages/ListSettingsView/index.js +16 -41
  11. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +2 -2
  12. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
  13. package/admin/src/content-manager/pages/ListView/index.js +27 -1
  14. package/admin/src/content-manager/pages/ListViewLayoutManager/index.js +2 -2
  15. package/admin/src/hooks/useSettingsForm/index.js +14 -3
  16. package/admin/src/hooks/useSettingsMenu/index.js +2 -2
  17. package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +1 -3
  18. package/admin/src/hooks/useSettingsMenu/utils/sortLinks.js +1 -3
  19. package/admin/src/index.js +1 -1
  20. package/admin/src/pages/Admin/Onboarding/index.js +1 -3
  21. package/admin/src/pages/Admin/index.js +80 -74
  22. package/admin/src/pages/App/constants.js +1 -1
  23. package/admin/src/pages/App/index.js +160 -122
  24. package/admin/src/pages/AuthPage/index.js +2 -4
  25. package/admin/src/pages/HomePage/index.js +1 -3
  26. package/admin/src/pages/InstalledPluginsPage/index.js +1 -3
  27. package/admin/src/pages/{InternalErrorPage/index.js → InternalErrorPage.js} +3 -4
  28. package/admin/src/pages/MarketplacePage/index.js +0 -1
  29. package/admin/src/pages/{NotFoundPage/index.js → NotFoundPage.js} +1 -3
  30. package/admin/src/pages/ProfilePage/index.js +2 -4
  31. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +3 -3
  32. package/admin/src/pages/SettingsPage/constants.js +67 -132
  33. package/admin/src/pages/SettingsPage/index.js +31 -36
  34. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +1 -1
  35. package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +24 -31
  36. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +69 -35
  37. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
  38. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +11 -6
  39. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +4 -1
  40. package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
  41. package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +1 -0
  42. package/admin/src/pages/UseCasePage.js +174 -0
  43. package/admin/src/translations/zh-Hans.json +918 -902
  44. package/admin/src/utils/createRoute.js +5 -7
  45. package/admin/src/utils/formatAPIErrors.js +1 -3
  46. package/admin/src/utils/getFullName.js +1 -1
  47. package/admin/src/utils/sortLinks.js +1 -3
  48. package/admin/src/utils/uniqueAdminHash.js +2 -9
  49. package/build/{1049.f76cb14b.chunk.js → 1049.9d69d231.chunk.js} +1 -1
  50. package/build/1504.eff012f7.chunk.js +95 -0
  51. package/build/2166.c837469a.chunk.js +1 -0
  52. package/build/2225.33287e1b.chunk.js +79 -0
  53. package/build/2237.03792b63.chunk.js +114 -0
  54. package/build/2379.401f56f3.chunk.js +1 -0
  55. package/build/2395.e6a79fbb.chunk.js +26 -0
  56. package/build/{9806.3392505e.chunk.js → 2747.d1442a90.chunk.js} +78 -70
  57. package/build/2801.31393ffe.chunk.js +1 -0
  58. package/build/3483.8517171f.chunk.js +1 -0
  59. package/build/4546.7a3c0d03.chunk.js +1 -0
  60. package/build/502.8dd074ff.chunk.js +1 -0
  61. package/build/5483.5bfbb00d.chunk.js +6 -0
  62. package/build/7464.592a9295.chunk.js +1 -0
  63. package/build/748.fd2e5afd.chunk.js +105 -0
  64. package/build/773.6381d62d.chunk.js +18 -0
  65. package/build/7826.399afe81.chunk.js +103 -0
  66. package/build/8261.2525d35c.chunk.js +7 -0
  67. package/build/8276.e519a707.chunk.js +26 -0
  68. package/build/8299.62b67c72.chunk.js +1 -0
  69. package/build/Admin-AuthPage.90d64342.chunk.js +35 -0
  70. package/build/Admin-AuthenticatedApp.379ac945.chunk.js +24 -0
  71. package/build/Admin-UseCasePage.1f757db5.chunk.js +13 -0
  72. package/build/Admin_GuidedTourModal.8ccf1fbc.chunk.js +12 -0
  73. package/build/Admin_InternalErrorPage.9de92c6d.chunk.js +9 -0
  74. package/build/Admin_NotFoundPage.21620424.chunk.js +9 -0
  75. package/build/Admin_Onboarding.dbfa32f6.chunk.js +43 -0
  76. package/build/Admin_homePage.2000cbe9.chunk.js +86 -0
  77. package/build/Admin_marketplace.ec80e29b.chunk.js +63 -0
  78. package/build/Admin_pluginsPage.0c6851f8.chunk.js +14 -0
  79. package/build/Admin_profilePage.78cd8495.chunk.js +21 -0
  80. package/build/Admin_settingsPage.1760c3ce.chunk.js +119 -0
  81. package/build/StrapiApp.221fac30.chunk.js +5 -0
  82. package/build/{admin-edit-roles-page.6d567273.chunk.js → admin-edit-roles-page.24bdf746.chunk.js} +1 -1
  83. package/build/admin-edit-users.5d10d444.chunk.js +10 -0
  84. package/build/admin-users.2b3e4305.chunk.js +11 -0
  85. package/build/api-tokens-list-page.0af7d431.chunk.js +16 -0
  86. package/build/audit-logs-settings-page.0f73ccf8.chunk.js +1 -0
  87. package/build/content-manager.fb0833bd.chunk.js +1099 -0
  88. package/build/{content-type-builder.40534de5.chunk.js → content-type-builder.66066281.chunk.js} +18 -18
  89. package/build/email-settings-page.2f7e35c0.chunk.js +11 -0
  90. package/build/i18n-translation-ru-json.a3dbc125.chunk.js +1 -0
  91. package/build/index.html +1 -1
  92. package/build/main.ee3c1938.js +2859 -0
  93. package/build/review-workflows-settings-create-view.d24a32b9.chunk.js +1 -0
  94. package/build/review-workflows-settings-edit-view.6044b022.chunk.js +1 -0
  95. package/build/review-workflows-settings-list-view.3f0ef4bc.chunk.js +56 -0
  96. package/build/runtime~main.397ee447.js +2 -0
  97. package/build/{sso-settings-page.12b6d8ae.chunk.js → sso-settings-page.4dba0670.chunk.js} +1 -1
  98. package/build/transfer-tokens-list-page.d6986b03.chunk.js +16 -0
  99. package/build/users-advanced-settings-page.17052d72.chunk.js +9 -0
  100. package/build/users-email-settings-page.3de8ea50.chunk.js +9 -0
  101. package/build/users-permissions-translation-zh-Hans-json.8d82c809.chunk.js +1 -0
  102. package/build/users-providers-settings-page.0eaa916d.chunk.js +14 -0
  103. package/build/users-roles-settings-page.957ad48b.chunk.js +55 -0
  104. package/build/webhook-edit-page.665210af.chunk.js +33 -0
  105. package/build/zh-Hans-json.97efd015.chunk.js +1 -0
  106. package/ee/admin/hooks/useAuthProviders.js +25 -0
  107. package/ee/admin/hooks/{useLicenseLimitNotification/index.js → useLicenseLimitNotification.js} +2 -4
  108. package/ee/admin/hooks/{useLicenseLimits/useLicenseLimits.js → useLicenseLimits.js} +4 -1
  109. package/ee/admin/pages/App/constants.js +6 -5
  110. package/ee/admin/pages/AuthPage/components/Login/index.js +8 -4
  111. package/ee/admin/pages/AuthPage/components/Providers/index.js +8 -5
  112. package/ee/admin/pages/HomePage/index.js +1 -1
  113. package/ee/admin/pages/SettingsPage/constants.js +27 -42
  114. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/CreateView.js +1 -1
  115. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/EditView.js +1 -1
  116. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/ListView.js +1 -1
  117. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +1 -1
  118. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
  119. package/package.json +10 -10
  120. package/admin/src/components/AuthenticatedApp/index.js +0 -118
  121. package/admin/src/components/AuthenticatedApp/utils/api.js +0 -85
  122. package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.js +0 -11
  123. package/admin/src/components/PluginsInitializer/index.js +0 -68
  124. package/admin/src/components/PluginsInitializer/init.js +0 -11
  125. package/admin/src/components/PluginsInitializer/reducer.js +0 -22
  126. package/admin/src/layouts/AppLayout/index.js +0 -33
  127. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +0 -23
  128. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +0 -17
  129. package/admin/src/pages/SettingsPage/utils/createSectionsRoutes.js +0 -11
  130. package/admin/src/pages/SettingsPage/utils/getSectionsToDisplay.js +0 -5
  131. package/admin/src/pages/SettingsPage/utils/index.js +0 -2
  132. package/admin/src/pages/UseCasePage/index.js +0 -175
  133. package/admin/src/utils/checkFormValidity.js +0 -15
  134. package/admin/src/utils/getAttributesToDisplay.js +0 -19
  135. package/admin/src/utils/getExistingActions.js +0 -32
  136. package/admin/src/utils/index.js +0 -9
  137. package/admin/src/utils/makeUniqueRoutes.js +0 -6
  138. package/build/1386.879bcd90.chunk.js +0 -7
  139. package/build/2225.c6244756.chunk.js +0 -79
  140. package/build/2379.f1641312.chunk.js +0 -1
  141. package/build/2395.46f8d0c1.chunk.js +0 -26
  142. package/build/2801.5cef5ec8.chunk.js +0 -1
  143. package/build/3483.03c24f96.chunk.js +0 -1
  144. package/build/3739.63e352f1.chunk.js +0 -103
  145. package/build/3929.5632f24d.chunk.js +0 -114
  146. package/build/448.829e1344.chunk.js +0 -1
  147. package/build/4546.cfafae68.chunk.js +0 -1
  148. package/build/502.8ae8ef60.chunk.js +0 -1
  149. package/build/5483.6dd2e776.chunk.js +0 -6
  150. package/build/5542.2415a393.chunk.js +0 -63
  151. package/build/6691.4985ef22.chunk.js +0 -105
  152. package/build/7464.3e64a1d5.chunk.js +0 -1
  153. package/build/8276.10a3f883.chunk.js +0 -26
  154. package/build/9944.7af075a5.chunk.js +0 -26
  155. package/build/Admin-authenticatedApp.f5ece8ff.chunk.js +0 -79
  156. package/build/Admin_InternalErrorPage.f45f2462.chunk.js +0 -1
  157. package/build/Admin_homePage.ac9dfb86.chunk.js +0 -81
  158. package/build/Admin_marketplace.dde9c148.chunk.js +0 -55
  159. package/build/Admin_pluginsPage.bbe79434.chunk.js +0 -6
  160. package/build/Admin_profilePage.192edc52.chunk.js +0 -13
  161. package/build/Admin_settingsPage.97cb9d41.chunk.js +0 -111
  162. package/build/admin-app.91898385.chunk.js +0 -36
  163. package/build/admin-edit-users.79eeb125.chunk.js +0 -10
  164. package/build/admin-users.123aa08e.chunk.js +0 -11
  165. package/build/api-tokens-list-page.505bf7e0.chunk.js +0 -16
  166. package/build/audit-logs-settings-page.4b422831.chunk.js +0 -1
  167. package/build/content-manager.2af15f57.chunk.js +0 -1099
  168. package/build/email-settings-page.d494d1eb.chunk.js +0 -11
  169. package/build/i18n-translation-ru-json.401bc498.chunk.js +0 -1
  170. package/build/main.f13fc96c.js +0 -2856
  171. package/build/review-workflows-settings-create-view.cb08cfa2.chunk.js +0 -1
  172. package/build/review-workflows-settings-edit-view.3c7cbe63.chunk.js +0 -1
  173. package/build/review-workflows-settings-list-view.1611dc1f.chunk.js +0 -56
  174. package/build/runtime~main.bb4efc54.js +0 -2
  175. package/build/transfer-tokens-list-page.22147d2c.chunk.js +0 -16
  176. package/build/users-advanced-settings-page.f0760eb8.chunk.js +0 -9
  177. package/build/users-email-settings-page.ff4b32f3.chunk.js +0 -9
  178. package/build/users-permissions-translation-zh-Hans-json.6ab714ee.chunk.js +0 -1
  179. package/build/users-providers-settings-page.48de0306.chunk.js +0 -14
  180. package/build/users-roles-settings-page.3f9f063e.chunk.js +0 -30
  181. package/build/webhook-edit-page.6cb479ff.chunk.js +0 -33
  182. package/build/zh-Hans-json.937b395b.chunk.js +0 -1
  183. package/ee/admin/hooks/index.js +0 -4
  184. package/ee/admin/hooks/useAuthProviders/index.js +0 -50
  185. package/ee/admin/hooks/useAuthProviders/reducer.js +0 -26
  186. package/ee/admin/hooks/useLicenseLimits/index.js +0 -1
  187. /package/ee/admin/hooks/{useLicenseLimits/__mocks__/index.js → __mocks__/useLicenseLimits.js} +0 -0
@@ -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';
@@ -1,175 +0,0 @@
1
- import React, { useState } from 'react';
2
-
3
- import {
4
- Box,
5
- Button,
6
- Flex,
7
- Main,
8
- Option,
9
- Select,
10
- TextButton,
11
- TextInput,
12
- Typography,
13
- } from '@strapi/design-system';
14
- import { auth, pxToRem, useFetchClient, useNotification } from '@strapi/helper-plugin';
15
- import { parse } from 'qs';
16
- import { useIntl } from 'react-intl';
17
- import { useHistory } from 'react-router-dom';
18
- import styled from 'styled-components';
19
-
20
- import Logo from '../../components/UnauthenticatedLogo';
21
- import UnauthenticatedLayout, { LayoutContent } from '../../layouts/UnauthenticatedLayout';
22
-
23
- export const options = [
24
- {
25
- intlLabel: {
26
- id: 'Usecase.front-end',
27
- defaultMessage: 'Front-end developer',
28
- },
29
- value: 'front_end_developer',
30
- },
31
- {
32
- intlLabel: {
33
- id: 'Usecase.back-end',
34
- defaultMessage: 'Back-end developer',
35
- },
36
- value: 'back_end_developer',
37
- },
38
- {
39
- intlLabel: {
40
- id: 'Usecase.full-stack',
41
- defaultMessage: 'Full-stack developer',
42
- },
43
- value: 'full_stack_developer',
44
- },
45
- {
46
- intlLabel: {
47
- id: 'global.content-manager',
48
- defaultMessage: 'Content Manager',
49
- },
50
- value: 'content_manager',
51
- },
52
- {
53
- intlLabel: {
54
- id: 'Usecase.content-creator',
55
- defaultMessage: 'Content Creator',
56
- },
57
- value: 'content_creator',
58
- },
59
- {
60
- intlLabel: {
61
- id: 'Usecase.other',
62
- defaultMessage: 'Other',
63
- },
64
- value: 'other',
65
- },
66
- ];
67
-
68
- const TypographyCenter = styled(Typography)`
69
- text-align: center;
70
- `;
71
-
72
- const UseCasePage = () => {
73
- const toggleNotification = useNotification();
74
- const { push, location } = useHistory();
75
- const { formatMessage } = useIntl();
76
- const [role, setRole] = useState();
77
- const [otherRole, setOtherRole] = useState('');
78
- const { post } = useFetchClient();
79
-
80
- const { firstname, email } = auth.getUserInfo();
81
- const { hasAdmin } = parse(location?.search, { ignoreQueryPrefix: true });
82
- const isOther = role === 'other';
83
-
84
- const handleSubmit = async (event, skipPersona) => {
85
- event.preventDefault();
86
- try {
87
- await post('https://analytics.strapi.io/register', {
88
- email,
89
- username: firstname,
90
- firstAdmin: Boolean(!hasAdmin),
91
- persona: {
92
- role: skipPersona ? undefined : role,
93
- otherRole: skipPersona ? undefined : otherRole,
94
- },
95
- });
96
-
97
- toggleNotification({
98
- type: 'success',
99
- message: {
100
- id: 'Usecase.notification.success.project-created',
101
- defaultMessage: 'Project has been successfully created',
102
- },
103
- });
104
- push('/');
105
- } catch (err) {
106
- // Silent
107
- }
108
- };
109
-
110
- return (
111
- <UnauthenticatedLayout>
112
- <Main labelledBy="usecase-title">
113
- <LayoutContent>
114
- <form onSubmit={(e) => handleSubmit(e, false)}>
115
- <Flex direction="column" paddingBottom={7}>
116
- <Logo />
117
- <Box paddingTop={6} paddingBottom={1} width={pxToRem(250)}>
118
- <TypographyCenter variant="alpha" as="h1" id="usecase-title">
119
- {formatMessage({
120
- id: 'Usecase.title',
121
- defaultMessage: 'Tell us a bit more about yourself',
122
- })}
123
- </TypographyCenter>
124
- </Box>
125
- </Flex>
126
- <Flex direction="column" alignItems="stretch" gap={6}>
127
- <Select
128
- id="usecase"
129
- data-testid="usecase"
130
- label={formatMessage({
131
- id: 'Usecase.input.work-type',
132
- defaultMessage: 'What type of work do you do?',
133
- })}
134
- // onClear={() => setRole(null)}
135
- // clearLabel={formatMessage({ id: 'clearLabel', defaultMessage: 'Clear' })}
136
- onChange={setRole}
137
- value={role}
138
- >
139
- {options.map(({ intlLabel, value }) => (
140
- <Option key={value} value={value}>
141
- {formatMessage(intlLabel)}
142
- </Option>
143
- ))}
144
- </Select>
145
- {isOther && (
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
- <Button type="submit" size="L" fullWidth disabled={!role}>
155
- {formatMessage({ id: 'global.finish', defaultMessage: 'Finish' })}
156
- </Button>
157
- </Flex>
158
- </form>
159
- </LayoutContent>
160
- <Flex justifyContent="center">
161
- <Box paddingTop={4}>
162
- <TextButton onClick={() => handleSubmit(true)}>
163
- {formatMessage({
164
- id: 'Usecase.button.skip',
165
- defaultMessage: 'Skip this question',
166
- })}
167
- </TextButton>
168
- </Box>
169
- </Flex>
170
- </Main>
171
- </UnauthenticatedLayout>
172
- );
173
- };
174
-
175
- export default UseCasePage;
@@ -1,15 +0,0 @@
1
- import { getYupInnerErrors } from '@strapi/helper-plugin';
2
-
3
- const checkFormValidity = async (data, schema) => {
4
- let errors = null;
5
-
6
- try {
7
- await schema.validate(data, { abortEarly: false });
8
- } catch (err) {
9
- errors = getYupInnerErrors(err);
10
- }
11
-
12
- return errors;
13
- };
14
-
15
- export default checkFormValidity;
@@ -1,19 +0,0 @@
1
- const getAttributesToDisplay = (contentType) => {
2
- const timestamps = contentType?.options?.timestamps;
3
-
4
- // Sometimes timestamps is false
5
- let timestampsArray = Array.isArray(timestamps) ? timestamps : [];
6
- const idsAttributes = ['id', '_id']; // For both SQL and mongo
7
- const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'publishedAt'];
8
- const schemaAttributes = contentType?.attributes ?? {};
9
-
10
- return Object.keys(schemaAttributes).reduce((acc, current) => {
11
- if (!unwritableAttributes.includes(current)) {
12
- acc.push({ ...schemaAttributes[current], attributeName: current });
13
- }
14
-
15
- return acc;
16
- }, []);
17
- };
18
-
19
- export default getAttributesToDisplay;
@@ -1,32 +0,0 @@
1
- const getExistingActions = (permissions) => {
2
- return Array.from(
3
- new Set(
4
- Object.entries(permissions).reduce((acc, current) => {
5
- const getActionsPermission = (permission) =>
6
- permission.reduce((accAction, currentAction) => {
7
- let actionsToReturn = accAction;
8
-
9
- if (currentAction.actions) {
10
- actionsToReturn = [...actionsToReturn, ...currentAction.actions];
11
- }
12
-
13
- if (typeof currentAction === 'object' && !currentAction.actions) {
14
- actionsToReturn = [...actionsToReturn, ...Object.keys(currentAction)];
15
- }
16
-
17
- return actionsToReturn;
18
- }, []);
19
-
20
- return [
21
- ...acc,
22
- ...getActionsPermission([
23
- ...Object.values(current[1].attributes || {}),
24
- current[1]?.contentTypeActions ?? {},
25
- ]),
26
- ];
27
- }, [])
28
- )
29
- );
30
- };
31
-
32
- export default getExistingActions;
@@ -1,9 +0,0 @@
1
- export { default as checkFormValidity } from './checkFormValidity';
2
- export { default as createRoute } from './createRoute';
3
- export { default as formatAPIErrors } from './formatAPIErrors';
4
- export { default as getAttributesToDisplay } from './getAttributesToDisplay';
5
- export { default as getExistingActions } from './getExistingActions';
6
- export { default as getFullName } from './getFullName';
7
- export { default as makeUniqueRoutes } from './makeUniqueRoutes';
8
- export { default as sortLinks } from './sortLinks';
9
- export { default as hashAdminUserEmail } from './uniqueAdminHash';
@@ -1,6 +0,0 @@
1
- const makeUniqueRoutes = (routes) =>
2
- routes.filter((route, index, refArray) => {
3
- return refArray.findIndex((obj) => obj.key === route.key) === index;
4
- });
5
-
6
- export default makeUniqueRoutes;