@@ -40,6 +40,7 @@ export interface HeaderCol {
4040export interface TableProps {
4141 headerCols : HeaderCol [ ] ;
4242 tableRows : any [ ] ;
43+ activeSortingDirection ?: any ;
4344 activeSorting ?: any ;
4445 paginated ?: any ;
4546 filters ?: any [ ] ;
@@ -58,6 +59,7 @@ export const Table: React.FC<TableProps> = ({
5859 tableRows,
5960 paginated,
6061 activeSorting,
62+ activeSortingDirection,
6163 filters,
6264 showHeader = true ,
6365 pagination = true ,
@@ -160,7 +162,11 @@ export const Table: React.FC<TableProps> = ({
160162 // itemsPerPage: itemPerPage,
161163 // items: tableRows,
162164 // });
163- const isValidFilter = filters ?. map ( ( f ) => f . value ) . join ( '' ) ;
165+
166+ const isValidFilterFroValue : any = filters ?. map ( ( f ) => f . value ) . join ( '' ) ;
167+ const isValidFilterForCategory : any =
168+ isValidFilterFroValue && filters ?. map ( ( f ) => f . type . value ) . join ( '' ) ;
169+ const checkValidFilter = isValidFilterFroValue + isValidFilterForCategory ;
164170
165171 const { dispatchStackData } = callActionForStacksForPagination ( ) ;
166172 const {
@@ -183,87 +189,89 @@ export const Table: React.FC<TableProps> = ({
183189 componentName === 'components'
184190 ? locationPath . pathname . split ( '/' ) [ 5 ]
185191 : locationPath . pathname . split ( '/' ) [ 4 ] ;
186- // console.log(check, '333') ;
192+ const checkForLocationPath = locationPath . pathname . split ( '/' ) [ 4 ] ;
187193 useEffect ( ( ) => {
188194 // console.log(locationPath.pathname.split('/')[4], 'locationPath1');
189195 setItemPerPage ( itemPerPage ) ;
190196 if ( filters ) {
191197 setPageIndex ( 0 ) ;
192198 }
193- switch ( componentName ) {
194- case 'stacks' :
195- if ( CheckIfRun ) {
196- dispatchStackRunsData (
197- id ,
198- 1 ,
199- itemPerPage ,
200- filters as any ,
201- activeSorting ,
202- ) ;
203- break ;
204- } else {
205- dispatchStackData ( 1 , itemPerPage , filters as any , activeSorting ) ;
206- break ;
207- }
208- case 'components' :
209- if ( CheckIfRun ) {
210- dispatchStackComponentRunsData (
211- id ,
212- 1 ,
213- itemPerPage ,
214- filters as any ,
215- activeSorting ,
216- ) ;
217- break ;
218- } else {
219- dispatchStackComponentsData (
220- 1 ,
221- itemPerPage ,
222- filters as any ,
223- activeSorting ,
224- ) ;
225- break ;
226- }
227- case 'pipelines' :
228- if ( CheckIfRun ) {
229- dispatchPipelineRunsData (
230- id ,
231- 1 ,
232- itemPerPage ,
233- filters as any ,
234- activeSorting ,
235- ) ;
236- break ;
237- } else {
238- console . log ( itemPerPage , 'itemPerPage' ) ;
239- if ( ! renderAfterRow ) break ;
240- dispatchPipelineData ( 1 , itemPerPage , filters as any , activeSorting ) ;
241- break ;
242- }
199+ if ( checkValidFilter || activeSorting || checkForLocationPath ) {
200+ switch ( componentName ) {
201+ case 'stacks' :
202+ if ( CheckIfRun ) {
203+ dispatchStackRunsData (
204+ id ,
205+ 1 ,
206+ itemPerPage ,
207+ filters as any ,
208+ activeSorting ,
209+ ) ;
210+ break ;
211+ } else {
212+ dispatchStackData ( 1 , itemPerPage , filters as any , activeSorting ) ;
213+ break ;
214+ }
215+ case 'components' :
216+ if ( CheckIfRun ) {
217+ dispatchStackComponentRunsData (
218+ id ,
219+ 1 ,
220+ itemPerPage ,
221+ filters as any ,
222+ activeSorting ,
223+ ) ;
224+ break ;
225+ } else {
226+ dispatchStackComponentsData (
227+ 1 ,
228+ itemPerPage ,
229+ filters as any ,
230+ activeSorting ,
231+ ) ;
232+ break ;
233+ }
234+ case 'pipelines' :
235+ if ( CheckIfRun ) {
236+ dispatchPipelineRunsData (
237+ id ,
238+ 1 ,
239+ itemPerPage ,
240+ filters as any ,
241+ activeSorting ,
242+ ) ;
243+ break ;
244+ } else {
245+ console . log ( itemPerPage , 'itemPerPage' ) ;
246+ if ( ! renderAfterRow ) break ;
247+ dispatchPipelineData ( 1 , itemPerPage , filters as any , activeSorting ) ;
248+ break ;
249+ }
243250
244- case 'all-runs' :
245- dispatchAllrunsData ( 1 , itemPerPage , filters as any , activeSorting ) ;
246- break ;
251+ case 'all-runs' :
252+ dispatchAllrunsData ( 1 , itemPerPage , filters as any , activeSorting ) ;
253+ break ;
247254
248- default :
249- break ;
250- }
251- if ( locationPath . pathname . split ( '/' ) [ 2 ] === 'organization' ) {
252- // debugger;
253- setFetchingMembers ( true ) ;
254- dispatch (
255- organizationActions . getMembers ( {
256- page : 1 ,
257- size : ITEMS_PER_PAGE ? ITEMS_PER_PAGE : DEFAULT_ITEMS_PER_PAGE ,
258- sort_by : activeSorting ,
259- onSuccess : ( ) => setFetchingMembers ( false ) ,
260- onFailure : ( ) => setFetchingMembers ( false ) ,
261- } ) ,
262- ) ;
255+ default :
256+ break ;
257+ }
258+ if ( locationPath . pathname . split ( '/' ) [ 2 ] === 'organization' ) {
259+ // debugger;
260+ setFetchingMembers ( true ) ;
261+ dispatch (
262+ organizationActions . getMembers ( {
263+ page : 1 ,
264+ size : ITEMS_PER_PAGE ? ITEMS_PER_PAGE : DEFAULT_ITEMS_PER_PAGE ,
265+ sort_by : activeSorting ,
266+ onSuccess : ( ) => setFetchingMembers ( false ) ,
267+ onFailure : ( ) => setFetchingMembers ( false ) ,
268+ } ) ,
269+ ) ;
270+ }
263271 }
264272
265273 // eslint-disable-next-line react-hooks/exhaustive-deps
266- } , [ locationPath . pathname . split ( '/' ) [ 4 ] , isValidFilter , activeSorting ] ) ;
274+ } , [ checkForLocationPath , checkValidFilter , activeSorting ] ) ;
267275 let rowsToDisplay = tableRows ;
268276 // function getFetchedState(state: any) {
269277 // setFetchingMembers(state);
0 commit comments