2022-11-28 17:00:35 +01:00
|
|
|
import React, { useState } from 'react';
|
2021-11-13 14:15:31 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
2022-11-28 17:00:35 +01:00
|
|
|
import { useSelector } from 'react-redux';
|
2021-10-14 17:13:12 +02:00
|
|
|
|
2022-11-27 14:35:11 +01:00
|
|
|
import {
|
|
|
|
Dialog,
|
|
|
|
Flex,
|
|
|
|
Typography,
|
|
|
|
Button,
|
2022-11-28 17:00:35 +01:00
|
|
|
Checkbox,
|
|
|
|
Divider,
|
|
|
|
Box,
|
2022-11-27 14:35:11 +01:00
|
|
|
} from '@strapi/design-system';
|
2024-05-31 08:26:15 +02:00
|
|
|
import { WarningCircle } from '@strapi/icons';
|
2021-03-20 16:51:34 +01:00
|
|
|
|
|
|
|
const ConfirmModal = ({ isOpen, onClose, onSubmit, type }) => {
|
2022-11-28 17:00:35 +01:00
|
|
|
const soft = useSelector((state) => state.getIn(['config', 'appEnv', 'config', 'soft'], false));
|
|
|
|
const [force, setForce] = useState(false);
|
2021-11-13 14:15:31 +01:00
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
|
2021-03-21 17:55:14 +01:00
|
|
|
if (!isOpen) return null;
|
|
|
|
|
2021-03-20 16:51:34 +01:00
|
|
|
return (
|
2024-07-10 10:23:57 +02:00
|
|
|
<Dialog.Root
|
2021-10-14 17:13:12 +02:00
|
|
|
onClose={onClose}
|
2023-10-11 20:46:51 +02:00
|
|
|
title={formatMessage({ id: "config-sync.popUpWarning.Confirmation" })}
|
2021-03-20 16:51:34 +01:00
|
|
|
isOpen={isOpen}
|
2021-10-14 17:13:12 +02:00
|
|
|
>
|
2024-07-10 10:23:57 +02:00
|
|
|
<Dialog.Body icon={<WarningCircle />}>
|
2024-05-31 08:26:15 +02:00
|
|
|
<Flex size={2}>
|
2021-10-27 13:28:06 +02:00
|
|
|
<Flex justifyContent="center">
|
2022-03-16 21:29:54 +01:00
|
|
|
<Typography variant="omega" id="confirm-description" style={{ textAlign: 'center' }}>
|
2021-11-13 14:15:31 +01:00
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}<br />
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })}
|
2022-03-16 21:29:54 +01:00
|
|
|
</Typography>
|
2021-10-27 13:28:06 +02:00
|
|
|
</Flex>
|
2024-05-31 08:26:15 +02:00
|
|
|
</Flex>
|
2024-07-10 10:23:57 +02:00
|
|
|
</Dialog.Body>
|
2022-11-28 17:00:35 +01:00
|
|
|
{(soft && type === 'import') && (
|
|
|
|
<React.Fragment>
|
|
|
|
<Divider />
|
|
|
|
<Box padding={4}>
|
|
|
|
<Checkbox
|
|
|
|
onValueChange={(value) => setForce(value)}
|
|
|
|
value={force}
|
|
|
|
name="force"
|
|
|
|
hint="Check this to ignore the soft setting."
|
|
|
|
>
|
|
|
|
{formatMessage({ id: 'config-sync.popUpWarning.force' })}
|
|
|
|
</Checkbox>
|
|
|
|
</Box>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2024-07-10 10:23:57 +02:00
|
|
|
<Dialog.Footer
|
2021-10-14 17:13:12 +02:00
|
|
|
startAction={(
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
onClose();
|
|
|
|
}}
|
|
|
|
variant="tertiary"
|
|
|
|
>
|
2021-11-13 14:15:31 +01:00
|
|
|
{formatMessage({ id: 'config-sync.popUpWarning.button.cancel' })}
|
2021-10-14 17:13:12 +02:00
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
endAction={(
|
2021-11-13 14:15:31 +01:00
|
|
|
<Button
|
|
|
|
variant="secondary"
|
|
|
|
onClick={() => {
|
|
|
|
onClose();
|
2022-11-28 17:00:35 +01:00
|
|
|
onSubmit(force);
|
2021-11-13 14:15:31 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.button.${type}` })}
|
2021-10-14 17:13:12 +02:00
|
|
|
</Button>
|
|
|
|
)} />
|
2024-07-10 10:23:57 +02:00
|
|
|
</Dialog.Root>
|
2021-03-20 16:51:34 +01:00
|
|
|
);
|
2021-10-14 17:13:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ConfirmModal;
|