X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1c7242e61e9d71c7a37483ec0583dd0256f8ee7e..dd89200ad6fdbfa337fdbab5f54def8712c6746c:/src/store/collection-panel/collection-panel-reducer.ts diff --git a/src/store/collection-panel/collection-panel-reducer.ts b/src/store/collection-panel/collection-panel-reducer.ts index 0dd233ea..2c3edf1a 100644 --- a/src/store/collection-panel/collection-panel-reducer.ts +++ b/src/store/collection-panel/collection-panel-reducer.ts @@ -3,19 +3,24 @@ // SPDX-License-Identifier: AGPL-3.0 import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action"; -import { CollectionResource } from "../../models/collection"; +import { CollectionResource } from "~/models/collection"; +import { TagResource } from "~/models/tag"; export interface CollectionPanelState { item: CollectionResource | null; + tags: TagResource[]; } const initialState = { - item: null + item: null, + tags: [] }; export const collectionPanelReducer = (state: CollectionPanelState = initialState, action: CollectionPanelAction) => collectionPanelActions.match(action, { default: () => state, - LOAD_COLLECTION: () => state, LOAD_COLLECTION_SUCCESS: ({ item }) => ({ ...state, item }), + LOAD_COLLECTION_TAGS_SUCCESS: ({ tags }) => ({...state, tags }), + CREATE_COLLECTION_TAG_SUCCESS: ({ tag }) => ({...state, tags: [...state.tags, tag] }), + DELETE_COLLECTION_TAG_SUCCESS: ({ uuid }) => ({...state, tags: state.tags.filter(tag => tag.uuid !== uuid) }) });