Skip to content

Commit ed9cd6a

Browse files
feat(ui): simpler workflow action buttons
1 parent c44c28e commit ed9cd6a

File tree

6 files changed

+42
-97
lines changed

6 files changed

+42
-97
lines changed

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowLibraryListItemActions/DeleteWorkflow.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,19 @@ import { useCallback } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { PiTrashBold } from 'react-icons/pi';
77

8-
export const DeleteWorkflow = ({
9-
isHovered,
10-
setIsHovered,
11-
workflowId,
12-
}: {
13-
isHovered: boolean;
14-
setIsHovered: (isHovered: boolean) => void;
15-
workflowId: string;
16-
}) => {
8+
export const DeleteWorkflow = ({ workflowId }: { workflowId: string }) => {
179
const { t } = useTranslation();
1810
const deleteWorkflow = useDeleteWorkflow();
1911

2012
const handleClickDelete = useCallback(
2113
(e: MouseEvent<HTMLButtonElement>) => {
2214
e.stopPropagation();
23-
setIsHovered(false);
2415
deleteWorkflow(workflowId);
2516
},
26-
[deleteWorkflow, workflowId, setIsHovered]
17+
[deleteWorkflow, workflowId]
2718
);
2819
return (
29-
<Tooltip
30-
label={t('workflows.delete')}
31-
// This prevents an issue where the tooltip isn't closed after the modal is opened
32-
isOpen={!isHovered ? false : undefined}
33-
closeOnScroll
34-
>
20+
<Tooltip label={t('workflows.delete')} closeOnScroll>
3521
<IconButton
3622
size="sm"
3723
variant="ghost"

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowLibraryListItemActions/DownloadWorkflow.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,20 @@ import { useCallback } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { PiDownloadSimpleBold } from 'react-icons/pi';
77

8-
// needs to be updated to work for a workflow other than the one loaded in editor
9-
export const DownloadWorkflow = ({
10-
isHovered,
11-
setIsHovered,
12-
workflowId,
13-
}: {
14-
isHovered: boolean;
15-
setIsHovered: (isHovered: boolean) => void;
16-
workflowId: string;
17-
}) => {
8+
export const DownloadWorkflow = ({ workflowId }: { workflowId: string }) => {
189
const downloadWorkflowById = useDownloadWorkflowById();
10+
1911
const handleClickDownload = useCallback(
2012
(e: MouseEvent<HTMLButtonElement>) => {
2113
e.stopPropagation();
22-
setIsHovered(false);
2314
downloadWorkflowById.downloadWorkflow(workflowId);
2415
},
25-
[downloadWorkflowById, setIsHovered, workflowId]
16+
[downloadWorkflowById, workflowId]
2617
);
2718

2819
const { t } = useTranslation();
2920
return (
30-
<Tooltip
31-
label={t('workflows.download')}
32-
// This prevents an issue where the tooltip isn't closed after the modal is opened
33-
isOpen={!isHovered ? false : undefined}
34-
closeOnScroll
35-
>
21+
<Tooltip label={t('workflows.download')} closeOnScroll>
3622
<IconButton
3723
size="sm"
3824
variant="ghost"

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowLibraryListItemActions/EditWorkflow.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
import { IconButton, Tooltip } from '@invoke-ai/ui-library';
22
import { useLoadWorkflow } from 'features/workflowLibrary/components/LoadWorkflowConfirmationAlertDialog';
3+
import type { MouseEvent} from 'react';
34
import { useCallback } from 'react';
45
import { useTranslation } from 'react-i18next';
56
import { PiPencilBold } from 'react-icons/pi';
67

7-
export const EditWorkflow = ({
8-
isHovered,
9-
setIsHovered,
10-
workflowId,
11-
}: {
12-
isHovered: boolean;
13-
setIsHovered: (isHovered: boolean) => void;
14-
workflowId: string;
15-
}) => {
8+
export const EditWorkflow = ({ workflowId }: { workflowId: string }) => {
169
const loadWorkflow = useLoadWorkflow();
1710
const { t } = useTranslation();
1811

19-
const handleClickEdit = useCallback(() => {
20-
setIsHovered(false);
21-
loadWorkflow.loadWithDialog(workflowId, 'edit');
22-
}, [loadWorkflow, workflowId, setIsHovered]);
12+
const handleClickEdit = useCallback(
13+
(e: MouseEvent<HTMLButtonElement>) => {
14+
e.stopPropagation();
15+
loadWorkflow.loadWithDialog(workflowId, 'edit');
16+
},
17+
[loadWorkflow, workflowId]
18+
);
2319

2420
return (
25-
<Tooltip
26-
label={t('workflows.edit')}
27-
// This prevents an issue where the tooltip isn't closed after the modal is opened
28-
isOpen={!isHovered ? false : undefined}
29-
closeOnScroll
30-
>
21+
<Tooltip label={t('workflows.edit')} closeOnScroll>
3122
<IconButton
3223
size="sm"
3324
variant="ghost"

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowLibraryListItemActions/SaveWorkflow.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
import { IconButton, Tooltip } from '@invoke-ai/ui-library';
22
import { useLoadWorkflow } from 'features/workflowLibrary/components/LoadWorkflowConfirmationAlertDialog';
3+
import type { MouseEvent } from 'react';
34
import { useCallback } from 'react';
45
import { useTranslation } from 'react-i18next';
56
import { PiFloppyDiskBold } from 'react-icons/pi';
67

78
// needs to clone and save workflow to account without taking over editor
8-
export const SaveWorkflow = ({
9-
isHovered,
10-
setIsHovered,
11-
workflowId,
12-
}: {
13-
isHovered: boolean;
14-
setIsHovered: (isHovered: boolean) => void;
15-
workflowId: string;
16-
}) => {
9+
export const SaveWorkflow = ({ workflowId }: { workflowId: string }) => {
1710
const loadWorkflow = useLoadWorkflow();
1811
const { t } = useTranslation();
1912

20-
const handleClickSave = useCallback(() => {
21-
setIsHovered(false);
22-
loadWorkflow.loadWithDialog(workflowId, 'view');
23-
}, [loadWorkflow, workflowId, setIsHovered]);
13+
const handleClickSave = useCallback(
14+
(e: MouseEvent<HTMLButtonElement>) => {
15+
e.stopPropagation();
16+
loadWorkflow.loadWithDialog(workflowId, 'view');
17+
},
18+
[loadWorkflow, workflowId]
19+
);
2420

2521
return (
26-
<Tooltip
27-
label={t('workflows.edit')}
28-
// This prevents an issue where the tooltip isn't closed after the modal is opened
29-
isOpen={!isHovered ? false : undefined}
30-
closeOnScroll
31-
>
22+
<Tooltip label={t('workflows.edit')} closeOnScroll>
3223
<IconButton
3324
size="sm"
3425
variant="ghost"

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowLibraryListItemActions/ViewWorkflow.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
import { IconButton, Tooltip } from '@invoke-ai/ui-library';
22
import { useLoadWorkflow } from 'features/workflowLibrary/components/LoadWorkflowConfirmationAlertDialog';
3+
import type { MouseEvent } from 'react';
34
import { useCallback } from 'react';
45
import { useTranslation } from 'react-i18next';
56
import { PiEyeBold } from 'react-icons/pi';
67

7-
export const ViewWorkflow = ({
8-
isHovered,
9-
setIsHovered,
10-
workflowId,
11-
}: {
12-
isHovered: boolean;
13-
setIsHovered: (isHovered: boolean) => void;
14-
workflowId: string;
15-
}) => {
8+
export const ViewWorkflow = ({ workflowId }: { workflowId: string }) => {
169
const loadWorkflow = useLoadWorkflow();
1710
const { t } = useTranslation();
1811

19-
const handleClickLoad = useCallback(() => {
20-
setIsHovered(false);
21-
loadWorkflow.loadWithDialog(workflowId, 'view');
22-
}, [loadWorkflow, workflowId, setIsHovered]);
12+
const handleClickLoad = useCallback(
13+
(e: MouseEvent<HTMLButtonElement>) => {
14+
e.stopPropagation();
15+
loadWorkflow.loadWithDialog(workflowId, 'view');
16+
},
17+
[loadWorkflow, workflowId]
18+
);
2319

2420
return (
25-
<Tooltip
26-
label={t('workflows.edit')}
27-
// This prevents an issue where the tooltip isn't closed after the modal is opened
28-
isOpen={!isHovered ? false : undefined}
29-
closeOnScroll
30-
>
21+
<Tooltip label={t('workflows.edit')} closeOnScroll>
3122
<IconButton
3223
size="sm"
3324
variant="ghost"

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowLibrary/WorkflowListItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ export const WorkflowListItem = ({ workflow }: { workflow: WorkflowRecordListIte
107107
{workflow.category === 'default' && (
108108
<>
109109
{/* need to consider what is useful here and which icons show that. idea is to "try it out"/"view" or "clone for your own changes" */}
110-
<ViewWorkflow isHovered={isHovered} setIsHovered={setIsHovered} workflowId={workflow.workflow_id} />
111-
<SaveWorkflow isHovered={isHovered} setIsHovered={setIsHovered} workflowId={workflow.workflow_id} />
110+
<ViewWorkflow workflowId={workflow.workflow_id} />
111+
<SaveWorkflow workflowId={workflow.workflow_id} />
112112
</>
113113
)}
114114
{workflow.category !== 'default' && (
115115
<>
116-
<EditWorkflow isHovered={isHovered} setIsHovered={setIsHovered} workflowId={workflow.workflow_id} />
117-
<DownloadWorkflow isHovered={isHovered} setIsHovered={setIsHovered} workflowId={workflow.workflow_id} />
118-
<DeleteWorkflow isHovered={isHovered} setIsHovered={setIsHovered} workflowId={workflow.workflow_id} />
116+
<EditWorkflow workflowId={workflow.workflow_id} />
117+
<DownloadWorkflow workflowId={workflow.workflow_id} />
118+
<DeleteWorkflow workflowId={workflow.workflow_id} />
119119
</>
120120
)}
121121
</Flex>

0 commit comments

Comments
 (0)