Simplify desktop unlock flow
This commit is contained in:
@@ -1776,6 +1776,44 @@ func (u *ui) showLocalVaultChooser() bool {
|
||||
return u.lifecycleMode != "local" || !u.hasSelectedVaultPath()
|
||||
}
|
||||
|
||||
func (u *ui) switchToLifecycleSelection(mode string) {
|
||||
u.state.Session = &session.Manager{}
|
||||
u.state.CurrentPath = nil
|
||||
u.state.SelectedEntryID = ""
|
||||
u.state.Section = appstate.SectionEntries
|
||||
u.state.Dirty = false
|
||||
u.state.ErrorMessage = ""
|
||||
u.state.StatusMessage = ""
|
||||
u.loadingMessage = ""
|
||||
u.loadingActionLabel = ""
|
||||
u.lastLifecycleAction = ""
|
||||
u.lifecycleMode = mode
|
||||
u.editingEntry = false
|
||||
u.currentPath = nil
|
||||
u.syncedPath = nil
|
||||
u.clearMasterPassword()
|
||||
u.keyFilePath.SetText("")
|
||||
u.search.SetText("")
|
||||
switch mode {
|
||||
case "remote":
|
||||
u.vaultPath.SetText("")
|
||||
u.remoteBaseURL.SetText("")
|
||||
u.remotePath.SetText("")
|
||||
u.remoteUsername.SetText("")
|
||||
u.remotePassword.SetText("")
|
||||
u.rememberRemoteAuth.Value = false
|
||||
default:
|
||||
u.vaultPath.SetText("")
|
||||
u.remoteBaseURL.SetText("")
|
||||
u.remotePath.SetText("")
|
||||
u.remoteUsername.SetText("")
|
||||
u.remotePassword.SetText("")
|
||||
u.rememberRemoteAuth.Value = false
|
||||
}
|
||||
u.requestMasterPassFocus = u.hasSelectedLifecycleTarget()
|
||||
u.filter()
|
||||
}
|
||||
|
||||
func (u *ui) latestRecentRemote() (recentRemoteRecord, bool, time.Time) {
|
||||
for _, record := range u.recentRemotes {
|
||||
if strings.TrimSpace(record.BaseURL) == "" || strings.TrimSpace(record.Path) == "" {
|
||||
@@ -3153,6 +3191,10 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
||||
if u.lifecycleBusy() {
|
||||
continue
|
||||
}
|
||||
if u.shouldUseLockedSinglePane() {
|
||||
u.switchToLifecycleSelection("local")
|
||||
continue
|
||||
}
|
||||
u.vaultPath.SetText("")
|
||||
u.state.ErrorMessage = ""
|
||||
u.state.StatusMessage = ""
|
||||
@@ -3162,6 +3204,10 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
||||
if u.lifecycleBusy() {
|
||||
continue
|
||||
}
|
||||
if u.shouldUseLockedSinglePane() {
|
||||
u.switchToLifecycleSelection("remote")
|
||||
continue
|
||||
}
|
||||
u.remoteBaseURL.SetText("")
|
||||
u.remotePath.SetText("")
|
||||
u.remoteUsername.SetText("")
|
||||
@@ -4692,7 +4738,6 @@ func (u *ui) detailPanelContent(gtx layout.Context) layout.Dimensions {
|
||||
_ = panel
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, func() []layout.FlexChild {
|
||||
if u.isVaultLocked() {
|
||||
summary := u.currentVaultSummary()
|
||||
return []layout.FlexChild{
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(18), "Unlock Vault")
|
||||
@@ -4705,47 +4750,6 @@ func (u *ui) detailPanelContent(gtx layout.Context) layout.Dimensions {
|
||||
lbl.Color = mutedColor
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
if strings.TrimSpace(summary.Title) == "" {
|
||||
return layout.Dimensions{}
|
||||
}
|
||||
return compactCard(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(11), "UNLOCK TARGET")
|
||||
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(15), summary.Title)
|
||||
lbl.Color = accentColor
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
if strings.TrimSpace(summary.Detail) == "" || summary.Detail == summary.Title {
|
||||
return layout.Dimensions{}
|
||||
}
|
||||
return layout.Inset{Top: unit.Dp(2)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(12), summary.Detail)
|
||||
lbl.Color = mutedColor
|
||||
return lbl.Layout(gtx)
|
||||
})
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
if strings.TrimSpace(summary.Context) == "" {
|
||||
return layout.Dimensions{}
|
||||
}
|
||||
return layout.Inset{Top: unit.Dp(2)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(12), summary.Context)
|
||||
lbl.Color = mutedColor
|
||||
return lbl.Layout(gtx)
|
||||
})
|
||||
}),
|
||||
)
|
||||
})
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout),
|
||||
layout.Rigid(u.unlockPanel),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user