mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Create ClearNodesButton.tsx
This commit is contained in:
parent
10bb05b753
commit
c7dcf1f4a0
@ -0,0 +1,41 @@
|
|||||||
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
|
import { clearNodes } from 'features/nodes/store/nodesSlice';
|
||||||
|
import { makeToast } from 'app/components/Toaster';
|
||||||
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
|
import { memo } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { FaTrash } from 'react-icons/fa';
|
||||||
|
import IAIIconButton from 'common/components/IAIIconButton';
|
||||||
|
|
||||||
|
const ClearNodesButton = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const handleClearNodes = () => {
|
||||||
|
const confirmed = window.confirm(t('common.clearNodes'));
|
||||||
|
|
||||||
|
if (confirmed) {
|
||||||
|
dispatch(clearNodes());
|
||||||
|
|
||||||
|
dispatch(
|
||||||
|
addToast(
|
||||||
|
makeToast({
|
||||||
|
title: t('toast.nodesCleared'),
|
||||||
|
status: 'success',
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IAIIconButton
|
||||||
|
icon={<FaTrash />}
|
||||||
|
tooltip={t('nodes.clearNodes')}
|
||||||
|
aria-label={t('nodes.clearNodes')}
|
||||||
|
onClick={handleClearNodes}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(ClearNodesButton);
|
Loading…
Reference in New Issue
Block a user