18368: initial impl
[arvados.git] / src / store / details-panel / details-panel-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { detailsPanelActions, DetailsPanelAction } from "./details-panel-action";
6
7 export interface DetailsPanelState {
8     resourceUuid: string;
9     isOpened: boolean;
10     tabNr: number;
11 }
12
13 const initialState = {
14     resourceUuid: '',
15     isOpened: false,
16     tabNr: 0
17 };
18
19 export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
20     detailsPanelActions.match(action, {
21         default: () => state,
22         LOAD_DETAILS_PANEL: resourceUuid => ({ ...state, resourceUuid }),
23         OPEN_DETAILS_PANEL: tabNr => ({ ...state, isOpened: true, tabNr }),
24         TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }),
25     });