1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { OutputDetails, 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 type OutputDataUpdate = {
21 payload: OutputDetails;
24 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
25 processPanelActions.match(action, {
26 RESET_PROCESS_PANEL: () => initialState,
27 SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: containerRequestUuid => ({
31 SET_PROCESS_PANEL_FILTERS: statuses => {
32 const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
33 return { ...state, filters };
35 TOGGLE_PROCESS_PANEL_FILTER: status => {
36 const filters = { ...state.filters, [status]: !state.filters[status] };
37 return { ...state, filters };
39 SET_INPUT_RAW: inputRaw => {
40 // Since mounts can disappear and reappear, only set inputs
41 // if current state is null or new inputs has content
42 if (state.inputRaw === null || (inputRaw && Object.keys(inputRaw).length)) {
43 return { ...state, inputRaw };
48 SET_INPUT_PARAMS: inputParams => {
49 // Since mounts can disappear and reappear, only set inputs
50 // if current state is null or new inputs has content
51 if (state.inputParams === null || (inputParams && inputParams.length)) {
52 return { ...state, inputParams };
57 SET_OUTPUT_DATA: (update: OutputDataUpdate) => {
58 //never set output to {} unless initializing
59 if (state.outputData?.raw && Object.keys(state.outputData?.raw).length && state.containerRequestUuid === update.uuid) {
62 return { ...state, outputData: update.payload };
64 SET_NODE_INFO: ({ nodeInfo }) => {
65 return { ...state, nodeInfo };
67 SET_OUTPUT_DEFINITIONS: outputDefinitions => {
68 // Set output definitions is only additive to avoid clearing when mounts go temporarily missing
69 if (outputDefinitions.length) {
70 return { ...state, outputDefinitions };
75 SET_OUTPUT_PARAMS: outputParams => {
76 return { ...state, outputParams };