From 43c43092cbc2c05cb0e434b6e0547763d645b9d8 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:45:13 +0530 Subject: [PATCH] hiding deactivated collections from the test editor's dropdown search menu and showing title directly inside dropdown comp --- .../components/CollectionComponent.jsx | 3 ++- .../components/ConditionComponent.jsx | 15 ++++---------- .../components/shared/DropdownSearch.jsx | 20 ++++++++++++++----- .../observe/api_collections/ApiGroupModal.jsx | 17 +++++----------- .../test_editor/components/SampleApi.jsx | 3 ++- .../TestRunsPage/TestrunsBannerComponent.jsx | 2 +- 6 files changed, 29 insertions(+), 31 deletions(-) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx index 8a76a9e200..43ce23584b 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx @@ -34,7 +34,8 @@ function CollectionComponent(props) { }, [condition]) const allCollections = PersistStore(state => state.allCollections); - const allCollectionsOptions = allCollections.filter(x => x.type !== "API_GROUP") + const activatedCollections = allCollections.filter(collection => collection.deactivated === false) + const allCollectionsOptions = activatedCollections.filter(x => x.type !== "API_GROUP") .map(collection => { return { label: collection.displayName, diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/ConditionComponent.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/ConditionComponent.jsx index 5c78143018..820334b2c2 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/ConditionComponent.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/ConditionComponent.jsx @@ -17,15 +17,10 @@ function ConditionComponent(props) { },[condition]) const allCollections = PersistStore(state => state.allCollections); const activatedCollections = allCollections.filter(collection => collection.deactivated === false) - const allCollectionsOptions = [ - { - title: `Search from ${activatedCollections.length} Collection${func.addPlurality(activatedCollections.length)} (type more to refine results)`, - options: activatedCollections.map(collection => ({ - label: collection.displayName, - value: collection.id - })) - } - ] + const allCollectionsOptions = activatedCollections.map(collection => ({ + label: collection.displayName, + value: collection.id + })) const getApiEndpointsOptions = (data) => { return data.map(apiEndpoint => { let str = func.toMethodUrlString(apiEndpoint); @@ -119,8 +114,6 @@ function ConditionComponent(props) { setSelected={(collectionId) => handleCollectionSelected(collectionId)} preSelected={[Number(getCollectionId(field))]} value={mapCollectionIdToName[getCollectionId(field)]} - isNested={true} - dynamicTitle={true} />
diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx index 28962c8826..adf632e989 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx @@ -6,7 +6,7 @@ function DropdownSearch(props) { const id = props.id ? props.id : "dropdown-search" - const { disabled, label, placeholder, optionsList, setSelected, value , avatarIcon, preSelected, allowMultiple, itemName, dropdownSearchKey, isNested, sliceMaxVal, dynamicTitle} = props + const { disabled, label, placeholder, optionsList, setSelected, value , avatarIcon, preSelected, allowMultiple, itemName, dropdownSearchKey, isNested, sliceMaxVal} = props const deselectedOptions = optionsList const [selectedOptions, setSelectedOptions] = useState(preSelected ? preSelected : []); @@ -78,17 +78,27 @@ function DropdownSearch(props) { deselectedOptions.forEach((opt) => { const options = opt.options.filter((option) => option[searchKey].match(filterRegex), - ).slice(0, sliceMaxVal || 20); + ); resultOptions.push({ - title: dynamicTitle ? `Showing ${options.length} result${func.addPlurality(options.length)} (type more to refine results)` : opt.title, + title: opt.title, options, }); }); }else{ + const defaultSliceValue = sliceMaxVal || 20 resultOptions = deselectedOptions.filter((option) => - option[searchKey].match(filterRegex) - ); + option[searchKey].match(filterRegex) + ).slice(0, defaultSliceValue); + + const title = resultOptions.length >= defaultSliceValue + ? `Showing ${resultOptions.length} result${func.addPlurality(resultOptions.length)} only. (type more to refine results)` + : "Showing all results"; + + resultOptions = [{ + title: title, + options: resultOptions + }] } setOptions(resultOptions); setLoading(false); diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/ApiGroupModal.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/ApiGroupModal.jsx index fb0a84b553..3cf756e12e 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/ApiGroupModal.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/ApiGroupModal.jsx @@ -67,21 +67,14 @@ function ApiGroupModal(props){ label="Select API group" placeholder="Select API group" optionsList={ - [ - { - title: `Search from ${activatedGroupCollections.length} Group${func.addPlurality(activatedGroupCollections.length)} (type more to refine results)`, - options: allCollections.filter((x) => { return (x.type === 'API_GROUP' && x.deactivated === false) }).map((x) => { - return { - label: x.displayName, - value: x.displayName - } - }) + allCollections.filter((x) => { return (x.type === 'API_GROUP' && x.deactivated === false) }).map((x) => { + return { + label: x.displayName, + value: x.displayName } - ] + }) } setSelected={setApiGroupName} - dynamicTitle={true} - isNested={true} /> ) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx index 887c9c319c..6c61d73653 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx @@ -154,7 +154,8 @@ const SampleApi = () => { } - const allCollectionsOptions = allCollections.map(collection => { + const activatedCollections = allCollections.filter(collection => collection.deactivated === false) + const allCollectionsOptions = activatedCollections.map(collection => { return { label: collection.displayName, value: collection.id diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestrunsBannerComponent.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestrunsBannerComponent.jsx index 23adac845d..af7a4d767d 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestrunsBannerComponent.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestrunsBannerComponent.jsx @@ -12,7 +12,7 @@ function SelectCollectionComponent() { const allCollections = PersistStore(state => state.allCollections); const navigate = useNavigate() let urlsCount = 0 - const allCollectionsOptions = allCollections.filter(x => x.type !== "API_GROUP") + const allCollectionsOptions = allCollections.filter(x => (x.type !== "API_GROUP" && x.deactivated === false)) .map(collection => { urlsCount += collection.urlsCount return {