17928: Adds storage classes checkboxes to collection create dialog.
[arvados-workbench2.git] / src / models / user.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Resource, ResourceKind } from 'models/resource';
6
7 export type UserPrefs = {
8     profile?: {
9         organization?: string,
10         organization_email?: string,
11         lab?: string,
12         website_url?: string,
13         role?: string
14     }
15 };
16
17 export interface User {
18     email: string;
19     firstName: string;
20     lastName: string;
21     uuid: string;
22     ownerUuid: string;
23     username: string;
24     prefs: UserPrefs;
25     isAdmin: boolean;
26     isActive: boolean;
27 }
28
29 export const getUserFullname = (user: User) => {
30     return user.firstName && user.lastName
31         ? `${user.firstName} ${user.lastName}`
32         : "";
33 };
34
35 export const getUserDisplayName = (user: User, withEmail = false) => {
36     const displayName = getUserFullname(user) || user.email || user.username || user.uuid;
37     if (withEmail && user.email && displayName !== user.email) {
38         return `${displayName} <<${user.email}>>`;
39     }
40     return displayName;
41 };
42
43 export interface UserResource extends Resource, User {
44     kind: ResourceKind.USER;
45     defaultOwnerUuid: string;
46     writableBy: string[];
47 }