Skip to content

Commit 063d07f

Browse files
Mary Hipppsychedelicious
authored andcommitted
switch to using recommended with star insteaed of auto-selecting
1 parent c78eac6 commit 063d07f

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,7 @@
17011701
"shared": "Shared",
17021702
"browseWorkflows": "Browse Workflows",
17031703
"deselectAll": "Deselect All",
1704+
"recommended": "Recommended For You",
17041705
"opened": "Opened",
17051706
"openWorkflow": "Open Workflow",
17061707
"updated": "Updated",

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { ButtonProps, CheckboxProps } from '@invoke-ai/ui-library';
22
import {
3+
Box,
34
Button,
45
ButtonGroup,
56
Checkbox,
67
Collapse,
78
Flex,
9+
Icon,
810
IconButton,
911
Spacer,
1012
Text,
@@ -29,7 +31,7 @@ import { UploadWorkflowButton } from 'features/workflowLibrary/components/Upload
2931
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
3032
import { memo, useCallback, useEffect, useMemo } from 'react';
3133
import { useTranslation } from 'react-i18next';
32-
import { PiArrowCounterClockwiseBold, PiUsersBold } from 'react-icons/pi';
34+
import { PiArrowCounterClockwiseBold, PiStarFill, PiUsersBold } from 'react-icons/pi';
3335
import { useDispatch } from 'react-redux';
3436
import { useGetCountsByTagQuery } from 'services/api/endpoints/workflows';
3537

@@ -199,15 +201,6 @@ WorkflowLibraryViewButton.displayName = 'NavButton';
199201
const TagCategory = memo(({ tagCategory }: { tagCategory: WorkflowTagCategory }) => {
200202
const { t } = useTranslation();
201203
const count = useCountForTagCategory(tagCategory);
202-
const dispatch = useAppDispatch();
203-
204-
useEffect(() => {
205-
for (const tag of tagCategory.tags) {
206-
if (tag.selected) {
207-
dispatch(workflowLibraryTagToggled(tag.label));
208-
}
209-
}
210-
}, [count, tagCategory.tags, dispatch]);
211204

212205
if (count === 0) {
213206
return null;
@@ -220,22 +213,23 @@ const TagCategory = memo(({ tagCategory }: { tagCategory: WorkflowTagCategory })
220213
</Text>
221214
<Flex flexDir="column" gap={2} pl={4}>
222215
{tagCategory.tags.map((tag) => (
223-
<TagCheckbox key={tag.label} tag={tag.label} />
216+
<TagCheckbox key={tag.label} tag={tag} />
224217
))}
225218
</Flex>
226219
</Flex>
227220
);
228221
});
229222
TagCategory.displayName = 'TagCategory';
230223

231-
const TagCheckbox = memo(({ tag, ...rest }: CheckboxProps & { tag: string }) => {
224+
const TagCheckbox = memo(({ tag, ...rest }: CheckboxProps & { tag: { label: string; recommended?: boolean } }) => {
232225
const dispatch = useAppDispatch();
226+
const { t } = useTranslation();
233227
const selectedTags = useAppSelector(selectWorkflowLibrarySelectedTags);
234-
const isChecked = selectedTags.includes(tag);
235-
const count = useCountForIndividualTag(tag);
228+
const isChecked = selectedTags.includes(tag.label);
229+
const count = useCountForIndividualTag(tag.label);
236230

237231
const onChange = useCallback(() => {
238-
dispatch(workflowLibraryTagToggled(tag));
232+
dispatch(workflowLibraryTagToggled(tag.label));
239233
}, [dispatch, tag]);
240234

241235
if (count === 0) {
@@ -244,7 +238,16 @@ const TagCheckbox = memo(({ tag, ...rest }: CheckboxProps & { tag: string }) =>
244238

245239
return (
246240
<Checkbox isChecked={isChecked} onChange={onChange} {...rest} flexShrink={0}>
247-
<Text>{`${tag} (${count})`}</Text>
241+
<Flex alignItems="center" gap={2}>
242+
<Text>{`${tag.label} (${count})`}</Text>
243+
{tag.recommended && (
244+
<Tooltip label={t('workflows.recommended')}>
245+
<Box>
246+
<Icon as={PiStarFill} boxSize={4} fill="invokeYellow.500" />
247+
</Box>
248+
</Tooltip>
249+
)}
250+
</Flex>
248251
</Checkbox>
249252
);
250253
});

invokeai/frontend/web/src/features/nodes/store/workflowLibrarySlice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ export const selectWorkflowLibraryView = createWorkflowLibrarySelector(({ view }
9292
export const DEFAULT_WORKFLOW_LIBRARY_CATEGORIES = ['user', 'default'] satisfies WorkflowCategory[];
9393
export const $workflowLibraryCategoriesOptions = atom<WorkflowCategory[]>(DEFAULT_WORKFLOW_LIBRARY_CATEGORIES);
9494

95-
export type WorkflowTagCategory = { categoryTKey: string; tags: Array<{ label: string; selected?: boolean }> };
95+
export type WorkflowTagCategory = { categoryTKey: string; tags: Array<{ label: string; recommended?: boolean }> };
9696
export const DEFAULT_WORKFLOW_LIBRARY_TAG_CATEGORIES: WorkflowTagCategory[] = [
9797
{
9898
categoryTKey: 'Industry',
9999
tags: [{ label: 'Architecture' }, { label: 'Fashion' }, { label: 'Game Dev' }, { label: 'Food' }],
100100
},
101101
{
102102
categoryTKey: 'Common Tasks',
103-
tags: [{ label: 'Upscaling' }, { label: 'Text to Image' }, { label: 'Image to Image' }],
103+
tags: [{ label: 'Upscaling' }, { label: 'Text to Image' }, { label: 'Image to Image', recommended: true }],
104104
},
105105
{
106106
categoryTKey: 'Model Architecture',

0 commit comments

Comments
 (0)