mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
647aed5f14
Summary: - Include ES6 files in spec-suite - Fix template store specs - Refactors TemplateStore a little bit to adjust to specs - Convert coffe .cjsx files to ES6 .jsx files - Fix TemplateDraftStoreExtension functions - Update ComposerTemplates example README Test Plan: - Plugin unit tests Reviewers: bengotow, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2250
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
import {DraftStore, React} from 'nylas-exports';
|
|
|
|
class TemplateStatusBar extends React.Component {
|
|
static displayName = 'TemplateStatusBar'
|
|
|
|
static propTypes = {
|
|
draftClientId: React.PropTypes.string,
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = { draft: null };
|
|
}
|
|
|
|
componentDidMount() {
|
|
DraftStore.sessionForClientId(this.props.draftClientId).then((_proxy)=> {
|
|
if (this._unmounted) {
|
|
return;
|
|
}
|
|
if (_proxy.draftClientId === this.props.draftClientId) {
|
|
this._proxy = _proxy;
|
|
this.unsubscribe = this._proxy.listen(this._onDraftChange.bind(this), this);
|
|
this._onDraftChange();
|
|
}
|
|
});
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this._unmounted = true;
|
|
if (this.unsubscribe) this.unsubscribe();
|
|
}
|
|
|
|
static containerStyles = {
|
|
textAlign: 'center',
|
|
width: 530,
|
|
margin: 'auto',
|
|
}
|
|
|
|
_onDraftChange() {
|
|
this.setState({draft: this._proxy.draft()});
|
|
}
|
|
|
|
_draftUsesTemplate() {
|
|
if (this.state.draft) {
|
|
return this.state.draft.body.search(/<code[^>]*class="var[^>]*>/i) > 0;
|
|
}
|
|
}
|
|
|
|
render() {
|
|
if (this._draftUsesTemplate()) {
|
|
return (
|
|
<div className="template-status-bar">
|
|
Press "tab" to quickly fill in the blanks - highlighting will not be visible to recipients.
|
|
</div>
|
|
);
|
|
}
|
|
return <div></div>;
|
|
}
|
|
|
|
}
|
|
|
|
export default TemplateStatusBar;
|