Improve local vault open usability
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"gioui.org/app"
|
"gioui.org/app"
|
||||||
"gioui.org/gesture"
|
"gioui.org/gesture"
|
||||||
|
"gioui.org/io/key"
|
||||||
"gioui.org/io/pointer"
|
"gioui.org/io/pointer"
|
||||||
"gioui.org/layout"
|
"gioui.org/layout"
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
@@ -277,6 +278,8 @@ type ui struct {
|
|||||||
allowApproval widget.Clickable
|
allowApproval widget.Clickable
|
||||||
denyApproval widget.Clickable
|
denyApproval widget.Clickable
|
||||||
cancelApproval widget.Clickable
|
cancelApproval widget.Clickable
|
||||||
|
cancelLifecycleProgress widget.Clickable
|
||||||
|
retryLifecycleOpen widget.Clickable
|
||||||
approvalPermanent widget.Bool
|
approvalPermanent widget.Bool
|
||||||
rememberRemoteAuth widget.Bool
|
rememberRemoteAuth widget.Bool
|
||||||
apiPolicyAllow widget.Bool
|
apiPolicyAllow widget.Bool
|
||||||
@@ -323,6 +326,7 @@ type ui struct {
|
|||||||
settingsIcon *widget.Icon
|
settingsIcon *widget.Icon
|
||||||
clipboardWriter clipboard.Writer
|
clipboardWriter clipboard.Writer
|
||||||
loadingMessage string
|
loadingMessage string
|
||||||
|
loadingActionLabel string
|
||||||
lifecycleMode string
|
lifecycleMode string
|
||||||
syncSourceMode syncSourceMode
|
syncSourceMode syncSourceMode
|
||||||
syncDirection syncDirection
|
syncDirection syncDirection
|
||||||
@@ -360,6 +364,10 @@ type ui struct {
|
|||||||
auditLog *apiaudit.Log
|
auditLog *apiaudit.Log
|
||||||
grpcAddress string
|
grpcAddress string
|
||||||
backgroundResults chan backgroundActionResult
|
backgroundResults chan backgroundActionResult
|
||||||
|
backgroundActionSerial int
|
||||||
|
activeBackgroundAction int
|
||||||
|
lastLifecycleAction string
|
||||||
|
requestMasterPassFocus bool
|
||||||
invalidate func()
|
invalidate func()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +375,7 @@ type backgroundActionResult struct {
|
|||||||
label string
|
label string
|
||||||
apply func() error
|
apply func() error
|
||||||
err error
|
err error
|
||||||
|
id int
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -416,13 +425,13 @@ func newUIWithState(mode string, sess appstate.CurrentSession, paths statePaths)
|
|||||||
remoteBaseURL: widget.Editor{SingleLine: true, Submit: false},
|
remoteBaseURL: widget.Editor{SingleLine: true, Submit: false},
|
||||||
remotePath: widget.Editor{SingleLine: true, Submit: false},
|
remotePath: widget.Editor{SingleLine: true, Submit: false},
|
||||||
remoteUsername: widget.Editor{SingleLine: true, Submit: false},
|
remoteUsername: widget.Editor{SingleLine: true, Submit: false},
|
||||||
remotePassword: widget.Editor{SingleLine: true, Submit: false, Mask: '•'},
|
remotePassword: widget.Editor{SingleLine: true, Submit: false, Mask: '•', InputHint: key.HintPassword},
|
||||||
syncLocalPath: widget.Editor{SingleLine: true, Submit: false},
|
syncLocalPath: widget.Editor{SingleLine: true, Submit: false},
|
||||||
syncRemoteBaseURL: widget.Editor{SingleLine: true, Submit: false},
|
syncRemoteBaseURL: widget.Editor{SingleLine: true, Submit: false},
|
||||||
syncRemotePath: widget.Editor{SingleLine: true, Submit: false},
|
syncRemotePath: widget.Editor{SingleLine: true, Submit: false},
|
||||||
syncRemoteUsername: widget.Editor{SingleLine: true, Submit: false},
|
syncRemoteUsername: widget.Editor{SingleLine: true, Submit: false},
|
||||||
syncRemotePassword: widget.Editor{SingleLine: true, Submit: false, Mask: '•'},
|
syncRemotePassword: widget.Editor{SingleLine: true, Submit: false, Mask: '•', InputHint: key.HintPassword},
|
||||||
masterPassword: widget.Editor{SingleLine: true, Submit: false},
|
masterPassword: widget.Editor{SingleLine: true, Submit: false, InputHint: key.HintPassword},
|
||||||
keyFilePath: widget.Editor{SingleLine: true, Submit: false},
|
keyFilePath: widget.Editor{SingleLine: true, Submit: false},
|
||||||
apiTokenName: widget.Editor{SingleLine: true, Submit: false},
|
apiTokenName: widget.Editor{SingleLine: true, Submit: false},
|
||||||
apiTokenClientName: widget.Editor{SingleLine: true, Submit: false},
|
apiTokenClientName: widget.Editor{SingleLine: true, Submit: false},
|
||||||
@@ -481,6 +490,7 @@ func newUIWithState(mode string, sess appstate.CurrentSession, paths statePaths)
|
|||||||
syncDirection: syncDirectionPull,
|
syncDirection: syncDirectionPull,
|
||||||
apiPolicyGroupScope: true,
|
apiPolicyGroupScope: true,
|
||||||
backgroundResults: make(chan backgroundActionResult, 8),
|
backgroundResults: make(chan backgroundActionResult, 8),
|
||||||
|
requestMasterPassFocus: true,
|
||||||
}
|
}
|
||||||
u.apiPolicyAllow.Value = true
|
u.apiPolicyAllow.Value = true
|
||||||
u.apiPolicyGroupScopeW.Value = true
|
u.apiPolicyGroupScopeW.Value = true
|
||||||
@@ -791,13 +801,16 @@ func (u *ui) startOpenVaultAction() {
|
|||||||
u.clearMasterPassword()
|
u.clearMasterPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.state.ErrorMessage = u.describeActionError("open vault", err)
|
u.state.ErrorMessage = u.describeActionError("open vault", err)
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
path := strings.TrimSpace(u.vaultPath.Text())
|
path := strings.TrimSpace(u.vaultPath.Text())
|
||||||
if path == "" {
|
if path == "" {
|
||||||
u.state.ErrorMessage = u.describeActionError("open vault", errors.New(errVaultPathRequired))
|
u.state.ErrorMessage = u.describeActionError("open vault", errors.New(errVaultPathRequired))
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
u.lastLifecycleAction = "open vault"
|
||||||
u.runBackgroundAction("open vault", func() (func() error, error) {
|
u.runBackgroundAction("open vault", func() (func() error, error) {
|
||||||
prepared, err := session.PrepareLocalOpen(path, key)
|
prepared, err := session.PrepareLocalOpen(path, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -875,6 +888,7 @@ func (u *ui) startOpenRemoteAction() {
|
|||||||
u.clearMasterPassword()
|
u.clearMasterPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.state.ErrorMessage = u.describeActionError("open remote vault", err)
|
u.state.ErrorMessage = u.describeActionError("open remote vault", err)
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := webdav.Client{
|
client := webdav.Client{
|
||||||
@@ -883,6 +897,7 @@ func (u *ui) startOpenRemoteAction() {
|
|||||||
Password: u.remotePassword.Text(),
|
Password: u.remotePassword.Text(),
|
||||||
}
|
}
|
||||||
remotePath := strings.TrimSpace(u.remotePath.Text())
|
remotePath := strings.TrimSpace(u.remotePath.Text())
|
||||||
|
u.lastLifecycleAction = "open remote vault"
|
||||||
u.runBackgroundAction("open remote vault", func() (func() error, error) {
|
u.runBackgroundAction("open remote vault", func() (func() error, error) {
|
||||||
prepared, err := session.PrepareRemoteOpen(client, remotePath, key)
|
prepared, err := session.PrepareRemoteOpen(client, remotePath, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -912,6 +927,7 @@ func (u *ui) lockAction() error {
|
|||||||
if err := u.state.Lock(); err != nil {
|
if err := u.state.Lock(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
u.currentPath = append([]string(nil), u.state.CurrentPath...)
|
u.currentPath = append([]string(nil), u.state.CurrentPath...)
|
||||||
u.resetPasswordPeek()
|
u.resetPasswordPeek()
|
||||||
u.editingEntry = false
|
u.editingEntry = false
|
||||||
@@ -946,6 +962,7 @@ func (u *ui) startUnlockAction() {
|
|||||||
u.clearMasterPassword()
|
u.clearMasterPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.state.ErrorMessage = u.describeActionError("unlock vault", err)
|
u.state.ErrorMessage = u.describeActionError("unlock vault", err)
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
encoded := append([]byte(nil), manager.EncodedBytes()...)
|
encoded := append([]byte(nil), manager.EncodedBytes()...)
|
||||||
@@ -1667,14 +1684,17 @@ func (u *ui) runAction(label string, action func() error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
u.loadingMessage = actionLoadingLabel(label)
|
u.loadingMessage = actionLoadingLabel(label)
|
||||||
|
u.loadingActionLabel = strings.TrimSpace(label)
|
||||||
if err := action(); err != nil {
|
if err := action(); err != nil {
|
||||||
u.loadingMessage = ""
|
u.loadingMessage = ""
|
||||||
|
u.loadingActionLabel = ""
|
||||||
u.state.ErrorMessage = u.describeActionError(label, err)
|
u.state.ErrorMessage = u.describeActionError(label, err)
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
u.statusExpiresAt = time.Time{}
|
u.statusExpiresAt = time.Time{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
u.loadingMessage = ""
|
u.loadingMessage = ""
|
||||||
|
u.loadingActionLabel = ""
|
||||||
u.syncAutofillCache()
|
u.syncAutofillCache()
|
||||||
u.state.ErrorMessage = ""
|
u.state.ErrorMessage = ""
|
||||||
if suppressStatusMessage(label) {
|
if suppressStatusMessage(label) {
|
||||||
@@ -1690,13 +1710,17 @@ func (u *ui) runBackgroundAction(label string, prepare func() (func() error, err
|
|||||||
if strings.TrimSpace(u.loadingMessage) != "" {
|
if strings.TrimSpace(u.loadingMessage) != "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
u.backgroundActionSerial++
|
||||||
|
actionID := u.backgroundActionSerial
|
||||||
|
u.activeBackgroundAction = actionID
|
||||||
u.loadingMessage = actionLoadingLabel(label)
|
u.loadingMessage = actionLoadingLabel(label)
|
||||||
|
u.loadingActionLabel = strings.TrimSpace(label)
|
||||||
u.state.ErrorMessage = ""
|
u.state.ErrorMessage = ""
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
u.statusExpiresAt = time.Time{}
|
u.statusExpiresAt = time.Time{}
|
||||||
go func() {
|
go func() {
|
||||||
apply, err := prepare()
|
apply, err := prepare()
|
||||||
u.backgroundResults <- backgroundActionResult{label: label, apply: apply, err: err}
|
u.backgroundResults <- backgroundActionResult{label: label, apply: apply, err: err, id: actionID}
|
||||||
if u.invalidate != nil {
|
if u.invalidate != nil {
|
||||||
u.invalidate()
|
u.invalidate()
|
||||||
}
|
}
|
||||||
@@ -1704,9 +1728,17 @@ func (u *ui) runBackgroundAction(label string, prepare func() (func() error, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) applyBackgroundResult(result backgroundActionResult) {
|
func (u *ui) applyBackgroundResult(result backgroundActionResult) {
|
||||||
|
if result.id != 0 && result.id != u.activeBackgroundAction {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u.activeBackgroundAction = 0
|
||||||
u.loadingMessage = ""
|
u.loadingMessage = ""
|
||||||
|
u.loadingActionLabel = ""
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
u.state.ErrorMessage = u.describeActionError(result.label, result.err)
|
u.state.ErrorMessage = u.describeActionError(result.label, result.err)
|
||||||
|
if strings.HasPrefix(result.label, "open ") {
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
|
}
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
u.statusExpiresAt = time.Time{}
|
u.statusExpiresAt = time.Time{}
|
||||||
return
|
return
|
||||||
@@ -1714,6 +1746,9 @@ func (u *ui) applyBackgroundResult(result backgroundActionResult) {
|
|||||||
if result.apply != nil {
|
if result.apply != nil {
|
||||||
if err := result.apply(); err != nil {
|
if err := result.apply(); err != nil {
|
||||||
u.state.ErrorMessage = u.describeActionError(result.label, err)
|
u.state.ErrorMessage = u.describeActionError(result.label, err)
|
||||||
|
if strings.HasPrefix(result.label, "open ") {
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
|
}
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
u.statusExpiresAt = time.Time{}
|
u.statusExpiresAt = time.Time{}
|
||||||
return
|
return
|
||||||
@@ -1730,6 +1765,40 @@ func (u *ui) applyBackgroundResult(result backgroundActionResult) {
|
|||||||
u.statusExpiresAt = u.now().Add(statusBannerDuration)
|
u.statusExpiresAt = u.now().Add(statusBannerDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *ui) cancelLifecycleBusyState() {
|
||||||
|
if !u.lifecycleBusy() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u.activeBackgroundAction = 0
|
||||||
|
u.loadingMessage = ""
|
||||||
|
u.loadingActionLabel = ""
|
||||||
|
u.state.ErrorMessage = ""
|
||||||
|
u.state.StatusMessage = ""
|
||||||
|
u.statusExpiresAt = time.Time{}
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *ui) retryLastLifecycleOpen() {
|
||||||
|
switch strings.TrimSpace(u.lastLifecycleAction) {
|
||||||
|
case "open vault":
|
||||||
|
u.startOpenVaultAction()
|
||||||
|
case "open remote vault":
|
||||||
|
u.startOpenRemoteAction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *ui) canRetryLifecycleOpen() bool {
|
||||||
|
if !u.shouldShowLifecycleSetup() || u.lifecycleBusy() || strings.TrimSpace(u.state.ErrorMessage) == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
switch strings.TrimSpace(u.lastLifecycleAction) {
|
||||||
|
case "open vault", "open remote vault":
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (u *ui) processBackgroundActions() {
|
func (u *ui) processBackgroundActions() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@@ -1980,6 +2049,29 @@ func isAutofillOperation(operation apitokens.Operation) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *ui) bannerActionLabels(banner uiBanner) (primary, secondary string) {
|
||||||
|
if !u.shouldShowLifecycleSetup() {
|
||||||
|
if banner.Dismissable {
|
||||||
|
return "", "Dismiss"
|
||||||
|
}
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
switch banner.Kind {
|
||||||
|
case bannerLoading:
|
||||||
|
if strings.HasPrefix(u.loadingActionLabel, "open ") {
|
||||||
|
return "Cancel", ""
|
||||||
|
}
|
||||||
|
case bannerError:
|
||||||
|
if u.canRetryLifecycleOpen() {
|
||||||
|
return "Retry", "Dismiss"
|
||||||
|
}
|
||||||
|
if banner.Dismissable {
|
||||||
|
return "", "Dismiss"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
func (u *ui) loadingDetailMessage() string {
|
func (u *ui) loadingDetailMessage() string {
|
||||||
if !u.shouldShowLifecycleSetup() {
|
if !u.shouldShowLifecycleSetup() {
|
||||||
return ""
|
return ""
|
||||||
@@ -2048,6 +2140,41 @@ func (u *ui) vaultResumeContext(path []string) string {
|
|||||||
return "Resume in: " + strings.Join(displayPath, " / ")
|
return "Resume in: " + strings.Join(displayPath, " / ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func compactPathDirectorySummary(path string) string {
|
||||||
|
cleaned := filepath.Clean(strings.TrimSpace(path))
|
||||||
|
if cleaned == "." || cleaned == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
dir := filepath.Dir(cleaned)
|
||||||
|
if dir == "." || dir == cleaned {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if dir == string(filepath.Separator) {
|
||||||
|
return dir
|
||||||
|
}
|
||||||
|
parts := strings.Split(filepath.ToSlash(dir), "/")
|
||||||
|
filtered := parts[:0]
|
||||||
|
for _, part := range parts {
|
||||||
|
if strings.TrimSpace(part) != "" {
|
||||||
|
filtered = append(filtered, part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts = filtered
|
||||||
|
if len(parts) <= 2 {
|
||||||
|
return filepath.ToSlash(dir)
|
||||||
|
}
|
||||||
|
return parts[0] + "/.../" + parts[len(parts)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *ui) requestMasterPasswordFocusIfNeeded(gtx layout.Context) {
|
||||||
|
if !u.requestMasterPassFocus {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gtx.Execute(key.FocusCmd{Tag: &u.masterPassword})
|
||||||
|
gtx.Execute(op.InvalidateCmd{})
|
||||||
|
u.requestMasterPassFocus = false
|
||||||
|
}
|
||||||
|
|
||||||
func (u *ui) sessionSurface() uiSurface {
|
func (u *ui) sessionSurface() uiSurface {
|
||||||
if u.state.Session == nil {
|
if u.state.Session == nil {
|
||||||
return uiSurface{}
|
return uiSurface{}
|
||||||
@@ -2326,6 +2453,13 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
for u.unlockVault.Clicked(gtx) {
|
for u.unlockVault.Clicked(gtx) {
|
||||||
u.startUnlockAction()
|
u.startUnlockAction()
|
||||||
}
|
}
|
||||||
|
for u.cancelLifecycleProgress.Clicked(gtx) {
|
||||||
|
u.cancelLifecycleBusyState()
|
||||||
|
}
|
||||||
|
for u.retryLifecycleOpen.Clicked(gtx) {
|
||||||
|
u.state.ErrorMessage = ""
|
||||||
|
u.retryLastLifecycleOpen()
|
||||||
|
}
|
||||||
for u.showEntries.Clicked(gtx) {
|
for u.showEntries.Clicked(gtx) {
|
||||||
u.clearDeleteGroupConfirmation()
|
u.clearDeleteGroupConfirmation()
|
||||||
u.showEntriesSection()
|
u.showEntriesSection()
|
||||||
@@ -2351,12 +2485,14 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
u.lifecycleMode = "local"
|
u.lifecycleMode = "local"
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
for u.showRemoteLifecycle.Clicked(gtx) {
|
for u.showRemoteLifecycle.Clicked(gtx) {
|
||||||
if u.lifecycleBusy() {
|
if u.lifecycleBusy() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
u.lifecycleMode = "remote"
|
u.lifecycleMode = "remote"
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
for u.toggleLifecycleAdvanced.Clicked(gtx) {
|
for u.toggleLifecycleAdvanced.Clicked(gtx) {
|
||||||
if u.lifecycleBusy() {
|
if u.lifecycleBusy() {
|
||||||
@@ -2479,6 +2615,7 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
if i < len(u.recentVaults) {
|
if i < len(u.recentVaults) {
|
||||||
u.lifecycleMode = "local"
|
u.lifecycleMode = "local"
|
||||||
u.vaultPath.SetText(u.recentVaults[i])
|
u.vaultPath.SetText(u.recentVaults[i])
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2490,6 +2627,7 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
if i < len(u.recentRemotes) {
|
if i < len(u.recentRemotes) {
|
||||||
u.lifecycleMode = "remote"
|
u.lifecycleMode = "remote"
|
||||||
u.applyRecentRemoteRecord(u.recentRemotes[i])
|
u.applyRecentRemoteRecord(u.recentRemotes[i])
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2500,6 +2638,7 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
u.vaultPath.SetText("")
|
u.vaultPath.SetText("")
|
||||||
u.state.ErrorMessage = ""
|
u.state.ErrorMessage = ""
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
for u.clearRemoteSelection.Clicked(gtx) {
|
for u.clearRemoteSelection.Clicked(gtx) {
|
||||||
if u.lifecycleBusy() {
|
if u.lifecycleBusy() {
|
||||||
@@ -2512,6 +2651,7 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
|||||||
u.rememberRemoteAuth.Value = false
|
u.rememberRemoteAuth.Value = false
|
||||||
u.state.ErrorMessage = ""
|
u.state.ErrorMessage = ""
|
||||||
u.state.StatusMessage = ""
|
u.state.StatusMessage = ""
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
for u.dismissBanner.Clicked(gtx) {
|
for u.dismissBanner.Clicked(gtx) {
|
||||||
u.state.ErrorMessage = ""
|
u.state.ErrorMessage = ""
|
||||||
@@ -3908,6 +4048,7 @@ func (u *ui) banner(gtx layout.Context) layout.Dimensions {
|
|||||||
bg = color.NRGBA{R: 248, G: 228, B: 225, A: 255}
|
bg = color.NRGBA{R: 248, G: 228, B: 225, A: 255}
|
||||||
fg = color.NRGBA{R: 130, G: 36, B: 25, A: 255}
|
fg = color.NRGBA{R: 130, G: 36, B: 25, A: 255}
|
||||||
}
|
}
|
||||||
|
primaryAction, secondaryAction := u.bannerActionLabels(banner)
|
||||||
|
|
||||||
return layout.Background{}.Layout(gtx, fill(bg), func(gtx layout.Context) layout.Dimensions {
|
return layout.Background{}.Layout(gtx, fill(bg), func(gtx layout.Context) layout.Dimensions {
|
||||||
return layout.UniformInset(unit.Dp(12)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
return layout.UniformInset(unit.Dp(12)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
@@ -3932,11 +4073,34 @@ func (u *ui) banner(gtx layout.Context) layout.Dimensions {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
if !banner.Dismissable {
|
if primaryAction == "" && secondaryAction == "" {
|
||||||
return layout.Dimensions{}
|
return layout.Dimensions{}
|
||||||
}
|
}
|
||||||
return layout.Inset{Left: unit.Dp(10)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
return layout.Inset{Left: unit.Dp(10)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
return tonedButton(gtx, u.theme, &u.dismissBanner, "Dismiss")
|
return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx,
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
if primaryAction == "" {
|
||||||
|
return layout.Dimensions{}
|
||||||
|
}
|
||||||
|
click := &u.cancelLifecycleProgress
|
||||||
|
if primaryAction == "Retry" {
|
||||||
|
click = &u.retryLifecycleOpen
|
||||||
|
}
|
||||||
|
return tonedButton(gtx, u.theme, click, primaryAction)
|
||||||
|
}),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
if primaryAction == "" || secondaryAction == "" {
|
||||||
|
return layout.Dimensions{}
|
||||||
|
}
|
||||||
|
return layout.Spacer{Width: unit.Dp(6)}.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
if secondaryAction == "" {
|
||||||
|
return layout.Dimensions{}
|
||||||
|
}
|
||||||
|
return tonedButton(gtx, u.theme, &u.dismissBanner, secondaryAction)
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -105,6 +105,15 @@ func TestUIFiltersUsingVaultModelPathsAndSearch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUIMasterPasswordUsesPasswordInputHint(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithSession("phone", &session.Manager{})
|
||||||
|
if got := u.masterPassword.InputHint; got != key.HintPassword {
|
||||||
|
t.Fatalf("masterPassword.InputHint = %v, want %v", got, key.HintPassword)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUISearchBehaviorIsConsistentAcrossDesktopAndPhoneLayouts(t *testing.T) {
|
func TestUISearchBehaviorIsConsistentAcrossDesktopAndPhoneLayouts(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -268,6 +277,48 @@ func TestUIRunBackgroundActionIgnoresDuplicateWhileLoading(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUICancelLifecycleBusyStateIgnoresLateResultAndKeepsRetryAvailable(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithSession("desktop", &session.Manager{})
|
||||||
|
u.vaultPath.SetText("/tmp/example.kdbx")
|
||||||
|
u.lastLifecycleAction = "open vault"
|
||||||
|
|
||||||
|
started := make(chan struct{})
|
||||||
|
release := make(chan struct{})
|
||||||
|
u.runBackgroundAction("open vault", func() (func() error, error) {
|
||||||
|
close(started)
|
||||||
|
<-release
|
||||||
|
return func() error {
|
||||||
|
u.state.StatusMessage = "should not apply"
|
||||||
|
return nil
|
||||||
|
}, nil
|
||||||
|
})
|
||||||
|
<-started
|
||||||
|
|
||||||
|
u.cancelLifecycleBusyState()
|
||||||
|
if got := u.loadingMessage; got != "" {
|
||||||
|
t.Fatalf("loadingMessage after cancel = %q, want empty", got)
|
||||||
|
}
|
||||||
|
if got := u.activeBackgroundAction; got != 0 {
|
||||||
|
t.Fatalf("activeBackgroundAction after cancel = %d, want 0", got)
|
||||||
|
}
|
||||||
|
if !u.requestMasterPassFocus {
|
||||||
|
t.Fatal("requestMasterPassFocus after cancel = false, want true")
|
||||||
|
}
|
||||||
|
|
||||||
|
close(release)
|
||||||
|
result := waitForBackgroundResult(t, u)
|
||||||
|
u.applyBackgroundResult(result)
|
||||||
|
|
||||||
|
if got := u.state.StatusMessage; got != "" {
|
||||||
|
t.Fatalf("StatusMessage after stale apply = %q, want empty", got)
|
||||||
|
}
|
||||||
|
if got := u.lastLifecycleAction; got != "open vault" {
|
||||||
|
t.Fatalf("lastLifecycleAction after cancel = %q, want open vault", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUIChildGroupsComeFromVaultModel(t *testing.T) {
|
func TestUIChildGroupsComeFromVaultModel(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -2695,6 +2746,43 @@ func TestUIBannerSurfacePrefersLoadingThenErrorThenStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUIBannerActionLabelsExposeCancelAndRetryForLifecycleOpen(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithSession("desktop", &session.Manager{})
|
||||||
|
u.loadingMessage = "Open vault..."
|
||||||
|
u.loadingActionLabel = "open vault"
|
||||||
|
|
||||||
|
primary, secondary := u.bannerActionLabels(u.bannerSurface())
|
||||||
|
if primary != "Cancel" || secondary != "" {
|
||||||
|
t.Fatalf("bannerActionLabels(loading) = %q/%q, want Cancel/empty", primary, secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
u.loadingMessage = ""
|
||||||
|
u.loadingActionLabel = ""
|
||||||
|
u.lastLifecycleAction = "open vault"
|
||||||
|
u.state.ErrorMessage = "open failed"
|
||||||
|
|
||||||
|
primary, secondary = u.bannerActionLabels(u.bannerSurface())
|
||||||
|
if primary != "Retry" || secondary != "Dismiss" {
|
||||||
|
t.Fatalf("bannerActionLabels(error) = %q/%q, want Retry/Dismiss", primary, secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompactPathDirectorySummaryCollapsesLongPaths(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
got := compactPathDirectorySummary("/home/julian/vaults/family/main.kdbx")
|
||||||
|
if got != "home/.../family" {
|
||||||
|
t.Fatalf("compactPathDirectorySummary() = %q, want %q", got, "home/.../family")
|
||||||
|
}
|
||||||
|
|
||||||
|
short := compactPathDirectorySummary("/tmp/main.kdbx")
|
||||||
|
if short != "/tmp" {
|
||||||
|
t.Fatalf("compactPathDirectorySummary(short) = %q, want %q", short, "/tmp")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUIStatusToastExpiresAfterTimeout(t *testing.T) {
|
func TestUIStatusToastExpiresAfterTimeout(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -3304,6 +3392,7 @@ func TestSelectingRecentVaultSwitchesToLocalMode(t *testing.T) {
|
|||||||
|
|
||||||
u := newUIWithSession("desktop", &session.Manager{})
|
u := newUIWithSession("desktop", &session.Manager{})
|
||||||
u.lifecycleMode = "remote"
|
u.lifecycleMode = "remote"
|
||||||
|
u.requestMasterPassFocus = false
|
||||||
u.recentVaults = []string{"/tmp/example.kdbx"}
|
u.recentVaults = []string{"/tmp/example.kdbx"}
|
||||||
u.recentVaultClicks = make([]widget.Clickable, 1)
|
u.recentVaultClicks = make([]widget.Clickable, 1)
|
||||||
u.recentVaultClicks[0].Click()
|
u.recentVaultClicks[0].Click()
|
||||||
@@ -3313,6 +3402,7 @@ func TestSelectingRecentVaultSwitchesToLocalMode(t *testing.T) {
|
|||||||
if 0 < len(u.recentVaults) {
|
if 0 < len(u.recentVaults) {
|
||||||
u.lifecycleMode = "local"
|
u.lifecycleMode = "local"
|
||||||
u.vaultPath.SetText(u.recentVaults[0])
|
u.vaultPath.SetText(u.recentVaults[0])
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3322,6 +3412,9 @@ func TestSelectingRecentVaultSwitchesToLocalMode(t *testing.T) {
|
|||||||
if got := u.vaultPath.Text(); got != "/tmp/example.kdbx" {
|
if got := u.vaultPath.Text(); got != "/tmp/example.kdbx" {
|
||||||
t.Fatalf("vaultPath after recent vault click = %q, want /tmp/example.kdbx", got)
|
t.Fatalf("vaultPath after recent vault click = %q, want /tmp/example.kdbx", got)
|
||||||
}
|
}
|
||||||
|
if !u.requestMasterPassFocus {
|
||||||
|
t.Fatal("requestMasterPassFocus after recent vault click = false, want true")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
||||||
@@ -3329,6 +3422,7 @@ func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
|||||||
|
|
||||||
u := newUIWithSession("desktop", &session.Manager{})
|
u := newUIWithSession("desktop", &session.Manager{})
|
||||||
u.lifecycleMode = "local"
|
u.lifecycleMode = "local"
|
||||||
|
u.requestMasterPassFocus = false
|
||||||
u.recentRemotes = []recentRemoteRecord{{
|
u.recentRemotes = []recentRemoteRecord{{
|
||||||
BaseURL: "https://dav.example.com",
|
BaseURL: "https://dav.example.com",
|
||||||
Path: "vaults/home.kdbx",
|
Path: "vaults/home.kdbx",
|
||||||
@@ -3341,6 +3435,7 @@ func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
|||||||
if 0 < len(u.recentRemotes) {
|
if 0 < len(u.recentRemotes) {
|
||||||
u.lifecycleMode = "remote"
|
u.lifecycleMode = "remote"
|
||||||
u.applyRecentRemoteRecord(u.recentRemotes[0])
|
u.applyRecentRemoteRecord(u.recentRemotes[0])
|
||||||
|
u.requestMasterPassFocus = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3350,6 +3445,9 @@ func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
|||||||
if got := u.remoteBaseURL.Text(); got != "https://dav.example.com" {
|
if got := u.remoteBaseURL.Text(); got != "https://dav.example.com" {
|
||||||
t.Fatalf("remoteBaseURL after recent remote click = %q, want https://dav.example.com", got)
|
t.Fatalf("remoteBaseURL after recent remote click = %q, want https://dav.example.com", got)
|
||||||
}
|
}
|
||||||
|
if !u.requestMasterPassFocus {
|
||||||
|
t.Fatal("requestMasterPassFocus after recent remote click = false, want true")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUILoadingDetailMessageUsesSelectedVault(t *testing.T) {
|
func TestUILoadingDetailMessageUsesSelectedVault(t *testing.T) {
|
||||||
|
|||||||
+120
-66
@@ -21,10 +21,20 @@ func (u *ui) lifecycleControls(gtx layout.Context) layout.Dimensions {
|
|||||||
busy := u.lifecycleBusy()
|
busy := u.lifecycleBusy()
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
lbl := material.Label(u.theme, unit.Sp(12), "OPEN OR CREATE VAULT")
|
lbl := material.Label(u.theme, unit.Sp(12), "OPEN A VAULT")
|
||||||
lbl.Color = mutedColor
|
lbl.Color = mutedColor
|
||||||
return lbl.Layout(gtx)
|
return lbl.Layout(gtx)
|
||||||
}),
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
message := "Choose a recent vault or pick a `.kdbx` file, then unlock it."
|
||||||
|
if u.lifecycleMode == "remote" {
|
||||||
|
message = "Connect to a remote vault, then unlock it with the KeePass master key."
|
||||||
|
}
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(14), message)
|
||||||
|
lbl.Color = accentColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx,
|
return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx,
|
||||||
@@ -44,17 +54,6 @@ func (u *ui) lifecycleControls(gtx layout.Context) layout.Dimensions {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
|
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
return u.masterPasswordField(gtx, "Leave blank if this vault is protected by key file only.")
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
if busy {
|
|
||||||
return labeledEditorHelp(u.theme, "Key File", "Optional path to a KeePass-compatible key file.", &u.keyFilePath, false)(gtx)
|
|
||||||
}
|
|
||||||
return selectorEditorHelp(u.theme, "Key File", "Optional path to a KeePass-compatible key file.", &u.keyFilePath, &u.pickKeyFile, "Choose File", false)(gtx)
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
if u.lifecycleMode == "remote" {
|
if u.lifecycleMode == "remote" {
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
@@ -162,62 +161,92 @@ func (u *ui) lifecycleControls(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
lbl := material.Label(u.theme, unit.Sp(12), "VAULT FILE")
|
lbl := material.Label(u.theme, unit.Sp(12), "RECENT VAULTS")
|
||||||
lbl.Color = mutedColor
|
lbl.Color = mutedColor
|
||||||
return lbl.Layout(gtx)
|
return lbl.Layout(gtx)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
if busy {
|
|
||||||
return labeledEditorHelp(u.theme, "Vault Path", "Choose the existing .kdbx file to open.", &u.vaultPath, false)(gtx)
|
|
||||||
}
|
|
||||||
return selectorEditorHelp(u.theme, "Vault Path", "Choose the existing .kdbx file to open.", &u.vaultPath, &u.pickVaultPath, "Choose File", false)(gtx)
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
if strings.TrimSpace(u.vaultPath.Text()) == "" {
|
|
||||||
return layout.Dimensions{}
|
|
||||||
}
|
|
||||||
return compactCard(gtx, func(gtx layout.Context) layout.Dimensions {
|
|
||||||
return layout.UniformInset(unit.Dp(10)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
lbl := material.Label(u.theme, unit.Sp(12), "SELECTED VAULT")
|
|
||||||
lbl.Color = mutedColor
|
|
||||||
return lbl.Layout(gtx)
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
lbl := material.Label(u.theme, unit.Sp(14), friendlyRecentVaultLabel(u.vaultPath.Text()))
|
|
||||||
lbl.Color = accentColor
|
|
||||||
return lbl.Layout(gtx)
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
if busy {
|
|
||||||
return layout.Dimensions{}
|
|
||||||
}
|
|
||||||
return tonedButton(gtx, u.theme, &u.clearVaultSelection, "Change...")
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
|
||||||
lbl := material.Label(u.theme, unit.Sp(11), u.vaultPath.Text())
|
|
||||||
lbl.Color = mutedColor
|
|
||||||
return lbl.Layout(gtx)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
|
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
if busy {
|
if busy {
|
||||||
return layout.Dimensions{}
|
return layout.Dimensions{}
|
||||||
}
|
}
|
||||||
return u.recentVaultList(gtx)
|
return u.recentVaultList(gtx)
|
||||||
}),
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(12), "VAULT FILE")
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
selectedPath := strings.TrimSpace(u.vaultPath.Text())
|
||||||
|
switch {
|
||||||
|
case busy:
|
||||||
|
return labeledEditorHelp(u.theme, "Vault Path", "Choose the existing .kdbx file to open.", &u.vaultPath, false)(gtx)
|
||||||
|
case selectedPath == "":
|
||||||
|
return selectorEditorHelp(u.theme, "Vault Path", "Choose the existing .kdbx file to open.", &u.vaultPath, &u.pickVaultPath, "Choose File", false)(gtx)
|
||||||
|
default:
|
||||||
|
lastGroup := u.recentVaultGroup(selectedPath)
|
||||||
|
return compactCard(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
|
return layout.UniformInset(unit.Dp(10)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(12), "SELECTED VAULT")
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(16), friendlyRecentVaultLabel(selectedPath))
|
||||||
|
lbl.Color = accentColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
dir := compactPathDirectorySummary(selectedPath)
|
||||||
|
if dir == "" {
|
||||||
|
return layout.Dimensions{}
|
||||||
|
}
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(11), dir)
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
if len(lastGroup) == 0 {
|
||||||
|
return layout.Dimensions{}
|
||||||
|
}
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(11), "Last group: "+strings.Join(u.displayEntryPath(lastGroup), " / "))
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
return tonedButton(gtx, u.theme, &u.clearVaultSelection, "Change...")
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(12), "UNLOCK")
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
return u.masterPasswordField(gtx, "Leave blank if this vault is protected by key file only.")
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
if busy {
|
||||||
|
return labeledEditorHelp(u.theme, "Key File", "Optional path to a KeePass-compatible key file.", &u.keyFilePath, false)(gtx)
|
||||||
|
}
|
||||||
|
return selectorEditorHelp(u.theme, "Key File", "Optional path to a KeePass-compatible key file.", &u.keyFilePath, &u.pickKeyFile, "Choose File", false)(gtx)
|
||||||
|
}),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
if busy {
|
if busy {
|
||||||
return layout.Dimensions{}
|
return layout.Dimensions{}
|
||||||
@@ -255,7 +284,7 @@ func (u *ui) lifecycleControls(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
return tonedButton(gtx, u.theme, &u.openRemote, label)
|
return tonedButton(gtx, u.theme, &u.openRemote, label)
|
||||||
}
|
}
|
||||||
return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
label := "Open Vault"
|
label := "Open Vault"
|
||||||
if busy {
|
if busy {
|
||||||
@@ -266,12 +295,18 @@ func (u *ui) lifecycleControls(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
return tonedButton(gtx, u.theme, &u.openVault, label)
|
return tonedButton(gtx, u.theme, &u.openVault, label)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout),
|
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(11), "Need a fresh database instead?")
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
if busy {
|
if busy {
|
||||||
return passiveTonedButton(gtx, u.theme, "New Vault")
|
return passiveSectionTab(gtx, u.theme, "Create New Vault", false)
|
||||||
}
|
}
|
||||||
return tonedButton(gtx, u.theme, &u.createVault, "New Vault")
|
return sectionTabButton(gtx, u.theme, &u.createVault, "Create New Vault", false)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
@@ -317,7 +352,7 @@ func (u *ui) recentVaultList(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
lbl := material.Label(u.theme, unit.Sp(12), "RECENTLY OPENED")
|
lbl := material.Label(u.theme, unit.Sp(12), "TAP TO SELECT")
|
||||||
lbl.Color = mutedColor
|
lbl.Color = mutedColor
|
||||||
return lbl.Layout(gtx)
|
return lbl.Layout(gtx)
|
||||||
}),
|
}),
|
||||||
@@ -344,13 +379,30 @@ func (u *ui) recentVaultList(gtx layout.Context) layout.Dimensions {
|
|||||||
return layout.UniformInset(unit.Dp(10)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
return layout.UniformInset(unit.Dp(10)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
lbl := material.Label(u.theme, unit.Sp(14), label)
|
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
|
||||||
lbl.Color = accentColor
|
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
|
||||||
return lbl.Layout(gtx)
|
lbl := material.Label(u.theme, unit.Sp(15), label)
|
||||||
|
lbl.Color = accentColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
badge := "Tap to use"
|
||||||
|
if selected {
|
||||||
|
badge = "Selected"
|
||||||
|
}
|
||||||
|
lbl := material.Label(u.theme, unit.Sp(11), badge)
|
||||||
|
if selected {
|
||||||
|
lbl.Color = accentColor
|
||||||
|
} else {
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
}
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
lbl := material.Label(u.theme, unit.Sp(11), path)
|
lbl := material.Label(u.theme, unit.Sp(11), compactPathDirectorySummary(path))
|
||||||
lbl.Color = mutedColor
|
lbl.Color = mutedColor
|
||||||
return lbl.Layout(gtx)
|
return lbl.Layout(gtx)
|
||||||
}),
|
}),
|
||||||
@@ -1213,7 +1265,9 @@ func (u *ui) masterPasswordField(gtx layout.Context, help string) layout.Dimensi
|
|||||||
defer func() { u.masterPassword.Mask = restore }()
|
defer func() { u.masterPassword.Mask = restore }()
|
||||||
gtx.Constraints.Min.X = gtx.Constraints.Max.X
|
gtx.Constraints.Min.X = gtx.Constraints.Max.X
|
||||||
ed := material.Editor(u.theme, &u.masterPassword, "Master Password")
|
ed := material.Editor(u.theme, &u.masterPassword, "Master Password")
|
||||||
return ed.Layout(gtx)
|
dims := ed.Layout(gtx)
|
||||||
|
u.requestMasterPasswordFocusIfNeeded(gtx)
|
||||||
|
return dims
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout),
|
layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
|||||||
Reference in New Issue
Block a user