UI : Sorted tier filters in explore Leftpanel (#10434)

* Sorted tier filters in explore leftpanel

* fix unit test issue
This commit is contained in:
Ashish Gupta 2023-03-06 18:09:45 +05:30 committed by GitHub
parent 5be1a77f94
commit 9866d355ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -37,7 +37,7 @@ const aggregations: Aggregations = {
},
],
},
tier: {
'tier.tagFQN': {
buckets: [],
},
'service.name.keyword': {
@ -98,6 +98,10 @@ const aggregations: Aggregations = {
},
};
jest.mock('utils/EntityUtils', () => ({
getSortedTierBucketList: jest.fn().mockReturnValue([]),
}));
const filters = {
serviceType: ['BigQuery', 'Glue'],
'service.name.keyword': ['bigquery_gcp', 'glue'],

View File

@ -17,6 +17,7 @@ import { AggregationEntry } from 'interface/search.interface';
import { isEmpty, isNil } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { getSortedTierBucketList } from 'utils/EntityUtils';
import {
compareAggregationKey,
@ -45,7 +46,14 @@ const FacetFilter: React.FC<FacetFilterProps> = ({
*/
const aggregationEntries = useMemo(() => {
if (isNil(filters) || isEmpty(filters)) {
return Object.entries(aggregations)
const { 'tier.tagFQN': tier, ...restProps } = aggregations;
const sortedTiersList = {
...tier,
buckets: getSortedTierBucketList(tier.buckets),
};
return Object.entries({ ...restProps, 'tier.tagFQN': sortedTiersList })
.filter(([, { buckets }]) => buckets.length)
.sort(([key1], [key2]) => compareAggregationKey(key1, key2));
}

View File

@ -582,3 +582,6 @@ export const getFrequentlyJoinedColumns = (
</div>
) : null;
};
export const getSortedTierBucketList = (buckets: Bucket[]): Bucket[] =>
buckets.sort((a, b) => Number(a.key.slice(-1)) - Number(b.key.slice(-1)));