-
Notifications
You must be signed in to change notification settings - Fork 613
/
masthead.jsx
76 lines (71 loc) · 2.19 KB
/
masthead.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
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { Brand, PageHeader } from '@patternfly/react-core';
import { MastheadToolbar } from './masthead-toolbar';
import { history } from './utils';
import okdLogoImg from '../imgs/okd-logo.svg';
import openshiftLogoImg from '../imgs/openshift-logo.svg';
import ocpLogoImg from '../imgs/openshift-platform-logo.svg';
import onlineLogoImg from '../imgs/openshift-online-logo.svg';
import dedicatedLogoImg from '../imgs/openshift-dedicated-logo.svg';
export const getBrandingDetails = () => {
let logoImg, productName;
// Webpack won't bundle these images if we don't directly reference them, hence the switch
switch (window.SERVER_FLAGS.branding) {
case 'openshift':
logoImg = openshiftLogoImg;
productName = 'Red Hat OpenShift';
break;
case 'ocp':
logoImg = ocpLogoImg;
productName = 'Red Hat OpenShift Container Platform';
break;
case 'online':
logoImg = onlineLogoImg;
productName = 'Red Hat OpenShift Online';
break;
case 'dedicated':
logoImg = dedicatedLogoImg;
productName = 'Red Hat OpenShift Dedicated';
break;
case 'azure':
logoImg = openshiftLogoImg;
productName = 'Azure Red Hat OpenShift';
break;
default:
logoImg = okdLogoImg;
productName = 'OKD';
}
if (window.SERVER_FLAGS.customLogoURL) {
logoImg = window.SERVER_FLAGS.customLogoURL;
}
if (window.SERVER_FLAGS.customProductName) {
productName = window.SERVER_FLAGS.customProductName;
}
return { logoImg, productName };
};
export const Masthead = React.memo(({ onNavToggle }) => {
const details = getBrandingDetails();
const defaultRoute = '/';
const logoProps = {
href: defaultRoute,
// use onClick to prevent browser reload
onClick: (e) => {
e.preventDefault();
history.push(defaultRoute);
},
};
return (
<PageHeader
id="page-main-header"
logo={<Brand src={details.logoImg} alt={details.productName} />}
logoProps={logoProps}
headerTools={<MastheadToolbar />}
showNavToggle
onNavToggle={onNavToggle}
/>
);
});
Masthead.propTypes = {
onNavToggle: PropTypes.func,
};