From 9da3114b2e2fdf3bd68062d1ec26f28b42d8f75f Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 2 Aug 2024 18:34:55 +0200 Subject: [PATCH] fix marketplace sorting display --- ui/marketplace/utils.ts | 9 ++++++--- ui/pages/Marketplace.tsx | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ui/marketplace/utils.ts b/ui/marketplace/utils.ts index 3f0fb9538b..646efb482c 100644 --- a/ui/marketplace/utils.ts +++ b/ui/marketplace/utils.ts @@ -1,16 +1,19 @@ import type { NextRouter } from 'next/router'; +import config from 'configs/app'; import getQueryParamString from 'lib/router/getQueryParamString'; import removeQueryParam from 'lib/router/removeQueryParam'; import type { TOption } from 'ui/shared/sort/Option'; +const feature = config.features.marketplace; + export type SortValue = 'rating' | 'security_score'; export const SORT_OPTIONS: Array> = [ { title: 'Default', id: undefined }, - { title: 'Rating', id: 'rating' }, - { title: 'Security score', id: 'security_score' }, -]; + (feature.isEnabled && feature.rating) && { title: 'Rating', id: 'rating' }, + (feature.isEnabled && feature.securityReportsUrl) && { title: 'Security score', id: 'security_score' }, +].filter(Boolean) as Array>; export function getAppUrl(url: string | undefined, router: NextRouter) { if (!url) { diff --git a/ui/pages/Marketplace.tsx b/ui/pages/Marketplace.tsx index aeab726593..8e4347a6f1 100644 --- a/ui/pages/Marketplace.tsx +++ b/ui/pages/Marketplace.tsx @@ -137,6 +137,8 @@ const Marketplace = () => { return null; } + const showSort = SORT_OPTIONS.length > 1; + return ( <> { /> - { feature.securityReportsUrl && ( + { showSort && ( { onChange={ onSearchInputChange } placeholder="Find app by name or keyword..." isLoading={ isPlaceholderData } - size={ feature.securityReportsUrl ? 'xs' : 'sm' } + size={ showSort ? 'xs' : 'sm' } w={{ base: '100%', lg: '350px' }} />