21764: Add more type safety to TreePicker
[arvados.git] / services / workbench2 / src / store / all-processes-panel / all-processes-panel-middleware-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { getDataExplorerColumnFilters } from "store/data-explorer/data-explorer-middleware-service";
6 import { RootState } from "../store";
7 import { ServiceRepository } from "services/services";
8 import { joinFilters } from "services/api/filter-builder";
9 import { allProcessesPanelActions } from "./all-processes-panel-action";
10 import { Dispatch, MiddlewareAPI } from "redux";
11 import { DataExplorer } from "store/data-explorer/data-explorer-reducer";
12 import { DataColumns } from "components/data-table/data-table";
13 import {
14     serializeOnlyProcessTypeFilters
15 } from "../resource-type-filters/resource-type-filters";
16 import { AllProcessesPanelColumnNames } from "views/all-processes-panel/all-processes-panel";
17 import { ProcessesMiddlewareService } from "store/processes/processes-middleware-service";
18 import { ContainerRequestResource } from 'models/container-request';
19
20 export class AllProcessesPanelMiddlewareService extends ProcessesMiddlewareService {
21     constructor(services: ServiceRepository, id: string) {
22         super(services, allProcessesPanelActions, id);
23     }
24
25     getFilters(api: MiddlewareAPI<Dispatch, RootState>, dataExplorer: DataExplorer): string | null {
26         const sup = super.getFilters(api, dataExplorer);
27         if (sup === null) { return null; }
28         const columns = dataExplorer.columns as DataColumns<string, ContainerRequestResource>;
29
30         const typeFilters = serializeOnlyProcessTypeFilters(getDataExplorerColumnFilters(columns, AllProcessesPanelColumnNames.TYPE));
31         return joinFilters(sup, typeFilters);
32     }
33 }