1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ProcessPanel } from 'store/process-panel/process-panel';
6 import { ProcessPanelAction, processPanelActions } from 'store/process-panel/process-panel-actions';
8 const initialState: ProcessPanel = {
9 containerRequestUuid: "",
14 outputDefinitions: [],
18 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
19 processPanelActions.match(action, {
20 RESET_PROCESS_PANEL: () => initialState,
21 SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: containerRequestUuid => ({
22 ...state, containerRequestUuid
24 SET_PROCESS_PANEL_FILTERS: statuses => {
25 const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
26 return { ...state, filters };
28 TOGGLE_PROCESS_PANEL_FILTER: status => {
29 const filters = { ...state.filters, [status]: !state.filters[status] };
30 return { ...state, filters };
32 SET_INPUT_RAW: inputRaw => {
33 // Since mounts can disappear and reappear, only set inputs
34 // if current state is null or new inputs has content
35 if (state.inputRaw === null || (inputRaw && inputRaw.length)) {
36 return { ...state, inputRaw };
41 SET_INPUT_PARAMS: inputParams => {
42 // Since mounts can disappear and reappear, only set inputs
43 // if current state is null or new inputs has content
44 if (state.inputParams === null || (inputParams && inputParams.length)) {
45 return { ...state, inputParams };
50 SET_OUTPUT_RAW: outputRaw => {
51 return { ...state, outputRaw };
53 SET_OUTPUT_DEFINITIONS: outputDefinitions => {
54 // Set output definitions is only additive to avoid clearing when mounts go temporarily missing
55 if (outputDefinitions.length) {
56 return { ...state, outputDefinitions }
61 SET_OUTPUT_PARAMS: outputParams => {
62 return { ...state, outputParams };