Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
5d29bcdc
Commit
5d29bcdc
authored
6 years ago
by
mashazyu
Committed by
Sofiya Tepikin
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reuse ConfirmWithPassword component in ChangePassword component
parent
95359ce2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/settings/password/update.js
+23
-60
23 additions, 60 deletions
components/settings/password/update.js
with
23 additions
and
60 deletions
components/settings/password/update.js
+
23
−
60
View file @
5d29bcdc
import
React
,
{
Component
}
from
'
react
'
import
React
,
{
Component
}
from
'
react
'
import
{
View
}
from
'
react-native
'
import
nodejs
from
'
nodejs-mobile-react-native
'
import
{
shared
as
sharedLabels
}
from
'
../../../i18n/en/labels
'
import
settings
from
'
../../../i18n/en/settings
'
import
settings
from
'
../../../i18n/en/settings
'
import
{
requestHash
}
from
'
../../../db
'
import
EnterNewPassword
from
'
./enter-new-password
'
import
EnterNewPassword
from
'
./enter-new-password
'
import
PasswordField
from
'
./password-field
'
import
SettingsButton
from
'
../settings-button
'
import
SettingsButton
from
'
../settings-button
'
import
showBackUpReminder
from
'
./show-backup-reminder
'
import
showBackUpReminder
from
'
./show-backup-reminder
'
import
checkCurrent
Password
from
'
./c
heck-current
-password
'
import
ConfirmWith
Password
from
'
.
.
/c
ommon/confirm-with
-password
'
export
default
class
ChangePassword
extends
Component
{
export
default
class
ChangePassword
extends
Component
{
...
@@ -19,35 +14,6 @@ export default class ChangePassword extends Component {
...
@@ -19,35 +14,6 @@ export default class ChangePassword extends Component {
enteringCurrentPassword
:
false
,
enteringCurrentPassword
:
false
,
enteringNewPassword
:
false
enteringNewPassword
:
false
}
}
nodejs
.
channel
.
addListener
(
'
pre-change-pw-check
'
,
this
.
openNewPasswordField
,
this
)
}
componentWillUnmount
()
{
nodejs
.
channel
.
removeListener
(
'
pre-change-pw-check
'
,
this
.
openNewPasswordField
)
}
openNewPasswordField
=
async
hash
=>
{
const
passwordCorrect
=
await
checkCurrentPassword
({
hash
,
onTryAgain
:
()
=>
this
.
setState
({
currentPassword
:
null
}),
onCancel
:
()
=>
this
.
setState
({
enteringCurrentPassword
:
false
,
currentPassword
:
null
})
})
if
(
passwordCorrect
)
{
this
.
setState
({
currentPassword
:
null
,
enteringNewPassword
:
true
,
enteringCurrentPassword
:
false
})
}
}
}
startChangingPassword
=
()
=>
{
startChangingPassword
=
()
=>
{
...
@@ -56,12 +22,20 @@ export default class ChangePassword extends Component {
...
@@ -56,12 +22,20 @@ export default class ChangePassword extends Component {
})
})
}
}
handleCurrentPasswordInput
=
(
currentPassword
)
=>
{
startEnteringNewPassword
=
()
=>
{
this
.
setState
({
currentPassword
})
this
.
setState
({
currentPassword
:
null
,
enteringNewPassword
:
true
,
enteringCurrentPassword
:
false
})
}
}
checkCurrentPassword
=
()
=>
{
cancelConfirmationWithPassword
=
()
=>
{
requestHash
(
'
pre-change-pw-check
'
,
this
.
state
.
currentPassword
)
this
.
setState
({
currentPassword
:
null
,
enteringNewPassword
:
false
,
enteringCurrentPassword
:
false
})
}
}
render
()
{
render
()
{
...
@@ -76,19 +50,10 @@ export default class ChangePassword extends Component {
...
@@ -76,19 +50,10 @@ export default class ChangePassword extends Component {
if
(
enteringCurrentPassword
)
{
if
(
enteringCurrentPassword
)
{
return
(
return
(
<
View
>
<
ConfirmWithPassword
<
PasswordField
onSuccess
=
{
this
.
startEnteringNewPassword
}
placeholder
=
{
labels
.
enterCurrent
}
onCancel
=
{
this
.
cancelConfirmationWithPassword
}
value
=
{
currentPassword
}
/
>
onChangeText
=
{
this
.
handleCurrentPasswordInput
}
/
>
<
SettingsButton
onPress
=
{
this
.
checkCurrentPassword
}
disabled
=
{
!
currentPassword
}
>
{
sharedLabels
.
unlock
}
<
/SettingsButton
>
<
/View
>
)
)
}
}
...
@@ -97,14 +62,12 @@ export default class ChangePassword extends Component {
...
@@ -97,14 +62,12 @@ export default class ChangePassword extends Component {
}
}
return
(
return
(
<
View
>
<
SettingsButton
<
SettingsButton
onPress
=
{
this
.
startChangingPassword
}
onPress
=
{
this
.
startChangingPassword
}
disabled
=
{
currentPassword
}
disabled
=
{
currentPassword
}
>
>
{
labels
.
changePassword
}
{
labels
.
changePassword
}
<
/SettingsButton
>
<
/SettingsButton
>
<
/View
>
)
)
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment