17415: Added path for ip based hostnames
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 23 Apr 2021 11:00:11 +0000 (13:00 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 23 Apr 2021 11:02:57 +0000 (13:02 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/collection.spec.js
src/store/collections/collection-info-actions.ts
src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx

index 8da52d3a7417ae50867585ba37f79e470d2a7529..e8fe13668253ae1c397364cfe100b3d6e3c197a4 100644 (file)
@@ -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 }));
index d874c322d068a4d9f3d2b779e2da1cb39b435e33..5aa1cf804666d68bb85b84c8868e4dfbc9144a3a 100644 (file)
@@ -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<any>(openWebDavS3InfoDialog(uuid, tabNr)),
                 uuid
             }
index c1acfd80b7241695ee4179949c4c60d0ccba412e..d2d27c09a57abc5248acaaeca14f943d98017978 100644 (file)
@@ -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) => `<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-   <dict>
-      <key>Protocol</key>
-      <string>davs</string>
-      <key>Provider</key>
-      <string>iterate GmbH</string>
-      <key>UUID</key>
-      <string>${uuid}</string>
-      <key>Hostname</key>
-      <string>${collectionsUrl.replace('https://', ``).replace('*', uuid).split(':')[0]}</string>
-      <key>Port</key>
-      <string>${(cyberDavStr.split(':')[2] || '443').split('/')[0]}</string>
-      <key>Username</key>
-      <string>${username}</string>
-      <key>Labels</key>
-      <array>
-      </array>
-   </dict>
-</plist>
-`.split(/\r?\n/).join('\n');
+}: any) => {
+    
+    return `<?xml version="1.0" encoding="UTF-8"?>
+        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+        <plist version="1.0">
+        <dict>
+            <key>Protocol</key>
+            <string>davs</string>
+            <key>Provider</key>
+            <string>iterate GmbH</string>
+            <key>UUID</key>
+            <string>${uuid}</string>
+            <key>Hostname</key>
+            <string>${collectionsUrl.replace('https://', ``).replace('*', uuid).split(':')[0]}</string>
+            <key>Port</key>
+            <string>${(cyberDavStr.split(':')[2] || '443').split('/')[0]}</string>
+            <key>Username</key>
+            <string>${username}</string>${isValidIpAddress(collectionsUrl.replace('https://', ``).split(':')[0])? 
+            `
+            <key>Path</key>
+            <string>/c=${uuid}</string>` : ''}
+            <key>Labels</key>
+            <array>
+            </array>
+        </dict>
+        </plist>`.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'>
                         <DownloadIcon />
-                        Download config
+                        Download Cyber/Mountain Duck bookmark
                     </Button>
 
                     <h3>Gnome</h3>