Skip to content

Commit 3dc1322

Browse files
Mary Hipppsychedelicious
authored andcommitted
add project as a workflow category in the front-end
1 parent b4cf549 commit 3dc1322

File tree

5 files changed

+630
-170
lines changed

5 files changed

+630
-170
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@
16971697
"workflowLibrary": "Library",
16981698
"userWorkflows": "My Workflows",
16991699
"defaultWorkflows": "Default Workflows",
1700+
"projectWorkflows": "Project Workflows",
17001701
"openWorkflow": "Open Workflow",
17011702
"uploadWorkflow": "Load from File",
17021703
"deleteWorkflow": "Delete Workflow",
@@ -1709,6 +1710,7 @@
17091710
"workflowSaved": "Workflow Saved",
17101711
"noRecentWorkflows": "No Recent Workflows",
17111712
"noUserWorkflows": "No User Workflows",
1713+
"noWorkflows": "No Workflows",
17121714
"noSystemWorkflows": "No System Workflows",
17131715
"problemLoading": "Problem Loading Workflows",
17141716
"loading": "Loading Workflows",

invokeai/frontend/web/src/features/nodes/types/workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type XYPosition = z.infer<typeof zXYPosition>;
1515
export const zDimension = z.number().gt(0).nullish();
1616
export type Dimension = z.infer<typeof zDimension>;
1717

18-
export const zWorkflowCategory = z.enum(['user', 'default']);
18+
export const zWorkflowCategory = z.enum(['user', 'default', 'project']);
1919
export type WorkflowCategory = z.infer<typeof zWorkflowCategory>;
2020
// #endregion
2121

invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryList.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
InputRightElement,
1414
Spacer,
1515
} from '@invoke-ai/ui';
16+
import { useStore } from '@nanostores/react';
17+
import { $projectId } from 'app/store/nanostores/projectId';
1618
import {
1719
IAINoContentFallback,
1820
IAINoContentFallbackWithSpinner,
@@ -62,6 +64,7 @@ const WorkflowLibraryList = () => {
6264
const [order_by, setOrderBy] = useState<WorkflowRecordOrderBy>('opened_at');
6365
const [direction, setDirection] = useState<SQLiteDirection>('ASC');
6466
const [debouncedQuery] = useDebounce(query, 500);
67+
const projectId = useStore($projectId);
6568

6669
const queryArg = useMemo<Parameters<typeof useListWorkflowsQuery>[0]>(() => {
6770
if (category === 'user') {
@@ -142,13 +145,8 @@ const WorkflowLibraryList = () => {
142145
[]
143146
);
144147

145-
const handleSetUserCategory = useCallback(() => {
146-
setCategory('user');
147-
setPage(0);
148-
}, []);
149-
150-
const handleSetDefaultCategory = useCallback(() => {
151-
setCategory('default');
148+
const handleSetCategory = useCallback((category: WorkflowCategory) => {
149+
setCategory(category);
152150
setPage(0);
153151
}, []);
154152

@@ -158,21 +156,31 @@ const WorkflowLibraryList = () => {
158156
<ButtonGroup>
159157
<Button
160158
variant={category === 'user' ? undefined : 'ghost'}
161-
onClick={handleSetUserCategory}
159+
onClick={handleSetCategory.bind(null, 'user')}
162160
isChecked={category === 'user'}
163161
>
164162
{t('workflows.userWorkflows')}
165163
</Button>
166-
<Button
167-
variant={category === 'default' ? undefined : 'ghost'}
168-
onClick={handleSetDefaultCategory}
169-
isChecked={category === 'default'}
170-
>
171-
{t('workflows.defaultWorkflows')}
172-
</Button>
164+
{projectId ? (
165+
<Button
166+
variant={category === 'project' ? undefined : 'ghost'}
167+
onClick={handleSetCategory.bind(null, 'project')}
168+
isChecked={category === 'project'}
169+
>
170+
{t('workflows.projectWorkflows')}
171+
</Button>
172+
) : (
173+
<Button
174+
variant={category === 'default' ? undefined : 'ghost'}
175+
onClick={handleSetCategory.bind(null, 'default')}
176+
isChecked={category === 'default'}
177+
>
178+
{t('workflows.defaultWorkflows')}
179+
</Button>
180+
)}
173181
</ButtonGroup>
174182
<Spacer />
175-
{category === 'user' && (
183+
{category !== 'default' && (
176184
<>
177185
<FormControl isDisabled={isFetching} w={64} minW={56}>
178186
<FormLabel>{t('common.orderBy')}</FormLabel>
@@ -228,7 +236,7 @@ const WorkflowLibraryList = () => {
228236
</Flex>
229237
</ScrollableContent>
230238
) : (
231-
<IAINoContentFallback label={t('workflows.noUserWorkflows')} />
239+
<IAINoContentFallback label={t('workflows.noWorkflows')} />
232240
)}
233241
<Divider />
234242
{data && (

invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryListItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
5252
{workflowDTO.name || t('workflows.unnamedWorkflow')}
5353
</Heading>
5454
<Spacer />
55-
{workflowDTO.category === 'user' && (
55+
{workflowDTO.category !== 'default' && (
5656
<Text
5757
fontSize="sm"
5858
variant="subtext"
@@ -81,7 +81,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
8181
</Text>
8282
)}
8383
<Spacer />
84-
{workflowDTO.category === 'user' && (
84+
{workflowDTO.category !== 'default' && (
8585
<Text
8686
fontSize="sm"
8787
variant="subtext"
@@ -104,7 +104,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
104104
>
105105
{t('common.load')}
106106
</Button>
107-
{workflowDTO.category === 'user' && (
107+
{workflowDTO.category !== 'default' && (
108108
<Button
109109
flexShrink={0}
110110
colorScheme="error"

0 commit comments

Comments
 (0)