diff --git a/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FacetFilter.tsx b/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FacetFilter.tsx index 0ffdb5ad8a3..4461869f074 100644 --- a/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FacetFilter.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FacetFilter.tsx @@ -34,11 +34,6 @@ const FacetFilter: FunctionComponent = ({ const [showAllTags, setShowAllTags] = useState(false); const [showAllServices, setShowAllServices] = useState(false); const [showAllTier, setShowAllTier] = useState(false); - const sortAggregations = () => { - return aggregations.sort((a, b) => - a.buckets.length > b.buckets.length ? 1 : -1 - ); - }; const getLinkText = ( length: number, state: boolean, @@ -128,7 +123,7 @@ const FacetFilter: FunctionComponent = ({ return ( <> - {sortAggregations().map((aggregation: AggregationType, index: number) => { + {aggregations.map((aggregation: AggregationType, index: number) => { return ( {aggregation.buckets.length > 0 ? ( diff --git a/catalog-rest-service/src/main/resources/ui/src/constants/constants.ts b/catalog-rest-service/src/main/resources/ui/src/constants/constants.ts index 077d5f541a5..d557bf7f76d 100644 --- a/catalog-rest-service/src/main/resources/ui/src/constants/constants.ts +++ b/catalog-rest-service/src/main/resources/ui/src/constants/constants.ts @@ -54,6 +54,8 @@ export const tiers = [ { key: 'Tier.Tier5', doc_count: 0 }, ]; +export const visibleFilters = ['service', 'tier', 'tags']; + export const tableSortingFields = [ { name: 'Last Updated', diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/explore/explore.constants.ts b/catalog-rest-service/src/main/resources/ui/src/pages/explore/explore.constants.ts index d031d3e9192..64ead496f1c 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/explore/explore.constants.ts +++ b/catalog-rest-service/src/main/resources/ui/src/pages/explore/explore.constants.ts @@ -43,7 +43,7 @@ export const getBucketList = (buckets: Array) => { export const getAggrWithDefaultValue = ( aggregations: Array, visibleAgg: Array = [] -) => { +): Array => { const aggregation = aggregations.find( (aggregation) => aggregation.title === 'Tier' ); @@ -55,9 +55,19 @@ export const getAggrWithDefaultValue = ( aggregations[index].buckets = getBucketList(aggregations[index].buckets); } - return !allowedAgg.length + const visibleAggregations = !allowedAgg.length ? aggregations : aggregations.filter((item) => allowedAgg.includes(lowerCase(item.title))); + + return allowedAgg + .map((agg) => { + const aggregation = visibleAggregations.find( + (a) => lowerCase(a.title) === agg + ); + + return aggregation; + }) + .filter(Boolean) as Array; }; export const tabsInfo = [ diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx index 860c2aa57f0..3132add1349 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx @@ -38,6 +38,7 @@ import { getExplorePathWithSearch, PAGE_SIZE, tableSortingFields, + visibleFilters, } from '../../constants/constants'; import { SearchIndex } from '../../enums/search.enum'; import { usePrevious } from '../../hooks/usePrevious'; @@ -51,8 +52,6 @@ import SVGIcons from '../../utils/SvgUtils'; import { getAggrWithDefaultValue, tabsInfo } from './explore.constants'; import { Params } from './explore.interface'; -const visibleFilters = ['tags', 'service', 'tier']; - const getQueryParam = (urlSearchQuery = ''): FilterObject => { const arrSearchQuery = urlSearchQuery ? urlSearchQuery.startsWith('?')