1
1
import type { ButtonProps , CheckboxProps } from '@invoke-ai/ui-library' ;
2
2
import {
3
+ Box ,
3
4
Button ,
4
5
ButtonGroup ,
5
6
Checkbox ,
6
7
Collapse ,
7
8
Flex ,
9
+ Icon ,
8
10
IconButton ,
9
11
Spacer ,
10
12
Text ,
@@ -29,7 +31,7 @@ import { UploadWorkflowButton } from 'features/workflowLibrary/components/Upload
29
31
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react' ;
30
32
import { memo , useCallback , useEffect , useMemo } from 'react' ;
31
33
import { useTranslation } from 'react-i18next' ;
32
- import { PiArrowCounterClockwiseBold , PiUsersBold } from 'react-icons/pi' ;
34
+ import { PiArrowCounterClockwiseBold , PiStarFill , PiUsersBold } from 'react-icons/pi' ;
33
35
import { useDispatch } from 'react-redux' ;
34
36
import { useGetCountsByTagQuery } from 'services/api/endpoints/workflows' ;
35
37
@@ -199,15 +201,6 @@ WorkflowLibraryViewButton.displayName = 'NavButton';
199
201
const TagCategory = memo ( ( { tagCategory } : { tagCategory : WorkflowTagCategory } ) => {
200
202
const { t } = useTranslation ( ) ;
201
203
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 ] ) ;
211
204
212
205
if ( count === 0 ) {
213
206
return null ;
@@ -220,22 +213,23 @@ const TagCategory = memo(({ tagCategory }: { tagCategory: WorkflowTagCategory })
220
213
</ Text >
221
214
< Flex flexDir = "column" gap = { 2 } pl = { 4 } >
222
215
{ tagCategory . tags . map ( ( tag ) => (
223
- < TagCheckbox key = { tag . label } tag = { tag . label } />
216
+ < TagCheckbox key = { tag . label } tag = { tag } />
224
217
) ) }
225
218
</ Flex >
226
219
</ Flex >
227
220
) ;
228
221
} ) ;
229
222
TagCategory . displayName = 'TagCategory' ;
230
223
231
- const TagCheckbox = memo ( ( { tag, ...rest } : CheckboxProps & { tag : string } ) => {
224
+ const TagCheckbox = memo ( ( { tag, ...rest } : CheckboxProps & { tag : { label : string ; recommended ?: boolean } } ) => {
232
225
const dispatch = useAppDispatch ( ) ;
226
+ const { t } = useTranslation ( ) ;
233
227
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 ) ;
236
230
237
231
const onChange = useCallback ( ( ) => {
238
- dispatch ( workflowLibraryTagToggled ( tag ) ) ;
232
+ dispatch ( workflowLibraryTagToggled ( tag . label ) ) ;
239
233
} , [ dispatch , tag ] ) ;
240
234
241
235
if ( count === 0 ) {
@@ -244,7 +238,16 @@ const TagCheckbox = memo(({ tag, ...rest }: CheckboxProps & { tag: string }) =>
244
238
245
239
return (
246
240
< 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 >
248
251
</ Checkbox >
249
252
) ;
250
253
} ) ;
0 commit comments