Skip to content

Commit

Permalink
fix: use single prop in header for username and name
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed May 17, 2024
1 parent 36ecf9f commit c3cffff
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 2 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ subscribe(APP_READY, () => {
authenticatedUser: {
userId: '123abc',
username: 'testuser',
username: 'Test user',
roles: [],
administrator: false,
},
Expand All @@ -38,6 +39,7 @@ subscribe(APP_READY, () => {
authenticatedUser: {
userId: '123abc',
username: 'testuser',
username: 'Test user',
roles: [],
administrator: false,
},
Expand Down
5 changes: 1 addition & 4 deletions src/DesktopHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class DesktopHeader extends React.Component {
userMenu,
avatar,
username,
name,
intl,
} = this.props;

Expand All @@ -89,7 +88,7 @@ class DesktopHeader extends React.Component {
className="btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3"
>
<Avatar size="1.5em" src={avatar} alt="" className="mr-2" />
{name || username} <CaretIcon role="img" aria-hidden focusable="false" />
{username} <CaretIcon role="img" aria-hidden focusable="false" />
</MenuTrigger>
<MenuContent className="mb-0 dropdown-menu show dropdown-menu-right pin-right shadow py-2">
{userMenu.map((group, index) => (
Expand Down Expand Up @@ -201,7 +200,6 @@ DesktopHeader.propTypes = {
logoDestination: PropTypes.string,
avatar: PropTypes.string,
username: PropTypes.string,
name: PropTypes.string,
loggedIn: PropTypes.bool,

// i18n
Expand All @@ -218,7 +216,6 @@ DesktopHeader.defaultProps = {
logoDestination: null,
avatar: null,
username: null,
name: null,
loggedIn: false,
};

Expand Down
3 changes: 1 addition & 2 deletions src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ const Header = ({
logoAltText: config.SITE_NAME,
logoDestination: `${config.LMS_BASE_URL}/dashboard`,
loggedIn: authenticatedUser !== null,
username: authenticatedUser !== null ? authenticatedUser.username : null,
name: authenticatedUser !== null ? authenticatedUser.name : null,
username: authenticatedUser !== null ? authenticatedUser.name || authenticatedUser.username : null,
avatar: authenticatedUser !== null ? authenticatedUser.avatar : null,
mainMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : mainMenu,
secondaryMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : secondaryMenu,
Expand Down
5 changes: 1 addition & 4 deletions src/MobileHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class MobileHeader extends React.Component {
loggedIn,
avatar,
username,
name,
stickyOnMobile,
intl,
mainMenu,
Expand Down Expand Up @@ -167,7 +166,7 @@ class MobileHeader extends React.Component {
aria-label={intl.formatMessage(messages['header.label.account.menu'])}
title={intl.formatMessage(messages['header.label.account.menu'])}
>
<Avatar size="1.5rem" src={avatar} alt={name || username} />
<Avatar size="1.5rem" src={avatar} alt={username} />
</MenuTrigger>
<MenuContent tag="ul" className="nav flex-column pin-left pin-right border-top shadow py-2">
{loggedIn ? this.renderUserMenuItems() : this.renderLoggedOutItems()}
Expand Down Expand Up @@ -209,7 +208,6 @@ MobileHeader.propTypes = {
logoDestination: PropTypes.string,
avatar: PropTypes.string,
username: PropTypes.string,
name: PropTypes.string,
loggedIn: PropTypes.bool,
stickyOnMobile: PropTypes.bool,

Expand All @@ -227,7 +225,6 @@ MobileHeader.defaultProps = {
logoDestination: null,
avatar: null,
username: null,
name: null,
loggedIn: false,
stickyOnMobile: true,

Expand Down

0 comments on commit c3cffff

Please sign in to comment.