added side-panel-reducer file, minor code cleanup Arvados-DCO-1.1-Signed-off-by:...
[arvados-workbench2.git] / src / store / side-panel / side-panel-action.ts
index 6a83946cc8fcdf75e1ebbd7bb4abcce3951a3d41..e4f53ceaa6be6df93c35c0831fb4d8c93d986d59 100644 (file)
@@ -2,16 +2,20 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { default as unionize, ofType, UnionOf } from "unionize";
+import { Dispatch } from 'redux';
+import { navigateTo } from 'store/navigation/navigation-action';
 
-const actions = unionize({
-    TOGGLE_SIDE_PANEL_ITEM_OPEN: ofType<string>(),
-    TOGGLE_SIDE_PANEL_ITEM_ACTIVE: ofType<string>(),
-    RESET_SIDE_PANEL_ACTIVITY: ofType<{}>(),
-}, {
-    tag: 'type',
-    value: 'payload'
-});
+export const sidePanelActions = {
+    TOGGLE_COLLAPSE: 'TOGGLE_COLLAPSE'
+}
 
-export type SidePanelAction = UnionOf<typeof actions>;
-export default actions;
\ No newline at end of file
+export const navigateFromSidePanel = (id: string) =>
+    (dispatch: Dispatch) => {
+        dispatch<any>(navigateTo(id));
+    };
+
+export const toggleSidePanel = (collapsedState: boolean) => {
+    return (dispatch) => {
+        dispatch({type: sidePanelActions.TOGGLE_COLLAPSE, payload: !collapsedState})
+    }
+}
\ No newline at end of file