Skip to content

Commit 63b9f5f

Browse files
fixed rendeing issue for stack tab in components
1 parent d99688b commit 63b9f5f

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

src/ui/layouts/stacks/Stacks/List/index.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState } from 'react';
22

33
import { translate } from '../translate';
44
import { CollapseTable } from '../../../common/CollapseTable';
5-
import { useHistory, useSelector } from '../../../../hooks';
5+
import { useDispatch, useHistory, useSelector } from '../../../../hooks';
66
import { routePaths } from '../../../../../routes/routePaths';
77

88
import { useService } from './useService';
@@ -13,6 +13,7 @@ import {
1313
stackSelectors,
1414
} from '../../../../../redux/selectors';
1515
import { callActionForStacksForPagination } from '../useService';
16+
import { stacksActions } from '../../../../../redux/actions';
1617

1718
interface Props {
1819
filter: any;
@@ -29,6 +30,11 @@ export const List: React.FC<Props> = ({
2930
stackComponentId,
3031
}: Props) => {
3132
const history = useHistory();
33+
const dispatch = useDispatch();
34+
const [
35+
fetchingForStacksFroComponents,
36+
setFetchingForStacksFroComponents,
37+
] = useState(false);
3238
const { dispatchStackData } = callActionForStacksForPagination();
3339
const ITEMS_PER_PAGE = parseInt(
3440
process.env.REACT_APP_ITEMS_PER_PAGE as string,
@@ -50,12 +56,18 @@ export const List: React.FC<Props> = ({
5056

5157
useEffect(() => {
5258
if (stackComponentId) {
53-
dispatchStackData(
54-
1,
55-
ITEMS_PER_PAGE ? ITEMS_PER_PAGE : DEFAULT_ITEMS_PER_PAGE,
56-
filter,
57-
activeSortingDirection?.toLowerCase() + ':' + activeSorting,
58-
stackComponentId,
59+
setFetchingForStacksFroComponents(true);
60+
dispatch(
61+
stacksActions.getMy({
62+
component_id: stackComponentId,
63+
sort_by: 'desc:created',
64+
logical_operator: 'and',
65+
page: 1,
66+
size: ITEMS_PER_PAGE ? ITEMS_PER_PAGE : DEFAULT_ITEMS_PER_PAGE,
67+
workspace: selectedWorkspace,
68+
onSuccess: () => setFetchingForStacksFroComponents(false),
69+
onFailure: () => setFetchingForStacksFroComponents(false),
70+
}),
5971
);
6072
}
6173
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -105,7 +117,7 @@ export const List: React.FC<Props> = ({
105117
// );
106118
// }
107119
// };
108-
120+
console.log(filter, 'filfilterter');
109121
return (
110122
<>
111123
<CollapseTable
@@ -129,7 +141,13 @@ export const List: React.FC<Props> = ({
129141
// }
130142
pagination={pagination}
131143
paginated={stacksPaginated}
132-
loading={expendedRow.length > 0 ? false : fetching}
144+
loading={
145+
expendedRow.length > 0
146+
? false
147+
: filter[0].value || !stackComponentId
148+
? fetching
149+
: fetchingForStacksFroComponents
150+
}
133151
showHeader={true}
134152
filters={filter}
135153
headerCols={headerCols}

0 commit comments

Comments
 (0)