21359: corrected owneruuid passed to creatproject function Arvados-DCO-1.1-Signed...
[arvados.git] / services / workbench2 / src / models / group.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import {
6     ResourceKind,
7     ResourceWithProperties,
8     RESOURCE_UUID_REGEX,
9     ResourceObjectType,
10     TrashableResource
11 } from "./resource";
12
13 export interface GroupResource extends TrashableResource, ResourceWithProperties {
14     kind: ResourceKind.GROUP;
15     name: string;
16     groupClass: GroupClass | null;
17     description: string;
18     ensure_unique_name: boolean;
19     canWrite: boolean;
20     canManage: boolean;
21 }
22
23 export enum GroupClass {
24     PROJECT = 'project',
25     FILTER = 'filter',
26     ROLE = 'role',
27 }
28
29 export enum BuiltinGroups {
30     ALL = 'fffffffffffffff',
31     ANON = 'anonymouspublic',
32     SYSTEM = '000000000000000',
33 }
34
35 export const getBuiltinGroupUuid = (cluster: string, groupName: BuiltinGroups): string => {
36     return cluster ? `${cluster}-${ResourceObjectType.GROUP}-${groupName}` : "";
37 };
38
39 export const isBuiltinGroup = (uuid: string) => {
40     const match = RESOURCE_UUID_REGEX.exec(uuid);
41     const parts = match ? match[0].split('-') : [];
42     return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && Object.values<string>(BuiltinGroups).includes(parts[2]);
43 };
44
45 export const selectedFieldsOfGroup = [
46     "uuid",
47     "name",
48     "group_class",
49     "description",
50     "properties",
51     "can_write",
52     "can_manage",
53     "trash_at",
54     "delete_at",
55     "is_trashed",
56     "frozen_by_uuid"
57 ];