Select saved remote bindings after local open
This commit is contained in:
@@ -1035,6 +1035,7 @@ func (u *ui) openVaultAction() error {
|
||||
u.resetPasswordPeek()
|
||||
u.currentPath = append([]string(nil), u.state.CurrentPath...)
|
||||
u.restoreRecentVaultGroup(path)
|
||||
u.syncSavedRemoteBindingSelection()
|
||||
u.loadSecuritySettingsFromSession()
|
||||
u.editingEntry = false
|
||||
u.filter()
|
||||
@@ -1072,6 +1073,7 @@ func (u *ui) startOpenVaultAction() {
|
||||
u.resetPasswordPeek()
|
||||
u.currentPath = append([]string(nil), u.state.CurrentPath...)
|
||||
u.restoreRecentVaultGroup(path)
|
||||
u.syncSavedRemoteBindingSelection()
|
||||
u.loadSecuritySettingsFromSession()
|
||||
u.editingEntry = false
|
||||
u.filter()
|
||||
@@ -2199,6 +2201,49 @@ func (u *ui) selectedVaultRemoteBinding() (appstate.RemoteBinding, bool) {
|
||||
}, true
|
||||
}
|
||||
|
||||
func (u *ui) syncSavedRemoteBindingSelection() {
|
||||
profiles := u.availableRemoteProfiles()
|
||||
entries := u.availableRemoteCredentialEntries()
|
||||
|
||||
profileID := strings.TrimSpace(u.selectedVaultRemoteProfileID)
|
||||
if profileID != "" {
|
||||
var found bool
|
||||
for _, profile := range profiles {
|
||||
if profile.ID == profileID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
u.selectedVaultRemoteProfileID = ""
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(u.selectedVaultRemoteProfileID) == "" && len(profiles) == 1 {
|
||||
u.selectedVaultRemoteProfileID = profiles[0].ID
|
||||
}
|
||||
if profile, ok := u.selectedVaultRemoteProfile(); ok {
|
||||
u.remoteBaseURL.SetText(profile.BaseURL)
|
||||
u.remotePath.SetText(profile.Path)
|
||||
}
|
||||
|
||||
entryID := strings.TrimSpace(u.selectedVaultRemoteCredentialEntryID)
|
||||
if entryID != "" {
|
||||
var found bool
|
||||
for _, entry := range entries {
|
||||
if entry.ID == entryID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
u.selectedVaultRemoteCredentialEntryID = ""
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(u.selectedVaultRemoteCredentialEntryID) == "" && len(entries) == 1 {
|
||||
u.selectedVaultRemoteCredentialEntryID = entries[0].ID
|
||||
}
|
||||
}
|
||||
|
||||
func (u *ui) shouldShowSavedRemoteBindingSelectors() bool {
|
||||
profiles := u.availableRemoteProfiles()
|
||||
entries := u.availableRemoteCredentialEntries()
|
||||
|
||||
Reference in New Issue
Block a user