Skip to content

Commit 82f645c

Browse files
feat(ui): add new workflow button to library menu
1 parent cc36cfb commit 82f645c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

invokeai/frontend/web/src/features/nodes/components/sidePanel/WorkflowListMenu/WorkflowListMenuTrigger.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useAppSelector } from 'app/store/storeHooks';
1515
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent';
1616
import { useWorkflowListMenu } from 'features/nodes/store/workflowListMenu';
1717
import { selectWorkflowName } from 'features/nodes/store/workflowSlice';
18+
import { NewWorkflowButton } from 'features/workflowLibrary/components/NewWorkflowButton';
1819
import UploadWorkflowButton from 'features/workflowLibrary/components/UploadWorkflowButton';
1920
import { useRef } from 'react';
2021
import { useTranslation } from 'react-i18next';
@@ -63,6 +64,7 @@ export const WorkflowListMenuTrigger = () => {
6364
<WorkflowSearch searchInputRef={searchInputRef} />
6465
<WorkflowSortControl />
6566
<UploadWorkflowButton />
67+
<NewWorkflowButton />
6668
</Flex>
6769
<Box position="relative" w="full" h="full">
6870
<ScrollableContent>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { IconButton } from '@invoke-ai/ui-library';
2+
import { useNewWorkflow } from 'features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog';
3+
import type { MouseEvent } from 'react';
4+
import { memo, useCallback } from 'react';
5+
import { useTranslation } from 'react-i18next';
6+
import { PiFilePlusBold } from 'react-icons/pi';
7+
8+
export const NewWorkflowButton = memo(() => {
9+
const newWorkflow = useNewWorkflow();
10+
11+
const { t } = useTranslation();
12+
13+
const onClickNewWorkflow = useCallback(
14+
(e: MouseEvent<HTMLButtonElement>) => {
15+
// We need to stop the event from propagating to the parent element, else the click will open the list menu
16+
e.stopPropagation();
17+
newWorkflow.createWithDialog();
18+
},
19+
[newWorkflow]
20+
);
21+
22+
return (
23+
<IconButton
24+
onClick={onClickNewWorkflow}
25+
variant="ghost"
26+
aria-label={t('nodes.newWorkflow')}
27+
tooltip={t('nodes.newWorkflow')}
28+
icon={<PiFilePlusBold />}
29+
/>
30+
);
31+
});
32+
33+
NewWorkflowButton.displayName = 'NewWorkflowButton';

0 commit comments

Comments
 (0)