strapi-plugin-config-sync/admin/src/components/ConfigDiff/index.jsx

49 lines
1.4 KiB
React
Raw Normal View History

import React from 'react';
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued';
2023-10-11 20:46:51 +02:00
import { useIntl } from 'react-intl';
2021-10-14 17:13:12 +02:00
import {
ModalLayout,
ModalBody,
ModalHeader,
Grid,
GridItem,
Typography,
} from '@strapi/design-system';
2021-10-14 17:39:53 +02:00
const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => {
2023-10-11 20:46:51 +02:00
const { formatMessage } = useIntl();
2023-10-15 03:53:57 +02:00
if (!isOpen) return null;
2021-10-14 17:13:12 +02:00
return (
2021-10-14 17:13:12 +02:00
<ModalLayout
onClose={onClose}
labelledBy="title"
>
2021-10-14 17:13:12 +02:00
<ModalHeader>
2022-03-16 21:29:54 +01:00
<Typography variant="omega" fontWeight="bold" textColor="neutral800">
2023-10-11 20:46:51 +02:00
{formatMessage({ id: 'config-sync.ConfigDiff.Title' })} {configName}
2022-03-16 21:29:54 +01:00
</Typography>
2021-10-14 17:13:12 +02:00
</ModalHeader>
<ModalBody>
2021-11-19 20:39:32 +01:00
<Grid paddingBottom={4} style={{ textAlign: 'center' }}>
<GridItem col={6}>
2023-10-11 20:46:51 +02:00
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}</Typography>
2021-11-19 20:39:32 +01:00
</GridItem>
<GridItem col={6}>
2023-10-11 20:46:51 +02:00
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
2021-11-19 20:39:32 +01:00
</GridItem>
</Grid>
<ReactDiffViewer
oldValue={JSON.stringify(oldValue, null, 2)}
newValue={JSON.stringify(newValue, null, 2)}
splitView
compareMethod={DiffMethod.WORDS}
/>
</ModalBody>
2021-10-14 17:13:12 +02:00
</ModalLayout>
);
2021-10-14 17:39:53 +02:00
};
2021-10-14 17:13:12 +02:00
export default ConfigDiff;