/* eslint global-require: 0*/ import React from 'react'; import PropTypes from 'prop-types'; import rimraf from 'rimraf'; import { localized } from 'mailspring-exports'; import ConfigSchemaItem from './config-schema-item'; import WorkspaceSection from './workspace-section'; import SendingSection from './sending-section'; import LanguageSection from './language-section'; import { ConfigLike, ConfigSchemaLike } from '../types'; import { remote } from 'electron'; class PreferencesGeneral extends React.Component<{ config: ConfigLike; configSchema: ConfigSchemaLike; }> { static displayName = 'PreferencesGeneral'; static propTypes = { config: PropTypes.object, configSchema: PropTypes.object, }; _onReboot = () => { const app = require('electron').remote.app; app.relaunch(); app.quit(); }; _onResetAccountsAndSettings = () => { const chosen = remote.dialog.showMessageBox(AppEnv.getCurrentWindow(), { type: 'info', message: localized('Are you sure?'), buttons: [localized('Cancel'), localized('Reset')], }); if (chosen === 1) { rimraf(AppEnv.getConfigDirPath(), { disableGlob: true }, err => { if (err) { return AppEnv.showErrorDialog( localized( `Could not reset accounts and settings. Please delete the folder %@ manually.\n\n%@`, AppEnv.getConfigDirPath(), err.toString() ) ); } this._onReboot(); }); } }; _onResetEmailCache = () => { const ipc = require('electron').ipcRenderer; ipc.send('command', 'application:reset-database', {}); }; render() { return (