feat(ui): add new workflow button to library menu

This commit is contained in:
psychedelicious
2025-02-28 14:46:03 +10:00
parent cc36cfb617
commit 82f645c7a1
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { IconButton } from '@invoke-ai/ui-library';
import { useNewWorkflow } from 'features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog';
import type { MouseEvent } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiFilePlusBold } from 'react-icons/pi';
export const NewWorkflowButton = memo(() => {
const newWorkflow = useNewWorkflow();
const { t } = useTranslation();
const onClickNewWorkflow = useCallback(
(e: MouseEvent<HTMLButtonElement>) => {
// We need to stop the event from propagating to the parent element, else the click will open the list menu
e.stopPropagation();
newWorkflow.createWithDialog();
},
[newWorkflow]
);
return (
<IconButton
onClick={onClickNewWorkflow}
variant="ghost"
aria-label={t('nodes.newWorkflow')}
tooltip={t('nodes.newWorkflow')}
icon={<PiFilePlusBold />}
/>
);
});
NewWorkflowButton.displayName = 'NewWorkflowButton';