Browse Source

Connect username and hard reset

master
meriadec 7 years ago
committed by Loëck Vézien
parent
commit
2a97d89965
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 6
      src/components/DashboardPage/index.js
  2. 2
      src/components/SettingsPage/index.js
  3. 4
      src/components/SettingsPage/sections/Display.js
  4. 54
      src/components/SettingsPage/sections/Profile.js
  5. 7
      src/components/base/Box/index.js
  6. 1
      src/components/base/Button/index.js
  7. 4
      src/components/base/Input/index.js
  8. 21
      src/components/base/Modal/ConfirmModal.js
  9. 1
      src/components/base/Modal/index.js
  10. 1
      src/types/common.js
  11. 1
      static/i18n/en/common.yml
  12. 5
      static/i18n/en/settings.yml

6
src/components/DashboardPage/index.js

@ -33,6 +33,7 @@ import AccountCard from './AccountCard'
import AccountsOrder from './AccountsOrder' import AccountsOrder from './AccountsOrder'
const mapStateToProps = state => ({ const mapStateToProps = state => ({
username: state.settings.username,
accounts: getVisibleAccounts(state), accounts: getVisibleAccounts(state),
counterValue: getCounterValueCode(state), counterValue: getCounterValueCode(state),
}) })
@ -48,6 +49,7 @@ type Props = {
accounts: Account[], accounts: Account[],
push: Function, push: Function,
counterValue: string, counterValue: string,
username: string,
} }
type State = { type State = {
@ -109,7 +111,7 @@ class DashboardPage extends PureComponent<Props, State> {
_cacheBalance = null _cacheBalance = null
render() { render() {
const { push, accounts, t, counterValue } = this.props const { push, accounts, t, counterValue, username } = this.props
const { accountsChunk, selectedTime, daysCount } = this.state const { accountsChunk, selectedTime, daysCount } = this.state
const totalAccounts = accounts.length const totalAccounts = accounts.length
@ -119,7 +121,7 @@ class DashboardPage extends PureComponent<Props, State> {
<Box horizontal alignItems="flex-end"> <Box horizontal alignItems="flex-end">
<Box grow> <Box grow>
<Text color="dark" ff="Museo Sans" fontSize={7}> <Text color="dark" ff="Museo Sans" fontSize={7}>
{t('dashboard:greetings', { name: 'Khalil' })} {t('dashboard:greetings', { name: username })}
</Text> </Text>
<Text color="grey" fontSize={5} ff="Museo Sans|Light"> <Text color="grey" fontSize={5} ff="Museo Sans|Light">
{totalAccounts > 0 {totalAccounts > 0

2
src/components/SettingsPage/index.js

@ -43,7 +43,7 @@ type State = {
class SettingsPage extends PureComponent<Props, State> { class SettingsPage extends PureComponent<Props, State> {
state = { state = {
tab: 2, tab: 0,
} }
_items = [] _items = []

4
src/components/SettingsPage/sections/Display.js

@ -31,7 +31,7 @@ type Props = {
type State = { type State = {
cachedLanguageKey: string, cachedLanguageKey: string,
cachedCounterValue: ?string, cachedCounterValue: ?Object,
} }
class TabProfile extends PureComponent<Props, State> { class TabProfile extends PureComponent<Props, State> {
@ -47,7 +47,7 @@ class TabProfile extends PureComponent<Props, State> {
} }
} }
handleChangeCounterValue = item => { handleChangeCounterValue = (item: Object) => {
const { saveSettings } = this.props const { saveSettings } = this.props
this.setState({ cachedCounterValue: item.fiat }) this.setState({ cachedCounterValue: item.fiat })
window.requestIdleCallback(() => { window.requestIdleCallback(() => {

54
src/components/SettingsPage/sections/Profile.js

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

7
src/components/base/Box/index.js

@ -11,12 +11,18 @@ import {
fontSize, fontSize,
justifyContent, justifyContent,
space, space,
style,
} from 'styled-system' } from 'styled-system'
import fontFamily from 'styles/styled/fontFamily' import fontFamily from 'styles/styled/fontFamily'
import Text from 'components/base/Text' import Text from 'components/base/Text'
const textAlign = style({
prop: 'textAlign',
cssProperty: 'textAlign',
})
const Box = styled.div` const Box = styled.div`
${alignItems}; ${alignItems};
${borderRadius}; ${borderRadius};
@ -27,6 +33,7 @@ const Box = styled.div`
${fontSize}; ${fontSize};
${justifyContent}; ${justifyContent};
${space}; ${space};
${textAlign};
display: flex; display: flex;
flex-shrink: ${p => (p.noShrink === true ? '0' : p.shrink === true ? '1' : '')}; flex-shrink: ${p => (p.noShrink === true ? '0' : p.shrink === true ? '1' : '')};

1
src/components/base/Button/index.js

@ -72,6 +72,7 @@ const Base = styled.button.attrs({
fontSize: p => p.fontSize || 3, fontSize: p => p.fontSize || 3,
px: 2, px: 2,
color: 'grey', color: 'grey',
bg: 'transparent',
})` })`
${space}; ${space};
${color}; ${color};

4
src/components/base/Input/index.js

@ -95,7 +95,7 @@ class Input extends PureComponent<Props, State> {
handleClick = () => this._input && this._input.focus() handleClick = () => this._input && this._input.focus()
handleFocus = e => { handleFocus = (e: SyntheticInputEvent<HTMLInputElement>) => {
const { onFocus } = this.props const { onFocus } = this.props
this.setState({ this.setState({
isFocus: true, isFocus: true,
@ -103,7 +103,7 @@ class Input extends PureComponent<Props, State> {
onFocus(e) onFocus(e)
} }
handleBlur = e => { handleBlur = (e: SyntheticInputEvent<HTMLInputElement>) => {
const { onBlur } = this.props const { onBlur } = this.props
this.setState({ this.setState({
isFocus: false, isFocus: false,

21
src/components/base/Modal/ConfirmModal.js

@ -18,18 +18,33 @@ type Props = {
desc: string, desc: string,
confirmText: string, confirmText: string,
cancelText: string, cancelText: string,
onReject: Function,
onConfirm: Function,
t: T, t: T,
} }
class ConfirmModal extends PureComponent<Props> { class ConfirmModal extends PureComponent<Props> {
render() { render() {
const { isOpened, title, subTitle, desc, confirmText, cancelText, isDanger, t } = this.props const {
isOpened,
title,
subTitle,
desc,
confirmText,
cancelText,
isDanger,
onReject,
onConfirm,
t,
...props
} = this.props
const realConfirmText = confirmText || t('common:confirm') const realConfirmText = confirmText || t('common:confirm')
const realCancelText = cancelText || t('common:cancel') const realCancelText = cancelText || t('common:cancel')
return ( return (
<Modal <Modal
isOpened={isOpened} isOpened={isOpened}
{...props}
render={({ onClose }) => ( render={({ onClose }) => (
<ModalBody onClose={onClose}> <ModalBody onClose={onClose}>
<ModalTitle>{title}</ModalTitle> <ModalTitle>{title}</ModalTitle>
@ -44,8 +59,8 @@ class ConfirmModal extends PureComponent<Props> {
</Box> </Box>
</ModalContent> </ModalContent>
<ModalFooter horizontal align="center" justify="flex-end" flow={2}> <ModalFooter horizontal align="center" justify="flex-end" flow={2}>
<Button>{realCancelText}</Button> <Button onClick={onReject}>{realCancelText}</Button>
<Button primary={!isDanger} danger={isDanger}> <Button onClick={onConfirm} primary={!isDanger} danger={isDanger}>
{realConfirmText} {realConfirmText}
</Button> </Button>
</ModalFooter> </ModalFooter>

1
src/components/base/Modal/index.js

@ -21,6 +21,7 @@ import GrowScroll from 'components/base/GrowScroll'
import Defer from 'components/base/Defer' import Defer from 'components/base/Defer'
export { default as ModalBody } from './ModalBody' export { default as ModalBody } from './ModalBody'
export { default as ConfirmModal } from './ConfirmModal'
const springConfig = { const springConfig = {
stiffness: 320, stiffness: 320,

1
src/types/common.js

@ -14,6 +14,7 @@ export type Devices = Array<Device>
export type Settings = { export type Settings = {
language: string, language: string,
username: string,
counterValue: string, counterValue: string,
password: { password: {
isEnabled: boolean, isEnabled: boolean,

1
static/i18n/en/common.yml

@ -1,4 +1,5 @@
ok: Okay ok: Okay
confirm: Confirm
cancel: Cancel cancel: Cancel
chooseWalletPlaceholder: Choose a wallet... chooseWalletPlaceholder: Choose a wallet...
currency: Currency currency: Currency

5
static/i18n/en/settings.yml

@ -33,6 +33,7 @@ profile:
exportDesc: Lorem ipsum dolor sit amet exportDesc: Lorem ipsum dolor sit amet
reset: Reset application reset: Reset application
resetDesc: Lorem ipsum dolor sit amet resetDesc: Lorem ipsum dolor sit amet
resetButton: Hard reset
about: about:
faq: FAQ faq: FAQ
faqDesc: Lorem ipsum dolor sit amet faqDesc: Lorem ipsum dolor sit amet
@ -40,3 +41,7 @@ about:
contactUsDesc: Lorem ipsum dolor sit amet contactUsDesc: Lorem ipsum dolor sit amet
terms: Terms and Privacy policy terms: Terms and Privacy policy
termsDesc: Lorem ipsum dolor sit amet termsDesc: Lorem ipsum dolor sit amet
hardResetModal:
title: Hard reset
subTitle: Are you sure houston?
desc: Lorem ipsum dolor sit amet

Loading…
Cancel
Save