X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/18a8117437056f65e3c9d84b0231c5f64b1346d1..3def82c401e28a430b222bee86ede13158165976:/src/store/details-panel/details-panel-reducer.ts diff --git a/src/store/details-panel/details-panel-reducer.ts b/src/store/details-panel/details-panel-reducer.ts index f57b9f1c..6c32551c 100644 --- a/src/store/details-panel/details-panel-reducer.ts +++ b/src/store/details-panel/details-panel-reducer.ts @@ -2,25 +2,24 @@ // // SPDX-License-Identifier: AGPL-3.0 -import actions, { DetailsPanelAction } from "./details-panel-action"; -import { Resource } from "../../models/resource"; +import { detailsPanelActions, DetailsPanelAction } from "./details-panel-action"; export interface DetailsPanelState { - item: Resource | null; + resourceUuid: string; isOpened: boolean; + tabNr: number; } const initialState = { - item: null, - isOpened: false + resourceUuid: '', + isOpened: false, + tabNr: 0 }; -const reducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) => - actions.match(action, { +export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) => + detailsPanelActions.match(action, { default: () => state, - LOAD_DETAILS: () => state, - LOAD_DETAILS_SUCCESS: ({ item }) => ({ ...state, item }), - TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }) + LOAD_DETAILS_PANEL: resourceUuid => ({ ...state, resourceUuid }), + OPEN_DETAILS_PANEL: tabNr => ({ ...state, isOpened: true, tabNr }), + TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }), }); - -export default reducer;