mirror of
https://github.com/desktop/desktop
synced 2024-11-05 20:49:32 +00:00
🎨 cleanup
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
This commit is contained in:
parent
e7ebaa0d2e
commit
00b5a9e8a4
1 changed files with 17 additions and 24 deletions
|
@ -256,35 +256,28 @@ export class Avatar extends React.Component<IAvatarProps, IAvatarState> {
|
|||
this.state = { user, candidates, imageError: false }
|
||||
}
|
||||
|
||||
private getTitle(): string | JSX.Element | undefined {
|
||||
if (this.props.title === null) {
|
||||
return undefined
|
||||
private getTitle() {
|
||||
const { title, user, accounts } = this.props
|
||||
|
||||
if (title !== undefined) {
|
||||
return title
|
||||
}
|
||||
|
||||
if (this.props.title !== undefined) {
|
||||
return this.props.title
|
||||
}
|
||||
|
||||
const user = this.props.user
|
||||
if (user) {
|
||||
if (user.name) {
|
||||
return (
|
||||
<>
|
||||
<Avatar title={null} user={user} accounts={this.props.accounts} />
|
||||
if (user?.name) {
|
||||
return (
|
||||
<>
|
||||
<Avatar title={null} user={user} accounts={accounts} />
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<strong>{user.name}</strong>
|
||||
</div>
|
||||
<div>{user.email}</div>
|
||||
<strong>{user.name}</strong>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
return user.email
|
||||
}
|
||||
<div>{user.email}</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return 'Unknown user'
|
||||
return user?.email ?? 'Unknown user'
|
||||
}
|
||||
|
||||
private onImageError = (e: React.SyntheticEvent<HTMLImageElement>) => {
|
||||
|
@ -317,7 +310,7 @@ export class Avatar extends React.Component<IAvatarProps, IAvatarState> {
|
|||
<TooltippedContent
|
||||
className="avatar-container"
|
||||
tooltipClassName={this.props.title ? undefined : 'user-info'}
|
||||
tooltip={title}
|
||||
tooltip={title ?? undefined}
|
||||
direction={TooltipDirection.NORTH}
|
||||
tagName="div"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue