19294: Only show cluster id part of uuid in participant select chip tooltip 19294-sharing-dialog-overflow
authorStephen Smith <stephen@curii.com>
Fri, 10 Feb 2023 20:10:33 +0000 (15:10 -0500)
committerStephen Smith <stephen@curii.com>
Fri, 10 Feb 2023 20:10:33 +0000 (15:10 -0500)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/models/user.ts

index 6d66d9d32829fa39e6f8bb91fbd3d3f006272e0e..87a2e8c13d472200bfdd97ebf333ed6defe8f57f 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Resource, ResourceKind } from 'models/resource';
+import { Resource, ResourceKind, RESOURCE_UUID_REGEX } from 'models/resource';
 
 export type UserPrefs = {
     profile?: {
@@ -46,12 +46,19 @@ export const getUserDisplayName = (user: User, withEmail = false, withUuid = fal
 
 export const getUserDetailsString = (user: User) => {
     let parts: string[] = [];
+    const userCluster = getUserClusterID(user);
     user.username.length && parts.push(user.username);
     user.email.length && parts.push(`<${user.email}>`);
-    user.uuid.length && parts.push(`(${user.uuid})`);
+    userCluster && userCluster.length && parts.push(`(${userCluster})`);
     return parts.join(' ');
 };
 
+export const getUserClusterID = (user: User): string | undefined => {
+    const match = RESOURCE_UUID_REGEX.exec(user.uuid);
+    const parts = match ? match[0].split('-') : [];
+    return parts.length === 3 ? parts[0] : undefined;
+};
+
 export interface UserResource extends Resource, User {
     kind: ResourceKind.USER;
     defaultOwnerUuid: string;