File tree Expand file tree Collapse file tree 5 files changed +21
-14
lines changed Expand file tree Collapse file tree 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 {
3131      < Menu  transitionClassName = "menu-dropdown"  transitionTimeout = { 250 } > 
3232        < MenuTrigger 
3333          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 } ) } 
3535          className = "btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3" 
3636        > 
3737          < Avatar  size = "1.5em"  src = { avatar }  alt = ""  className = "mr-2"  /> 
@@ -58,7 +58,7 @@ class DesktopHeader extends React.Component {
5858      < Menu  transitionClassName = "menu-dropdown"  transitionTimeout = { 250 } > 
5959        < MenuTrigger 
6060          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 } ) } 
6262          className = "btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3" 
6363        > 
6464          < 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({
7676    defaultMessage : 'Account Menu' , 
7777    description : 'The aria label for the account menu trigger' , 
7878  } , 
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' , 
8181    defaultMessage : 'Account menu for {username}' , 
8282    description : 'The aria label for the account menu trigger when the username is displayed in it' , 
8383  } , 
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 ' , 
8686    defaultMessage : 'Account menu for {name}' , 
8787    description : 'The aria label for the account menu trigger when ENABLE_HEADER_WITHOUT_USERNAME is enabled' , 
8888  } , 
Original file line number Diff line number Diff line change @@ -22,11 +22,13 @@ const AuthenticatedUserDropdown = ({
2222  const  showDropdownToggle  =  ( 
2323    < Dropdown . Toggle  variant = "outline-primary" > 
2424      < 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+       )  : ( 
2628        < span  data-hj-suppress  className = "d-none d-md-inline"  data-testid = "username" > 
2729          { username } 
2830        </ span > 
29-       )  :  < Avatar   size = "sm"   src = { avatar }   alt = { name }   className = "mr-2"   /> } 
31+       ) } 
3032    </ Dropdown . Toggle > 
3133  ) ; 
3234
Original file line number Diff line number Diff line change 11/* eslint-disable react/prop-types */ 
22import  React ,  {  useMemo  }  from  'react' ; 
3+ import  {  getConfig ,  mergeConfig  }  from  '@edx/frontend-platform' ; 
34import  { 
45  render , 
56  fireEvent , 
@@ -128,9 +129,13 @@ describe('Header', () => {
128129      expect ( avatarIcon ) . toBeVisible ( ) ; 
129130    } ) ; 
130131
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 }  /> ) ; 
134139      const  userMenue  =  container . querySelector ( '#user-dropdown-menu' ) ; 
135140      expect ( userMenue . textContent ) . toContain ( '' ) ; 
136141    } ) ; 
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ const UserMenu = ({
1919  // injected 
2020  intl, 
2121} )  =>  { 
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 ; 
2424  const  avatar  =  authenticatedUserAvatar  ? ( 
2525    < img 
2626      className = "d-block w-100 h-100" 
@@ -36,7 +36,7 @@ const UserMenu = ({
3636      data-testid = "avatar-icon" 
3737    /> 
3838  ) ; 
39-   const  title  =  isMobile  ? avatar  : < > { avatar } { showUsername   &&   username } </ > ; 
39+   const  title  =  ( isMobile  ||   hideUsername )   ? avatar  : < > { avatar } { username } </ > ; 
4040
4141  return  ( 
4242    < NavDropdownMenu 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments