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: [],
20 export type OutputDataUpdate = {
22 payload: OutputDetails;
25 export const processPanelReducer = (state = initialState, action: ProcessPanelAction): ProcessPanel =>
26 processPanelActions.match(action, {
27 RESET_PROCESS_PANEL: () => initialState,
28 SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: containerRequestUuid => ({
32 SET_PROCESS_PANEL_FILTERS: statuses => {
33 const filters = statuses.reduce((filters, status) => ({ ...filters, [status]: true }), {});
34 return { ...state, filters };
36 TOGGLE_PROCESS_PANEL_FILTER: status => {
37 const filters = { ...state.filters, [status]: !state.filters[status] };
38 return { ...state, filters };
40 SET_INPUT_RAW: inputRaw => {
41 // Since mounts can disappear and reappear, only set inputs
42 // if current state is null or new inputs has content
43 if (state.inputRaw === null || (inputRaw && Object.keys(inputRaw).length)) {
44 return { ...state, inputRaw };
49 SET_INPUT_PARAMS: inputParams => {
50 // Since mounts can disappear and reappear, only set inputs
51 // if current state is null or new inputs has content
52 if (state.inputParams === null || (inputParams && inputParams.length)) {
53 return { ...state, inputParams };
58 SET_OUTPUT_DATA: (update: OutputDataUpdate) => {
59 //never set output to {} unless initializing
60 if (state.outputData?.raw && Object.keys(state.outputData?.raw).length && state.containerRequestUuid === update.uuid) {
63 return { ...state, outputData: update.payload };
65 SET_NODE_INFO: ({ nodeInfo }) => {
66 return { ...state, nodeInfo };
68 SET_OUTPUT_DEFINITIONS: outputDefinitions => {
69 // Set output definitions is only additive to avoid clearing when mounts go temporarily missing
70 if (outputDefinitions.length) {
71 return { ...state, outputDefinitions };
76 SET_OUTPUT_PARAMS: outputParams => {
77 return { ...state, outputParams };
79 SET_USAGE_REPORT: ({ usageReport }) => {
80 return { ...state, usageReport };