-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup and simplify the settings password code (#2982)
- Loading branch information
Showing
8 changed files
with
76 additions
and
132 deletions.
There are no files selected for viewing
11 changes: 5 additions & 6 deletions
11
src/renderer/components/password-dialog/password-dialog.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
.card { | ||
position: relative; | ||
width: 85%; | ||
height: 25%; | ||
margin: auto; | ||
box-sizing: border-box; | ||
width: 85%; | ||
margin: auto; | ||
box-sizing: border-box; | ||
} | ||
|
||
.passwordInput { | ||
width: 100%; | ||
width: 100%; | ||
} |
47 changes: 8 additions & 39 deletions
47
src/renderer/components/password-dialog/password-dialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,27 @@ | ||
import Vue from 'vue' | ||
import { mapActions } from 'vuex' | ||
import FtCard from '../ft-card/ft-card.vue' | ||
import FtInput from '../ft-input/ft-input.vue' | ||
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue' | ||
import FtPrompt from '../ft-prompt/ft-prompt.vue' | ||
|
||
export default Vue.extend({ | ||
name: 'PasswordDialog', | ||
components: { | ||
'ft-input': FtInput, | ||
'ft-card': FtCard, | ||
'ft-flex-box': FtFlexBox, | ||
'ft-prompt': FtPrompt, | ||
}, | ||
emits: ['settingsUnlocked'], | ||
data: function() { | ||
return { | ||
password: '', | ||
showIncorrectPassword: false | ||
} | ||
'ft-card': FtCard | ||
}, | ||
emits: ['unlocked'], | ||
computed: { | ||
getStoredPassword: function() { | ||
settingsPassword: function () { | ||
return this.$store.getters.getSettingsPassword | ||
}, | ||
incorrectPassword: function() { | ||
return this.password !== '' && !this.unlocked | ||
}, | ||
unlocked: function() { | ||
return this.getStoredPassword === '' || this.password === this.getStoredPassword | ||
} | ||
}, | ||
watch: { | ||
unlocked(val, oldVal) { | ||
if (val !== oldVal) { | ||
this.propagateUnlockStatus() | ||
} | ||
}, | ||
}, | ||
mounted: function () { | ||
this.propagateUnlockStatus() | ||
this.$refs.password.focus() | ||
}, | ||
methods: { | ||
handleLock: function () { | ||
this.password = '' | ||
this.showIncorrectPassword = false | ||
}, | ||
propagateUnlockStatus: function() { | ||
this.$emit('settingsUnlocked', this.unlocked) | ||
}, | ||
...mapActions([ | ||
'updateSettingsPassword' | ||
]), | ||
|
||
handlePasswordInput: function (input) { | ||
if (input === this.settingsPassword) { | ||
this.$emit('unlocked') | ||
} | ||
} | ||
} | ||
}) |
38 changes: 13 additions & 25 deletions
38
src/renderer/components/password-dialog/password-dialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/renderer/components/password-settings/password-settings.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.centerButton { | ||
align-self: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters