Merge branch '14841-link-workbench1' refs #14841 refs #14720
[arvados-workbench2.git] / src / services / collection-service / collection-service.ts
index b0d5cb1445db854e8d88d43e10c95a6b59e80569..f7e25541fd06bf1702abfb3513ade63359e3d6d7 100644 (file)
@@ -32,7 +32,12 @@ export class CollectionService extends TrashableResourceService<CollectionResour
 
     async deleteFiles(collectionUuid: string, filePaths: string[]) {
         for (const path of filePaths) {
-            await this.webdavClient.delete(`c=${collectionUuid}${path}`);
+            const splittedPath = path.split('/');
+            if (collectionUuid) {
+                await this.webdavClient.delete(`c=${collectionUuid}/${splittedPath[1]}`);
+            } else {
+                await this.webdavClient.delete(`c=${collectionUuid}${path}`);
+            }
         }
     }
 
@@ -54,9 +59,14 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         const baseUrl = this.webdavClient.defaults.baseURL.endsWith('/')
             ? this.webdavClient.defaults.baseURL.slice(0, -1)
             : this.webdavClient.defaults.baseURL;
+        const apiToken = this.authService.getApiToken();
+        const splittedApiToken = apiToken ? apiToken.split('/') : [];
+        const userApiToken = `/t=${splittedApiToken[2]}/`;
+        const splittedPrevFileUrl = file.url.split('/');
+        const url = `${baseUrl}/${splittedPrevFileUrl[1]}${userApiToken}${splittedPrevFileUrl[2]}`;
         return {
             ...file,
-            url: baseUrl + file.url + '?api_token=' + this.authService.getApiToken()
+            url
         };
     }