From ef925b80e9d4cb8d0c7e86c7bc0e642533eaf7b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Fri, 23 Apr 2021 13:00:11 +0200 Subject: [PATCH] 17415: Added path for ip based hostnames MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- cypress/integration/collection.spec.js | 1 + .../collections/collection-info-actions.ts | 5 +- .../webdav-s3-dialog/webdav-s3-dialog.tsx | 60 ++++++++++++------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js index 8da52d3a..e8fe1366 100644 --- a/cypress/integration/collection.spec.js +++ b/cypress/integration/collection.spec.js @@ -66,6 +66,7 @@ describe('Collection panel tests', function () { expect(map['Username']).to.equal(activeUser.user.username); expect(map['Port']).to.equal(port); expect(map['Hostname']).to.equal(host); + expect(map['Path']).to.equal(`/c=${testCollection.uuid}`); }); }) .then(() => cy.task('clearDownload', { filename })); diff --git a/src/store/collections/collection-info-actions.ts b/src/store/collections/collection-info-actions.ts index d874c322..5aa1cf80 100644 --- a/src/store/collections/collection-info-actions.ts +++ b/src/store/collections/collection-info-actions.ts @@ -7,6 +7,7 @@ import { RootState } from "~/store/store"; import { ServiceRepository } from "~/services/services"; import { dialogActions } from '~/store/dialog/dialog-actions'; import { getNewExtraToken } from "../auth/auth-action"; +import { CollectionResource } from "~/models/collection"; export const COLLECTION_WEBDAV_S3_DIALOG_NAME = 'collectionWebdavS3Dialog'; @@ -18,7 +19,7 @@ export interface WebDavS3InfoDialogData { localCluster: string; username: string; activeTab: number; - collectionName?: string; + collectionName: string; setActiveTab: (event: any, tabNr: number) => void; } @@ -35,7 +36,7 @@ export const openWebDavS3InfoDialog = (uuid: string, activeTab?: number) => localCluster: getState().auth.localCluster, username: getState().auth.user!.username, activeTab: activeTab || 0, - collectionName: (getState().collectionPanel.item || {} as any).name, + collectionName: (getState().resources[uuid] as CollectionResource).name, setActiveTab: (event: any, tabNr: number) => dispatch(openWebDavS3InfoDialog(uuid, tabNr)), uuid } 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 c1acfd80..d2d27c09 100644 --- a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx +++ b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx @@ -44,33 +44,47 @@ function TabPanel(props: TabPanelData) { ); } +const isValidIpAddress = (ipAddress: string): Boolean => { + console.log(ipAddress); + 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) => ` - - - - 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'); @@ -199,7 +213,7 @@ export const WebDavS3InfoDialog = compose( color='primary' size='small'> - Download config + Download Cyber/Mountain Duck bookmark

Gnome

-- 2.30.2