Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / services / common-service / trashable-resource-service.ts
index 92e02734806a5b2716453d3a6905ba9de5b1be4d..5e4704b64d7020852e5d314b18bb3270403c8fb8 100644 (file)
@@ -2,36 +2,32 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as _ from "lodash";
+import { snakeCase } from "lodash";
 import { AxiosInstance } from "axios";
-import { TrashableResource } from "src/models/resource";
-import { CommonResourceService } from "~/services/common-service/common-resource-service";
-import { ProgressFn } from "~/services/api/api-progress";
+import { TrashableResource } from "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, progressFn: ProgressFn) {
-        super(serverApi, resourceType, progressFn);
+    constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions, readOnlyFields: string[] = []) {
+        super(serverApi, resourceType, actions, readOnlyFields);
     }
 
     trash(uuid: string): Promise<T> {
-        return CommonResourceService.defaultResponse(
-            this.serverApi
-                .post(this.resourceType + `${uuid}/trash`),
-            this.progressFn
-        );
+        return CommonResourceService.defaultResponse(this.serverApi.post(this.resourceType + `/${uuid}/trash`), this.actions);
     }
 
     untrash(uuid: string): Promise<T> {
         const params = {
-            ensure_unique_name: true
+            ensure_unique_name: true,
         };
         return CommonResourceService.defaultResponse(
-            this.serverApi
-                .post(this.resourceType + `${uuid}/untrash`, {
-                    params: CommonResourceService.mapKeys(_.snakeCase)(params)
-                }),
-            this.progressFn
+            this.serverApi.post(this.resourceType + `/${uuid}/untrash`, {
+                params: CommonResourceService.mapKeys(snakeCase)(params),
+            }),
+            this.actions,
+            undefined,
+            false
         );
     }
 }