-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: set username behind flag #465
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name should be added to the |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ subscribe(APP_READY, () => { | |
authenticatedUser: { | ||
userId: '123abc', | ||
username: 'testuser', | ||
name: 'test user', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another general question: Would we prefer this as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The authenticated data sent in JWT has "name" not "fullName" |
||
roles: [], | ||
administrator: false, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -74,21 +74,25 @@ class DesktopHeader extends React.Component { | |||||
|
||||||
renderUserMenu() { | ||||||
const { | ||||||
intl, | ||||||
userMenu, | ||||||
avatar, | ||||||
name, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll copy-paste from another review on a related PR: This would make so there's no longer a 1:1 relationship between the DesktopHeader props and what is actually shown. In other words, it's not immediately obvious without looking at the implementation what happens if you provide both username and name. In other words, unless I'm missing something, DesktopHeader has no reason to distinguish between |
||||||
username, | ||||||
intl, | ||||||
} = this.props; | ||||||
const hideUsername = getConfig().HIDE_USERNAME_FROM_HEADER; | ||||||
const usernameOrName = hideUsername ? name : username; | ||||||
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this has been implemented in a way that assumes the "hide username from menu button in header" is tied to "don't use usernames." It seems to me those are two separate things. I could definitely see someone running an Open edX instance that uses usernames but not wanting to show them in the menu dropdown button. In this case the difference seems quite minor, but I can imagine scenarios where having "hide username" and "we don't use usernames" coupled could be problematic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will be auto-generating username and showing that in alt text doesn't make sense. I can see how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can go with your suggestion of |
||||||
|
||||||
return ( | ||||||
<Menu transitionClassName="menu-dropdown" transitionTimeout={250}> | ||||||
<MenuTrigger | ||||||
tag="button" | ||||||
aria-label={intl.formatMessage(messages['header.label.account.menu.for'], { username })} | ||||||
aria-label={intl.formatMessage(messages['header.label.account.menu.using.name.or.username'], { usernameOrName })} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another open question: Do we want to use a new message key here? An alternative solution that comes to mind is
Suggested change
|
||||||
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" /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this wasn't added in this PR, but StudioHeader uses name/username for the alt test in UserMenu. Does it make sense to do the same here for consistency? |
||||||
{username} <CaretIcon role="img" aria-hidden focusable="false" /> | ||||||
{!hideUsername && 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(({ type, href, content }) => ( | ||||||
|
@@ -178,6 +182,7 @@ DesktopHeader.propTypes = { | |||||
logoDestination: PropTypes.string, | ||||||
avatar: PropTypes.string, | ||||||
username: PropTypes.string, | ||||||
name: PropTypes.string, | ||||||
loggedIn: PropTypes.bool, | ||||||
|
||||||
// i18n | ||||||
|
@@ -207,6 +212,7 @@ DesktopHeader.defaultProps = { | |||||
logoDestination: null, | ||||||
avatar: null, | ||||||
username: null, | ||||||
name: null, | ||||||
loggedIn: false, | ||||||
appMenu: null, | ||||||
}; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,27 +5,38 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | |||||
import { faUserCircle } from '@fortawesome/free-solid-svg-icons'; | ||||||
import { getConfig } from '@edx/frontend-platform'; | ||||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||||||
import { Dropdown } from '@openedx/paragon'; | ||||||
import { Avatar, Dropdown } from '@openedx/paragon'; | ||||||
|
||||||
import messages from './messages'; | ||||||
|
||||||
const AuthenticatedUserDropdown = ({ intl, username }) => { | ||||||
const AuthenticatedUserDropdown = ({ | ||||||
intl, username, name, | ||||||
}) => { | ||||||
const dashboardMenuItem = ( | ||||||
<Dropdown.Item href={`${getConfig().LMS_BASE_URL}/dashboard`}> | ||||||
{intl.formatMessage(messages.dashboard)} | ||||||
</Dropdown.Item> | ||||||
); | ||||||
|
||||||
// show avatar instead username if HIDE_USERNAME_FROM_HEADER flag is enabled | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const dropdownToggle = ( | ||||||
<Dropdown.Toggle variant="outline-primary"> | ||||||
<FontAwesomeIcon icon={faUserCircle} className="d-md-none" size="lg" /> | ||||||
{getConfig().HIDE_USERNAME_FROM_HEADER ? ( | ||||||
<Avatar size="sm" alt={name} className="mr-2" /> | ||||||
) : ( | ||||||
<span data-hj-suppress className="d-none d-md-inline" data-testid="username"> | ||||||
{username} | ||||||
</span> | ||||||
)} | ||||||
</Dropdown.Toggle> | ||||||
); | ||||||
|
||||||
return ( | ||||||
<> | ||||||
<a className="text-gray-700" href={`${getConfig().SUPPORT_URL}`}>{intl.formatMessage(messages.help)}</a> | ||||||
<Dropdown className="user-dropdown ml-3"> | ||||||
<Dropdown.Toggle variant="outline-primary"> | ||||||
<FontAwesomeIcon icon={faUserCircle} className="d-md-none" size="lg" /> | ||||||
<span data-hj-suppress className="d-none d-md-inline"> | ||||||
{username} | ||||||
</span> | ||||||
</Dropdown.Toggle> | ||||||
{dropdownToggle} | ||||||
<Dropdown.Menu className="dropdown-menu-right"> | ||||||
{dashboardMenuItem} | ||||||
<Dropdown.Item href={`${getConfig().ACCOUNT_PROFILE_URL}/u/${username}`}> | ||||||
|
@@ -51,6 +62,11 @@ const AuthenticatedUserDropdown = ({ intl, username }) => { | |||||
AuthenticatedUserDropdown.propTypes = { | ||||||
intl: intlShape.isRequired, | ||||||
username: PropTypes.string.isRequired, | ||||||
name: PropTypes.string, | ||||||
}; | ||||||
|
||||||
AuthenticatedUserDropdown.defaultProps = { | ||||||
name: null, | ||||||
}; | ||||||
|
||||||
export default injectIntl(AuthenticatedUserDropdown); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question (hoping to hear what others think): Do we prefer this as
HIDE
or asSHOW
? I could be persuaded either way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, I could even see this being non-boolean: something like
NAME_IN_MENU_BUTTON
with the options beingusername
,fullName
,none