2016-05-20 12:42:26 -07:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-03-05 21:06:04 -08:00
|
|
|
import { Button, ButtonGroup } from 'react-bootstrap';
|
|
|
|
import PureComponent from 'react-pure-render/component';
|
|
|
|
|
2016-06-14 18:47:43 -07:00
|
|
|
export default class ToolPanel extends PureComponent {
|
|
|
|
constructor(...props) {
|
|
|
|
super(...props);
|
|
|
|
this.makeHint = this.makeHint.bind(this);
|
2016-07-07 20:02:03 -07:00
|
|
|
this.makeReset = this.makeReset.bind(this);
|
2016-06-14 18:47:43 -07:00
|
|
|
}
|
2016-03-05 21:06:04 -08:00
|
|
|
static displayName = 'ToolPanel';
|
|
|
|
|
2016-05-20 12:42:26 -07:00
|
|
|
static propTypes = {
|
2016-06-14 18:47:43 -07:00
|
|
|
executeChallenge: PropTypes.func,
|
|
|
|
updateHint: PropTypes.func,
|
2016-07-11 17:44:50 -07:00
|
|
|
hint: PropTypes.string,
|
|
|
|
toggleHelpChat: PropTypes.func
|
2016-05-20 12:42:26 -07:00
|
|
|
};
|
|
|
|
|
2016-06-14 18:47:43 -07:00
|
|
|
makeHint() {
|
|
|
|
this.props.makeToast({
|
2016-07-08 12:06:02 -07:00
|
|
|
message: this.props.hint,
|
|
|
|
timeout: 4000
|
2016-06-14 18:47:43 -07:00
|
|
|
});
|
|
|
|
this.props.updateHint();
|
|
|
|
}
|
|
|
|
|
2016-07-07 20:02:03 -07:00
|
|
|
makeReset() {
|
|
|
|
this.props.makeToast({
|
|
|
|
message: 'This will restore your code editor to its original state.',
|
|
|
|
action: 'clear my code',
|
2016-07-08 12:06:02 -07:00
|
|
|
actionCreator: 'resetChallenge',
|
|
|
|
timeout: 4000
|
2016-07-07 20:02:03 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-14 18:47:43 -07:00
|
|
|
renderHint(hint, makeHint) {
|
|
|
|
if (!hint) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
block={ true }
|
|
|
|
bsStyle='primary'
|
|
|
|
className='btn-big'
|
|
|
|
onClick={ makeHint }
|
|
|
|
>
|
2016-07-07 20:02:03 -07:00
|
|
|
Hint
|
2016-06-14 18:47:43 -07:00
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-03-05 21:06:04 -08:00
|
|
|
render() {
|
2016-07-11 17:44:50 -07:00
|
|
|
const {
|
|
|
|
hint,
|
|
|
|
executeChallenge,
|
|
|
|
toggleHelpChat
|
|
|
|
} = this.props;
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
|
|
|
<div>
|
2016-06-14 18:47:43 -07:00
|
|
|
{ this.renderHint(hint, this.makeHint) }
|
2016-03-05 21:06:04 -08:00
|
|
|
<Button
|
|
|
|
block={ true }
|
|
|
|
bsStyle='primary'
|
2016-05-20 12:42:26 -07:00
|
|
|
className='btn-big'
|
2016-06-10 14:01:13 -07:00
|
|
|
onClick={ executeChallenge }
|
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
Run tests (ctrl + enter)
|
|
|
|
</Button>
|
|
|
|
<div className='button-spacer' />
|
|
|
|
<ButtonGroup
|
|
|
|
className='input-group'
|
2016-06-10 14:01:13 -07:00
|
|
|
justified={ true }
|
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
<Button
|
|
|
|
bsSize='large'
|
|
|
|
bsStyle='primary'
|
2016-06-10 14:01:13 -07:00
|
|
|
componentClass='label'
|
2016-07-07 20:02:03 -07:00
|
|
|
onClick={ this.makeReset }
|
2016-06-10 14:01:13 -07:00
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
Reset
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
bsSize='large'
|
|
|
|
bsStyle='primary'
|
2016-06-10 14:01:13 -07:00
|
|
|
componentClass='label'
|
2016-07-11 17:44:50 -07:00
|
|
|
onClick={ toggleHelpChat }
|
2016-06-10 14:01:13 -07:00
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
Help
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
bsSize='large'
|
|
|
|
bsStyle='primary'
|
2016-06-10 14:01:13 -07:00
|
|
|
componentClass='label'
|
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
Bug
|
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
<div className='button-spacer' />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|