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 => ({
26 SET_PROCESS_PANEL_FILTERS: statuses => {
27 const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
28 return { ...state, filters };
30 TOGGLE_PROCESS_PANEL_FILTER: status => {
31 const filters = { ...state.filters, [status]: !state.filters[status] };
32 return { ...state, filters };
34 SET_INPUT_RAW: inputRaw => {
35 // Since mounts can disappear and reappear, only set inputs
36 // if current state is null or new inputs has content
37 if (state.inputRaw === null || (inputRaw && Object.keys(inputRaw).length)) {
38 return { ...state, inputRaw };
43 SET_INPUT_PARAMS: inputParams => {
44 // Since mounts can disappear and reappear, only set inputs
45 // if current state is null or new inputs has content
46 if (state.inputParams === null || (inputParams && inputParams.length)) {
47 return { ...state, inputParams };
52 SET_OUTPUT_RAW: (data: any) => {
53 //never set output to {} unless initializing
54 if (state.outputRaw?.rawOutputs && Object.keys(state.outputRaw?.rawOutputs).length && state.containerRequestUuid === data.uuid) {
57 return { ...state, outputRaw: data.outputRaw };
59 SET_NODE_INFO: ({ nodeInfo }) => {
60 return { ...state, nodeInfo };
62 SET_OUTPUT_DEFINITIONS: outputDefinitions => {
63 // Set output definitions is only additive to avoid clearing when mounts go temporarily missing
64 if (outputDefinitions.length) {
65 return { ...state, outputDefinitions };
70 SET_OUTPUT_PARAMS: outputParams => {
71 return { ...state, outputParams };