1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { Dialog, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles, CardHeader, Tab, Tabs } from '@material-ui/core';
7 import { withDialog } from "~/store/dialog/with-dialog";
8 import { COLLECTION_WEBDAV_S3_DIALOG_NAME, WebDavS3InfoDialogData } from '~/store/collections/collection-info-actions';
9 import { WithDialogProps } from '~/store/dialog/with-dialog';
10 import { compose } from 'redux';
11 import { DetailsAttribute } from "~/components/details-attribute/details-attribute";
13 type CssRules = 'details';
15 const styles: StyleRulesCallback<CssRules> = theme => ({
17 marginLeft: theme.spacing.unit * 3,
18 marginRight: theme.spacing.unit * 3,
22 interface TabPanelData {
23 children: React.ReactElement<any>[];
28 function TabPanel(props: TabPanelData) {
29 const { children, value, index } = props;
34 hidden={value !== index}
35 id={`simple-tabpanel-${index}`}
36 aria-labelledby={`simple-tab-${index}`}
38 {value === index && children}
43 export const WebDavS3InfoDialog = compose(
44 withDialog(COLLECTION_WEBDAV_S3_DIALOG_NAME),
47 (props: WithDialogProps<WebDavS3InfoDialogData> & WithStyles<CssRules>) => {
48 if (!props.data.downloadUrl) { return null; }
50 const keepwebUrl = props.data.downloadUrl.replace(/\/\*(--[^.]+)?\./, "/");
52 const winDav = new URL(props.data.downloadUrl.replace("*", props.data.uuid));
54 const gnomeDav = new URL(keepwebUrl);
55 gnomeDav.username = props.data.username;
56 gnomeDav.pathname = `/c=${props.data.uuid}/`;
57 gnomeDav.protocol = "davs:";
59 const s3endpoint = new URL(keepwebUrl);
61 const sp = props.data.token.split("/");
64 if (sp.length === 3 && sp[0] === "v2" && props.data.homeCluster === props.data.localCluster) {
68 tokenUuid = props.data.token.replace(/\//g, "_");
69 tokenSecret = tokenUuid;
75 onClose={props.closeDialog}
76 style={{ alignSelf: 'stretch' }}>
78 title={`WebDAV and S3`} />
79 <div className={props.classes.details} >
80 <Tabs value={props.data.activeTab} onChange={props.data.setActiveTab}>
81 <Tab key="windows" label="Add a Network Location in Windows" />
82 <Tab key="gnome" label="Connect to Server in GNOME" />
83 <Tab key="s3" label="Using an S3 client" />
86 <TabPanel index={0} value={props.data.activeTab}>
88 <li>Open File Explorer</li>
89 <li>Click on "This PC", then go to Computer → Add a Network Location</li>
90 <li>Click Next, then choose "Add a custom network location", then click Next</li>
94 label='Internet address'
95 value={winDav.toString()}
96 copyValue={winDav.toString()} />
100 value={props.data.username}
101 copyValue={props.data.username} />
105 value={props.data.token}
106 copyValue={props.data.token} />
109 <TabPanel index={1} value={props.data.activeTab}>
112 <li>Select +Other Locations</li>
113 <li>Connect to Server → Enter server address</li>
117 label='Server address'
118 value={gnomeDav.toString()}
119 copyValue={gnomeDav.toString()} />
123 value={props.data.token}
124 copyValue={props.data.token} />
127 <TabPanel index={2} value={props.data.activeTab}>
130 value={s3endpoint.host}
131 copyValue={s3endpoint.host} />
135 value={props.data.uuid}
136 copyValue={props.data.uuid} />
141 copyValue={tokenUuid} />
146 copyValue={tokenSecret} />
155 onClick={props.closeDialog}>