Merge branch '13860-process-statuses-filters'
[arvados.git] / src / store / process-panel / process-panel-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ProcessPanel } from '~/store/process-panel/process-panel';
6 import { ProcessPanelAction, procesPanelActions } from '~/store/process-panel/process-panel-actions';
7
8 const initialState: ProcessPanel = {
9     filters: {}
10 };
11
12 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
13     procesPanelActions.match(action, {
14         SET_PROCESS_PANEL_FILTERS: statuses => {
15             const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
16             return { filters };
17         },
18         TOGGLE_PROCESS_PANEL_FILTER: status => {
19             const filters = { ...state.filters, [status]: !state.filters[status] };
20             return { filters };
21         },
22         default: () => state,
23     });
24