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: "",
15 outputDefinitions: [],
19 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
20 processPanelActions.match(action, {
21 RESET_PROCESS_PANEL: () => initialState,
22 SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: containerRequestUuid => ({
23 ...state, containerRequestUuid
25 SET_PROCESS_PANEL_FILTERS: statuses => {
26 const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
27 return { ...state, filters };
29 TOGGLE_PROCESS_PANEL_FILTER: status => {
30 const filters = { ...state.filters, [status]: !state.filters[status] };
31 return { ...state, filters };
33 SET_INPUT_RAW: inputRaw => {
34 // Since mounts can disappear and reappear, only set inputs
35 // if current state is null or new inputs has content
36 if (state.inputRaw === null || (inputRaw && Object.keys(inputRaw).length)) {
37 return { ...state, inputRaw };
42 SET_INPUT_PARAMS: inputParams => {
43 // Since mounts can disappear and reappear, only set inputs
44 // if current state is null or new inputs has content
45 if (state.inputParams === null || (inputParams && inputParams.length)) {
46 return { ...state, inputParams };
51 SET_OUTPUT_RAW: outputRaw => {
52 return { ...state, outputRaw };
54 SET_NODE_INFO: ({ nodeInfo }) => {
55 return { ...state, nodeInfo };
57 SET_OUTPUT_DEFINITIONS: outputDefinitions => {
58 // Set output definitions is only additive to avoid clearing when mounts go temporarily missing
59 if (outputDefinitions.length) {
60 return { ...state, outputDefinitions }
65 SET_OUTPUT_PARAMS: outputParams => {
66 return { ...state, outputParams };