Skip to content

Commit 2096b02

Browse files
committed
feat: custom header links
1 parent 1ba7c9e commit 2096b02

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
ACCESS_TOKEN_COOKIE_NAME=edx-jwt-cookie-header-payload
22
ACCOUNT_PROFILE_URL=http://localhost:1995
3+
ACCOUNT_SETTINGS_LABEL=
34
ACCOUNT_SETTINGS_URL=http://localhost:1997
45
BASE_URL=localhost:8080
56
CREDENTIALS_BASE_URL=http://localhost:18150
67
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
8+
DASHBOARD_URL=null
79
ECOMMERCE_BASE_URL=http://localhost:18130
10+
EXTERNAL_ACCOUNT_PROFILE_URL=null
811
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
912
LMS_BASE_URL=http://localhost:18000
1013
STUDIO_BASE_URL=http://localhost:18010

src/Header.jsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ ensureConfig([
2626

2727
subscribe(APP_CONFIG_INITIALIZED, () => {
2828
mergeConfig({
29+
ACCOUNT_SETTINGS_LABEL: process.env.ACCOUNT_SETTINGS_LABEL,
2930
AUTHN_MINIMAL_HEADER: !!process.env.AUTHN_MINIMAL_HEADER,
31+
DASHBOARD_URL: process.env.DASHBOARD_URL,
32+
EXTERNAL_ACCOUNT_PROFILE_URL: process.env.EXTERNAL_ACCOUNT_PROFILE_URL,
3033
SHOW_FULLNAME: process.env.SHOW_FULLNAME,
3134
}, 'Header additional config');
3235
});
3336

3437
const Header = ({ intl }) => {
3538
const { authenticatedUser, config } = useContext(AppContext);
3639

40+
const dashboardURL = config.DASHBOARD_URL ? config.DASHBOARD_URL : `${config.LMS_BASE_URL}/dashboard`
3741
const mainMenu = [
3842
{
3943
type: 'item',
40-
href: `${config.LMS_BASE_URL}/dashboard`,
44+
href: dashboardURL,
4145
content: intl.formatMessage(messages['header.links.courses']),
4246
},
4347
];
@@ -51,18 +55,18 @@ const Header = ({ intl }) => {
5155
const userMenu = authenticatedUser === null ? [] : [
5256
{
5357
type: 'item',
54-
href: `${config.LMS_BASE_URL}/dashboard`,
58+
href: dashboardURL,
5559
content: intl.formatMessage(messages['header.user.menu.dashboard']),
5660
},
5761
{
5862
type: 'item',
59-
href: `${config.ACCOUNT_PROFILE_URL}/u/${authenticatedUser.username}`,
63+
href: config.EXTERNAL_ACCOUNT_PROFILE_URL ? config.EXTERNAL_ACCOUNT_PROFILE_URL : `${config.ACCOUNT_PROFILE_URL}/u/${authenticatedUser.username}`,
6064
content: intl.formatMessage(messages['header.user.menu.profile']),
6165
},
6266
{
6367
type: 'item',
6468
href: config.ACCOUNT_SETTINGS_URL,
65-
content: intl.formatMessage(messages['header.user.menu.account.settings']),
69+
content: config.ACCOUNT_SETTINGS_LABEL ? config.ACCOUNT_SETTINGS_LABEL : intl.formatMessage(messages['header.user.menu.account.settings']),
6670
},
6771
{
6872
type: 'item',
@@ -89,12 +93,19 @@ const Header = ({ intl }) => {
8993
},
9094
];
9195

96+
let name = null
97+
if (authenticatedUser !== null && config.SHOW_FULLNAME) {
98+
name = authenticatedUser.name
99+
} else if (authenticatedUser !== null) {
100+
name = authenticatedUser.username
101+
}
102+
92103
const props = {
93104
logo: config.LOGO_URL,
94105
logoAltText: config.SITE_NAME,
95106
logoDestination: `${config.LMS_BASE_URL}/dashboard`,
96107
loggedIn: authenticatedUser !== null,
97-
username: authenticatedUser !== null ? authenticatedUser.username : null,
108+
username: name,
98109
avatar: authenticatedUser !== null ? authenticatedUser.avatar : null,
99110
mainMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : mainMenu,
100111
userMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : userMenu,

0 commit comments

Comments
 (0)