Skip to content

Commit

Permalink
Implementing alternative view of output (judge) logs -- in a modal wi…
Browse files Browse the repository at this point in the history
…ndow (which is much wider) for better readability.
  • Loading branch information
krulis-martin committed Jun 5, 2024
1 parent b58199d commit 2ce7d09
Show file tree
Hide file tree
Showing 8 changed files with 674 additions and 369 deletions.
40 changes: 40 additions & 0 deletions src/components/Solutions/TestResultsTable/CopyLogToClipboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { CopyToClipboard } from 'react-copy-to-clipboard';

import Button from '../../widgets/TheButton';
import Icon, { CopyIcon } from '../../icons';

class CopyLogToClipboard extends Component {
state = { logCopied: false };

logCopied = () => {
this.setState({ logCopied: true });
if (this.resetLogCopied) {
clearTimeout(this.resetLogCopied);
}
this.resetLogCopied = setTimeout(() => {
this.setState({ logCopied: false });
this.resetLogCopied = undefined;
}, 2000);
};

render() {
const { log, ...props } = this.props;
return (
<CopyToClipboard text={log} onCopy={this.logCopied}>
<Button variant="success" {...props} disabled={this.state.logCopied}>
{this.state.logCopied ? <Icon icon="clipboard-check" gapRight /> : <CopyIcon gapRight />}
<FormattedMessage id="generic.copyToClipboard" defaultMessage="Copy to clipboard" />
</Button>
</CopyToClipboard>
);
}
}

CopyLogToClipboard.propTypes = {
log: PropTypes.string,
};

export default CopyLogToClipboard;
Loading

0 comments on commit 2ce7d09

Please sign in to comment.