Merge branch '16812-token-appears-in-the-download-URL'
[arvados-workbench2.git] / src / store / open-in-new-tab / open-in-new-tab.actions.ts
diff --git a/src/store/open-in-new-tab/open-in-new-tab.actions.ts b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
new file mode 100644 (file)
index 0000000..42bdc4c
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { ResourceKind } from '~/models/resource';
+import { unionize, ofType } from '~/common/unionize';
+
+export const openInNewTabActions = unionize({
+    COPY_STORE: ofType<{}>(),
+    OPEN_COLLECTION_IN_NEW_TAB: ofType<string>(),
+    OPEN_PROJECT_IN_NEW_TAB: ofType<string>()
+});
+
+export const openInNewTabAction = (resource: any) => (dispatch: Dispatch) => {
+    const { uuid, kind } = resource;
+
+    dispatch(openInNewTabActions.COPY_STORE());
+
+    if (kind === ResourceKind.COLLECTION) {
+        dispatch(openInNewTabActions.OPEN_COLLECTION_IN_NEW_TAB(uuid));
+    }
+    if (kind === ResourceKind.PROJECT) {
+        dispatch(openInNewTabActions.OPEN_PROJECT_IN_NEW_TAB(uuid));
+    }
+
+    console.log(uuid);
+};
\ No newline at end of file