Skip to content

Commit 2808794

Browse files
committed
fix sorting logic for generated apps && add unique ID
Signed-off-by: Atif Ali <atali@redhat.com>
1 parent 0da9bce commit 2808794

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/gitops/components/shared/ApplicationSetList.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ const ApplicationSetList: React.FC<ApplicationSetProps> = ({
146146

147147
const columnsDV = useColumnsDV(namespace, getSortParams);
148148
const sortedApplicationSets = React.useMemo(() => {
149-
return sortData(applicationSets as ApplicationSetKind[], sortBy, direction);
150-
}, [applicationSets, sortBy, direction]);
149+
return sortData(applicationSets as ApplicationSetKind[], sortBy, direction, applications, appsLoaded);
150+
}, [applicationSets, sortBy, direction, applications, appsLoaded]);
151151
const [data, filteredData, onFilterChange] = useListPageFilter(sortedApplicationSets, filters);
152152
const rows = useApplicationSetRowsDV(filteredData, namespace, applications, appsLoaded);
153153

@@ -264,11 +264,11 @@ const useApplicationSetRowsDV = (applicationSetsList, namespace, applications, a
264264
),
265265
},
266266
{
267-
id: getGeneratedAppsCount(appSet, applications, appsLoaded).toString(),
267+
id: 'generated-apps-' + index,
268268
cell: getGeneratedAppsCount(appSet, applications, appsLoaded).toString(),
269269
},
270270
{
271-
id: getAppSetGeneratorCount(appSet).toString(),
271+
id: 'generators-' + index,
272272
cell: getAppSetGeneratorCount(appSet).toString(),
273273
},
274274
{
@@ -386,6 +386,8 @@ export const sortData = (
386386
data: ApplicationSetKind[],
387387
sortBy: string | undefined,
388388
direction: 'asc' | 'desc' | undefined,
389+
applications: any[] = [],
390+
appsLoaded: boolean = false,
389391
) => {
390392
if (!sortBy || !direction) return data;
391393

@@ -406,8 +408,8 @@ export const sortData = (
406408
bValue = getAppSetStatus(b);
407409
break;
408410
case 'generated-apps':
409-
aValue = getGeneratedAppsCount(a, [], false);
410-
bValue = getGeneratedAppsCount(b, [], false);
411+
aValue = getGeneratedAppsCount(a, applications, appsLoaded);
412+
bValue = getGeneratedAppsCount(b, applications, appsLoaded);
411413
break;
412414

413415
case 'generators':

0 commit comments

Comments
 (0)