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,
|
2024-10-12 18:46:42 +02:00
|
|
|
Field,
|
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
|
|
|
|
2024-10-12 18:46:42 +02:00
|
|
|
const ConfirmModal = ({ onClose, onSubmit, type, trigger }) => {
|
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-20 16:51:34 +01:00
|
|
|
return (
|
2024-10-12 18:46:42 +02:00
|
|
|
<Dialog.Root>
|
|
|
|
<Dialog.Trigger>
|
|
|
|
{trigger}
|
|
|
|
</Dialog.Trigger>
|
|
|
|
<Dialog.Content>
|
|
|
|
<Dialog.Header>{formatMessage({ id: "config-sync.popUpWarning.Confirmation" })}</Dialog.Header>
|
|
|
|
<Dialog.Body>
|
|
|
|
<WarningCircle fill="danger600" width="32px" height="32px" />
|
|
|
|
<Flex size={2}>
|
|
|
|
<Flex justifyContent="center">
|
|
|
|
<Typography variant="omega" id="confirm-description" style={{ textAlign: 'center' }}>
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}<br />
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })}
|
|
|
|
</Typography>
|
|
|
|
</Flex>
|
2021-10-27 13:28:06 +02:00
|
|
|
</Flex>
|
2024-10-12 18:46:42 +02:00
|
|
|
{(soft && type === 'import') && (
|
|
|
|
<Box width="100%">
|
|
|
|
<Divider marginTop={4} />
|
|
|
|
<Box paddingTop={6}>
|
|
|
|
<Field.Root hint="Check this to ignore the soft setting.">
|
|
|
|
<Checkbox
|
|
|
|
onValueChange={(value) => setForce(value)}
|
|
|
|
value={force}
|
|
|
|
name="force"
|
|
|
|
>
|
|
|
|
{formatMessage({ id: 'config-sync.popUpWarning.force' })}
|
|
|
|
</Checkbox>
|
|
|
|
<Field.Hint />
|
|
|
|
</Field.Root>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
</Dialog.Body>
|
|
|
|
<Dialog.Footer>
|
|
|
|
<Dialog.Cancel>
|
|
|
|
<Button fullWidth variant="tertiary">
|
|
|
|
{formatMessage({ id: 'config-sync.popUpWarning.button.cancel' })}
|
|
|
|
</Button>
|
|
|
|
</Dialog.Cancel>
|
|
|
|
<Dialog.Action>
|
|
|
|
<Button
|
|
|
|
fullWidth
|
|
|
|
variant="secondary"
|
|
|
|
onClick={() => {
|
|
|
|
onSubmit(force);
|
|
|
|
}}
|
2022-11-28 17:00:35 +01:00
|
|
|
>
|
2024-10-12 18:46:42 +02:00
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.button.${type}` })}
|
|
|
|
</Button>
|
|
|
|
</Dialog.Action>
|
|
|
|
</Dialog.Footer>
|
|
|
|
</Dialog.Content>
|
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;
|