import React, { PropTypes } from 'react'; import { Button, ButtonGroup, Tooltip, OverlayTrigger } from 'react-bootstrap'; import PureComponent from 'react-pure-render/component'; const unlockWarning = (

Careful! Only run code you trust

); export default class ToolPanel extends PureComponent { constructor(...props) { super(...props); this.makeHint = this.makeHint.bind(this); this.makeReset = this.makeReset.bind(this); } static displayName = 'ToolPanel'; static propTypes = { executeChallenge: PropTypes.func.isRequired, updateHint: PropTypes.func.isRequired, hint: PropTypes.string, isCodeLocked: PropTypes.bool, unlockUntrustedCode: PropTypes.func.isRequired, toggleHelpChat: PropTypes.func.isRequired, openBugModal: PropTypes.func.isRequired, makeToast: PropTypes.func.isRequired }; makeHint() { this.props.makeToast({ message: this.props.hint, timeout: 4000 }); this.props.updateHint(); } makeReset() { this.props.makeToast({ message: 'This will restore your code editor to its original state.', action: 'clear my code', actionCreator: 'resetChallenge', timeout: 4000 }); } renderHint(hint, makeHint) { if (!hint) { return null; } return ( ); } renderExecute(isCodeLocked, executeChallenge, unlockUntrustedCode) { if (isCodeLocked) { return ( ); } return ( ); } render() { const { hint, isCodeLocked, executeChallenge, toggleHelpChat, openBugModal, unlockUntrustedCode } = this.props; return (
{ this.renderHint(hint, this.makeHint) } { this.renderExecute( isCodeLocked, executeChallenge, unlockUntrustedCode ) }
); } }