Skip to content

Commit 62bc532

Browse files
fix(ui): hide workflow thumbnail for unsaved and default workflows
1 parent 445cec5 commit 62bc532

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ const WorkflowGeneralTab = () => {
9696
<FormLabel>{t('nodes.workflowName')}</FormLabel>
9797
<Input variant="darkFilled" value={name} onChange={handleChangeName} />
9898
</FormControl>
99-
{/* we should not show this field if default workflow or not saved to DB yet */}
100-
{/* {data?.meta.category !== 'default' || !data.workflow_id && ( */}
101-
<FormControl>
102-
<FormLabel>{t('workflows.workflowThumbnail')}</FormLabel>
103-
<WorkflowThumbnailEditor thumbnailUrl={data?.thumbnail_url || null} workflowId={id} />
104-
</FormControl>
105-
{/* )} */}
99+
{/*
100+
* Only saved and non-default workflows can have a thumbnail.
101+
* - Unsaved workflows have no id.
102+
* - Default workflows have a category of 'default'.
103+
*/}
104+
{id && data && data.workflow.meta.category !== 'default' && (
105+
<FormControl>
106+
<FormLabel>{t('workflows.workflowThumbnail')}</FormLabel>
107+
<WorkflowThumbnailEditor thumbnailUrl={data.thumbnail_url} workflowId={id} />
108+
</FormControl>
109+
)}
106110
<FormControl>
107111
<FormLabel>{t('nodes.workflowVersion')}</FormLabel>
108112
<Input variant="darkFilled" value={version} onChange={handleChangeVersion} />

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowThumbnail/WorkflowThumbnailEditor.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const WorkflowThumbnailEditor = ({
1111
workflowId,
1212
thumbnailUrl,
1313
}: {
14-
workflowId?: string;
15-
thumbnailUrl: string | null;
14+
workflowId: string;
15+
thumbnailUrl?: string | null;
1616
}) => {
1717
const { t } = useTranslation();
1818

@@ -28,10 +28,6 @@ export const WorkflowThumbnailEditor = ({
2828
}, []);
2929

3030
const handleSaveChanges = useCallback(async () => {
31-
if (!workflowId) {
32-
return;
33-
}
34-
3531
try {
3632
if (localThumbnailUrl) {
3733
const blob = await convertImageUrlToBlob(localThumbnailUrl);

invokeai/frontend/web/src/features/nodes/components/sidePanel/workflow/WorkflowThumbnail/WorkflowThumbnailField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export const WorkflowThumbnailField = ({
99
imageUrl,
1010
onChange,
1111
}: {
12-
imageUrl: string | null;
12+
imageUrl?: string | null;
1313
onChange: (localThumbnailUrl: string | null) => void;
1414
}) => {
1515
const [thumbnail, setThumbnail] = useState<File | null>(null);
1616

17-
const syncThumbnail = useCallback(async (imageUrl: string | null) => {
17+
const syncThumbnail = useCallback(async (imageUrl?: string | null) => {
1818
if (!imageUrl) {
1919
setThumbnail(null);
2020
return;

0 commit comments

Comments
 (0)