1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ProcessLogsPanel } from './process-logs-panel';
6 import { ProcessLogsPanelAction, processLogsPanelActions } from './process-logs-panel-actions';
8 const initialState: ProcessLogsPanel = {
14 export const processLogsPanelReducer = (state = initialState, action: ProcessLogsPanelAction): ProcessLogsPanel =>
15 processLogsPanelActions.match(action, {
16 RESET_PROCESS_LOGS_PANEL: () => initialState,
17 INIT_PROCESS_LOGS_PANEL: ({ filters, logs }) => ({
20 selectedFilter: filters[0] || '',
22 SET_PROCESS_LOGS_PANEL_FILTER: selectedFilter => ({
26 ADD_PROCESS_LOGS_PANEL_ITEM: ({ logType, log }) => {
27 const currentLogs = state.logs[logType] || [];
28 const logsOfType = [...currentLogs, log];
29 const logs = { ...state.logs, [logType]: logsOfType };
30 return { ...state, logs };