-
Notifications
You must be signed in to change notification settings - Fork 13
feat: display multiple dashboards and some style fixes #667
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
base: master
Are you sure you want to change the base?
Changes from all commits
c53d2a1
d1ed685
b7a021a
c264df0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ import { | |
| getConfig, | ||
| subscribe, | ||
| } from '@edx/frontend-platform'; | ||
| import { useEnterpriseConfig } from '@edx/frontend-enterprise-utils'; | ||
| import { useEnterpriseConfig, isEnterpriseUser } from '@edx/frontend-enterprise-utils'; | ||
| import './index.scss'; | ||
|
|
||
| import PropTypes from 'prop-types'; | ||
| import DesktopHeader from './DesktopHeader'; | ||
|
|
@@ -35,6 +36,7 @@ subscribe(APP_CONFIG_INITIALIZED, () => { | |
| mergeConfig({ | ||
| MINIMAL_HEADER: !!process.env.MINIMAL_HEADER, | ||
| ENTERPRISE_LEARNER_PORTAL_HOSTNAME: process.env.ENTERPRISE_LEARNER_PORTAL_HOSTNAME, | ||
| ENABLE_EDX_PERSONAL_DASHBOARD: process.env.ENABLE_EDX_PERSONAL_DASHBOARD, | ||
| AUTHN_MINIMAL_HEADER: !!process.env.AUTHN_MINIMAL_HEADER, | ||
| ACCOUNT_SETTINGS_URL: process.env.ACCOUNT_SETTINGS_URL, | ||
| NOTIFICATION_FEEDBACK_URL: process.env.NOTIFICATION_FEEDBACK_URL, | ||
|
|
@@ -64,12 +66,14 @@ const Header = ({ | |
| enterpriseLearnerPortalLink, | ||
| enterpriseCustomerBrandingConfig, | ||
| } = useEnterpriseConfig(authenticatedUser, config.ENTERPRISE_LEARNER_PORTAL_HOSTNAME, config.LMS_BASE_URL); | ||
| const hasEnterpriseAccount = isEnterpriseUser(authenticatedUser); | ||
|
|
||
| const defaultMainMenu = [ | ||
| { | ||
| type: 'item', | ||
| href: `${config.LMS_BASE_URL}/dashboard`, | ||
| content: intl.formatMessage(messages['header.links.courses']), | ||
| isActive: document.title.includes(intl.formatMessage(messages['header.pages.learner.home'])), | ||
| }, | ||
| { | ||
| type: 'item', | ||
|
|
@@ -89,32 +93,29 @@ const Header = ({ | |
| }, | ||
| ]; | ||
|
|
||
| const dashboardMenuItem = { | ||
| type: 'item', | ||
| href: `${config.LMS_BASE_URL}/dashboard`, | ||
| content: intl.formatMessage(messages['header.user.menu.dashboard']), | ||
| }; | ||
|
|
||
| const logoutMenuItem = { | ||
| type: 'item', | ||
| href: config.LOGOUT_URL, | ||
| content: intl.formatMessage(messages['header.user.menu.logout']), | ||
| }; | ||
|
|
||
| // If there is an Enterprise LP link, use that instead of the B2C Dashboard | ||
| let baseUserMenuDashboardLinks = []; | ||
| if (enterpriseLearnerPortalLink) { | ||
| baseUserMenuDashboardLinks = [enterpriseLearnerPortalLink]; | ||
| } else { | ||
| baseUserMenuDashboardLinks = [dashboardMenuItem]; | ||
| } | ||
| const defaultSecondaryMenu = [ | ||
| ...(getConfig().SUPPORT_URL ? [{ | ||
| type: 'item', | ||
| href: `${getConfig().SUPPORT_URL}`, | ||
| content: intl.formatMessage(messages['header.links.help']), | ||
| }] : []), | ||
| ]; | ||
|
|
||
| const careerItemContent = <>{intl.formatMessage(messages['header.user.menu.career'])}<Badge className="px-2 mx-2" variant="warning">{intl.formatMessage(messages['header.user.menu.newAlert'])}</Badge></>; | ||
| const defaultUserMenu = authenticatedUser === null ? [] : [{ | ||
| heading: '', | ||
| items: [ | ||
| ...baseUserMenuDashboardLinks, | ||
| { | ||
| // Users should only see Career button if they do not have an available | ||
| // learner portal, because an available learner portal currently means | ||
| // that they access content via B2B Subscriptions, in which context "career" button | ||
| // is not relevant. | ||
| ...(!enterpriseLearnerPortalLink ? [{ | ||
| type: 'item', | ||
| href: 'https://careers.edx.org/', | ||
| content: careerItemContent, | ||
|
|
@@ -124,16 +125,18 @@ const Header = ({ | |
| { category: 'header', label: 'header' }, | ||
| ); | ||
| }, | ||
| }, | ||
| }] : []), | ||
|
Member
Author
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. Only render the Career button when the user doesn't have an Enterprise account, similarly with the Order History button. |
||
| { | ||
| type: 'item', | ||
| href: `${config.ACCOUNT_PROFILE_URL}/u/${authenticatedUser.username}`, | ||
| content: intl.formatMessage(messages['header.user.menu.profile']), | ||
| isActive: document.title.includes(intl.formatMessage(messages['header.user.menu.profile'])), | ||
| }, | ||
| { | ||
| type: 'item', | ||
| href: config.ACCOUNT_SETTINGS_URL, | ||
| content: intl.formatMessage(messages['header.user.menu.account.settings']), | ||
| isActive: document.title.includes(intl.formatMessage(messages['header.user.menu.account.settings'])), | ||
| }, | ||
| // Users should only see Order History if they do not have an available | ||
| // learner portal and have a ORDER_HISTORY_URL define in the environment, | ||
|
|
@@ -150,14 +153,20 @@ const Header = ({ | |
| }]; | ||
|
|
||
| const mainMenu = mainMenuItems || defaultMainMenu; | ||
| const secondaryMenu = secondaryMenuItems || []; | ||
| const secondaryMenu = secondaryMenuItems || defaultSecondaryMenu; | ||
| let userMenu = authenticatedUser === null ? [] : userMenuItems || defaultUserMenu; | ||
|
|
||
| const minimalDashboardMenuItem = { | ||
|
Member
Author
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 Minimal header (used in Payment MFE) should only display one dashboard, which has historically pointed to the personal dashboard, so I'm choosing to leave this unchanged. |
||
| type: 'item', | ||
| href: `${config.LMS_BASE_URL}/dashboard`, | ||
| content: intl.formatMessage(messages['header.user.menu.dashboard']), | ||
| }; | ||
|
|
||
| if (getConfig().MINIMAL_HEADER && authenticatedUser !== null) { | ||
| userMenu = [{ | ||
| heading: '', | ||
| items: [ | ||
| dashboardMenuItem, | ||
| minimalDashboardMenuItem, | ||
| logoutMenuItem, | ||
| ], | ||
| }]; | ||
|
|
@@ -190,6 +199,7 @@ const Header = ({ | |
| userMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : userMenu, | ||
| loggedOutItems: getConfig().AUTHN_MINIMAL_HEADER ? [] : loggedOutItems, | ||
| studioBaseUrl: config.STUDIO_BASE_URL, | ||
| hasEnterpriseAccount, | ||
| }; | ||
|
|
||
| if (enterpriseCustomerBrandingConfig) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { getConfig } from '@edx/frontend-platform'; | ||
| import { useIntl } from '@edx/frontend-platform/i18n'; | ||
| import { | ||
| breakpoints, Dropdown, useWindowSize, | ||
| } from '@openedx/paragon'; | ||
|
|
||
| import messages from './messages'; | ||
|
|
||
| const UserDashboardMenu = ({ enterpriseOrg, enterpriseSrc, hasEnterpriseAccount }) => { | ||
| const { formatMessage } = useIntl(); | ||
| const { width } = useWindowSize(); | ||
| const isMobile = width <= breakpoints.small.maxWidth; | ||
|
|
||
| if (getConfig().ENABLE_EDX_PERSONAL_DASHBOARD) { | ||
| if (!isMobile) { | ||
| return ( | ||
| <> | ||
| { hasEnterpriseAccount && <Dropdown.Header>{formatMessage(messages.dashboardSwitch)}</Dropdown.Header> } | ||
| <Dropdown.Item as="a" href="/edx-dashboard" className={document.title === 'Learner Home' ? 'active' : ''} key="item-dashboard"> | ||
| {formatMessage(hasEnterpriseAccount ? messages.dashboardPersonal : messages.dashboard)} | ||
| </Dropdown.Item> | ||
| { hasEnterpriseAccount && ( | ||
| <Dropdown.Item as="a" href={enterpriseSrc} key={enterpriseOrg}> | ||
| {enterpriseOrg} {formatMessage(messages.dashboard)} | ||
| </Dropdown.Item> | ||
| )} | ||
| {hasEnterpriseAccount && <Dropdown.Divider />} | ||
| </> | ||
| ); | ||
| } | ||
| return ( | ||
| <> | ||
| <li className="nav-item" key="item-dashboard"> | ||
| <a href="/edx-dashboard" className={`nav-link ${document.title === 'Learner Home' ? 'active' : ''})`}> | ||
| {formatMessage(messages.dashboardPersonal)} | ||
| </a> | ||
| </li> | ||
| {hasEnterpriseAccount && ( | ||
| <li className="nav-item" key={enterpriseOrg}> | ||
| <a href={enterpriseSrc} className="nav-link"> | ||
| {enterpriseOrg} {formatMessage(messages.dashboard)} | ||
| </a> | ||
| </li> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
| return null; | ||
| }; | ||
|
|
||
| UserDashboardMenu.defaultProps = { | ||
| enterpriseOrg: null, | ||
| enterpriseSrc: null, | ||
| hasEnterpriseAccount: false, | ||
| }; | ||
|
|
||
| UserDashboardMenu.propTypes = { | ||
| enterpriseOrg: PropTypes.string, | ||
| enterpriseSrc: PropTypes.string, | ||
| hasEnterpriseAccount: PropTypes.bool, | ||
| }; | ||
|
|
||
| export default UserDashboardMenu; |
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.
This "Help" button is new to the default Header experience, but it has already existed for a while in the Learning and Learner Dashboard pages.