@strapi/admin 4.2.0-beta.3 → 4.2.1-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 (160) hide show
  1. package/admin/src/app.js +4 -7
  2. package/admin/src/components/ConfigurationsProvider/index.js +51 -0
  3. package/admin/src/components/ConfigurationsProvider/reducer.js +28 -0
  4. package/admin/src/components/LeftMenu/index.js +12 -2
  5. package/admin/src/components/Providers/index.js +8 -4
  6. package/admin/src/components/UnauthenticatedLogo/index.js +4 -2
  7. package/admin/src/hooks/useFetchMarketplaceProviders/index.js +23 -0
  8. package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +11 -0
  9. package/admin/src/pages/Admin/index.js +5 -15
  10. package/admin/src/pages/App/index.js +9 -18
  11. package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch/EmptyPluginGrid.js → EmptyNpmPackageSearch/EmptyNpmPackageGrid.js} +1 -1
  12. package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch → EmptyNpmPackageSearch}/index.js +6 -4
  13. package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/InstallPluginButton.js +0 -0
  14. package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/index.js +22 -10
  15. package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +42 -0
  16. package/admin/src/pages/MarketplacePage/components/PageHeader/index.js +12 -5
  17. package/admin/src/pages/MarketplacePage/index.js +99 -37
  18. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/index.js +85 -0
  19. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/init.js +13 -0
  20. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/Form/reducer.js +43 -0
  21. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoInput/index.js +118 -0
  22. package/admin/src/pages/{App → SettingsPage/pages/ApplicationInfosPage/components/LogoInput}/reducer.js +13 -7
  23. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoInput/stepper.js +25 -0
  24. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/AddLogoDialog.js +67 -0
  25. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromComputerForm.js +176 -0
  26. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromUrlForm.js +82 -0
  27. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/ImageCardAsset.js +51 -0
  28. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/PendingLogoDialog.js +97 -0
  29. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/index.js +85 -0
  30. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/reducer.js +28 -0
  31. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +153 -91
  32. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +16 -0
  33. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/constants.js +3 -0
  34. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/getFormData.js +17 -0
  35. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/parseFileMetadatas.js +76 -0
  36. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/prefixAllUrls.js +17 -0
  37. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/urlToFile.js +21 -0
  38. package/admin/src/reducers.js +2 -4
  39. package/admin/src/translations/en.json +33 -3
  40. package/admin/src/translations/pl.json +264 -12
  41. package/admin/src/translations/vi.json +17 -17
  42. package/build/1856.6a94980b.chunk.js +172 -0
  43. package/build/2077.5456ccd1.chunk.js +194 -0
  44. package/build/2758.9475712b.chunk.js +162 -0
  45. package/build/2912.dd031292.chunk.js +253 -0
  46. package/build/4715.4588fdf5.chunk.js +385 -0
  47. package/build/4800.d3ebc81d.chunk.js +1 -0
  48. package/build/4982.c57c5675.chunk.js +308 -0
  49. package/build/7197.47565569.chunk.js +113 -0
  50. package/build/{6229.a5cca9f2.chunk.js → 7589.77ef4fbf.chunk.js} +2 -2
  51. package/build/{210.014495c1.chunk.js → 7757.f6eb5e92.chunk.js} +58 -58
  52. package/build/7841.9e9cf739.chunk.js +253 -0
  53. package/build/8681.aec05472.chunk.js +163 -0
  54. package/build/9066.2847fdff.chunk.js +101 -0
  55. package/build/{4073.41ac1235.chunk.js → 9115.623dc4f7.chunk.js} +1 -1
  56. package/build/9158.e48d88af.chunk.js +503 -0
  57. package/build/{7191.3bde3cbf.chunk.js → 9298.cb3b6bc1.chunk.js} +112 -113
  58. package/build/9420.ba035f29.chunk.js +508 -0
  59. package/build/948.d64fb515.chunk.js +2 -0
  60. package/build/Admin-authenticatedApp.63a5061a.chunk.js +80 -0
  61. package/build/{Admin_homePage.f157e33e.chunk.js → Admin_homePage.447df176.chunk.js} +2 -2
  62. package/build/Admin_marketplace.8a503eec.chunk.js +11 -0
  63. package/build/Admin_pluginsPage.91a96fa5.chunk.js +1 -0
  64. package/build/{Admin_profilePage.62c203ad.chunk.js → Admin_profilePage.249cbfc9.chunk.js} +2 -2
  65. package/build/Admin_settingsPage.0d138832.chunk.js +180 -0
  66. package/build/{admin-edit-roles-page.94e1403b.chunk.js → admin-edit-roles-page.7c2c9752.chunk.js} +1 -1
  67. package/build/admin-edit-users.b835bc48.chunk.js +11 -0
  68. package/build/admin-users.19900b75.chunk.js +12 -0
  69. package/build/api-tokens-create-page.8d299dde.chunk.js +1 -0
  70. package/build/api-tokens-edit-page.3e453fc1.chunk.js +1 -0
  71. package/build/{api-tokens-list-page.340750a6.chunk.js → api-tokens-list-page.872c3800.chunk.js} +1 -1
  72. package/build/{codemirror-css.b467b1de.chunk.js → codemirror-css.98490df3.chunk.js} +2 -2
  73. package/build/{codemirror-javacript.41bdefda.chunk.js → codemirror-javacript.cafbda9c.chunk.js} +1 -1
  74. package/build/codemirror-theme.b3c64617.chunk.js +34 -0
  75. package/build/{content-manager.6cdcfb6e.chunk.js → content-manager.002bfd99.chunk.js} +16 -16
  76. package/build/content-type-builder.a0450dfe.chunk.js +141 -0
  77. package/build/{cropper-css.ecc0d670.chunk.js → cropper-css.0055cd53.chunk.js} +2 -2
  78. package/build/email-settings-page.1f235173.chunk.js +103 -0
  79. package/build/en-json.0a5ba154.chunk.js +1 -0
  80. package/build/{fontawesome-css-all.04f33619.chunk.js → fontawesome-css-all.b88d464e.chunk.js} +3 -3
  81. package/build/{fontawesome-css.477ba714.chunk.js → fontawesome-css.a92a7b6c.chunk.js} +2 -2
  82. package/build/highlight.js.9d8ef460.chunk.js +86 -0
  83. package/build/i18n-settings-page.06e88cf2.chunk.js +101 -0
  84. package/build/index.html +1 -1
  85. package/build/main.e3a13431.js +8404 -0
  86. package/build/pl-json.f65302c2.chunk.js +1 -0
  87. package/build/{runtime~main.e7611418.js → runtime~main.dacf1aff.js} +2 -2
  88. package/build/sso-settings-page.a7c2e854.chunk.js +1 -0
  89. package/build/upload-settings.4ee2f135.chunk.js +101 -0
  90. package/build/upload.0d4153e8.chunk.js +105 -0
  91. package/build/users-advanced-settings-page.747b2ec1.chunk.js +101 -0
  92. package/build/users-email-settings-page.8b9a266d.chunk.js +1 -0
  93. package/build/users-providers-settings-page.fc9d8f9d.chunk.js +1 -0
  94. package/build/{users-roles-settings-page.988ebc3b.chunk.js → users-roles-settings-page.1bf4ffc5.chunk.js} +2 -2
  95. package/build/vi-json.bf3424be.chunk.js +1 -0
  96. package/build/webhook-edit-page.142b23ac.chunk.js +23 -0
  97. package/build/webhook-list-page.671582a0.chunk.js +133 -0
  98. package/index.js +239 -53
  99. package/package.json +8 -12
  100. package/scripts/build.js +3 -17
  101. package/server/config/admin-actions.js +14 -0
  102. package/server/controllers/admin.js +29 -12
  103. package/server/policies/index.js +0 -1
  104. package/server/routes/admin.js +28 -9
  105. package/server/routes/serve-admin-panel.js +1 -1
  106. package/server/services/index.js +1 -0
  107. package/server/services/project-settings.js +173 -0
  108. package/server/utils/index.d.ts +2 -0
  109. package/server/validation/project-settings.js +39 -0
  110. package/webpack.alias.js +30 -19
  111. package/webpack.config.js +5 -28
  112. package/admin/src/pages/App/constants.js +0 -1
  113. package/admin/src/tsconfig.json +0 -10
  114. package/build/1709.ceed0e18.chunk.js +0 -503
  115. package/build/1856.521a99fd.chunk.js +0 -172
  116. package/build/20.cf744c35.chunk.js +0 -308
  117. package/build/2077.51485bfb.chunk.js +0 -194
  118. package/build/2135.95ee6de1.chunk.js +0 -162
  119. package/build/2524.688d0355.chunk.js +0 -1
  120. package/build/2912.79c2b3c8.chunk.js +0 -253
  121. package/build/4715.77e04177.chunk.js +0 -385
  122. package/build/4761.3eabdf46.chunk.js +0 -101
  123. package/build/6281.f10a7e3a.chunk.js +0 -1
  124. package/build/7009.79fce86d.chunk.js +0 -164
  125. package/build/7841.f0e7d629.chunk.js +0 -253
  126. package/build/7863.bc7a8f3a.chunk.js +0 -112
  127. package/build/9420.cb0b75e8.chunk.js +0 -508
  128. package/build/Admin-authenticatedApp.4ce8d292.chunk.js +0 -80
  129. package/build/Admin_marketplace.1e3393c9.chunk.js +0 -11
  130. package/build/Admin_pluginsPage.788fb2f6.chunk.js +0 -1
  131. package/build/Admin_settingsPage.924a7816.chunk.js +0 -170
  132. package/build/admin-edit-users.6c2bf718.chunk.js +0 -10
  133. package/build/admin-users.e03db115.chunk.js +0 -11
  134. package/build/api-tokens-create-page.787ab302.chunk.js +0 -1
  135. package/build/api-tokens-edit-page.e4010c0c.chunk.js +0 -1
  136. package/build/codemirror-theme.cf9f9eb6.chunk.js +0 -34
  137. package/build/content-type-builder.e73879b9.chunk.js +0 -141
  138. package/build/email-settings-page.f67d13b2.chunk.js +0 -103
  139. package/build/en-json.3e1a222e.chunk.js +0 -1
  140. package/build/highlight.js.3381ffc3.chunk.js +0 -86
  141. package/build/i18n-settings-page.6b67cb75.chunk.js +0 -101
  142. package/build/main.45472ea9.js +0 -8404
  143. package/build/pl-json.94f05d2c.chunk.js +0 -1
  144. package/build/sso-settings-page.e9034e22.chunk.js +0 -1
  145. package/build/upload-settings.3db55de0.chunk.js +0 -101
  146. package/build/upload.070c189b.chunk.js +0 -105
  147. package/build/users-advanced-settings-page.a23cda17.chunk.js +0 -101
  148. package/build/users-email-settings-page.0a096388.chunk.js +0 -1
  149. package/build/users-providers-settings-page.bfe7755a.chunk.js +0 -1
  150. package/build/vi-json.3d14e91e.chunk.js +0 -1
  151. package/build/webhook-edit-page.2fa94db3.chunk.js +0 -23
  152. package/build/webhook-list-page.b594db49.chunk.js +0 -133
  153. package/server/policies/isTelemetryEnabled.js +0 -16
  154. package/utils/create-cache-dir.js +0 -161
  155. package/utils/get-custom-app-config-file.js +0 -23
  156. package/utils/get-custom-webpack-config.js +0 -38
  157. package/utils/get-plugins-path.js +0 -26
  158. package/utils/index.js +0 -13
  159. package/utils/should-build-admin.js +0 -52
  160. package/utils/watch-admin-files.js +0 -59
package/admin/src/app.js CHANGED
@@ -1,9 +1,6 @@
1
- const config = {
2
- locales: ['fr'],
3
- };
4
- const bootstrap = () => {};
5
-
6
1
  export default {
7
- config,
8
- bootstrap,
2
+ config: {
3
+ locales: ['fr'],
4
+ },
5
+ bootstrap() {},
9
6
  };
@@ -0,0 +1,51 @@
1
+ import React, { useReducer, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ConfigurationsContext } from '../../contexts';
4
+ import reducer, { initialState } from './reducer';
5
+
6
+ const ConfigurationsProvider = ({
7
+ children,
8
+ authLogo,
9
+ menuLogo: defaultMenuLogo,
10
+ showReleaseNotification,
11
+ showTutorials,
12
+ }) => {
13
+ const [{ menuLogo }, dispatch] = useReducer(reducer, initialState);
14
+
15
+ const updateProjectSettings = ({ menuLogo }) => {
16
+ return dispatch({
17
+ type: 'UPDATE_PROJECT_SETTINGS',
18
+ values: {
19
+ menuLogo: menuLogo || defaultMenuLogo,
20
+ },
21
+ });
22
+ };
23
+
24
+ const updateProjectSettingsRef = useRef(updateProjectSettings);
25
+
26
+ return (
27
+ <ConfigurationsContext.Provider
28
+ value={{
29
+ logos: {
30
+ menu: { custom: menuLogo, default: defaultMenuLogo },
31
+ auth: { custom: null, default: authLogo },
32
+ },
33
+ updateProjectSettings: updateProjectSettingsRef.current,
34
+ showReleaseNotification,
35
+ showTutorials,
36
+ }}
37
+ >
38
+ {children}
39
+ </ConfigurationsContext.Provider>
40
+ );
41
+ };
42
+
43
+ ConfigurationsProvider.propTypes = {
44
+ authLogo: PropTypes.string.isRequired,
45
+ children: PropTypes.element.isRequired,
46
+ menuLogo: PropTypes.string.isRequired,
47
+ showReleaseNotification: PropTypes.bool.isRequired,
48
+ showTutorials: PropTypes.bool.isRequired,
49
+ };
50
+
51
+ export default ConfigurationsProvider;
@@ -0,0 +1,28 @@
1
+ /* eslint-disable consistent-return */
2
+ /*
3
+ *
4
+ * ConfigurationsProvider reducer
5
+ *
6
+ */
7
+
8
+ import produce from 'immer';
9
+
10
+ const initialState = {
11
+ menuLogo: null,
12
+ };
13
+
14
+ const reducer = (state = initialState, action) =>
15
+ produce(state, draftState => {
16
+ switch (action.type) {
17
+ case 'UPDATE_PROJECT_SETTINGS': {
18
+ Object.assign(draftState, action.values);
19
+ break;
20
+ }
21
+ default: {
22
+ return draftState;
23
+ }
24
+ }
25
+ });
26
+
27
+ export default reducer;
28
+ export { initialState };
@@ -53,7 +53,9 @@ const LinkUser = styled(RouterNavLink)`
53
53
  const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
54
54
  const buttonRef = useRef();
55
55
  const [userLinksVisible, setUserLinksVisible] = useState(false);
56
- const { menuLogo } = useConfigurations();
56
+ const {
57
+ logos: { menu },
58
+ } = useConfigurations();
57
59
  const [condensed, setCondensed] = usePersistentState('navbar-condensed', false);
58
60
  const { userDisplayName } = useAppInfos();
59
61
  const { formatMessage } = useIntl();
@@ -94,7 +96,15 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
94
96
  defaultMessage: 'Workplace',
95
97
  })}
96
98
  title={menuTitle}
97
- icon={<img src={menuLogo} alt={menuTitle} />}
99
+ icon={
100
+ <img
101
+ src={menu.custom || menu.default}
102
+ alt={formatMessage({
103
+ id: 'app.components.LeftMenu.logo.alt',
104
+ defaultMessage: 'Application logo',
105
+ })}
106
+ />
107
+ }
98
108
  />
99
109
 
100
110
  <Divider />
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
3
3
  import { QueryClientProvider, QueryClient } from 'react-query';
4
4
  import { LibraryProvider, StrapiAppProvider } from '@strapi/helper-plugin';
5
5
  import { Provider } from 'react-redux';
6
- import { AdminContext, ConfigurationsContext } from '../../contexts';
6
+ import { AdminContext } from '../../contexts';
7
+ import ConfigurationsProvider from '../ConfigurationsProvider';
7
8
  import LanguageProvider from '../LanguageProvider';
8
9
  import GuidedTour from '../GuidedTour';
9
10
  import AutoReloadOverlayBlockerProvider from '../AutoReloadOverlayBlockerProvider';
@@ -47,8 +48,11 @@ const Providers = ({
47
48
  <QueryClientProvider client={queryClient}>
48
49
  <Provider store={store}>
49
50
  <AdminContext.Provider value={{ getAdminInjectedComponents }}>
50
- <ConfigurationsContext.Provider
51
- value={{ authLogo, menuLogo, showReleaseNotification, showTutorials }}
51
+ <ConfigurationsProvider
52
+ authLogo={authLogo}
53
+ menuLogo={menuLogo}
54
+ showReleaseNotification={showReleaseNotification}
55
+ showTutorials={showTutorials}
52
56
  >
53
57
  <StrapiAppProvider
54
58
  getPlugin={getPlugin}
@@ -71,7 +75,7 @@ const Providers = ({
71
75
  </LanguageProvider>
72
76
  </LibraryProvider>
73
77
  </StrapiAppProvider>
74
- </ConfigurationsContext.Provider>
78
+ </ConfigurationsProvider>
75
79
  </AdminContext.Provider>
76
80
  </Provider>
77
81
  </QueryClientProvider>
@@ -7,9 +7,11 @@ const Img = styled.img`
7
7
  `;
8
8
 
9
9
  const Logo = () => {
10
- const { authLogo } = useConfigurations();
10
+ const {
11
+ logos: { auth },
12
+ } = useConfigurations();
11
13
 
12
- return <Img src={authLogo} aria-hidden alt="" />;
14
+ return <Img src={auth.default} aria-hidden alt="" />;
13
15
  };
14
16
 
15
17
  export default Logo;
@@ -0,0 +1,23 @@
1
+ import { useQuery } from 'react-query';
2
+ import { useNotification } from '@strapi/helper-plugin';
3
+ import { fetchMarketplacePlugins } from './utils/api';
4
+
5
+ const useFetchMarketplaceProviders = (notifyLoad) => {
6
+ const toggleNotification = useNotification();
7
+
8
+ return useQuery('list-marketplace-providers', () => fetchMarketplacePlugins(), {
9
+ onSuccess: () => {
10
+ if (notifyLoad) {
11
+ notifyLoad();
12
+ }
13
+ },
14
+ onError: () => {
15
+ toggleNotification({
16
+ type: 'warning',
17
+ message: { id: 'notification.error', defaultMessage: 'An error occured' },
18
+ });
19
+ },
20
+ });
21
+ };
22
+
23
+ export default useFetchMarketplaceProviders;
@@ -0,0 +1,11 @@
1
+ import axios from 'axios';
2
+
3
+ const MARKETPLACE_API_URL = 'https://market-api.strapi.io';
4
+
5
+ const fetchMarketplacePlugins = async () => {
6
+ const { data } = await axios.get(`${MARKETPLACE_API_URL}/providers`);
7
+
8
+ return data;
9
+ };
10
+
11
+ export { fetchMarketplacePlugins };
@@ -6,17 +6,16 @@
6
6
 
7
7
  import React, { Suspense, useEffect, useMemo, lazy } from 'react';
8
8
  import { Switch, Route } from 'react-router-dom';
9
+ // Components from @strapi/helper-plugin
9
10
  import { useTracking, LoadingIndicatorPage, useStrapiApp } from '@strapi/helper-plugin';
10
- import { useDispatch, useSelector } from 'react-redux';
11
11
  import { DndProvider } from 'react-dnd';
12
12
  import { HTML5Backend } from 'react-dnd-html5-backend';
13
- import GuidedTourModal from '../../components/GuidedTour/Modal';
14
13
  import LeftMenu from '../../components/LeftMenu';
15
14
  import AppLayout from '../../layouts/AppLayout';
16
15
  import { useMenu } from '../../hooks';
17
- import { createRoute } from '../../utils';
18
- import { SET_APP_RUNTIME_STATUS } from '../App/constants';
19
16
  import Onboarding from './Onboarding';
17
+ import { createRoute } from '../../utils';
18
+ import GuidedTourModal from '../../components/GuidedTour/Modal';
20
19
 
21
20
  const CM = lazy(() =>
22
21
  import(/* webpackChunkName: "content-manager" */ '../../content-manager/pages/App')
@@ -41,20 +40,11 @@ const SettingsPage = lazy(() =>
41
40
  // Simple hook easier for testing
42
41
  const useTrackUsage = () => {
43
42
  const { trackUsage } = useTracking();
44
- const dispatch = useDispatch();
45
- const appStatus = useSelector(state => state.admin_app.status);
46
43
 
47
44
  useEffect(() => {
48
- // Make sure the event is only send once after accessing the admin panel
49
- // and not at runtime for example when regenerating the permissions with the ctb
50
- // or with i18n
51
- if (appStatus === 'init') {
52
- trackUsage('didAccessAuthenticatedAdministration');
53
-
54
- dispatch({ type: SET_APP_RUNTIME_STATUS });
55
- }
45
+ trackUsage('didAccessAuthenticatedAdministration');
56
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
57
- }, [appStatus]);
47
+ }, []);
58
48
  };
59
49
 
60
50
  const Admin = () => {
@@ -12,8 +12,8 @@ import {
12
12
  request,
13
13
  useNotification,
14
14
  TrackingContext,
15
+ prefixFileUrlWithBackendUrl,
15
16
  } from '@strapi/helper-plugin';
16
- import axios from 'axios';
17
17
  import { SkipToContent } from '@strapi/design-system/Main';
18
18
  import { useIntl } from 'react-intl';
19
19
  import PrivateRoute from '../../components/PrivateRoute';
@@ -23,6 +23,7 @@ import NotFoundPage from '../NotFoundPage';
23
23
  import UseCasePage from '../UseCasePage';
24
24
  import { getUID } from './utils';
25
25
  import routes from './utils/routes';
26
+ import { useConfigurations } from '../../hooks';
26
27
 
27
28
  const AuthenticatedApp = lazy(() =>
28
29
  import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp')
@@ -30,6 +31,7 @@ const AuthenticatedApp = lazy(() =>
30
31
 
31
32
  function App() {
32
33
  const toggleNotification = useNotification();
34
+ const { updateProjectSettings } = useConfigurations();
33
35
  const { formatMessage } = useIntl();
34
36
  const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
35
37
 
@@ -39,8 +41,6 @@ function App() {
39
41
  );
40
42
  }, []);
41
43
 
42
- const [telemetryProperties, setTelemetryProperties] = useState(null);
43
-
44
44
  useEffect(() => {
45
45
  const currentToken = auth.getToken();
46
46
 
@@ -69,18 +69,12 @@ function App() {
69
69
  const getData = async () => {
70
70
  try {
71
71
  const {
72
- data: {
73
- data: { hasAdmin, uuid },
74
- },
75
- } = await axios.get(`${strapi.backendURL}/admin/init`);
76
-
77
- if (uuid) {
78
- const {
79
- data: { data: properties },
80
- } = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`);
72
+ data: { hasAdmin, uuid, menuLogo },
73
+ } = await request('/admin/init', { method: 'GET' });
81
74
 
82
- setTelemetryProperties(properties);
75
+ updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) });
83
76
 
77
+ if (uuid) {
84
78
  try {
85
79
  const deviceId = await getUID();
86
80
 
@@ -90,9 +84,6 @@ function App() {
90
84
  event: 'didInitializeAdministration',
91
85
  uuid,
92
86
  deviceId,
93
- properties: {
94
- ...properties,
95
- },
96
87
  }),
97
88
  headers: {
98
89
  'Content-Type': 'application/json',
@@ -113,7 +104,7 @@ function App() {
113
104
  };
114
105
 
115
106
  getData();
116
- }, [toggleNotification]);
107
+ }, [toggleNotification, updateProjectSettings]);
117
108
 
118
109
  const setHasAdmin = hasAdmin => setState(prev => ({ ...prev, hasAdmin }));
119
110
 
@@ -124,7 +115,7 @@ function App() {
124
115
  return (
125
116
  <Suspense fallback={<LoadingIndicatorPage />}>
126
117
  <SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent>
127
- <TrackingContext.Provider value={{ uuid, telemetryProperties }}>
118
+ <TrackingContext.Provider value={uuid}>
128
119
  <Switch>
129
120
  {authRoutes}
130
121
  <Route
@@ -9,7 +9,7 @@ const EmptyPluginCard = styled(Box)`
9
9
  opacity: 0.33;
10
10
  `;
11
11
 
12
- export const EmptyPluginGrid = () => {
12
+ export const EmptyNpmPackageGrid = () => {
13
13
  return (
14
14
  <GridLayout>
15
15
  {Array(12)
@@ -5,12 +5,12 @@ import { Box } from '@strapi/design-system/Box';
5
5
  import { Flex } from '@strapi/design-system/Flex';
6
6
  import { Icon } from '@strapi/design-system/Icon';
7
7
  import EmptyStateDocument from '@strapi/icons/EmptyDocuments';
8
- import { EmptyPluginGrid } from './EmptyPluginGrid';
8
+ import { EmptyNpmPackageGrid } from './EmptyNpmPackageGrid';
9
9
 
10
- export const EmptyPluginSearch = ({ content }) => {
10
+ const EmptyNpmPackageSearch = ({ content }) => {
11
11
  return (
12
12
  <Box position="relative">
13
- <EmptyPluginGrid />
13
+ <EmptyNpmPackageGrid />
14
14
  <Box position="absolute" top={11} width="100%">
15
15
  <Flex alignItems="center" justifyContent="center" direction="column">
16
16
  <Icon as={EmptyStateDocument} color="" width="160px" height="88px" />
@@ -25,6 +25,8 @@ export const EmptyPluginSearch = ({ content }) => {
25
25
  );
26
26
  };
27
27
 
28
- EmptyPluginSearch.propTypes = {
28
+ EmptyNpmPackageSearch.propTypes = {
29
29
  content: PropTypes.string.isRequired,
30
30
  };
31
+
32
+ export default EmptyNpmPackageSearch;
@@ -25,12 +25,18 @@ const EllipsisText = styled(Typography)`
25
25
  overflow: hidden;
26
26
  `;
27
27
 
28
- const PluginCard = ({ plugin, installedPluginNames, useYarn, isInDevelopmentMode }) => {
29
- const { attributes } = plugin;
28
+ const NpmPackageCard = ({
29
+ npmPackage,
30
+ installedPackageNames,
31
+ useYarn,
32
+ isInDevelopmentMode,
33
+ npmPackageType,
34
+ }) => {
35
+ const { attributes } = npmPackage;
30
36
  const { formatMessage } = useIntl();
31
37
  const { trackUsage } = useTracking();
32
38
 
33
- const isInstalled = installedPluginNames.includes(attributes.npmPackageName);
39
+ const isInstalled = installedPackageNames.includes(attributes.npmPackageName);
34
40
 
35
41
  const commandToCopy = useYarn
36
42
  ? `yarn add ${attributes.npmPackageName}`
@@ -41,6 +47,11 @@ const PluginCard = ({ plugin, installedPluginNames, useYarn, isInDevelopmentMode
41
47
  defaultMessage: 'Made by Strapi',
42
48
  });
43
49
 
50
+ const npmPackageHref =
51
+ npmPackageType === 'provider'
52
+ ? attributes.npmPackageUrl
53
+ : `https://market.strapi.io/plugins/${attributes.slug}`;
54
+
44
55
  return (
45
56
  <Flex
46
57
  direction="column"
@@ -107,7 +118,7 @@ const PluginCard = ({ plugin, installedPluginNames, useYarn, isInDevelopmentMode
107
118
  <Stack horizontal spacing={2} style={{ alignSelf: 'flex-end' }} paddingTop={6}>
108
119
  <LinkButton
109
120
  size="S"
110
- href={`https://market.strapi.io/plugins/${attributes.slug}`}
121
+ href={npmPackageHref}
111
122
  isExternal
112
123
  endIcon={<ExternalLink />}
113
124
  aria-label={formatMessage(
@@ -135,12 +146,12 @@ const PluginCard = ({ plugin, installedPluginNames, useYarn, isInDevelopmentMode
135
146
  );
136
147
  };
137
148
 
138
- PluginCard.defaultProps = {
149
+ NpmPackageCard.defaultProps = {
139
150
  isInDevelopmentMode: false,
140
151
  };
141
152
 
142
- PluginCard.propTypes = {
143
- plugin: PropTypes.shape({
153
+ NpmPackageCard.propTypes = {
154
+ npmPackage: PropTypes.shape({
144
155
  id: PropTypes.string.isRequired,
145
156
  attributes: PropTypes.shape({
146
157
  name: PropTypes.string.isRequired,
@@ -153,12 +164,13 @@ PluginCard.propTypes = {
153
164
  developerName: PropTypes.string.isRequired,
154
165
  validated: PropTypes.bool.isRequired,
155
166
  madeByStrapi: PropTypes.bool.isRequired,
156
- strapiCompatibility: PropTypes.oneOf(['v3', 'v4']).isRequired,
167
+ strapiCompatibility: PropTypes.oneOf(['v3', 'v4']),
157
168
  }).isRequired,
158
169
  }).isRequired,
159
- installedPluginNames: PropTypes.arrayOf(PropTypes.string).isRequired,
170
+ installedPackageNames: PropTypes.arrayOf(PropTypes.string).isRequired,
160
171
  useYarn: PropTypes.bool.isRequired,
161
172
  isInDevelopmentMode: PropTypes.bool,
173
+ npmPackageType: PropTypes.string.isRequired,
162
174
  };
163
175
 
164
- export default PluginCard;
176
+ export default NpmPackageCard;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Grid, GridItem } from '@strapi/design-system/Grid';
4
+ import NpmPackageCard from '../NpmPackageCard';
5
+
6
+ const NpmPackagesGrid = ({
7
+ npmPackages,
8
+ installedPackageNames,
9
+ useYarn,
10
+ isInDevelopmentMode,
11
+ npmPackageType,
12
+ }) => {
13
+ return (
14
+ <Grid gap={4}>
15
+ {npmPackages.map((npmPackage) => (
16
+ <GridItem col={4} s={6} xs={12} style={{ height: '100%' }} key={npmPackage.id}>
17
+ <NpmPackageCard
18
+ npmPackage={npmPackage}
19
+ installedPackageNames={installedPackageNames}
20
+ useYarn={useYarn}
21
+ isInDevelopmentMode={isInDevelopmentMode}
22
+ npmPackageType={npmPackageType}
23
+ />
24
+ </GridItem>
25
+ ))}
26
+ </Grid>
27
+ );
28
+ };
29
+
30
+ NpmPackagesGrid.defaultProps = {
31
+ installedPackageNames: [],
32
+ };
33
+
34
+ NpmPackagesGrid.propTypes = {
35
+ npmPackages: PropTypes.array.isRequired,
36
+ installedPackageNames: PropTypes.arrayOf(PropTypes.string),
37
+ useYarn: PropTypes.bool.isRequired,
38
+ isInDevelopmentMode: PropTypes.bool.isRequired,
39
+ npmPackageType: PropTypes.string.isRequired,
40
+ };
41
+
42
+ export default NpmPackagesGrid;
@@ -6,10 +6,12 @@ import { LinkButton } from '@strapi/design-system/v2/LinkButton';
6
6
  import Upload from '@strapi/icons/Upload';
7
7
  import { useTracking } from '@strapi/helper-plugin';
8
8
 
9
- const PageHeader = ({ isOnline }) => {
9
+ const PageHeader = ({ isOnline, npmPackageType }) => {
10
10
  const { formatMessage } = useIntl();
11
11
  const { trackUsage } = useTracking();
12
12
 
13
+ const tracking = npmPackageType === 'provider' ? 'didSubmitProvider' : 'didSubmitPlugin';
14
+
13
15
  return (
14
16
  <HeaderLayout
15
17
  title={formatMessage({
@@ -25,13 +27,13 @@ const PageHeader = ({ isOnline }) => {
25
27
  <LinkButton
26
28
  startIcon={<Upload />}
27
29
  variant="tertiary"
28
- href="https://market.strapi.io/submit-plugin"
29
- onClick={() => trackUsage('didSubmitPlugin')}
30
+ href={`https://market.strapi.io/submit-${npmPackageType}`}
31
+ onClick={() => trackUsage(tracking)}
30
32
  isExternal
31
33
  >
32
34
  {formatMessage({
33
- id: 'admin.pages.MarketPlacePage.submit.plugin.link',
34
- defaultMessage: 'Submit your plugin',
35
+ id: `admin.pages.MarketPlacePage.submit.${npmPackageType}.link`,
36
+ defaultMessage: `Submit ${npmPackageType}`,
35
37
  })}
36
38
  </LinkButton>
37
39
  )
@@ -42,6 +44,11 @@ const PageHeader = ({ isOnline }) => {
42
44
 
43
45
  export default PageHeader;
44
46
 
47
+ PageHeader.defaultProps = {
48
+ npmPackageType: 'plugin',
49
+ };
50
+
45
51
  PageHeader.propTypes = {
46
52
  isOnline: PropTypes.bool.isRequired,
53
+ npmPackageType: PropTypes.string,
47
54
  };