16672: Initial Log viewer placement on process panel. WIP
[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, processPanelActions } from 'store/process-panel/process-panel-actions';
7
8 const initialState: ProcessPanel = {
9     containerRequestUuid: "",
10     filters: {}
11 };
12
13 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
14     processPanelActions.match(action, {
15         SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: containerRequestUuid => ({
16             ...state, containerRequestUuid
17         }),
18         SET_PROCESS_PANEL_FILTERS: statuses => {
19             const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
20             return { ...state, filters };
21         },
22         TOGGLE_PROCESS_PANEL_FILTER: status => {
23             const filters = { ...state.filters, [status]: !state.filters[status] };
24             return { ...state, filters };
25         },
26         default: () => state,
27     });