store project - fix test, update panel details after edit resource, change label tag
[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 import { Resource } from "~/models/resource";
7
8 export interface DetailsPanelState {
9     item: Resource | null;
10     isOpened: boolean;
11 }
12
13 const initialState = {
14     item: null,
15     isOpened: false
16 };
17
18 export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
19     detailsPanelActions.match(action, {
20         default: () => state,
21         LOAD_DETAILS_SUCCESS: ({ item }) => ({ ...state, item }),
22         TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened })
23     });