diff --git a/src/store/reducers/nodes/selectors.ts b/src/store/reducers/nodes/selectors.ts index 2dabacdfa..61865bd5a 100644 --- a/src/store/reducers/nodes/selectors.ts +++ b/src/store/reducers/nodes/selectors.ts @@ -1,28 +1,9 @@ -import {EFlag} from '../../../types/api/enums'; import {HOUR_IN_SECONDS} from '../../../utils/constants'; import {calcUptimeInSeconds} from '../../../utils/dataFormatters/dataFormatters'; -import {prepareSearchValue} from '../../../utils/filters'; import {NodesUptimeFilterValues} from '../../../utils/nodes'; -import {ProblemFilterValues} from '../settings/settings'; -import type {ProblemFilterValue} from '../settings/types'; - -import type {NodesPreparedEntity} from './types'; // ==== Filters ==== -const filterNodesByProblemsStatus = ( - nodesList: NodesPreparedEntity[] = [], - problemFilter: ProblemFilterValue, -) => { - if (problemFilter === ProblemFilterValues.ALL) { - return nodesList; - } - - return nodesList.filter(({SystemState}) => { - return SystemState && SystemState !== EFlag.Green; - }); -}; - export const filterNodesByUptime = ( nodesList: T[] = [], nodesUptimeFilter: NodesUptimeFilterValues, @@ -34,33 +15,3 @@ export const filterNodesByUptime = ( return !StartTime || calcUptimeInSeconds(StartTime) < HOUR_IN_SECONDS; }); }; - -const filterNodesBySearchValue = (nodesList: NodesPreparedEntity[] = [], searchValue: string) => { - if (!searchValue) { - return nodesList; - } - const re = prepareSearchValue(searchValue); - - return nodesList.filter((node) => { - return node.Host ? re.test(node.Host) || re.test(String(node.NodeId)) : true; - }); -}; - -export function filterNodes( - nodesList: NodesPreparedEntity[] = [], - { - uptimeFilter, - searchValue, - problemFilter, - }: { - uptimeFilter: NodesUptimeFilterValues; - searchValue: string; - problemFilter: ProblemFilterValue; - }, -) { - let result = filterNodesByUptime(nodesList, uptimeFilter); - result = filterNodesByProblemsStatus(result, problemFilter); - result = filterNodesBySearchValue(result, searchValue); - - return result; -}