Skip to content

Commit

Permalink
hiding deactivated collections from the test editor's dropdown search…
Browse files Browse the repository at this point in the history
… menu and showing title directly inside dropdown comp
  • Loading branch information
TangoBeeAkto committed Dec 30, 2024
1 parent 0ea0127 commit 43c4309
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -119,8 +114,6 @@ function ConditionComponent(props) {
setSelected={(collectionId) => handleCollectionSelected(collectionId)}
preSelected={[Number(getCollectionId(field))]}
value={mapCollectionIdToName[getCollectionId(field)]}
isNested={true}
dynamicTitle={true}
/>
</div>
<div style={{flexGrow:"1"}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 : []);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 43c4309

Please sign in to comment.