Merge branch '14436-bugfix-expanding-collection-files-tree'
[arvados.git] / src / services / collection-service / collection-service.ts
index eb48e9dcb02a5e504ee061e9aa66c3854ed636a8..00ba85478bedcac9665a64087b913e3ef3a11e5d 100644 (file)
@@ -50,10 +50,15 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         );
     }
 
-    private extendFileURL = (file: CollectionDirectory | CollectionFile) => ({
-        ...file,
-        url: this.webdavClient.defaults.baseURL + file.url + '?api_token=' + this.authService.getApiToken()
-    })
+    private extendFileURL = (file: CollectionDirectory | CollectionFile) => {
+        const baseUrl = this.webdavClient.defaults.baseURL.endsWith('/')
+            ? this.webdavClient.defaults.baseURL.slice(0, -1)
+            : this.webdavClient.defaults.baseURL;
+        return {
+            ...file,
+            url: baseUrl + file.url + '?api_token=' + this.authService.getApiToken()
+        };
+    }
 
     private async uploadFile(collectionUuid: string, file: File, fileId: number, onProgress: UploadProgress = () => { return; }) {
         const fileURL = `c=${collectionUuid}/${file.name}`;
@@ -70,23 +75,20 @@ export class CollectionService extends TrashableResourceService<CollectionResour
 
     }
 
-    // ToDo: add get method
-
     update(uuid: string, data: Partial<CollectionResource>) {
-        if (uuid && data) {
+        if (uuid && data && data.properties) {
             const { properties } = data;
-            if (properties) {
-                const mappedData = {
-                    ...TrashableResourceService.mapKeys(snakeCase)(data),
-                    properties,
-                };
-                return TrashableResourceService
-                    .defaultResponse(
-                        this.serverApi
-                            .put<CollectionResource>(this.resourceType + uuid, mappedData),
-                        this.actions
-                    );
-            }
+            const mappedData = {
+                ...TrashableResourceService.mapKeys(snakeCase)(data),
+                properties,
+            };
+            return TrashableResourceService
+                .defaultResponse(
+                    this.serverApi
+                        .put<CollectionResource>(this.resourceType + uuid, mappedData),
+                    this.actions,
+                    false
+                );
         }
         return TrashableResourceService
             .defaultResponse(