mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 22:23:10 +00:00
Add admin configurations
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
194da25d2b
commit
8ec5fffc00
@ -36,8 +36,6 @@ module.exports = {
|
||||
BACKEND_URL: true,
|
||||
PUBLIC_PATH: true,
|
||||
NODE_ENV: true,
|
||||
STRAPI_ADMIN_SHOW_TUTORIALS: true,
|
||||
STRAPI_ADMIN_UPDATE_NOTIFICATION: true,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
|
||||
@ -45,8 +45,7 @@ module.exports = {
|
||||
BACKEND_URL: 'http://localhost:1337',
|
||||
ADMIN_PATH: '/admin',
|
||||
NODE_ENV: 'test',
|
||||
'process.env.STRAPI_ADMIN_SHOW_TUTORIALS': 'false',
|
||||
'process.env.STRAPI_ADMIN_UPDATE_NOTIFICATION': 'false',
|
||||
|
||||
// FIXME create a clean config file
|
||||
},
|
||||
moduleDirectories: [
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
STRAPI_ADMIN_SHOW_TUTORIALS=false
|
||||
STRAPI_ADMIN_UPDATE_NOTIFICATION=false
|
||||
@ -1,7 +1,9 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import merge from 'lodash/merge';
|
||||
import pick from 'lodash/pick';
|
||||
import invariant from 'invariant';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { basename, createHook } from './core/utils';
|
||||
import configureStore from './core/store/configureStore';
|
||||
import { Plugin } from './core/apis';
|
||||
@ -18,6 +20,7 @@ import {
|
||||
MUTATE_SINGLE_TYPES_LINKS,
|
||||
} from './exposedHooks';
|
||||
import injectionZones from './injectionZones';
|
||||
import favicon from './favicon.ico';
|
||||
import themes from './themes';
|
||||
|
||||
class StrapiApp {
|
||||
@ -25,9 +28,13 @@ class StrapiApp {
|
||||
this.customConfigurations = adminConfig;
|
||||
this.configurations = {
|
||||
authLogo: AuthLogo,
|
||||
head: { favicon },
|
||||
locales: ['en'],
|
||||
menuLogo: MenuLogo,
|
||||
notifications: { releases: true },
|
||||
theme: themes,
|
||||
translations: {},
|
||||
tutorials: true,
|
||||
};
|
||||
this.appPlugins = appPlugins || {};
|
||||
this.library = library;
|
||||
@ -191,6 +198,22 @@ class StrapiApp {
|
||||
if (this.customConfigurations?.menu?.logo) {
|
||||
this.configurations.menuLogo = this.customConfigurations.menu.logo;
|
||||
}
|
||||
|
||||
if (this.customConfigurations?.head?.favicon) {
|
||||
this.configurations.head.favicon = this.customConfigurations.head.favicon;
|
||||
}
|
||||
|
||||
if (this.customConfigurations?.theme) {
|
||||
this.configurations.theme = merge(this.configurations.theme, this.customConfigurations.theme);
|
||||
}
|
||||
|
||||
if (this.customConfigurations?.notifications?.releases !== undefined) {
|
||||
this.configurations.notifications.releases = this.customConfigurations.notifications.releases;
|
||||
}
|
||||
|
||||
if (this.customConfigurations?.tutorials !== undefined) {
|
||||
this.configurations.tutorials = this.customConfigurations.tutorials;
|
||||
}
|
||||
};
|
||||
|
||||
createHook = name => {
|
||||
@ -372,7 +395,7 @@ class StrapiApp {
|
||||
} = this.library;
|
||||
|
||||
return (
|
||||
<Theme theme={themes}>
|
||||
<Theme theme={this.configurations.theme}>
|
||||
<Providers
|
||||
authLogo={this.configurations.authLogo}
|
||||
components={components}
|
||||
@ -390,11 +413,24 @@ class StrapiApp {
|
||||
}}
|
||||
runHookSeries={this.runHookSeries}
|
||||
settings={this.settings}
|
||||
showTutorials={this.configurations.tutorials}
|
||||
showReleaseNotification={this.configurations.notifications.releases}
|
||||
store={store}
|
||||
>
|
||||
<BrowserRouter basename={basename}>
|
||||
<App store={store} />
|
||||
</BrowserRouter>
|
||||
<>
|
||||
<Helmet
|
||||
link={[
|
||||
{
|
||||
rel: 'icon',
|
||||
type: 'image/png',
|
||||
href: this.configurations.head.favicon,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<BrowserRouter basename={basename}>
|
||||
<App store={store} />
|
||||
</BrowserRouter>
|
||||
</>
|
||||
</Providers>
|
||||
</Theme>
|
||||
);
|
||||
|
||||
@ -1,26 +1,30 @@
|
||||
// module.exports = {
|
||||
// app: config => {
|
||||
// config.locales = ['fr'];
|
||||
|
||||
// return config;
|
||||
// },
|
||||
// };
|
||||
|
||||
export default {
|
||||
config: {
|
||||
auth: {
|
||||
logo:
|
||||
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
|
||||
},
|
||||
head: {
|
||||
favicon:
|
||||
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
|
||||
title: 'Strapi',
|
||||
},
|
||||
locales: ['fr', 'toto'],
|
||||
menu: {
|
||||
logo: null,
|
||||
},
|
||||
theme: {
|
||||
main: {
|
||||
colors: {},
|
||||
},
|
||||
},
|
||||
translations: {
|
||||
fr: {
|
||||
'Auth.form.email.label': 'test',
|
||||
},
|
||||
},
|
||||
tutorials: false,
|
||||
notifications: { release: false },
|
||||
},
|
||||
bootstrap() {},
|
||||
};
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import { LoadingIndicatorPage, AppInfosContext } from '@strapi/helper-plugin';
|
||||
import { useQueries } from 'react-query';
|
||||
import packageJSON from '../../../../package.json';
|
||||
import { ConfigurationsContext } from '../../contexts';
|
||||
import PluginsInitializer from '../PluginsInitializer';
|
||||
import RBACProvider from '../RBACProvider';
|
||||
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from './utils/api';
|
||||
import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
|
||||
|
||||
const { STRAPI_ADMIN_UPDATE_NOTIFICATION } = process.env;
|
||||
const canFetchRelease = STRAPI_ADMIN_UPDATE_NOTIFICATION === 'true';
|
||||
const strapiVersion = packageJSON.version;
|
||||
|
||||
const AuthenticatedApp = () => {
|
||||
const { showReleaseNotification } = useContext(ConfigurationsContext);
|
||||
const [
|
||||
{ data: appInfos, status },
|
||||
{ data: tag_name, isLoading },
|
||||
@ -21,7 +21,7 @@ const AuthenticatedApp = () => {
|
||||
{
|
||||
queryKey: 'strapi-release',
|
||||
queryFn: fetchStrapiLatestRelease,
|
||||
enabled: canFetchRelease,
|
||||
enabled: showReleaseNotification,
|
||||
initialData: strapiVersion,
|
||||
},
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { QueryClientProvider, QueryClient } from 'react-query';
|
||||
import { ConfigurationsContext } from '../../../contexts';
|
||||
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from '../utils/api';
|
||||
import packageJSON from '../../../../../package.json';
|
||||
import AuthenticatedApp from '..';
|
||||
@ -27,7 +28,9 @@ const queryClient = new QueryClient({
|
||||
|
||||
const app = (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AuthenticatedApp />
|
||||
<ConfigurationsContext.Provider value={{ showReleaseNotification: false }}>
|
||||
<AuthenticatedApp />
|
||||
</ConfigurationsContext.Provider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import React, { useEffect, useReducer } from 'react';
|
||||
import React, { useContext, useEffect, useReducer } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import axios from 'axios';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faQuestion, faTimes } from '@fortawesome/free-solid-svg-icons';
|
||||
import cn from 'classnames';
|
||||
import { useTracking } from '@strapi/helper-plugin';
|
||||
import { ConfigurationsContext } from '../../contexts';
|
||||
import formatVideoArray from './utils/formatAndStoreVideoArray';
|
||||
import StaticLinks from './StaticLinks';
|
||||
import Video from './Video';
|
||||
@ -12,7 +13,9 @@ import Wrapper from './Wrapper';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const Onboarding = () => {
|
||||
if (process.env.STRAPI_ADMIN_SHOW_TUTORIALS !== 'true') {
|
||||
const { showTutorials } = useContext(ConfigurationsContext);
|
||||
|
||||
if (!showTutorials) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -21,6 +24,7 @@ const Onboarding = () => {
|
||||
|
||||
const OnboardingVideos = () => {
|
||||
const { trackUsage } = useTracking();
|
||||
|
||||
const [{ isLoading, isOpen, videos }, dispatch] = useReducer(reducer, initialState);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -2,10 +2,8 @@ import React, { memo } from 'react';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import favicon from '../../favicon.ico';
|
||||
|
||||
const PageTitle = ({ title }) => {
|
||||
return <Helmet title={title} link={[{ rel: 'icon', type: 'image/png', href: favicon }]} />;
|
||||
return <Helmet title={title} />;
|
||||
};
|
||||
|
||||
PageTitle.propTypes = {
|
||||
|
||||
@ -3,7 +3,12 @@ import PropTypes from 'prop-types';
|
||||
import { QueryClientProvider, QueryClient } from 'react-query';
|
||||
import { LibraryProvider, StrapiAppProvider } from '@strapi/helper-plugin';
|
||||
import { Provider } from 'react-redux';
|
||||
import { AdminContext, AuthLogoContext, MenuLogoContext } from '../../contexts';
|
||||
import {
|
||||
AdminContext,
|
||||
AuthLogoContext,
|
||||
ConfigurationsContext,
|
||||
MenuLogoContext,
|
||||
} from '../../contexts';
|
||||
import LanguageProvider from '../LanguageProvider';
|
||||
import AutoReloadOverlayBlockerProvider from '../AutoReloadOverlayBlockerProvider';
|
||||
import Notifications from '../Notifications';
|
||||
@ -33,6 +38,9 @@ const Providers = ({
|
||||
runHookSeries,
|
||||
runHookWaterfall,
|
||||
settings,
|
||||
showReleaseNotification,
|
||||
showTutorials,
|
||||
|
||||
store,
|
||||
}) => {
|
||||
return (
|
||||
@ -41,25 +49,27 @@ const Providers = ({
|
||||
<AuthLogoContext.Provider value={{ logo: authLogo }}>
|
||||
<MenuLogoContext.Provider value={{ logo: menuLogo }}>
|
||||
<AdminContext.Provider value={{ getAdminInjectedComponents }}>
|
||||
<StrapiAppProvider
|
||||
getPlugin={getPlugin}
|
||||
menu={menu}
|
||||
plugins={plugins}
|
||||
runHookParallel={runHookParallel}
|
||||
runHookWaterfall={runHookWaterfall}
|
||||
runHookSeries={runHookSeries}
|
||||
settings={settings}
|
||||
>
|
||||
<LibraryProvider components={components} fields={fields}>
|
||||
<LanguageProvider messages={messages} localeNames={localeNames}>
|
||||
<AutoReloadOverlayBlockerProvider>
|
||||
<OverlayBlocker>
|
||||
<Notifications>{children}</Notifications>
|
||||
</OverlayBlocker>
|
||||
</AutoReloadOverlayBlockerProvider>
|
||||
</LanguageProvider>
|
||||
</LibraryProvider>
|
||||
</StrapiAppProvider>
|
||||
<ConfigurationsContext.Provider value={{ showReleaseNotification, showTutorials }}>
|
||||
<StrapiAppProvider
|
||||
getPlugin={getPlugin}
|
||||
menu={menu}
|
||||
plugins={plugins}
|
||||
runHookParallel={runHookParallel}
|
||||
runHookWaterfall={runHookWaterfall}
|
||||
runHookSeries={runHookSeries}
|
||||
settings={settings}
|
||||
>
|
||||
<LibraryProvider components={components} fields={fields}>
|
||||
<LanguageProvider messages={messages} localeNames={localeNames}>
|
||||
<AutoReloadOverlayBlockerProvider>
|
||||
<OverlayBlocker>
|
||||
<Notifications>{children}</Notifications>
|
||||
</OverlayBlocker>
|
||||
</AutoReloadOverlayBlockerProvider>
|
||||
</LanguageProvider>
|
||||
</LibraryProvider>
|
||||
</StrapiAppProvider>
|
||||
</ConfigurationsContext.Provider>
|
||||
</AdminContext.Provider>
|
||||
</MenuLogoContext.Provider>
|
||||
</AuthLogoContext.Provider>
|
||||
@ -95,6 +105,8 @@ Providers.propTypes = {
|
||||
runHookWaterfall: PropTypes.func.isRequired,
|
||||
runHookSeries: PropTypes.func.isRequired,
|
||||
settings: PropTypes.object.isRequired,
|
||||
showReleaseNotification: PropTypes.bool.isRequired,
|
||||
showTutorials: PropTypes.bool.isRequired,
|
||||
store: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
const ConfigurationsContext = createContext({});
|
||||
|
||||
export default ConfigurationsContext;
|
||||
@ -1,4 +1,5 @@
|
||||
export { default as AdminContext } from './Admin';
|
||||
export { default as AuthLogoContext } from './AuthLogo';
|
||||
export { default as ConfigurationsContext } from './Configurations';
|
||||
export { default as MenuLogoContext } from './MenuLogo';
|
||||
export { default as PermissionsDataManagerContext } from './PermisssionsDataManagerContext';
|
||||
|
||||
@ -25,8 +25,6 @@ const getClientEnvironment = options => {
|
||||
ADMIN_PATH: options.adminPath,
|
||||
NODE_ENV: options.env || 'development',
|
||||
STRAPI_ADMIN_BACKEND_URL: options.backend,
|
||||
STRAPI_ADMIN_SHOW_TUTORIALS: 'true',
|
||||
STRAPI_ADMIN_UPDATE_NOTIFICATION: 'true',
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user