Merge remote-tracking branch 'origin/main' into 18207-Workbench2-is-not-clearing...
[arvados-workbench2.git] / src / models / group.ts
index e13fbcbf05da2cb9584e21149020d3447350c0cd..3f3656ccd5fba90bcfb6a037c73ce0420c4c343c 100644 (file)
@@ -2,17 +2,37 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { ResourceKind, TrashableResource } from "./resource";
+import {
+    ResourceKind,
+    ResourceWithProperties,
+    RESOURCE_UUID_REGEX,
+    ResourceObjectType,
+    TrashableResource
+} from "./resource";
 
-export interface GroupResource extends TrashableResource {
+export interface GroupResource extends TrashableResource, ResourceWithProperties {
     kind: ResourceKind.GROUP;
     name: string;
     groupClass: GroupClass | null;
     description: string;
-    properties: any;
-    writeableBy: string[];
+    writableBy: string[];
+    ensure_unique_name: boolean;
 }
 
 export enum GroupClass {
-    PROJECT = "project"
+    PROJECT = 'project',
+    FILTER  = 'filter',
+    ROLE  = 'role',
 }
+
+export const BUILTIN_GROUP_IDS = [
+    'fffffffffffffff',
+    'anonymouspublic',
+    '000000000000000',
+]
+
+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 && BUILTIN_GROUP_IDS.includes(parts[2]);
+};