-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add new workflow button to library menu
- Loading branch information
1 parent
cc36cfb
commit 82f645c
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
invokeai/frontend/web/src/features/workflowLibrary/components/NewWorkflowButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |