X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f05e6a9cece7e3b118134136ee81bd7477ad10a0..9a59fad2b6a97af963728a5111395f9caa71802f:/src/models/group.ts diff --git a/src/models/group.ts b/src/models/group.ts index 4bb9a7fd..f6a72c53 100644 --- a/src/models/group.ts +++ b/src/models/group.ts @@ -2,21 +2,41 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { Resource } from "../common/api/common-resource-service"; -import { ResourceKind } from "./kinds"; +import { + ResourceKind, + ResourceWithProperties, + RESOURCE_UUID_REGEX, + ResourceObjectType, + TrashableResource +} from "./resource"; -export interface GroupResource extends Resource { - kind: ResourceKind.Group; +export interface GroupResource extends TrashableResource, ResourceWithProperties { + kind: ResourceKind.GROUP; name: string; groupClass: GroupClass | null; description: string; - properties: string; - writeableBy: string[]; - trashAt: string; - deleteAt: string; - isTrashed: boolean; + writableBy: string[]; + ensure_unique_name: boolean; } export enum GroupClass { - Project = "project" -} \ No newline at end of file + PROJECT = 'project', + FILTER = 'filter', + ROLE = 'role', +} + +export enum BuiltinGroups { + ALL = 'fffffffffffffff', + ANON = 'anonymouspublic', + SYSTEM = '000000000000000', +} + +export const getBuiltinGroupUuid = (cluster: string, groupName: BuiltinGroups): string => { + return cluster ? `${cluster}-${ResourceObjectType.GROUP}-${groupName}` : ""; +}; + +export const isBuiltinGroup = (uuid: string) => { + const match = RESOURCE_UUID_REGEX.exec(uuid); + const parts = match ? match[0].split('-') : []; + return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && Object.values(BuiltinGroups).includes(parts[2]); +};