X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/59ee572e791985a36bdd2015c9b494145109e8ed..5e9c2244747eff9fc02ff3c0d140bdde5e0b6845:/src/services/common-service/trashable-resource-service.ts diff --git a/src/services/common-service/trashable-resource-service.ts b/src/services/common-service/trashable-resource-service.ts index 23e7366e..4d6b130b 100644 --- a/src/services/common-service/trashable-resource-service.ts +++ b/src/services/common-service/trashable-resource-service.ts @@ -2,31 +2,36 @@ // // 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 { TrashableResource } from "models/resource"; +import { CommonResourceService } from "services/common-service/common-resource-service"; +import { ApiActions } from "services/api/api-actions"; export class TrashableResourceService extends CommonResourceService { - 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 { - 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 { 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 + ); } }