2021-03-20 14:42:15 +01:00
|
|
|
import React from 'react';
|
2022-11-27 15:11:28 +01:00
|
|
|
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
|
|
|
|
2022-11-27 14:35:11 +01:00
|
|
|
import {
|
2024-07-10 10:23:57 +02:00
|
|
|
Modal,
|
2022-11-27 14:35:11 +01:00
|
|
|
Grid,
|
|
|
|
Typography,
|
|
|
|
} from '@strapi/design-system';
|
2021-03-20 14:42:15 +01:00
|
|
|
|
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
|
|
|
|
2021-03-20 14:42:15 +01:00
|
|
|
return (
|
2024-07-10 10:23:57 +02:00
|
|
|
<Modal.Root
|
2021-10-14 17:13:12 +02:00
|
|
|
onClose={onClose}
|
|
|
|
labelledBy="title"
|
2021-03-20 14:42:15 +01:00
|
|
|
>
|
2024-07-10 10:23:57 +02:00
|
|
|
<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>
|
2024-07-10 10:23:57 +02:00
|
|
|
</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>
|
2024-07-10 10:23:57 +02:00
|
|
|
</Grid.Item>
|
|
|
|
<Grid.Item col={6}>
|
2023-10-11 20:46:51 +02:00
|
|
|
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
|
2024-07-10 10:23:57 +02:00
|
|
|
</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}
|
|
|
|
/>
|
2024-07-10 10:23:57 +02:00
|
|
|
</Modal.Body>
|
|
|
|
</Modal.Root>
|
2021-03-20 14:42:15 +01:00
|
|
|
);
|
2021-10-14 17:39:53 +02:00
|
|
|
};
|
2021-10-14 17:13:12 +02:00
|
|
|
|
|
|
|
export default ConfigDiff;
|