-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathHeader.jsx
160 lines (148 loc) · 4.91 KB
/
Header.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import React, { useContext } from 'react';
import Responsive from 'react-responsive';
import { AppContext } from '@edx/frontend-platform/react';
import {
APP_CONFIG_INITIALIZED,
ensureConfig,
mergeConfig,
getConfig,
subscribe,
} from '@edx/frontend-platform';
import DesktopHeader from './DesktopHeader';
import MobileHeader from './MobileHeader';
ensureConfig([
'LMS_BASE_URL',
'LOGOUT_URL',
'LOGIN_URL',
'MARKETING_SITE_BASE_URL',
'ORDER_HISTORY_URL',
], 'Header component');
subscribe(APP_CONFIG_INITIALIZED, () => {
mergeConfig({
MINIMAL_HEADER: !!process.env.MINIMAL_HEADER,
PUBLISHER_BASE_URL: process.env.PUBLISHER_BASE_URL,
}, 'Header additional config');
});
export default function Header() {
const { authenticatedUser, config } = useContext(AppContext);
const mainMenu = [
{
type: 'submenu',
content: 'Updates',
submenuContent: (
<>
<div className="mb-1"><a rel="noopener" href="https://docs.google.com/document/edit?hgd=1&id=17_FWEtnUXyeEMrj8Lu3kmXqopwHGUjKW2t61cek2ax0">Current Issues</a></div>
<div className="mb-1"><a rel="noopener" href="https://sites.google.com/a/edx.org/edx-support/-recent-updates">Support Site Recent Updates</a></div>
</>
),
},
{
type: 'submenu',
content: 'Escalations',
submenuContent: (
<>
<div className="mb-1"><a rel="noopener" href="https://edx.lightning.force.com/lightning/o/Case/list?filterName=00B0L000005D8BgUAK">Salesforce</a></div>
<div className="mb-1"><a rel="noopener" href="https://openedx.atlassian.net/servicedesk/customer/user/requests?page=1&status=open">CR Requests</a></div>
</>
),
},
{
type: 'submenu',
content: 'Payment',
submenuContent: (
<>
<div className="mb-1"><a rel="noopener" href={`${config.ECOMMERCE_BASE_URL}/dashboard/users/`}>Otto</a></div>
<div className="mb-1"><a rel="noopener" href="https://ebc2.cybersource.com/ebc2/app/Home">Cybersource</a></div>
<div className="mb-1"><a rel="noopener" href="https://www.paypal.com/mep/dashboard">Paypal</a></div>
<div className="mb-1"><a rel="noopener" href={`${config.ECOMMERCE_BASE_URL}/enterprise/coupons/`}>Enterprise Coupons</a></div>
</>
),
},
{
type: 'submenu',
content: 'Courses',
submenuContent: (
<>
<div className="mb-1"><a rel="noopener" href={`${config.PUBLISHER_BASE_URL}`}>Publisher</a></div>
<div className="mb-1"><a rel="noopener" href={`${config.DISCOVERY_API_BASE_URL}`}>Discovery</a></div>
<div className="mb-1"><a rel="noopener" href="https://www.edx.org/course">Course Catalogue</a></div>
</>
),
},
{
type: 'item',
content: 'Proctoring',
href: 'https://courses-internal.edx.org/admin/edx_proctoring/proctoredexamsoftwaresecurereview/',
},
{
type: 'submenu',
content: 'Programs',
submenuContent: (
<>
<div className="mb-1"><a rel="noopener" href={`${config.CREDENTIALS_BASE_URL}/records/`}>Learner Record</a></div>
<div className="mb-1"><a rel="noopener" href={`${config.CREDENTIALS_BASE_URL}/admin/credentials/usercredential/`}>Credentials Search</a></div>
<div className="mb-1"><a rel="noopener" href={`${config.DISCOVERY_API_BASE_URL}/admin/course_metadata/program/`}>Programs Discovery</a></div>
</>
),
},
];
const dashboardMenuItem = {
type: 'item',
href: `${config.LMS_BASE_URL}/dashboard`,
content: 'Dashboard',
};
const logoutMenuItem = {
type: 'item',
href: config.LOGOUT_URL,
content: 'Logout',
};
let userMenu = authenticatedUser === null ? [] : [
dashboardMenuItem,
{
type: 'item',
href: `${config.LMS_BASE_URL}/u/${authenticatedUser.username}`,
content: 'Profile',
},
{
type: 'item',
href: `${config.LMS_BASE_URL}/account/settings`,
content: 'Account',
},
logoutMenuItem,
];
if (getConfig().MINIMAL_HEADER && authenticatedUser !== null) {
userMenu = [
dashboardMenuItem,
logoutMenuItem,
];
}
const loggedOutItems = [
{
type: 'item',
href: config.LOGIN_URL,
content: 'Login',
},
];
const props = {
logo: config.LOGO_URL,
logoAltText: 'edX',
siteName: 'edX',
logoDestination: getConfig().MINIMAL_HEADER ? null : `${config.LMS_BASE_URL}/dashboard`,
loggedIn: authenticatedUser !== null,
username: authenticatedUser !== null ? authenticatedUser.username : null,
avatar: authenticatedUser !== null ? authenticatedUser.avatar : null,
mainMenu: getConfig().MINIMAL_HEADER ? [] : mainMenu,
userMenu,
loggedOutItems,
};
return (
<>
<Responsive maxWidth={768}>
<MobileHeader {...props} />
</Responsive>
<Responsive minWidth={769}>
<DesktopHeader {...props} />
</Responsive>
</>
);
}