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

46 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 {
Modal,
Grid,
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 (
<Modal.Root
2021-10-14 17:13:12 +02:00
onClose={onClose}
labelledBy="title"
>
<Modal.Header>
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>
</Modal.Header>
<Modal.Body>
<Grid.Root paddingBottom={4} style={{ textAlign: 'center' }}>
<Grid.Item col={6}>
2023-10-11 20:46:51 +02:00
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}</Typography>
</Grid.Item>
<Grid.Item col={6}>
2023-10-11 20:46:51 +02:00
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
</Grid.Item>
</Grid.Root>
2021-11-19 20:39:32 +01:00
<ReactDiffViewer
oldValue={JSON.stringify(oldValue, null, 2)}
newValue={JSON.stringify(newValue, null, 2)}
splitView
compareMethod={DiffMethod.WORDS}
/>
</Modal.Body>
</Modal.Root>
);
2021-10-14 17:39:53 +02:00
};
2021-10-14 17:13:12 +02:00
export default ConfigDiff;