enable active search through dropped targets (#10668)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
2381d7be57
commit
0a30ac3f9b
|
@ -22,11 +22,16 @@ export interface TargetLabels {
|
||||||
isDropped: boolean;
|
isDropped: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const kvSearch = new KVSearch<Target>({
|
const activeTargetKVSearch = new KVSearch<Target>({
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
indexedKeys: ['labels', 'discoveredLabels', ['discoveredLabels', /.*/], ['labels', /.*/]],
|
indexedKeys: ['labels', 'discoveredLabels', ['discoveredLabels', /.*/], ['labels', /.*/]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const droppedTargetKVSearch = new KVSearch<DroppedTarget>({
|
||||||
|
shouldSort: true,
|
||||||
|
indexedKeys: ['discoveredLabels', ['discoveredLabels', /.*/]],
|
||||||
|
});
|
||||||
|
|
||||||
export const processSummary = (
|
export const processSummary = (
|
||||||
activeTargets: Target[],
|
activeTargets: Target[],
|
||||||
droppedTargets: DroppedTarget[]
|
droppedTargets: DroppedTarget[]
|
||||||
|
@ -91,6 +96,7 @@ export const processTargets = (activeTargets: Target[], droppedTargets: DroppedT
|
||||||
|
|
||||||
export const ServiceDiscoveryContent: FC<ServiceMap> = ({ activeTargets, droppedTargets }) => {
|
export const ServiceDiscoveryContent: FC<ServiceMap> = ({ activeTargets, droppedTargets }) => {
|
||||||
const [activeTargetList, setActiveTargetList] = useState(activeTargets);
|
const [activeTargetList, setActiveTargetList] = useState(activeTargets);
|
||||||
|
const [droppedTargetList, setDroppedTargetList] = useState(droppedTargets);
|
||||||
const [targetList, setTargetList] = useState(processSummary(activeTargets, droppedTargets));
|
const [targetList, setTargetList] = useState(processSummary(activeTargets, droppedTargets));
|
||||||
const [labelList, setLabelList] = useState(processTargets(activeTargets, droppedTargets));
|
const [labelList, setLabelList] = useState(processTargets(activeTargets, droppedTargets));
|
||||||
|
|
||||||
|
@ -98,21 +104,23 @@ export const ServiceDiscoveryContent: FC<ServiceMap> = ({ activeTargets, dropped
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
setQuerySearchFilter(value);
|
setQuerySearchFilter(value);
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
const result = kvSearch.filter(value.trim(), activeTargets);
|
const activeTargetResult = activeTargetKVSearch.filter(value.trim(), activeTargets);
|
||||||
setActiveTargetList(result.map((value) => value.original));
|
const droppedTargetResult = droppedTargetKVSearch.filter(value.trim(), droppedTargets);
|
||||||
|
setActiveTargetList(activeTargetResult.map((value) => value.original));
|
||||||
|
setDroppedTargetList(droppedTargetResult.map((value) => value.original));
|
||||||
} else {
|
} else {
|
||||||
setActiveTargetList(activeTargets);
|
setActiveTargetList(activeTargets);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[activeTargets]
|
[activeTargets, droppedTargets]
|
||||||
);
|
);
|
||||||
|
|
||||||
const defaultValue = useMemo(getQuerySearchFilter, []);
|
const defaultValue = useMemo(getQuerySearchFilter, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTargetList(processSummary(activeTargetList, droppedTargets));
|
setTargetList(processSummary(activeTargetList, droppedTargetList));
|
||||||
setLabelList(processTargets(activeTargetList, droppedTargets));
|
setLabelList(processTargets(activeTargetList, droppedTargetList));
|
||||||
}, [activeTargetList, droppedTargets]);
|
}, [activeTargetList, droppedTargetList]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in New Issue