/
LogToolbar.jsx
64 lines (59 loc) · 1.95 KB
/
LogToolbar.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
import React, { Component, PropTypes } from 'react';
import { Icon, TimeDuration } from '@jenkins-cd/design-language';
import { fetchAllSuffix as suffix } from '../../../util/UrlUtils';
const { string } = PropTypes;
export default class LogToolbar extends Component {
render() {
const { url, title, duration, t, running } = this.props;
// early out
if (!url) {
return null;
}
const logUrl = url.includes(suffix) ? url : `${url}${suffix}`;
return (<div className="log-header">
<div className="log-header__section selected">
<span>
{title}
</span>
{duration &&
<span>
<span> - </span>
<TimeDuration
millis={ duration }
liveUpdate={ running }
updatePeriod={ 1000 }
t={ t }
/>
</span>
}
</div>
<div className="log-header__section download-log-button">
<a {...{
title: 'Display the log in new window',
target: '_blank',
href: logUrl,
}}
>
<Icon icon="ActionLaunch" size={24} />
</a>
<a
{...{
title: 'Download the log file',
href: `${logUrl}&download=true`,
}}
>
<Icon icon="FileFileDownload" size={24} />
</a>
</div>
</div>);
}
}
LogToolbar.propTypes = {
data: string,
title: string,
fileName: string,
url: string.isRequired,
duration: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
t: PropTypes.func,
running: PropTypes.bool,
};