X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a7c16589e1ae08addbd6a9aee75d5f90c1704e5c..576f56d6e525eebebe19d1f1bdc8aaf8703e6f1b:/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
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 c1acfd80b7..39c1068ecf 100644
--- a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
+++ b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
@@ -2,14 +2,14 @@
//
// 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 { DownloadIcon } from "~/components/icon/icon";
+import { DetailsAttribute } from "components/details-attribute/details-attribute";
+import { DownloadIcon } from "components/icon/icon";
export type CssRules = 'details' | 'downloadButton';
@@ -44,44 +44,57 @@ 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,
+ uuid,
username,
cyberDavStr,
collectionsUrl
-}: any) => `
-
-
-
- Protocol
- davs
- Provider
- iterate GmbH
- UUID
- ${uuid}
- Hostname
- ${collectionsUrl.replace('https://', ``).replace('*', uuid).split(':')[0]}
- Port
- ${(cyberDavStr.split(':')[2] || '443').split('/')[0]}
- Username
- ${username}
- Labels
-
-
-
-
-`.split(/\r?\n/).join('\n');
+}: 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);
};
@@ -148,7 +161,7 @@ export const WebDavS3InfoDialog = compose(
{winDav.toString()}}
+ value={{winDav.toString()}}
copyValue={winDav.toString()} />
{cyberDavStr}}
+ value={{cyberDavStr}}
copyValue={cyberDavStr} />
- Download config
+ Download Cyber/Mountain Duck bookmark
Gnome