@@ -27,7 +27,7 @@ import {
27
27
import { NewWorkflowButton } from 'features/workflowLibrary/components/NewWorkflowButton' ;
28
28
import { UploadWorkflowButton } from 'features/workflowLibrary/components/UploadWorkflowButton' ;
29
29
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react' ;
30
- import { memo , useCallback , useMemo } from 'react' ;
30
+ import { memo , useCallback , useEffect , useMemo } from 'react' ;
31
31
import { useTranslation } from 'react-i18next' ;
32
32
import { PiArrowCounterClockwiseBold , PiUsersBold } from 'react-icons/pi' ;
33
33
import { useDispatch } from 'react-redux' ;
@@ -43,6 +43,8 @@ export const WorkflowLibrarySideNav = () => {
43
43
dispatch ( workflowLibraryTagsReset ( ) ) ;
44
44
} , [ dispatch ] ) ;
45
45
46
+ useEffect ( ( ) => { } , [ selectedTags , dispatch ] ) ;
47
+
46
48
return (
47
49
< Flex h = "full" minH = { 0 } overflow = "hidden" flexDir = "column" w = { 64 } gap = { 0 } >
48
50
< Flex flexDir = "column" w = "full" pb = { 2 } >
@@ -121,7 +123,7 @@ const useCountForIndividualTag = (tag: string) => {
121
123
const queryArg = useMemo (
122
124
( ) =>
123
125
( {
124
- tags : allTags ,
126
+ tags : allTags . map ( ( tag ) => tag . label ) ,
125
127
categories : [ 'default' ] ,
126
128
} ) satisfies Parameters < typeof useGetCountsByTagQuery > [ 0 ] ,
127
129
[ allTags ]
@@ -146,7 +148,7 @@ const useCountForTagCategory = (tagCategory: WorkflowTagCategory) => {
146
148
const queryArg = useMemo (
147
149
( ) =>
148
150
( {
149
- tags : allTags ,
151
+ tags : allTags . map ( ( tag ) => tag . label ) ,
150
152
categories : [ 'default' ] , // We only allow filtering by tag for default workflows
151
153
} ) satisfies Parameters < typeof useGetCountsByTagQuery > [ 0 ] ,
152
154
[ allTags ]
@@ -159,7 +161,7 @@ const useCountForTagCategory = (tagCategory: WorkflowTagCategory) => {
159
161
return { count : 0 } ;
160
162
}
161
163
return {
162
- count : tagCategory . tags . reduce ( ( acc , tag ) => acc + ( data [ tag ] ?? 0 ) , 0 ) ,
164
+ count : tagCategory . tags . reduce ( ( acc , tag ) => acc + ( data [ tag . label ] ?? 0 ) , 0 ) ,
163
165
} ;
164
166
} ,
165
167
} ) satisfies Parameters < typeof useGetCountsByTagQuery > [ 1 ] ,
@@ -197,6 +199,15 @@ WorkflowLibraryViewButton.displayName = 'NavButton';
197
199
const TagCategory = memo ( ( { tagCategory } : { tagCategory : WorkflowTagCategory } ) => {
198
200
const { t } = useTranslation ( ) ;
199
201
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 ] ) ;
200
211
201
212
if ( count === 0 ) {
202
213
return null ;
@@ -209,7 +220,7 @@ const TagCategory = memo(({ tagCategory }: { tagCategory: WorkflowTagCategory })
209
220
</ Text >
210
221
< Flex flexDir = "column" gap = { 2 } pl = { 4 } >
211
222
{ tagCategory . tags . map ( ( tag ) => (
212
- < TagCheckbox key = { tag } tag = { tag } />
223
+ < TagCheckbox key = { tag . label } tag = { tag . label } />
213
224
) ) }
214
225
</ Flex >
215
226
</ Flex >
0 commit comments