mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
import { React, MailRulesStore, Actions } from 'mailspring-exports';
|
|
import { Notification } from 'mailspring-component-kit';
|
|
|
|
export default class DisabledMailRulesNotification extends React.Component {
|
|
static displayName = 'DisabledMailRulesNotification';
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = this.getStateFromStores();
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.unlisten = MailRulesStore.listen(() => this.setState(this.getStateFromStores()));
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.unlisten();
|
|
}
|
|
|
|
getStateFromStores() {
|
|
return {
|
|
disabledRules: MailRulesStore.disabledRules(),
|
|
};
|
|
}
|
|
|
|
_onOpenMailRulesPreferences = () => {
|
|
Actions.switchPreferencesTab('Mail Rules', {
|
|
accountId: this.state.disabledRules[0].accountId,
|
|
});
|
|
Actions.openPreferences();
|
|
};
|
|
|
|
render() {
|
|
if (this.state.disabledRules.length === 0) {
|
|
return <span />;
|
|
}
|
|
return (
|
|
<Notification
|
|
priority="2"
|
|
title="One or more of your mail rules have been disabled."
|
|
icon="volstead-defaultclient.png"
|
|
isError
|
|
actions={[
|
|
{
|
|
label: 'View Mail Rules',
|
|
fn: this._onOpenMailRulesPreferences,
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
}
|
|
}
|