From 075dd4fd268311d5e28029ad3372cd5efb000c4d Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Fri, 24 Apr 2020 17:55:34 -0300 Subject: [PATCH] 16212: Uses getUserDisplayName() wherever needed to show a user's name. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/models/user.test.ts | 4 ---- .../collections-content-address-middleware-service.ts | 7 ++++++- .../advanced-tab-dialog/metadataTab.tsx | 4 ++-- src/views-components/user-dialog/manage-dialog.tsx | 11 ++++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/models/user.test.ts b/src/models/user.test.ts index d313ef4e..baa86da9 100644 --- a/src/models/user.test.ts +++ b/src/models/user.test.ts @@ -5,10 +5,6 @@ import { User, getUserDisplayName } from './user'; describe('User', () => { - - beforeEach(() => { - }); - it('gets the user display name', () => { type UserCase = { caseName: string; diff --git a/src/store/collections-content-address-panel/collections-content-address-middleware-service.ts b/src/store/collections-content-address-panel/collections-content-address-middleware-service.ts index dc0f2c52..72da1d2e 100644 --- a/src/store/collections-content-address-panel/collections-content-address-middleware-service.ts +++ b/src/store/collections-content-address-panel/collections-content-address-middleware-service.ts @@ -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(ownerNameActions.SET_OWNER_NAME({ name: it.uuid === userUuid ? 'User: Me' : `User: ${it.firstName} ${it.lastName}`, uuid: it.uuid })); + api.dispatch(ownerNameActions.SET_OWNER_NAME({ + name: it.uuid === userUuid + ? 'User: Me' + : `User: ${getUserDisplayName(it)}`, + uuid: it.uuid })); }); responseGroups.items.map(it => { api.dispatch(ownerNameActions.SET_OWNER_NAME({ name: `Project: ${it.name}`, uuid: it.uuid })); diff --git a/src/views-components/advanced-tab-dialog/metadataTab.tsx b/src/views-components/advanced-tab-dialog/metadataTab.tsx index bcf277c0..467501a7 100644 --- a/src/views-components/advanced-tab-dialog/metadataTab.tsx +++ b/src/views-components/advanced-tab-dialog/metadataTab.tsx @@ -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 {it.uuid} {it.linkClass} {it.name} - {props.user && `User: ${props.user.firstName} ${props.user.lastName}`} + {props.user && `User: ${getUserDisplayName(props.user)}`} {it.headUuid === props.uuid ? 'this' : it.headUuid} {JSON.stringify(it.properties)} diff --git a/src/views-components/user-dialog/manage-dialog.tsx b/src/views-components/user-dialog/manage-dialog.tsx index 05e4a3fc..f1f0b6ce 100644 --- a/src/views-components/user-dialog/manage-dialog.tsx +++ b/src/views-components/user-dialog/manage-dialog.tsx @@ -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 && - {`Manage - ${props.data.firstName} ${props.data.lastName}`} + {`Manage - ${getUserDisplayName(props.data)}`} 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. 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. } -- 2.30.2