blueocean-plugin/blueocean-dashboard/src/main/js/components/LogToolbar.jsx

54 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { Component, PropTypes } from 'react';
import { DownloadLink, fetch } from '@jenkins-cd/design-language';
import { Icon } from 'react-material-icons-blue';
const { string } = PropTypes;
let rawUrl;
class LogToolbar extends Component {
render() {
const { data, fileName } = this.props;
// early out
if (!data) {
return null;
}
const style = { fill: '#4a4a4a' };
return (<div className="log-header">
<div className="log-header__section">
Build log Build > Build source
</div>
<div className="log-header__section download-log-button">
<DownloadLink {...{ style, fileData: {
filename: fileName,
contents: data,
mime: 'text/plain',
} }}
/>
<a {...{
title: 'Display the log in new window',
target: '_blank',
href: rawUrl,
}}
>
<Icon {...{ style, icon: 'launch' }} />
</a>
</div>
</div>);
}
}
LogToolbar.propTypes = {
data: string,
fileName: string,
url: string.isRequired,
};
export default fetch(LogToolbar, ({ url }, config) => {
rawUrl = config.getAppURLBase() + url;
return rawUrl;
}, false) ;