File tree 5 files changed +21
-14
lines changed
5 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class DesktopHeader extends React.Component {
31
31
< Menu transitionClassName = "menu-dropdown" transitionTimeout = { 250 } >
32
32
< MenuTrigger
33
33
tag = "button"
34
- aria-label = { intl . formatMessage ( messages [ 'header.label.account.menu.with .username' ] , { username } ) }
34
+ aria-label = { intl . formatMessage ( messages [ 'header.label.account.menu.using .username' ] , { username } ) }
35
35
className = "btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3"
36
36
>
37
37
< Avatar size = "1.5em" src = { avatar } alt = "" className = "mr-2" />
@@ -58,7 +58,7 @@ class DesktopHeader extends React.Component {
58
58
< Menu transitionClassName = "menu-dropdown" transitionTimeout = { 250 } >
59
59
< MenuTrigger
60
60
tag = "button"
61
- aria-label = { intl . formatMessage ( messages [ 'header.label.account.menu.without.username ' ] , { name } ) }
61
+ aria-label = { intl . formatMessage ( messages [ 'header.label.account.menu.using.name ' ] , { name } ) }
62
62
className = "btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3"
63
63
>
64
64
< Avatar size = "1.5em" src = { avatar } alt = "" className = "mr-2" />
Original file line number Diff line number Diff line change @@ -76,13 +76,13 @@ const messages = defineMessages({
76
76
defaultMessage : 'Account Menu' ,
77
77
description : 'The aria label for the account menu trigger' ,
78
78
} ,
79
- 'header.label.account.menu.with .username' : {
80
- id : 'header.label.account.menu.with .username' ,
79
+ 'header.label.account.menu.using .username' : {
80
+ id : 'header.label.account.menu.using .username' ,
81
81
defaultMessage : 'Account menu for {username}' ,
82
82
description : 'The aria label for the account menu trigger when the username is displayed in it' ,
83
83
} ,
84
- 'header.label.account.menu.without.username ' : {
85
- id : 'header.label.account.without.username ' ,
84
+ 'header.label.account.menu.using.name ' : {
85
+ id : 'header.label.account.using.name ' ,
86
86
defaultMessage : 'Account menu for {name}' ,
87
87
description : 'The aria label for the account menu trigger when ENABLE_HEADER_WITHOUT_USERNAME is enabled' ,
88
88
} ,
Original file line number Diff line number Diff line change @@ -22,11 +22,13 @@ const AuthenticatedUserDropdown = ({
22
22
const showDropdownToggle = (
23
23
< Dropdown . Toggle variant = "outline-primary" >
24
24
< FontAwesomeIcon icon = { faUserCircle } className = "d-md-none" size = "lg" />
25
- { ! getConfig ( ) . ENABLE_HEADER_WITHOUT_USERNAME ? (
25
+ { getConfig ( ) . ENABLE_HEADER_WITHOUT_USERNAME ? (
26
+ < Avatar size = "sm" src = { avatar } alt = { name } className = "mr-2" />
27
+ ) : (
26
28
< span data-hj-suppress className = "d-none d-md-inline" data-testid = "username" >
27
29
{ username }
28
30
</ span >
29
- ) : < Avatar size = "sm" src = { avatar } alt = { name } className = "mr-2" /> }
31
+ ) }
30
32
</ Dropdown . Toggle >
31
33
) ;
32
34
Original file line number Diff line number Diff line change 1
1
/* eslint-disable react/prop-types */
2
2
import React , { useMemo } from 'react' ;
3
+ import { getConfig , mergeConfig } from '@edx/frontend-platform' ;
3
4
import {
4
5
render ,
5
6
fireEvent ,
@@ -128,9 +129,13 @@ describe('Header', () => {
128
129
expect ( avatarIcon ) . toBeVisible ( ) ;
129
130
} ) ;
130
131
131
- it . only ( 'user menu should not contain username' , async ( ) => {
132
- const newProps = { ...props , ENABLE_HEADER_WITHOUT_USERNAME : true } ;
133
- const { container } = render ( < RootWrapper { ...newProps } /> ) ;
132
+ it ( 'user menu should not contain username' , async ( ) => {
133
+ const config = getConfig ( ) ;
134
+ mergeConfig ( {
135
+ ...config ,
136
+ ENABLE_HEADER_WITHOUT_USERNAME : true ,
137
+ } ) ;
138
+ const { container } = render ( < RootWrapper { ...props } /> ) ;
134
139
const userMenue = container . querySelector ( '#user-dropdown-menu' ) ;
135
140
expect ( userMenue . textContent ) . toContain ( '' ) ;
136
141
} ) ;
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ const UserMenu = ({
19
19
// injected
20
20
intl,
21
21
} ) => {
22
- const showUsername = ! getConfig ( ) . ENABLE_HEADER_WITHOUT_USERNAME ;
23
- const avatarAlt = showUsername ? username : name ;
22
+ const hideUsername = getConfig ( ) . ENABLE_HEADER_WITHOUT_USERNAME ;
23
+ const avatarAlt = hideUsername ? name : username ;
24
24
const avatar = authenticatedUserAvatar ? (
25
25
< img
26
26
className = "d-block w-100 h-100"
@@ -36,7 +36,7 @@ const UserMenu = ({
36
36
data-testid = "avatar-icon"
37
37
/>
38
38
) ;
39
- const title = isMobile ? avatar : < > { avatar } { showUsername && username } </ > ;
39
+ const title = ( isMobile || hideUsername ) ? avatar : < > { avatar } { username } </ > ;
40
40
41
41
return (
42
42
< NavDropdownMenu
You can’t perform that action at this time.
0 commit comments