16212: Uses getUserDisplayName() wherever needed to show a user's name.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 24 Apr 2020 20:55:34 +0000 (17:55 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 29 Apr 2020 20:24:36 +0000 (17:24 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/models/user.test.ts
src/store/collections-content-address-panel/collections-content-address-middleware-service.ts
src/views-components/advanced-tab-dialog/metadataTab.tsx
src/views-components/user-dialog/manage-dialog.tsx

index d313ef4eb265f5252c491588a9d724245c6fea1e..baa86da91bb7bef06ba70319f777149e7fff29eb 100644 (file)
@@ -5,10 +5,6 @@
 import { User, getUserDisplayName } from './user';
 
 describe('User', () => {
-
-    beforeEach(() => {
-    });
-
     it('gets the user display name', () => {
         type UserCase = {
             caseName: string;
index dc0f2c52c3cb10ef1db17f9d6885fec5683477b8..72da1d2e0144927395175ad4739f227b9cb02071 100644 (file)
@@ -24,6 +24,7 @@ import { updatePublicFavorites } from '~/store/public-favorites/public-favorites
 import { setBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
 import { ResourceKind, extractUuidKind } from '~/models/resource';
 import { ownerNameActions } from '~/store/owner-name/owner-name-actions';
+import { getUserDisplayName } from '~/models/user';
 
 export class CollectionsWithSameContentAddressMiddlewareService extends DataExplorerMiddlewareService {
     constructor(private services: ServiceRepository, id: string) {
@@ -90,7 +91,11 @@ export class CollectionsWithSameContentAddressMiddlewareService extends DataExpl
                         .getFilters()
                 });
                 responseUsers.items.map(it => {
-                    api.dispatch<any>(ownerNameActions.SET_OWNER_NAME({ name: it.uuid === userUuid ? 'User: Me' : `User: ${it.firstName} ${it.lastName}`, uuid: it.uuid }));
+                    api.dispatch<any>(ownerNameActions.SET_OWNER_NAME({
+                        name: it.uuid === userUuid
+                            ? 'User: Me'
+                            : `User: ${getUserDisplayName(it)}`,
+                        uuid: it.uuid }));
                 });
                 responseGroups.items.map(it => {
                     api.dispatch<any>(ownerNameActions.SET_OWNER_NAME({ name: `Project: ${it.name}`, uuid: it.uuid }));
index bcf277c0b1d963d238e63e6fc2a14085ce676397..467501a77f874c8fa66c1fde15a7f00a190c33ae 100644 (file)
@@ -4,7 +4,7 @@
 
 import * as React from "react";
 import { Table, TableHead, TableCell, TableRow, TableBody, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { UserResource } from "~/models/user";
+import { UserResource, getUserDisplayName } from "~/models/user";
 
 type CssRules = 'cell';
 
@@ -47,7 +47,7 @@ export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles
                     <TableCell className={props.classes.cell}>{it.uuid}</TableCell>
                     <TableCell className={props.classes.cell}>{it.linkClass}</TableCell>
                     <TableCell className={props.classes.cell}>{it.name}</TableCell>
-                    <TableCell className={props.classes.cell}>{props.user && `User: ${props.user.firstName} ${props.user.lastName}`}</TableCell>
+                    <TableCell className={props.classes.cell}>{props.user && `User: ${getUserDisplayName(props.user)}`}</TableCell>
                     <TableCell className={props.classes.cell}>{it.headUuid === props.uuid ? 'this' : it.headUuid}</TableCell>
                     <TableCell className={props.classes.cell}>{JSON.stringify(it.properties)}</TableCell>
                 </TableRow>
index 05e4a3fc091b5d71943f42adaa6da3e9110f05e9..f1f0b6ce8580162582d2e12dd1faf9a92cc33c96 100644 (file)
@@ -3,14 +3,15 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
+import { compose, Dispatch } from "redux";
+import { connect } from "react-redux";
 import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
 import { WithDialogProps } from "~/store/dialog/with-dialog";
 import { withDialog } from '~/store/dialog/with-dialog';
 import { WithStyles, withStyles } from '@material-ui/core/styles';
 import { ArvadosTheme } from '~/common/custom-theme';
-import { compose, Dispatch } from "redux";
 import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
-import { connect } from "react-redux";
+import { getUserDisplayName } from "~/models/user";
 
 type CssRules = 'spacing';
 
@@ -48,19 +49,19 @@ export const UserManageDialog = compose(
                 maxWidth="md">
                 {props.data &&
                     <span>
-                        <DialogTitle>{`Manage - ${props.data.firstName} ${props.data.lastName}`}</DialogTitle>
+                        <DialogTitle>{`Manage - ${getUserDisplayName(props.data)}`}</DialogTitle>
                         <DialogContent>
                             <Typography variant='body1' className={props.classes.spacing}>
                                 As an admin, you can log in as this user. When you’ve finished, you will need to log out and log in again with your own account.
                     </Typography>
                             <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.uuid)}>
-                                {`LOG IN AS ${props.data.firstName} ${props.data.lastName}`}
+                                {`LOG IN AS ${getUserDisplayName(props.data)}`}
                             </Button>
                             <Typography variant='body1' className={props.classes.spacing}>
                                 As an admin, you can setup a shell account for this user. The login name is automatically generated from the user's e-mail address.
                     </Typography>
                             <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
-                                {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
+                                {`SETUP SHELL ACCOUNT FOR ${getUserDisplayName(props.data)}`}
                             </Button>
                         </DialogContent></span>}