From 3dc13221d87498572c17d5388149ac8110b15a49 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Tue, 23 Jan 2024 09:49:50 -0500 Subject: [PATCH] add project as a workflow category in the front-end --- invokeai/frontend/web/public/locales/en.json | 2 + .../web/src/features/nodes/types/workflow.ts | 2 +- .../components/WorkflowLibraryList.tsx | 42 +- .../components/WorkflowLibraryListItem.tsx | 6 +- .../frontend/web/src/services/api/schema.ts | 748 ++++++++++++++---- 5 files changed, 630 insertions(+), 170 deletions(-) diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index 4aa31ede8a..54c259efbf 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -1697,6 +1697,7 @@ "workflowLibrary": "Library", "userWorkflows": "My Workflows", "defaultWorkflows": "Default Workflows", + "projectWorkflows": "Project Workflows", "openWorkflow": "Open Workflow", "uploadWorkflow": "Load from File", "deleteWorkflow": "Delete Workflow", @@ -1709,6 +1710,7 @@ "workflowSaved": "Workflow Saved", "noRecentWorkflows": "No Recent Workflows", "noUserWorkflows": "No User Workflows", + "noWorkflows": "No Workflows", "noSystemWorkflows": "No System Workflows", "problemLoading": "Problem Loading Workflows", "loading": "Loading Workflows", diff --git a/invokeai/frontend/web/src/features/nodes/types/workflow.ts b/invokeai/frontend/web/src/features/nodes/types/workflow.ts index f7ada635e5..8919e597dc 100644 --- a/invokeai/frontend/web/src/features/nodes/types/workflow.ts +++ b/invokeai/frontend/web/src/features/nodes/types/workflow.ts @@ -15,7 +15,7 @@ export type XYPosition = z.infer; export const zDimension = z.number().gt(0).nullish(); export type Dimension = z.infer; -export const zWorkflowCategory = z.enum(['user', 'default']); +export const zWorkflowCategory = z.enum(['user', 'default', 'project']); export type WorkflowCategory = z.infer; // #endregion diff --git a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryList.tsx b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryList.tsx index 9d5087d059..3ff519f672 100644 --- a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryList.tsx +++ b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryList.tsx @@ -13,6 +13,8 @@ import { InputRightElement, Spacer, } from '@invoke-ai/ui'; +import { useStore } from '@nanostores/react'; +import { $projectId } from 'app/store/nanostores/projectId'; import { IAINoContentFallback, IAINoContentFallbackWithSpinner, @@ -62,6 +64,7 @@ const WorkflowLibraryList = () => { const [order_by, setOrderBy] = useState('opened_at'); const [direction, setDirection] = useState('ASC'); const [debouncedQuery] = useDebounce(query, 500); + const projectId = useStore($projectId); const queryArg = useMemo[0]>(() => { if (category === 'user') { @@ -142,13 +145,8 @@ const WorkflowLibraryList = () => { [] ); - const handleSetUserCategory = useCallback(() => { - setCategory('user'); - setPage(0); - }, []); - - const handleSetDefaultCategory = useCallback(() => { - setCategory('default'); + const handleSetCategory = useCallback((category: WorkflowCategory) => { + setCategory(category); setPage(0); }, []); @@ -158,21 +156,31 @@ const WorkflowLibraryList = () => { - + {projectId ? ( + + ) : ( + + )} - {category === 'user' && ( + {category !== 'default' && ( <> {t('common.orderBy')} @@ -228,7 +236,7 @@ const WorkflowLibraryList = () => { ) : ( - + )} {data && ( diff --git a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryListItem.tsx b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryListItem.tsx index 59fd8983de..da122c39e0 100644 --- a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryListItem.tsx +++ b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryListItem.tsx @@ -52,7 +52,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => { {workflowDTO.name || t('workflows.unnamedWorkflow')} - {workflowDTO.category === 'user' && ( + {workflowDTO.category !== 'default' && ( { )} - {workflowDTO.category === 'user' && ( + {workflowDTO.category !== 'default' && ( { > {t('common.load')} - {workflowDTO.category === 'user' && ( + {workflowDTO.category !== 'default' && (