16848: Makes 'Open as S3 bucket' dialog use the extra api token if available.
[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
10 export const COLLECTION_WEBDAV_S3_DIALOG_NAME = 'collectionWebdavS3Dialog';
11
12 export interface WebDavS3InfoDialogData {
13     uuid: string;
14     token: string;
15     downloadUrl: string;
16     collectionsUrl: string;
17     localCluster: string;
18     username: string;
19     activeTab: number;
20     setActiveTab: (event: any, tabNr: number) => void;
21 }
22
23 export const openWebDavS3InfoDialog = (uuid: string, activeTab?: number) =>
24     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
25         dispatch(dialogActions.OPEN_DIALOG({
26             id: COLLECTION_WEBDAV_S3_DIALOG_NAME,
27             data: {
28                 title: 'Access Collection using WebDAV or S3',
29                 token: getState().auth.extraApiToken || getState().auth.apiToken,
30                 downloadUrl: getState().auth.config.keepWebServiceUrl,
31                 collectionsUrl: getState().auth.config.keepWebInlineServiceUrl,
32                 localCluster: getState().auth.localCluster,
33                 username: getState().auth.user!.username,
34                 activeTab: activeTab || 0,
35                 setActiveTab: (event: any, tabNr: number) => dispatch<any>(openWebDavS3InfoDialog(uuid, tabNr)),
36                 uuid
37             }
38         }));
39     };