15781: Merge branch 'master' into 15781-multi-value-property-edit
[arvados-workbench2.git] / src / services / common-service / trashable-resource-service.ts
index 23e7366e9f69537aa0905e1a982c02943d3fb8bd..63be3ab866673ee98084579d48bd160734ffa5f4 100644 (file)
@@ -6,27 +6,32 @@ import * as _ from "lodash";
 import { AxiosInstance } from "axios";
 import { TrashableResource } from "src/models/resource";
 import { CommonResourceService } from "~/services/common-service/common-resource-service";
+import { ApiActions } from "~/services/api/api-actions";
 
 export class TrashableResourceService<T extends TrashableResource> extends CommonResourceService<T> {
 
-    constructor(serverApi: AxiosInstance, resourceType: string) {
-        super(serverApi, resourceType);
+    constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions, readOnlyFields: string[] = []) {
+        super(serverApi, resourceType, actions, readOnlyFields);
     }
 
     trash(uuid: string): Promise<T> {
-        return this.serverApi
-            .post(this.resourceType + `${uuid}/trash`)
-            .then(CommonResourceService.mapResponseKeys);
+        return CommonResourceService.defaultResponse(
+            this.serverApi
+                .post(this.resourceType + `/${uuid}/trash`),
+            this.actions
+        );
     }
 
     untrash(uuid: string): Promise<T> {
         const params = {
             ensure_unique_name: true
         };
-        return this.serverApi
-            .post(this.resourceType + `${uuid}/untrash`, {
-                params: CommonResourceService.mapKeys(_.snakeCase)(params)
-            })
-            .then(CommonResourceService.mapResponseKeys);
+        return CommonResourceService.defaultResponse(
+            this.serverApi
+                .post(this.resourceType + `/${uuid}/untrash`, {
+                    params: CommonResourceService.mapKeys(_.snakeCase)(params)
+                }),
+            this.actions
+        );
     }
 }