Prefix global variables by STRAPI_ADMIN

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2021-05-05 17:52:41 +02:00
parent ddc7a3d60b
commit c7e2a2bd66
13 changed files with 26 additions and 24 deletions

View File

@ -14,6 +14,10 @@ import translationMessages from './translations';
// const App = () => 'todo';
window.strapi = {
backendURL: process.env.STRAPI_ADMIN_BACKEND_URL,
};
class StrapiApp {
plugins = {};

View File

@ -9,9 +9,7 @@ import { PropTypes } from 'prop-types';
import Wrapper, { A } from './Wrapper';
function LeftMenuFooter({ version }) {
// PROJECT_TYPE is an env variable defined in the webpack config
// eslint-disable-next-line no-undef
const projectType = PROJECT_TYPE;
const projectType = process.env.STRAPI_ADMIN_PROJECT_TYPE;
return (
<Wrapper>

View File

@ -94,7 +94,7 @@ export class Admin extends React.Component {
event,
// PROJECT_TYPE is an env variable defined in the webpack config
// eslint-disable-next-line no-undef
properties: { ...properties, projectType: PROJECT_TYPE },
properties: { ...properties, projectType: process.env.STRAPI_ADMIN_PROJECT_TYPE },
uuid,
});
} catch (err) {
@ -120,7 +120,7 @@ export class Admin extends React.Component {
getStrapiLatestReleaseSucceeded,
} = this.props;
if (!STRAPI_ADMIN_UPDATE_NOTIFICATION === 'true') {
if (!process.env.STRAPI_ADMIN_UPDATE_NOTIFICATION === 'true') {
return;
}
@ -292,7 +292,7 @@ export class Admin extends React.Component {
isOpen={blockApp && showGlobalAppBlocker}
{...overlayBlockerData}
/>
{STRAPI_ADMIN_SHOW_TUTORIALS === 'true' && <OnboardingVideos />}
{process.env.STRAPI_ADMIN_SHOW_TUTORIALS === 'true' && <OnboardingVideos />}
</Wrapper>
</GlobalContextProvider>
</PermissionsManager>

View File

@ -47,7 +47,7 @@ window.strapi = Object.assign(window.strapi || {}, {
notification: {
toggle: () => {},
},
backendURL: BACKEND_URL,
lockApp: () => console.log('todo lockApp'),
unlockApp: () => console.log('todo unlockApp'),
lockAppWithOverlay: () => console.log('todo unlockAppWithOverlay'),

View File

@ -1,3 +1,3 @@
const basename = ADMIN_PATH.replace(window.location.origin, '');
const basename = process.env.ADMIN_PATH.replace(window.location.origin, '');
export default basename;

View File

@ -1,6 +1,6 @@
import baseModel from '../../../../../../admin/src/components/Users/ModalCreateBody/utils/formDataModel';
const ssoInputsModel = ENABLED_EE_FEATURES.includes('sso')
const ssoInputsModel = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso')
? {
useSSORegistration: true,
}

View File

@ -1,6 +1,6 @@
import baseForm from '../../../../../../admin/src/components/Users/ModalCreateBody/utils/roleSettingsForm';
const ssoInputs = ENABLED_EE_FEATURES.includes('sso')
const ssoInputs = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso')
? {
useSSORegistration: {
label: 'Settings.permissions.users.form.sso',

View File

@ -17,7 +17,7 @@ import {
import { useAuthProviders } from '../../../../hooks';
const Login = loginProps => {
const ssoEnabled = ENABLED_EE_FEATURES.includes('sso');
const ssoEnabled = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso');
const theme = useTheme();
const { isLoading, data: providers } = useAuthProviders({ ssoEnabled });

View File

@ -17,7 +17,7 @@ const ProviderWrapper = styled.div`
`;
const Providers = () => {
const ssoEnabled = ENABLED_EE_FEATURES.includes('sso');
const ssoEnabled = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso');
const { push } = useHistory();
const { formatMessage } = useIntl();

View File

@ -1,6 +1,6 @@
import SingleSignOn from '../SingleSignOn';
const ssoRoutes = ENABLED_EE_FEATURES.includes('sso')
const ssoRoutes = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso')
? [
{
Component: SingleSignOn,

View File

@ -1,6 +1,6 @@
import adminPermissions from '../../../../../admin/src/permissions';
const ssoGlobalRoutes = ENABLED_EE_FEATURES.includes('sso')
const ssoGlobalRoutes = process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES.includes('sso')
? [
{
title: { id: 'Settings.sso.title' },

View File

@ -23,21 +23,21 @@ const getClientEnvironment = (useEE, options) => {
},
{
ADMIN_PATH: options.adminPath,
BACKEND_URL: options.backend,
ENABLED_EE_FEATURES: options.features,
PROJECT_TYPE: useEE ? 'Enterprise' : 'Community',
NODE_ENV: process.env.NODE_ENV || 'development',
// REQUIRED STRAPI_ADMIN variables
// TODO
STRAPI_ADMIN_BACKEND_URL: options.backend,
STRAPI_ADMIN_ENABLED_EE_FEATURES: options.features,
STRAPI_ADMIN_PROJECT_TYPE: useEE ? 'Enterprise' : 'Community',
STRAPI_ADMIN_SHOW_TUTORIALS: 'true',
STRAPI_ADMIN_UPDATE_NOTIFICATION: 'true',
}
);
const stringified = Object.keys(raw).reduce((env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {});
const stringified = {
'process.env': Object.keys(raw).reduce((env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {}),
};
return { raw, stringified };
};

View File

@ -18,7 +18,7 @@ module.exports = () => {
const options = {
backend: 'http://localhost:1337',
adminPath: '/admin/',
features: process.env.ENABLED_EE_FEATURES || ['sso'],
features: process.env.STRAPI_ADMIN_ENABLED_EE_FEATURES || ['sso'],
};
const useEE = process.env.STRAPI_DISABLE_EE === 'true' ? false : true;