mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Change Confirmation Dialog
Changed Confirmation Dialog to use chakra-ui alert dialog
This commit is contained in:
parent
8a25e22fb0
commit
d1ac50b061
@ -1,3 +1,15 @@
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogBody,
|
||||
AlertDialogContent,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogOverlay,
|
||||
Divider,
|
||||
Text,
|
||||
Button,
|
||||
} from '@chakra-ui/react';
|
||||
import { useAppDispatch } from 'app/store/storeHooks';
|
||||
import { clearNodes } from 'features/nodes/store/nodesSlice';
|
||||
import { makeToast } from 'app/components/Toaster';
|
||||
@ -10,31 +22,68 @@ import IAIIconButton from 'common/components/IAIIconButton';
|
||||
const ClearNodesButton = () => {
|
||||
const { t } = useTranslation();
|
||||
const dispatch = useAppDispatch();
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
|
||||
const handleClearNodes = () => {
|
||||
const confirmed = window.confirm(t('common.clearNodes'));
|
||||
setIsDialogOpen(true);
|
||||
};
|
||||
|
||||
if (confirmed) {
|
||||
dispatch(clearNodes());
|
||||
const handleConfirmClear = () => {
|
||||
dispatch(clearNodes());
|
||||
|
||||
dispatch(
|
||||
addToast(
|
||||
makeToast({
|
||||
title: t('toast.nodesCleared'),
|
||||
status: 'success',
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
dispatch(
|
||||
addToast(
|
||||
makeToast({
|
||||
title: t('toast.nodesCleared'),
|
||||
status: 'success',
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
setIsDialogOpen(false);
|
||||
};
|
||||
|
||||
const handleCancelClear = () => {
|
||||
setIsDialogOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<IAIIconButton
|
||||
icon={<FaTrash />}
|
||||
tooltip={t('nodes.clearNodes')}
|
||||
aria-label={t('nodes.clearNodes')}
|
||||
onClick={handleClearNodes}
|
||||
/>
|
||||
<>
|
||||
<IAIIconButton
|
||||
icon={<FaTrash />}
|
||||
tooltip={t('nodes.clearNodes')}
|
||||
aria-label={t('nodes.clearNodes')}
|
||||
onClick={handleClearNodes}
|
||||
/>
|
||||
|
||||
<AlertDialog
|
||||
isOpen={isDialogOpen}
|
||||
leastDestructiveRef={undefined}
|
||||
onClose={handleCancelClear}
|
||||
isCentered
|
||||
>
|
||||
<AlertDialogOverlay />
|
||||
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader fontSize="lg" fontWeight="bold">
|
||||
{t('nodes.clearNodes')}
|
||||
</AlertDialogHeader>
|
||||
|
||||
<AlertDialogBody>
|
||||
<Text>{t('common.clearNodes')}</Text>
|
||||
</AlertDialogBody>
|
||||
|
||||
<Divider />
|
||||
|
||||
<AlertDialogFooter>
|
||||
<Button onClick={handleCancelClear}>{t('common.cancel')}</Button>
|
||||
<Button colorScheme="red" ml={3} onClick={handleConfirmClear}>
|
||||
{t('common.accept')}
|
||||
</Button>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user