application/components/draftable/draft-restore.js
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import BaseView from './../base-view';
/**
* Draft restore notification, accepts
* * onRestore - callback
* * pendingDraft - immutable map
* * label - notification text
* * buttonLabel - label text for restore button
* * buttonClass = class(es) for restore button
*/
class DraftRestore extends BaseView {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
e.preventDefault();
e.stopPropagation();
this.props.onRestore();
}
render() {
if (this.props.pendingDraft && this.props.pendingDraft.size) {
return (
<div className='restore-draft-button' style={{display:'inline-block'}}>
{this.props.label ? this.props.label + ' ' : ' '}
<RaisedButton
className={this.props.buttonClass}
onClick={this.handleClick}
secondary={true}
label={this.props.buttonLabel ? this.props.buttonLabel : 'Restore?'}
/>
</div>
);
}
return <span></span>;
}
}
export default DraftRestore;