mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 11:39:12 +00:00
UI : Sorted tier filters in explore Leftpanel (#10434)
* Sorted tier filters in explore leftpanel * fix unit test issue
This commit is contained in:
parent
5be1a77f94
commit
9866d355ff
@ -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'],
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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)));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user