From 4fffdd136e79a00c479b9c8d464f168351a5ce5f Mon Sep 17 00:00:00 2001
From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com>
Date: Mon, 30 Dec 2024 19:26:03 +0530
Subject: [PATCH 1/5] hiding deactivated collections from the dropdown search
menu
---
.../components/ConditionComponent.jsx | 16 +++++++++-----
.../components/shared/DropdownSearch.jsx | 4 ++--
.../observe/api_collections/ApiGroupModal.jsx | 21 +++++++++++++------
.../web/polaris_web/web/src/util/func.js | 4 +++-
4 files changed, 31 insertions(+), 14 deletions(-)
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 e4f04456ab..5c78143018 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
@@ -16,12 +16,16 @@ function ConditionComponent(props) {
}
},[condition])
const allCollections = PersistStore(state => state.allCollections);
- const allCollectionsOptions = allCollections.map(collection => {
- return {
- label: collection.displayName,
- value: collection.id
+ 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 getApiEndpointsOptions = (data) => {
return data.map(apiEndpoint => {
let str = func.toMethodUrlString(apiEndpoint);
@@ -115,6 +119,8 @@ 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 2882edb20e..c2df5b374c 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} = props
+ const { disabled, label, placeholder, optionsList, setSelected, value , avatarIcon, preSelected, allowMultiple, itemName, dropdownSearchKey, isNested, sliceMaxVal, dynamicTitle} = props
const deselectedOptions = optionsList
const [selectedOptions, setSelectedOptions] = useState(preSelected ? preSelected : []);
@@ -81,7 +81,7 @@ function DropdownSearch(props) {
);
resultOptions.push({
- title: opt.title,
+ title: dynamicTitle ? `Showing ${options.length} result${func.addPlurality(options.length)} (type more to refine results)` : opt.title,
options,
});
});
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 fb7443e108..fb0a84b553 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
@@ -19,6 +19,7 @@ function ApiGroupModal(props){
const setCollectionsMap = PersistStore(state => state.setCollectionsMap)
const allCollections = PersistStore(state => state.allCollections);
const setAllCollections = PersistStore(state => state.setAllCollections)
+ const activatedGroupCollections = allCollections.filter((x) => { return (x.type === 'API_GROUP' && x.deactivated === false) })
const [apiGroupName, setApiGroupName] = useState(currentApiGroupName)
@@ -65,14 +66,22 @@ function ApiGroupModal(props){
id={"select-api-group"}
label="Select API group"
placeholder="Select API group"
- optionsList={allCollections.filter((x) => { return x.type === 'API_GROUP' }).map((x) => {
- return {
- label: x.displayName,
- value: x.displayName
- }
- })
+ 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
+ }
+ })
+ }
+ ]
}
setSelected={setApiGroupName}
+ dynamicTitle={true}
+ isNested={true}
/>
)
diff --git a/apps/dashboard/web/polaris_web/web/src/util/func.js b/apps/dashboard/web/polaris_web/web/src/util/func.js
index c473eb6a85..652b884201 100644
--- a/apps/dashboard/web/polaris_web/web/src/util/func.js
+++ b/apps/dashboard/web/polaris_web/web/src/util/func.js
@@ -1246,9 +1246,11 @@ getDeprecatedEndpoints(apiInfoList, unusedEndpoints, apiCollectionId) {
getSearchItemsArr(allRoutes,allCollections){
let combinedArr = []
+ const activatedColections = allCollections.filter((item) => item.deactivated === false)
+
let initialStr = "/dashboard/observe/inventory/"
- allCollections.forEach((item)=> {
+ activatedColections.forEach((item)=> {
combinedArr.push({content: item.displayName, url: initialStr + item.id, type:'collection'})
})
From 0ea012708fe63d725f757960f7c42d3fa644c319 Mon Sep 17 00:00:00 2001
From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com>
Date: Mon, 30 Dec 2024 19:57:31 +0530
Subject: [PATCH 2/5] showing first 20 items in dropdown
---
.../web/src/apps/dashboard/components/shared/DropdownSearch.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 c2df5b374c..28962c8826 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
@@ -78,7 +78,7 @@ 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,
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 3/5] 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 {
From 2cc072e4518459f961d5523db804bd64615a0c10 Mon Sep 17 00:00:00 2001
From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com>
Date: Mon, 30 Dec 2024 23:03:57 +0530
Subject: [PATCH 4/5] showing title even if search value is empty
---
.../dashboard/components/shared/DropdownSearch.jsx | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
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 adf632e989..1f5809c392 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
@@ -65,9 +65,19 @@ function DropdownSearch(props) {
setLoading(true);
}
+ const defaultSliceValue = sliceMaxVal || 20
+
setTimeout(() => {
if (value === '' && selectedOptions.length === 0) {
- setOptions(deselectedOptions);
+ const options = deselectedOptions.slice(0, defaultSliceValue);
+ const title = options.length >= defaultSliceValue
+ ? `Showing ${options.length} result${func.addPlurality(options.length)} only. (type more to refine results)`
+ : "Showing all results";
+ const nestedOptions = [{
+ title: title,
+ options: options
+ }]
+ setOptions(nestedOptions);
setLoading(false);
return;
}
@@ -86,7 +96,6 @@ function DropdownSearch(props) {
});
});
}else{
- const defaultSliceValue = sliceMaxVal || 20
resultOptions = deselectedOptions.filter((option) =>
option[searchKey].match(filterRegex)
).slice(0, defaultSliceValue);
From ff35d73547bb4f5b396c4bc92bd58a08e4da60b9 Mon Sep 17 00:00:00 2001
From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com>
Date: Tue, 31 Dec 2024 09:28:24 +0530
Subject: [PATCH 5/5] clean code
---
.../web/src/apps/dashboard/components/shared/DropdownSearch.jsx | 2 +-
.../dashboard/pages/observe/api_collections/ApiGroupModal.jsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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 1f5809c392..37bbc3c538 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
@@ -70,7 +70,7 @@ function DropdownSearch(props) {
setTimeout(() => {
if (value === '' && selectedOptions.length === 0) {
const options = deselectedOptions.slice(0, defaultSliceValue);
- const title = options.length >= defaultSliceValue
+ const title = options.length > defaultSliceValue
? `Showing ${options.length} result${func.addPlurality(options.length)} only. (type more to refine results)`
: "Showing all results";
const nestedOptions = [{
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 3cf756e12e..d809345cb4 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,7 +67,7 @@ function ApiGroupModal(props){
label="Select API group"
placeholder="Select API group"
optionsList={
- allCollections.filter((x) => { return (x.type === 'API_GROUP' && x.deactivated === false) }).map((x) => {
+ activatedGroupCollections.map((x) => {
return {
label: x.displayName,
value: x.displayName