-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing alternative view of output (judge) logs -- in a modal wi…
…ndow (which is much wider) for better readability.
- Loading branch information
1 parent
b58199d
commit 2ce7d09
Showing
8 changed files
with
674 additions
and
369 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/components/Solutions/TestResultsTable/CopyLogToClipboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.