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 357299f8825..33318850a49 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 @@ -39,8 +39,14 @@ const FacetFilter: FunctionComponent = ({ ) ); }; + const sortBuckets = (buckets: Array) => { + return buckets.sort((a, b) => (a.key > b.key ? 1 : -1)); + }; const getBuckets = (buckets: Array, state: boolean) => { - return buckets.slice(0, state ? buckets.length - 1 : LIST_SIZE); + return sortBuckets(buckets).slice( + 0, + state ? buckets.length - 1 : LIST_SIZE + ); }; const getLinkTextByTitle = (title: string, bucketLength: number) => { diff --git a/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.tsx b/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.tsx index c56a1315af5..a1bac298134 100644 --- a/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.tsx @@ -20,7 +20,7 @@ const FilterContainer: FunctionComponent = ({ onSelect(!isSelected, name, type); }} /> -
+
{name.startsWith('Tier.Tier') ? name.split('.')[1] : name}
) => { + let bucketList: Array = [...tiers]; + buckets.forEach((el) => { + bucketList = bucketList.map((tier) => { + if (tier.key === el.key) { + return el; + } else { + return tier; + } + }); + }); + + return bucketList ?? []; +}; + +export const getAggrWithDefaultValue = ( + aggregations: Array +) => { + const aggregation = aggregations.find( + (aggregation) => aggregation.title === 'Tier' + ); + + if (aggregation) { + const index = aggregations.indexOf(aggregation); + aggregations[index].buckets = getBucketList(aggregations[index].buckets); + + return aggregations; + } else { + return aggregations; + } +}; 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 bca87b780cd..238f0b21921 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 @@ -17,6 +17,7 @@ import useToastContext from '../../hooks/useToastContext'; import { getAggregationList } from '../../utils/AggregationUtils'; import { formatDataResponse } from '../../utils/APIUtils'; import { getFilterString } from '../../utils/FilterUtils'; +import { getAggrWithDefaultValue } from './explore.constants'; import { Params } from './explore.interface'; const visibleFilters = ['tags', 'service', 'service type', 'tier']; @@ -157,7 +158,7 @@ const ExplorePage: React.FC = (): React.ReactElement => { const fetchLeftPanel = () => { return (