Merge branch '17754-federated-acct-merge'. Closes #17754.
[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 {
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     writableBy: string[];
19     ensure_unique_name: boolean;
20 }
21
22 export enum GroupClass {
23     PROJECT = 'project',
24     FILTER  = 'filter',
25     ROLE  = 'role',
26 }
27
28 export const BUILTIN_GROUP_IDS = [
29     'fffffffffffffff',
30     'anonymouspublic',
31     '000000000000000',
32 ]
33
34 export const isBuiltinGroup = (uuid: string) => {
35     const match = RESOURCE_UUID_REGEX.exec(uuid);
36     const parts = match ? match[0].split('-') : [];
37     return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && BUILTIN_GROUP_IDS.includes(parts[2]);
38 };