38c0edd506d148c8442a98ad20e49bdfe8494d4d
[arvados-workbench2.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 }
11
12 const initialState = {
13     resourceUuid: '',
14     isOpened: false
15 };
16
17 export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
18     detailsPanelActions.match(action, {
19         default: () => state,
20         LOAD_DETAILS_PANEL: resourceUuid => ({ ...state, resourceUuid }),
21         OPEN_DETAILS_PANEL: resourceUuid => ({ resourceUuid, isOpened: true }),
22         TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }),
23     });