Skip to content

Commit 2ce7d09

Browse files
committed
Implementing alternative view of output (judge) logs -- in a modal window (which is much wider) for better readability.
1 parent b58199d commit 2ce7d09

File tree

8 files changed

+674
-369
lines changed

8 files changed

+674
-369
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { FormattedMessage } from 'react-intl';
4+
import { CopyToClipboard } from 'react-copy-to-clipboard';
5+
6+
import Button from '../../widgets/TheButton';
7+
import Icon, { CopyIcon } from '../../icons';
8+
9+
class CopyLogToClipboard extends Component {
10+
state = { logCopied: false };
11+
12+
logCopied = () => {
13+
this.setState({ logCopied: true });
14+
if (this.resetLogCopied) {
15+
clearTimeout(this.resetLogCopied);
16+
}
17+
this.resetLogCopied = setTimeout(() => {
18+
this.setState({ logCopied: false });
19+
this.resetLogCopied = undefined;
20+
}, 2000);
21+
};
22+
23+
render() {
24+
const { log, ...props } = this.props;
25+
return (
26+
<CopyToClipboard text={log} onCopy={this.logCopied}>
27+
<Button variant="success" {...props} disabled={this.state.logCopied}>
28+
{this.state.logCopied ? <Icon icon="clipboard-check" gapRight /> : <CopyIcon gapRight />}
29+
<FormattedMessage id="generic.copyToClipboard" defaultMessage="Copy to clipboard" />
30+
</Button>
31+
</CopyToClipboard>
32+
);
33+
}
34+
}
35+
36+
CopyLogToClipboard.propTypes = {
37+
log: PropTypes.string,
38+
};
39+
40+
export default CopyLogToClipboard;

0 commit comments

Comments
 (0)