1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action";
6 import { CollectionResource } from "~/models/collection";
7 import { TagResource } from "~/models/tag";
9 export interface CollectionPanelState {
10 item: CollectionResource | null;
14 const initialState = {
19 export const collectionPanelReducer = (state: CollectionPanelState = initialState, action: CollectionPanelAction) =>
20 collectionPanelActions.match(action, {
22 LOAD_COLLECTION_SUCCESS: ({ item }) => ({ ...state, item }),
23 LOAD_COLLECTION_TAGS_SUCCESS: ({ tags }) => ({...state, tags }),
24 CREATE_COLLECTION_TAG_SUCCESS: ({ tag }) => ({...state, tags: [...state.tags, tag] }),
25 DELETE_COLLECTION_TAG_SUCCESS: ({ uuid }) => ({...state, tags: state.tags.filter(tag => tag.uuid !== uuid) })