|
|
@ -2,12 +2,16 @@ |
|
|
|
|
|
|
|
import React, { PureComponent } from 'react' |
|
|
|
import { connect } from 'react-redux' |
|
|
|
import { remote } from 'electron' |
|
|
|
|
|
|
|
import type { Settings, T } from 'types/common' |
|
|
|
|
|
|
|
import { unlock } from 'reducers/application' |
|
|
|
import db from 'helpers/db' |
|
|
|
|
|
|
|
import Input from 'components/base/Input' |
|
|
|
import Button from 'components/base/Button' |
|
|
|
import { ConfirmModal } from 'components/base/Modal' |
|
|
|
import IconUser from 'icons/User' |
|
|
|
|
|
|
|
import { |
|
|
@ -17,6 +21,14 @@ import { |
|
|
|
SettingsSectionRow as Row, |
|
|
|
} from '../SettingsSection' |
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
username: state.settings, |
|
|
|
}) |
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
unlock, |
|
|
|
} |
|
|
|
|
|
|
|
type Props = { |
|
|
|
t: T, |
|
|
|
settings: Settings, |
|
|
@ -24,19 +36,15 @@ type Props = { |
|
|
|
// unlock: Function,
|
|
|
|
} |
|
|
|
|
|
|
|
type State = {} |
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
username: state.settings, |
|
|
|
}) |
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
unlock, |
|
|
|
type State = { |
|
|
|
isHardResetModalOpened: boolean, |
|
|
|
username: string, |
|
|
|
} |
|
|
|
|
|
|
|
class TabProfile extends PureComponent<Props, State> { |
|
|
|
state = { |
|
|
|
username: this.props.settings.username, |
|
|
|
isHardResetModalOpened: false, |
|
|
|
} |
|
|
|
|
|
|
|
handleChangeUsername = username => { |
|
|
@ -47,9 +55,18 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
handleOpenHardResetModal = () => this.setState({ isHardResetModalOpened: true }) |
|
|
|
handleCloseHardResetModal = () => this.setState({ isHardResetModalOpened: false }) |
|
|
|
|
|
|
|
handleHardReset = () => { |
|
|
|
db.resetAll() |
|
|
|
remote.app.relaunch() |
|
|
|
remote.app.exit() |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
const { t } = this.props |
|
|
|
const { username } = this.state |
|
|
|
const { username, isHardResetModalOpened } = this.state |
|
|
|
|
|
|
|
return ( |
|
|
|
<Section> |
|
|
@ -71,15 +88,28 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
|
{'-'} |
|
|
|
</Row> |
|
|
|
<Row title={t('settings:profile.sync')} desc={t('settings:profile.syncDesc')}> |
|
|
|
{'-'} |
|
|
|
<Button primary>{t('settings:profile.sync')}</Button> |
|
|
|
</Row> |
|
|
|
<Row title={t('settings:profile.export')} desc={t('settings:profile.exportDesc')}> |
|
|
|
{'-'} |
|
|
|
<Button primary>{t('settings:profile.export')}</Button> |
|
|
|
</Row> |
|
|
|
<Row title={t('settings:profile.reset')} desc={t('settings:profile.resetDesc')}> |
|
|
|
{'-'} |
|
|
|
<Button danger onClick={this.handleOpenHardResetModal}> |
|
|
|
{t('settings:profile.resetButton')} |
|
|
|
</Button> |
|
|
|
</Row> |
|
|
|
</Body> |
|
|
|
|
|
|
|
<ConfirmModal |
|
|
|
isDanger |
|
|
|
isOpened={isHardResetModalOpened} |
|
|
|
onClose={this.handleCloseHardResetModal} |
|
|
|
onReject={this.handleCloseHardResetModal} |
|
|
|
onConfirm={this.handleHardReset} |
|
|
|
title={t('settings:hardResetModal.title')} |
|
|
|
subTitle={t('settings:hardResetModal.subTitle')} |
|
|
|
desc={t('settings:hardResetModal.desc')} |
|
|
|
/> |
|
|
|
</Section> |
|
|
|
) |
|
|
|
} |
|
|
|