17415: Created mountainduck bookmark files generator
[arvados-workbench2.git] / src / store / collections / collection-info-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 { RootState } from "~/store/store";
7 import { ServiceRepository } from "~/services/services";
8 import { dialogActions } from '~/store/dialog/dialog-actions';
9 import { getNewExtraToken } from "../auth/auth-action";
10
11 export const COLLECTION_WEBDAV_S3_DIALOG_NAME = 'collectionWebdavS3Dialog';
12
13 export interface WebDavS3InfoDialogData {
14     uuid: string;
15     token: string;
16     downloadUrl: string;
17     collectionsUrl: string;
18     localCluster: string;
19     username: string;
20     activeTab: number;
21     collectionName?: string;
22     setActiveTab: (event: any, tabNr: number) => void;
23 }
24
25 export const openWebDavS3InfoDialog = (uuid: string, activeTab?: number) =>
26     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
27         await dispatch<any>(getNewExtraToken(true));
28         dispatch(dialogActions.OPEN_DIALOG({
29             id: COLLECTION_WEBDAV_S3_DIALOG_NAME,
30             data: {
31                 title: 'Access Collection using WebDAV or S3',
32                 token: getState().auth.extraApiToken || getState().auth.apiToken,
33                 downloadUrl: getState().auth.config.keepWebServiceUrl,
34                 collectionsUrl: getState().auth.config.keepWebInlineServiceUrl,
35                 localCluster: getState().auth.localCluster,
36                 username: getState().auth.user!.username,
37                 activeTab: activeTab || 0,
38                 collectionName: (getState().collectionPanel.item || {} as any).name,
39                 setActiveTab: (event: any, tabNr: number) => dispatch<any>(openWebDavS3InfoDialog(uuid, tabNr)),
40                 uuid
41             }
42         }));
43     };