11import type { ButtonProps , CheckboxProps } from '@invoke-ai/ui-library' ;
22import {
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
2931import { OverlayScrollbarsComponent } from 'overlayscrollbars-react' ;
3032import { memo , useCallback , useEffect , useMemo } from 'react' ;
3133import { useTranslation } from 'react-i18next' ;
32- import { PiArrowCounterClockwiseBold , PiUsersBold } from 'react-icons/pi' ;
34+ import { PiArrowCounterClockwiseBold , PiStarFill , PiUsersBold } from 'react-icons/pi' ;
3335import { useDispatch } from 'react-redux' ;
3436import { useGetCountsByTagQuery } from 'services/api/endpoints/workflows' ;
3537
@@ -199,15 +201,6 @@ WorkflowLibraryViewButton.displayName = 'NavButton';
199201const 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} ) ;
229222TagCategory . 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} ) ;
0 commit comments