1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { GroupsService } from "~/services/groups-service/groups-service";
6 import { UserService } from '../user-service/user-service';
7 import { GroupResource } from '~/models/group';
8 import { UserResource } from '~/models/user';
9 import { extractUuidObjectType, ResourceObjectType, TrashableResource } from "~/models/resource";
11 export class AncestorService {
13 private groupsService: GroupsService,
14 private userService: UserService
17 async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
18 const service = this.getService(extractUuidObjectType(uuid));
21 const resource = await service.get(uuid);
22 if (uuid === rootUuid) {
26 ...await this.ancestors(resource.ownerUuid, rootUuid),
38 private getService = (objectType?: string) => {
40 case ResourceObjectType.GROUP:
41 return this.groupsService;
42 case ResourceObjectType.USER:
43 return this.userService;