import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { Button, ButtonGroup, Tooltip, OverlayTrigger } from 'react-bootstrap'; const unlockWarning = (

Careful! Only run code you trust

); const propTypes = { executeChallenge: PropTypes.func.isRequired, helpChatRoom: PropTypes.string, hint: PropTypes.string, isCodeLocked: PropTypes.bool, makeToast: PropTypes.func.isRequired, openBugModal: PropTypes.func.isRequired, unlockUntrustedCode: PropTypes.func.isRequired, updateHint: PropTypes.func.isRequired }; export default class ToolPanel extends PureComponent { constructor(...props) { super(...props); this.makeHint = this.makeHint.bind(this); this.makeReset = this.makeReset.bind(this); } 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: 'clickOnReset', timeout: 4000 }); } renderHint(hint, makeHint) { if (!hint) { return null; } return ( ); } renderExecute(isCodeLocked, executeChallenge, unlockUntrustedCode) { if (isCodeLocked) { return ( ); } return ( ); } render() { const { executeChallenge, helpChatRoom, hint, isCodeLocked, openBugModal, unlockUntrustedCode } = this.props; return (
{ this.renderHint(hint, this.makeHint) } { this.renderExecute( isCodeLocked, executeChallenge, unlockUntrustedCode ) }
); } } ToolPanel.displayName = 'ToolPanel'; ToolPanel.propTypes = propTypes;