21316: Merge commit '1416f698b72de4b09350d9c2fb25c1405c3247bc' into 21316-left-panel...
[arvados.git] / services / workbench2 / 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     isTransitioning: boolean;
12 }
13
14 const initialState = {
15     resourceUuid: '',
16     isOpened: false,
17     tabNr: 0,
18     isTransitioning: false
19 };
20
21 export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
22     detailsPanelActions.match(action, {
23         default: () => state,
24         LOAD_DETAILS_PANEL: resourceUuid => ({ ...state, resourceUuid }),
25         OPEN_DETAILS_PANEL: tabNr => ({ ...state, isOpened: true, tabNr }),
26         TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }),
27         START_TRANSITION: () => ({...state, isTransitioning: true}),
28         END_TRANSITION: () => ({...state, isTransitioning: false})
29     });