Introduces password management section redesign
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View } from 'react-native'
|
|
||||||
import settings from '../../../i18n/en/settings'
|
import Button from '../../common/button'
|
||||||
|
|
||||||
import EnterNewPassword from './enter-new-password'
|
import EnterNewPassword from './enter-new-password'
|
||||||
import SettingsButton from '../shared/settings-button'
|
|
||||||
import showBackUpReminder from './show-backup-reminder'
|
import showBackUpReminder from './show-backup-reminder'
|
||||||
|
|
||||||
|
import settings from '../../../i18n/en/settings'
|
||||||
|
|
||||||
export default class CreatePassword extends Component {
|
export default class CreatePassword extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
|
||||||
isSettingPassword: false
|
this.state = { isSettingPassword: false }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSettingPassword = () => {
|
toggleSettingPassword = () => {
|
||||||
@@ -23,18 +24,14 @@ export default class CreatePassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const { isSettingPassword } = this.state
|
||||||
isSettingPassword
|
|
||||||
} = this.state
|
|
||||||
const labels = settings.passwordSettings
|
const labels = settings.passwordSettings
|
||||||
|
|
||||||
if (!isSettingPassword) {
|
if (!isSettingPassword) {
|
||||||
return (
|
return (
|
||||||
<View>
|
<Button isCTA onPress={this.startSettingPassword}>
|
||||||
<SettingsButton onPress={this.startSettingPassword}>
|
{labels.setPassword}
|
||||||
{labels.setPassword}
|
</Button>
|
||||||
</SettingsButton>
|
|
||||||
</View>
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return <EnterNewPassword />
|
return <EnterNewPassword />
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import labels from '../../../i18n/en/settings'
|
import Button from '../../common/button'
|
||||||
import { changeEncryptionAndRestartApp } from '../../../db'
|
|
||||||
import ConfirmWithPassword from '../shared/confirm-with-password'
|
import ConfirmWithPassword from '../shared/confirm-with-password'
|
||||||
import SettingsButton from '../shared/settings-button'
|
|
||||||
|
import { changeEncryptionAndRestartApp } from '../../../db'
|
||||||
|
import labels from '../../../i18n/en/settings'
|
||||||
|
|
||||||
export default class DeletePassword extends Component {
|
export default class DeletePassword extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
onStartDelete: PropTypes.func,
|
||||||
|
onCancelDelete: PropTypes.func
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
|
||||||
enteringCurrentPassword: false
|
this.state = { enteringCurrentPassword: false }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startConfirmWithPassword = () => {
|
startConfirmWithPassword = () => {
|
||||||
@@ -29,7 +34,6 @@ export default class DeletePassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const { enteringCurrentPassword } = this.state
|
const { enteringCurrentPassword } = this.state
|
||||||
|
|
||||||
if (enteringCurrentPassword) {
|
if (enteringCurrentPassword) {
|
||||||
@@ -42,14 +46,9 @@ export default class DeletePassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsButton onPress={this.startConfirmWithPassword} >
|
<Button isCTA onPress={this.startConfirmWithPassword}>
|
||||||
{labels.passwordSettings.deletePassword}
|
{labels.passwordSettings.deletePassword}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DeletePassword.propTypes = {
|
|
||||||
onStartDelete: PropTypes.func,
|
|
||||||
onCancelDelete: PropTypes.func
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View } from 'react-native'
|
import { StyleSheet } from 'react-native'
|
||||||
import nodejs from 'nodejs-mobile-react-native'
|
import nodejs from 'nodejs-mobile-react-native'
|
||||||
|
|
||||||
import { requestHash, changeEncryptionAndRestartApp } from '../../../db'
|
|
||||||
import AppText from '../../common/app-text'
|
import AppText from '../../common/app-text'
|
||||||
import PasswordField from '../shared/password-field'
|
import AppTextInput from '../../common/app-text-input'
|
||||||
import SettingsButton from '../shared/settings-button'
|
import Button from '../../common/button'
|
||||||
|
|
||||||
import styles from '../../../styles'
|
import { requestHash, changeEncryptionAndRestartApp } from '../../../db'
|
||||||
|
import { Colors, Spacing } from '../../../styles/redesign'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
|
|
||||||
const LISTENER_TYPE = 'create-or-change-pw'
|
const LISTENER_TYPE = 'create-or-change-pw'
|
||||||
@@ -36,9 +36,7 @@ export default class EnterNewPassword extends Component {
|
|||||||
if (this.comparePasswords()) {
|
if (this.comparePasswords()) {
|
||||||
requestHash(LISTENER_TYPE, this.state.password)
|
requestHash(LISTENER_TYPE, this.state.password)
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({ shouldShowErrorMessage: true })
|
||||||
shouldShowErrorMessage: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,40 +56,40 @@ export default class EnterNewPassword extends Component {
|
|||||||
const {
|
const {
|
||||||
password,
|
password,
|
||||||
passwordConfirmation,
|
passwordConfirmation,
|
||||||
shouldShowErrorMessage,
|
shouldShowErrorMessage
|
||||||
} = this.state
|
} = this.state
|
||||||
const labels = settings.passwordSettings
|
const labels = settings.passwordSettings
|
||||||
|
const isButtonActive =
|
||||||
const isSaveButtonDisabled =
|
Boolean(password.length && passwordConfirmation.length)
|
||||||
!password.length ||
|
|
||||||
!passwordConfirmation.length
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<React.Fragment>
|
||||||
<PasswordField
|
<AppTextInput
|
||||||
placeholder={labels.enterNew}
|
|
||||||
value={password}
|
|
||||||
onChangeText={this.handlePasswordInput}
|
onChangeText={this.handlePasswordInput}
|
||||||
|
placeholder={labels.enterNew}
|
||||||
|
textContentType="password"
|
||||||
|
value={password}
|
||||||
/>
|
/>
|
||||||
<PasswordField
|
<AppTextInput
|
||||||
autoFocus={false}
|
|
||||||
placeholder={labels.confirmPassword}
|
|
||||||
value={passwordConfirmation}
|
|
||||||
onChangeText={this.handleConfirmationInput}
|
onChangeText={this.handleConfirmationInput}
|
||||||
|
placeholder={labels.confirmPassword}
|
||||||
|
textContentType="password"
|
||||||
|
value={passwordConfirmation}
|
||||||
/>
|
/>
|
||||||
{
|
{shouldShowErrorMessage &&
|
||||||
shouldShowErrorMessage &&
|
<AppText style={styles.error}>{labels.passwordsDontMatch}</AppText>
|
||||||
<AppText style={styles.errorMessage}>
|
|
||||||
{labels.passwordsDontMatch}
|
|
||||||
</AppText>
|
|
||||||
}
|
}
|
||||||
<SettingsButton
|
<Button isCTA={isButtonActive} isSmall onPress={this.savePassword}>
|
||||||
onPress={this.savePassword}
|
|
||||||
disabled={isSaveButtonDisabled}
|
|
||||||
>
|
|
||||||
{labels.savePassword}
|
{labels.savePassword}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
</View>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
error: {
|
||||||
|
color: Colors.orange,
|
||||||
|
marginTop: Spacing.base
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { ScrollView } from 'react-native'
|
|
||||||
|
import AppPage from '../../common/app-page'
|
||||||
|
import AppText from '../../common/app-text'
|
||||||
|
import Segment from '../../common/segment'
|
||||||
|
|
||||||
import CreatePassword from './create'
|
import CreatePassword from './create'
|
||||||
import ChangePassword from './update'
|
import ChangePassword from './update'
|
||||||
import DeletePassword from './delete'
|
import DeletePassword from './delete'
|
||||||
import Segment from '../../common/segment'
|
|
||||||
import AppText from '../../common/app-text'
|
import { hasEncryptionObservable } from '../../../local-storage'
|
||||||
import {
|
|
||||||
hasEncryptionObservable
|
|
||||||
} from '../../../local-storage'
|
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
|
|
||||||
export default class PasswordSetting extends Component {
|
export default class PasswordSetting extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isPasswordSet: hasEncryptionObservable.value,
|
isPasswordSet: hasEncryptionObservable.value,
|
||||||
isChangingPassword: false,
|
isChangingPassword: false,
|
||||||
@@ -51,29 +53,29 @@ export default class PasswordSetting extends Component {
|
|||||||
} = labels.passwordSettings
|
} = labels.passwordSettings
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<AppPage>
|
||||||
<Segment title={title}>
|
<Segment title={title} last>
|
||||||
<AppText>
|
<AppText>
|
||||||
{ isPasswordSet ? explainerEnabled : explainerDisabled }
|
{isPasswordSet ? explainerEnabled : explainerDisabled}
|
||||||
</AppText>
|
</AppText>
|
||||||
|
|
||||||
{ !isPasswordSet && <CreatePassword/> }
|
{!isPasswordSet && <CreatePassword/>}
|
||||||
|
|
||||||
{ (isPasswordSet && !isDeletingPassword) && (
|
{(isPasswordSet && !isDeletingPassword) && (
|
||||||
<ChangePassword
|
<ChangePassword
|
||||||
onStartChange = {this.onChangingPassword}
|
onStartChange = {this.onChangingPassword}
|
||||||
onCancelChange = {this.onCancelChangingPassword}
|
onCancelChange = {this.onCancelChangingPassword}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{ (isPasswordSet && !isChangingPassword) && (
|
{(isPasswordSet && !isChangingPassword) && (
|
||||||
<DeletePassword
|
<DeletePassword
|
||||||
onStartDelete = {this.onDeletingPassword}
|
onStartDelete = {this.onDeletingPassword}
|
||||||
onCancelDelete = {this.onCancelDeletingPassword}
|
onCancelDelete = {this.onCancelDeletingPassword}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Segment>
|
</Segment>
|
||||||
</ScrollView>
|
</AppPage>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import settings from '../../../i18n/en/settings'
|
import Button from '../../common/button'
|
||||||
|
|
||||||
import EnterNewPassword from './enter-new-password'
|
import EnterNewPassword from './enter-new-password'
|
||||||
import SettingsButton from '../shared/settings-button'
|
|
||||||
import showBackUpReminder from './show-backup-reminder'
|
import showBackUpReminder from './show-backup-reminder'
|
||||||
import ConfirmWithPassword from '../shared/confirm-with-password'
|
import ConfirmWithPassword from '../shared/confirm-with-password'
|
||||||
|
|
||||||
|
import settings from '../../../i18n/en/settings'
|
||||||
|
|
||||||
export default class ChangePassword extends Component {
|
export default class ChangePassword extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
onStartChange: PropTypes.func,
|
||||||
|
onCancelChange: PropTypes.func
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
currentPassword: null,
|
currentPassword: null,
|
||||||
enteringCurrentPassword: false,
|
enteringCurrentPassword: false,
|
||||||
@@ -48,14 +55,13 @@ export default class ChangePassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
enteringCurrentPassword,
|
enteringCurrentPassword,
|
||||||
enteringNewPassword,
|
enteringNewPassword,
|
||||||
currentPassword
|
currentPassword
|
||||||
} = this.state
|
} = this.state
|
||||||
|
|
||||||
const labels = settings.passwordSettings
|
const labels = settings.passwordSettings
|
||||||
|
const isDisabled = currentPassword !== null
|
||||||
|
|
||||||
if (enteringCurrentPassword) {
|
if (enteringCurrentPassword) {
|
||||||
return (
|
return (
|
||||||
@@ -71,17 +77,9 @@ export default class ChangePassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsButton
|
<Button disabled={isDisabled} isCTA onPress={this.startChangingPassword}>
|
||||||
onPress={this.startChangingPassword}
|
|
||||||
disabled={currentPassword}
|
|
||||||
>
|
|
||||||
{labels.changePassword}
|
{labels.changePassword}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ChangePassword.propTypes = {
|
|
||||||
onStartChange: PropTypes.func,
|
|
||||||
onCancelChange: PropTypes.func
|
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,22 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { View, Alert } from 'react-native'
|
import { Alert, StyleSheet, View } from 'react-native'
|
||||||
|
|
||||||
import nodejs from 'nodejs-mobile-react-native'
|
import nodejs from 'nodejs-mobile-react-native'
|
||||||
|
|
||||||
|
import AppTextInput from '../../common/app-text-input'
|
||||||
|
import Button from '../../common/button'
|
||||||
|
|
||||||
import { requestHash, openDb } from '../../../db'
|
import { requestHash, openDb } from '../../../db'
|
||||||
|
import { Containers } from '../../../styles/redesign'
|
||||||
import PasswordField from './password-field'
|
|
||||||
import SettingsButton from '../shared/settings-button'
|
|
||||||
|
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import { shared } from '../../../i18n/en/labels'
|
import { shared } from '../../../i18n/en/labels'
|
||||||
|
|
||||||
export default class ConfirmWithPassword extends Component {
|
export default class ConfirmWithPassword extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
|
||||||
password: null
|
this.state = { password: null }
|
||||||
}
|
nodejs.channel.addListener('password-check', this.checkPassword, this)
|
||||||
nodejs.channel.addListener(
|
|
||||||
'password-check',
|
|
||||||
this.checkPassword,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@@ -67,36 +62,24 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const { password } = this.state
|
const { password } = this.state
|
||||||
const labels = settings.passwordSettings
|
const labels = settings.passwordSettings
|
||||||
|
const isCTA = password !== null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<React.Fragment>
|
||||||
<PasswordField
|
<AppTextInput
|
||||||
|
onChangeText={this.handlePasswordInput}
|
||||||
placeholder={labels.enterCurrent}
|
placeholder={labels.enterCurrent}
|
||||||
value={password}
|
value={password}
|
||||||
onChangeText={this.handlePasswordInput}
|
|
||||||
/>
|
/>
|
||||||
<View style={{
|
<View style={styles.container}>
|
||||||
flex: 1,
|
<Button isSmall onPress={this.props.onCancel}>
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between'
|
|
||||||
}}>
|
|
||||||
<SettingsButton
|
|
||||||
onPress={this.props.onCancel}
|
|
||||||
secondary
|
|
||||||
>
|
|
||||||
{shared.cancel}
|
{shared.cancel}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
<SettingsButton
|
<Button isCTA={isCTA} isSmall onPress={this.initPasswordCheck}>
|
||||||
onPress={this.initPasswordCheck}
|
|
||||||
disabled={!password}
|
|
||||||
style={{
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{shared.confirmToProceed}
|
{shared.confirmToProceed}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -105,4 +88,10 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
ConfirmWithPassword.propTypes = {
|
ConfirmWithPassword.propTypes = {
|
||||||
onSuccess: PropTypes.func,
|
onSuccess: PropTypes.func,
|
||||||
onCancel: PropTypes.func
|
onCancel: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
...Containers.rowContainer
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user