X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a353970c1fcfc61ebac8b3587f4b16b6c25b62e1..64c1e51d2d973cb0ef0f982afbb80efdb2700ea0:/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx?ds=sidebyside diff --git a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx index 018a0ef0..73c89621 100644 --- a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx +++ b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx @@ -2,20 +2,24 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from "react"; +import React from "react"; import { Dialog, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles, CardHeader, Tab, Tabs } from '@material-ui/core'; -import { withDialog } from "~/store/dialog/with-dialog"; -import { COLLECTION_WEBDAV_S3_DIALOG_NAME, WebDavS3InfoDialogData } from '~/store/collections/collection-info-actions'; -import { WithDialogProps } from '~/store/dialog/with-dialog'; +import { withDialog } from "store/dialog/with-dialog"; +import { COLLECTION_WEBDAV_S3_DIALOG_NAME, WebDavS3InfoDialogData } from 'store/collections/collection-info-actions'; +import { WithDialogProps } from 'store/dialog/with-dialog'; import { compose } from 'redux'; -import { DetailsAttribute } from "~/components/details-attribute/details-attribute"; +import { DetailsAttribute } from "components/details-attribute/details-attribute"; +import { DownloadIcon } from "components/icon/icon"; -export type CssRules = 'details'; +export type CssRules = 'details' | 'downloadButton'; const styles: StyleRulesCallback = theme => ({ details: { marginLeft: theme.spacing.unit * 3, marginRight: theme.spacing.unit * 3, + }, + downloadButton: { + marginTop: theme.spacing.unit * 2, } }); @@ -40,6 +44,60 @@ function TabPanel(props: TabPanelData) { ); } +const isValidIpAddress = (ipAddress: string): Boolean => { + if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipAddress)) { + return true; + } + + return false; +}; + +const mountainduckTemplate = ({ + uuid, + username, + cyberDavStr, + collectionsUrl +}: any) => { + + return ` + + + + Protocol + davs + Provider + iterate GmbH + UUID + ${uuid} + Hostname + ${collectionsUrl.replace('https://', ``).replace('*', uuid).split(':')[0]} + Port + ${(cyberDavStr.split(':')[2] || '443').split('/')[0]} + Username + ${username}${isValidIpAddress(collectionsUrl.replace('https://', ``).split(':')[0])? + ` + Path + /c=${uuid}` : ''} + Labels + + + + `.split(/\r?\n/).join('\n'); +}; + +const downloadMountainduckFileHandler = (filename: string, text: string) => { + const element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); +}; + export const WebDavS3InfoDialog = compose( withDialog(COLLECTION_WEBDAV_S3_DIALOG_NAME), withStyles(styles), @@ -77,25 +135,28 @@ export const WebDavS3InfoDialog = compose( tokenSecret = tokenUuid; } - const supportsWebdav = (props.data.uuid.indexOf("-4zz18-") === 5); + const isCollection = (props.data.uuid.indexOf("-4zz18-") === 5); let activeTab = props.data.activeTab; - if (!supportsWebdav) { + if (!isCollection) { activeTab = 2; } + const wgetCommand = `wget --http-user=${props.data.username} --http-passwd=${props.data.token} --mirror --no-parent --no-host --cut-dirs=0 ${winDav.toString()}`; + return + title={`Open with 3rd party client`} />
- {supportsWebdav && } - {supportsWebdav && } + {isCollection && } + {isCollection && } + {isCollection && } @@ -103,7 +164,7 @@ export const WebDavS3InfoDialog = compose( {winDav.toString()}} + value={{winDav.toString()}} copyValue={winDav.toString()} /> Open File Explorer
  • Click on "This PC", then go to Computer → Add a Network Location
  • Click Next, then choose "Add a custom network location", then click Next
  • +
  • Use the "internet address" and credentials listed under Settings, above
  • MacOS

    1. Open Finder
    2. Click Go → Connect to server
    3. +
    4. Use the "internet address" and credentials listed under Settings, above
    {cyberDavStr}} + value={{cyberDavStr}} copyValue={cyberDavStr} /> +

    Cyberduck/Mountain Duck

    + + +

    Gnome

    1. Open Files
    2. @@ -178,6 +254,25 @@ export const WebDavS3InfoDialog = compose( + + + + + + + + + +