2021-03-20 14:42:15 +01:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer';
|
2021-10-14 17:13:12 +02:00
|
|
|
|
2021-10-14 17:39:53 +02:00
|
|
|
import { ModalLayout, ModalBody, ModalHeader } from '@strapi/parts/ModalLayout';
|
2021-10-14 17:13:12 +02:00
|
|
|
import { ButtonText } from '@strapi/parts/Text';
|
2021-03-20 14:42:15 +01:00
|
|
|
|
2021-10-14 17:39:53 +02:00
|
|
|
const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => {
|
2021-10-14 17:13:12 +02:00
|
|
|
if (!isOpen) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-20 14:42:15 +01:00
|
|
|
return (
|
2021-10-14 17:13:12 +02:00
|
|
|
<ModalLayout
|
|
|
|
onClose={onClose}
|
|
|
|
labelledBy="title"
|
2021-03-20 14:42:15 +01:00
|
|
|
>
|
2021-10-14 17:13:12 +02:00
|
|
|
<ModalHeader>
|
|
|
|
<ButtonText textColor="neutral800" as="h2" id="title">
|
|
|
|
Config changes for {configName}
|
|
|
|
</ButtonText>
|
|
|
|
</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<section style={{ marginTop: 20 }}>
|
|
|
|
<ReactDiffViewer
|
|
|
|
oldValue={JSON.stringify(oldValue, null, 2)}
|
|
|
|
newValue={JSON.stringify(newValue, null, 2)}
|
|
|
|
splitView
|
|
|
|
compareMethod={DiffMethod.WORDS}
|
|
|
|
/>
|
2021-03-20 14:42:15 +01:00
|
|
|
</section>
|
|
|
|
</ModalBody>
|
2021-10-14 17:13:12 +02:00
|
|
|
</ModalLayout>
|
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;
|