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 { RootState } from '~/store/store';
7 import { ProcessLogsPanelAction, processLogsPanelActions } from './process-logs-panel-actions';
9 const initialState: ProcessLogsPanel = {
15 export const processLogsPanelReducer = (state = initialState, action: ProcessLogsPanelAction): ProcessLogsPanel =>
16 processLogsPanelActions.match(action, {
17 RESET_PROCESS_LOGS_PANEL: () => initialState,
18 INIT_PROCESS_LOGS_PANEL: ({ filters, logs }) => ({
21 selectedFilter: filters[0] || '',
23 SET_PROCESS_LOGS_PANEL_FILTER: selectedFilter => ({
27 ADD_PROCESS_LOGS_PANEL_ITEM: ({ logType, log }) => {
28 const currentLogs = state.logs[logType] || [];
29 const logsOfType = [...currentLogs, log];
30 const logs = { ...state.logs, [logType]: logsOfType };
31 return { ...state, logs };