Merge remote-tracking branch 'origin/main' into 18207-Workbench2-is-not-clearing...
[arvados-workbench2.git] / src / models / group.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ResourceKind, TrashableResource, ResourceObjectType, RESOURCE_UUID_REGEX } from "./resource";
6
7 export interface GroupResource extends TrashableResource {
8     kind: ResourceKind.GROUP;
9     name: string;
10     groupClass: GroupClass | null;
11     description: string;
12     properties: any;
13     writableBy: string[];
14     ensure_unique_name: boolean;
15 }
16
17 export enum GroupClass {
18     PROJECT = 'project',
19     FILTER  = 'filter',
20     ROLE  = 'role',
21 }
22
23 export const BUILTIN_GROUP_IDS = [
24     'fffffffffffffff',
25     'anonymouspublic',
26     '000000000000000',
27 ]
28
29 export const isBuiltinGroup = (uuid: string) => {
30     const match = RESOURCE_UUID_REGEX.exec(uuid);
31     const parts = match ? match[0].split('-') : [];
32     return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && BUILTIN_GROUP_IDS.includes(parts[2]);
33 };