15814: Now handles secret inputs properly.
[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     // Optional local-only field, undefined for not loaded, null for failed to load
22     memberCount?: number | null;
23 }
24
25 export enum GroupClass {
26     PROJECT = 'project',
27     FILTER = 'filter',
28     ROLE = 'role',
29 }
30
31 export enum BuiltinGroups {
32     ALL = 'fffffffffffffff',
33     ANON = 'anonymouspublic',
34     SYSTEM = '000000000000000',
35 }
36
37 export const getBuiltinGroupUuid = (cluster: string, groupName: BuiltinGroups): string => {
38     return cluster ? `${cluster}-${ResourceObjectType.GROUP}-${groupName}` : "";
39 };
40
41 export const isBuiltinGroup = (uuid: string) => {
42     const match = RESOURCE_UUID_REGEX.exec(uuid);
43     const parts = match ? match[0].split('-') : [];
44     return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && Object.values<string>(BuiltinGroups).includes(parts[2]);
45 };
46
47 export const selectedFieldsOfGroup = [
48     "uuid",
49     "name",
50     "group_class",
51     "description",
52     "properties",
53     "can_write",
54     "can_manage",
55     "trash_at",
56     "delete_at",
57     "is_trashed",
58     "frozen_by_uuid"
59 ];