Skip to content

Commit f0f1eb6

Browse files
authored
feat(global-header): add profile picture to the display name (#737)
1 parent 5707843 commit f0f1eb6

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-global-header': minor
3+
---
4+
5+
Added avatar to the Profile dropdown

workspaces/global-header/plugins/global-header/src/components/HeaderDropdownComponent/ProfileDropdown.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
1818
import { useUserProfile } from '@backstage/plugin-user-settings';
1919
import AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';
2020
import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';
21+
import Avatar from '@mui/material/Avatar';
2122
import Typography from '@mui/material/Typography';
2223
import { lighten } from '@mui/material/styles';
2324
import Box from '@mui/material/Box';
@@ -36,7 +37,7 @@ export interface ProfileDropdownProps {
3637

3738
export const ProfileDropdown = ({ layout }: ProfileDropdownProps) => {
3839
const { anchorEl, handleOpen, handleClose } = useDropdownManager();
39-
const { displayName } = useUserProfile();
40+
const { displayName, profile } = useUserProfile();
4041

4142
const profileDropdownMountPoints = useProfileDropdownMountPoints();
4243

@@ -82,7 +83,15 @@ export const ProfileDropdown = ({ layout }: ProfileDropdownProps) => {
8283
<Box sx={{ display: 'flex', alignItems: 'center', ...layout }}>
8384
{displayName && (
8485
<>
85-
<AccountCircleOutlinedIcon fontSize="small" sx={{ mr: 1 }} />
86+
{profile.picture ? (
87+
<Avatar
88+
src={profile.picture}
89+
sx={{ mr: 2, height: '32px', width: '32px' }}
90+
alt="Profile picture"
91+
/>
92+
) : (
93+
<AccountCircleOutlinedIcon fontSize="small" sx={{ mr: 1 }} />
94+
)}
8695
<Typography
8796
variant="body2"
8897
sx={{

0 commit comments

Comments
 (0)