/
ResultPageHeader.jsx
69 lines (60 loc) · 2.44 KB
/
ResultPageHeader.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
import React, { PropTypes } from 'react';
import { BasicHeader, TopNav, HeaderDetails, LiveStatusIndicator } from '@jenkins-cd/design-language';
import { _wrap } from './ContentPageHeader';
// Exported from Zeplin, path could use a little cleanup
const CloseButton = props => (
<span title={props.t('creation.core.header.close', { defaultValue: 'Close' })}>
<svg className="ResultPageHeader-close" width="24px" height="24px" viewBox="0 0 24 24" onClick={props.onClick} version="1.1">
<g strokeWidth="1">
<polygon points="19 6.415 17.585 5 12 10.585 6.415 5 5 6.415 10.585 12 5 17.585 6.415 19 12 13.415 17.585 19 19 17.585 13.415 12" />
</g>
</svg>
</span>
);
CloseButton.propTypes = {
onClick: PropTypes.func,
t: PropTypes.func,
};
export const ResultPageHeader = props => {
const { status = 'unknown', title, onCloseClick, startTime, estimatedDurationInMillis, t } = props;
const closeClicked = () => {
if (onCloseClick) {
onCloseClick();
}
};
const titleComp = _wrap(title, 'div', { className: 'ResultPageHeader-title u-flex-grow' });
const topNavLinks = _wrap(props.topNavLinks, 'nav');
const runButton = _wrap(props.runButton, 'div', { className: 'ResultPageHeader-run' });
const classNames = ['ResultPageHeader'];
if (props.className) {
classNames.push(props.className);
}
return (
<BasicHeader className={classNames.join(' ')} statusColor={status}>
<TopNav>
<section className="ResultPageHeader-indicator status inverse">
<LiveStatusIndicator result={status} startTime={startTime} estimatedDuration={estimatedDurationInMillis} noBackground />
</section>
{titleComp}
{topNavLinks}
{runButton}
<CloseButton onClick={closeClicked} t={t} />
</TopNav>
<HeaderDetails>
<div className="ResultPageHeader-main u-flex-grow">{props.children}</div>
</HeaderDetails>
</BasicHeader>
);
};
ResultPageHeader.propTypes = {
className: PropTypes.string,
children: PropTypes.node,
status: PropTypes.string,
onCloseClick: PropTypes.func,
title: PropTypes.node,
topNavLinks: PropTypes.node,
runButton: PropTypes.node,
startTime: PropTypes.string,
estimatedDurationInMillis: PropTypes.number,
t: PropTypes.func,
};