Fixed #598 Explore/Search filters should be in ordered fashion (#602)

This commit is contained in:
Sachin Chaurasiya 2021-09-28 13:59:22 +05:30 committed by GitHub
parent 0983ec7f1f
commit eb7b4cd79b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -34,11 +34,6 @@ const FacetFilter: FunctionComponent<FacetProp> = ({
const [showAllTags, setShowAllTags] = useState<boolean>(false);
const [showAllServices, setShowAllServices] = useState<boolean>(false);
const [showAllTier, setShowAllTier] = useState<boolean>(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<FacetProp> = ({
return (
<>
{sortAggregations().map((aggregation: AggregationType, index: number) => {
{aggregations.map((aggregation: AggregationType, index: number) => {
return (
<Fragment key={index}>
{aggregation.buckets.length > 0 ? (

View File

@ -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',

View File

@ -43,7 +43,7 @@ export const getBucketList = (buckets: Array<Bucket>) => {
export const getAggrWithDefaultValue = (
aggregations: Array<AggregationType>,
visibleAgg: Array<string> = []
) => {
): Array<AggregationType> => {
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<AggregationType>;
};
export const tabsInfo = [

View File

@ -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('?')