Mailspring/app/internal_packages/preferences/lib/tabs/preferences-general.jsx

91 lines
2.6 KiB
React
Raw Normal View History

/* eslint global-require: 0*/
import React from 'react';
2017-09-27 02:33:08 +08:00
import PropTypes from 'prop-types';
import { Actions } from 'mailspring-exports';
import ConfigSchemaItem from './config-schema-item';
import WorkspaceSection from './workspace-section';
import SendingSection from './sending-section';
2017-08-01 13:21:00 +08:00
class PreferencesGeneral extends React.Component {
2017-09-27 02:33:08 +08:00
static displayName = 'PreferencesGeneral';
2016-05-07 07:23:48 +08:00
static propTypes = {
2017-09-27 02:33:08 +08:00
config: PropTypes.object,
configSchema: PropTypes.object,
};
2016-05-07 07:23:48 +08:00
_reboot = () => {
const app = require('electron').remote.app;
2017-09-27 02:33:08 +08:00
app.relaunch();
app.quit();
};
_resetAccountsAndSettings = () => {
2017-09-27 02:33:08 +08:00
const rimraf = require('rimraf');
2017-09-27 02:36:58 +08:00
rimraf(AppEnv.getConfigDirPath(), { disableGlob: true }, err => {
2017-09-27 02:33:08 +08:00
if (err) console.log(err);
else this._reboot();
});
};
_resetEmailCache = () => {
2017-09-27 02:33:08 +08:00
Actions.resetEmailCache();
};
render() {
return (
2017-09-27 02:33:08 +08:00
<div className="container-general" style={{ maxWidth: 600 }}>
<WorkspaceSection config={this.props.config} configSchema={this.props.configSchema} />
<ConfigSchemaItem
configSchema={this.props.configSchema.properties.notifications}
keyName="Notifications"
keyPath="core.notifications"
config={this.props.config}
/>
<div className="platform-note platform-linux-only">
2017-09-27 02:33:08 +08:00
N1 desktop notifications on Linux require Zenity. You may need to install it with your
package manager (i.e., <code>sudo apt-get install zenity</code>).
</div>
<ConfigSchemaItem
configSchema={this.props.configSchema.properties.reading}
keyName="Reading"
keyPath="core.reading"
config={this.props.config}
/>
<ConfigSchemaItem
configSchema={this.props.configSchema.properties.composing}
keyName="Composing"
keyPath="core.composing"
config={this.props.config}
/>
2017-09-27 02:33:08 +08:00
<SendingSection config={this.props.config} configSchema={this.props.configSchema} />
<ConfigSchemaItem
configSchema={this.props.configSchema.properties.attachments}
keyName="Attachments"
keyPath="core.attachments"
config={this.props.config}
/>
<div className="local-data">
<h6>Local Data</h6>
2017-09-27 02:33:08 +08:00
<div className="btn" onClick={this._resetEmailCache}>
Reset Email Cache
</div>
<div className="btn" onClick={this._resetAccountsAndSettings}>
Reset Accounts and Settings
</div>
</div>
</div>
2017-09-27 02:33:08 +08:00
);
}
}
export default PreferencesGeneral;