2021-03-21 17:55:14 +01:00
|
|
|
import React, { useEffect } from 'react';
|
2021-03-20 03:20:48 +01:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
import { Map } from 'immutable';
|
2021-11-13 14:15:31 +01:00
|
|
|
import { Box } from '@strapi/design-system/Box';
|
2022-03-16 21:29:54 +01:00
|
|
|
import { ContentLayout } from '@strapi/design-system/Layout';
|
2021-11-20 19:51:03 +01:00
|
|
|
import { useNotification } from '@strapi/helper-plugin';
|
2021-12-01 17:08:36 +01:00
|
|
|
import { Alert } from '@strapi/design-system/Alert';
|
|
|
|
import { Typography } from '@strapi/design-system/Typography';
|
2021-03-20 03:20:48 +01:00
|
|
|
|
2021-12-08 16:05:45 +01:00
|
|
|
import { getAllConfigDiff, getAppEnv } from '../../state/actions/Config';
|
2021-03-20 14:42:15 +01:00
|
|
|
import ConfigList from '../../components/ConfigList';
|
2021-03-20 15:07:10 +01:00
|
|
|
import ActionButtons from '../../components/ActionButtons';
|
2021-03-20 00:54:18 +01:00
|
|
|
|
|
|
|
const ConfigPage = () => {
|
2021-11-20 19:51:03 +01:00
|
|
|
const toggleNotification = useNotification();
|
2021-03-20 03:20:48 +01:00
|
|
|
const dispatch = useDispatch();
|
2021-04-09 23:14:29 +02:00
|
|
|
const isLoading = useSelector((state) => state.getIn(['config', 'isLoading'], Map({})));
|
|
|
|
const configDiff = useSelector((state) => state.getIn(['config', 'configDiff'], Map({})));
|
2021-12-08 16:05:45 +01:00
|
|
|
const appEnv = useSelector((state) => state.getIn(['config', 'appEnv']));
|
2021-03-20 03:20:48 +01:00
|
|
|
|
|
|
|
useEffect(() => {
|
2021-11-20 19:51:03 +01:00
|
|
|
dispatch(getAllConfigDiff(toggleNotification));
|
2021-12-08 16:05:45 +01:00
|
|
|
dispatch(getAppEnv(toggleNotification));
|
2021-03-20 03:20:48 +01:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
2022-03-16 21:29:54 +01:00
|
|
|
<ContentLayout paddingBottom={8}>
|
2021-12-08 16:05:45 +01:00
|
|
|
{appEnv === 'production' && (
|
2021-12-01 17:08:36 +01:00
|
|
|
<Box paddingBottom={4}>
|
|
|
|
<Alert variant="danger">
|
|
|
|
<Typography variant="omega" fontWeight="bold">You're in the production environment</Typography><br />
|
|
|
|
Please be careful when syncing your config in production.<br />
|
|
|
|
Make sure you are not overriding critical config changes on import.
|
|
|
|
</Alert>
|
|
|
|
</Box>
|
|
|
|
)}
|
2021-11-20 19:06:01 +01:00
|
|
|
<ActionButtons />
|
2021-03-24 18:41:03 +01:00
|
|
|
<ConfigList isLoading={isLoading} diff={configDiff.toJS()} />
|
2022-03-16 21:29:54 +01:00
|
|
|
</ContentLayout>
|
2021-03-20 03:20:48 +01:00
|
|
|
);
|
2021-10-14 17:13:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ConfigPage;
|