17018: Fixes the bug adding checks for readonly context menu type.
[arvados-workbench2.git] / src / store / open-in-new-tab / open-in-new-tab.actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from 'redux';
6 import { ResourceKind } from '~/models/resource';
7 import { unionize, ofType } from '~/common/unionize';
8
9 export const openInNewTabActions = unionize({
10     COPY_STORE: ofType<{}>(),
11     OPEN_COLLECTION_IN_NEW_TAB: ofType<string>(),
12     OPEN_PROJECT_IN_NEW_TAB: ofType<string>()
13 });
14
15 export const openInNewTabAction = (resource: any) => (dispatch: Dispatch) => {
16     const { uuid, kind } = resource;
17
18     dispatch(openInNewTabActions.COPY_STORE());
19
20     if (kind === ResourceKind.COLLECTION) {
21         dispatch(openInNewTabActions.OPEN_COLLECTION_IN_NEW_TAB(uuid));
22     }
23     if (kind === ResourceKind.PROJECT) {
24         dispatch(openInNewTabActions.OPEN_PROJECT_IN_NEW_TAB(uuid));
25     }
26
27     console.log(uuid);
28 };