Add typescript paths to top level folders
[arvados-workbench2.git] / src / store / collection-panel / collection-panel-reducer.ts
index 0dd233eaf0c4c444d4f7fc50f8eb218e3aa50d16..2c3edf1a5afce13ec9059f523f042df3eef9751a 100644 (file)
@@ -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) })
     });