strapi-plugin-config-sync/admin/src/containers/ConfigPage/index.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-03-21 17:55:14 +01:00
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Map } from 'immutable';
import {
Box,
ContentLayout,
Alert,
Typography,
} from '@strapi/design-system';
2021-11-20 19:51:03 +01:00
import { useNotification } from '@strapi/helper-plugin';
2021-12-08 16:05:45 +01:00
import { getAllConfigDiff, getAppEnv } from '../../state/actions/Config';
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();
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']));
useEffect(() => {
2021-11-20 19:51:03 +01:00
dispatch(getAllConfigDiff(toggleNotification));
2021-12-08 16:05:45 +01:00
dispatch(getAppEnv(toggleNotification));
}, []);
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&apos;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-10-14 17:13:12 +02:00
};
export default ConfigPage;