Show sync mode in saved remote summary
This commit is contained in:
@@ -2593,20 +2593,24 @@ func (u *ui) shouldShowSavedRemoteBindingSelectors() bool {
|
|||||||
return len(profiles) > 1 || len(entries) > 1
|
return len(profiles) > 1 || len(entries) > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) savedRemoteBindingSummary() (profileLabel, credentialLabel string, ok bool) {
|
func (u *ui) savedRemoteBindingSummary() (profileLabel, credentialLabel, syncLabel string, ok bool) {
|
||||||
profile, ok := u.selectedVaultRemoteProfile()
|
profile, ok := u.selectedVaultRemoteProfile()
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", "", false
|
return "", "", "", false
|
||||||
}
|
}
|
||||||
entry, ok := u.selectedVaultRemoteCredentialEntry()
|
entry, ok := u.selectedVaultRemoteCredentialEntry()
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", "", false
|
return "", "", "", false
|
||||||
}
|
}
|
||||||
credentialLabel = entry.Title
|
credentialLabel = entry.Title
|
||||||
if strings.TrimSpace(entry.Username) != "" {
|
if strings.TrimSpace(entry.Username) != "" {
|
||||||
credentialLabel += " · " + strings.TrimSpace(entry.Username)
|
credentialLabel += " · " + strings.TrimSpace(entry.Username)
|
||||||
}
|
}
|
||||||
return profile.Name, credentialLabel, true
|
syncLabel = "Sync manually when you choose Use Remote Sync."
|
||||||
|
if normalizeUISyncMode(u.selectedVaultRemoteSyncMode) == appstate.SyncModeAutomaticOnOpenSave {
|
||||||
|
syncLabel = "Syncs automatically on open and save."
|
||||||
|
}
|
||||||
|
return profile.Name, credentialLabel, syncLabel, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) savedRemoteBindingHeading() string {
|
func (u *ui) savedRemoteBindingHeading() string {
|
||||||
@@ -5573,7 +5577,7 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
|
|||||||
if !u.shouldShowSavedRemoteBindingSelectors() {
|
if !u.shouldShowSavedRemoteBindingSelectors() {
|
||||||
rows = append(rows,
|
rows = append(rows,
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
profileLabel, credentialLabel, ok := u.savedRemoteBindingSummary()
|
profileLabel, credentialLabel, syncLabel, ok := u.savedRemoteBindingSummary()
|
||||||
if !ok {
|
if !ok {
|
||||||
return layout.Dimensions{}
|
return layout.Dimensions{}
|
||||||
}
|
}
|
||||||
@@ -5591,6 +5595,12 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
|
|||||||
lbl.Color = mutedColor
|
lbl.Color = mutedColor
|
||||||
return lbl.Layout(gtx)
|
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(12), syncLabel)
|
||||||
|
lbl.Color = mutedColor
|
||||||
|
return lbl.Layout(gtx)
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+33
-1
@@ -5692,7 +5692,7 @@ func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
|
||||||
profileLabel, credentialLabel, ok := u.savedRemoteBindingSummary()
|
profileLabel, credentialLabel, syncLabel, ok := u.savedRemoteBindingSummary()
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
|
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
|
||||||
}
|
}
|
||||||
@@ -5702,6 +5702,38 @@ func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(t *testing.T) {
|
|||||||
if credentialLabel != "WebDAV Sign-In · tjulian" {
|
if credentialLabel != "WebDAV Sign-In · tjulian" {
|
||||||
t.Fatalf("credentialLabel = %q, want WebDAV Sign-In · tjulian", credentialLabel)
|
t.Fatalf("credentialLabel = %q, want WebDAV Sign-In · tjulian", credentialLabel)
|
||||||
}
|
}
|
||||||
|
if syncLabel != "Sync manually when you choose Use Remote Sync." {
|
||||||
|
t.Fatalf("syncLabel = %q, want manual sync summary", syncLabel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUISavedRemoteBindingSummaryMentionsAutomaticSyncMode(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithModel("desktop", vault.Model{
|
||||||
|
Entries: []vault.Entry{{
|
||||||
|
ID: "remote-creds-1",
|
||||||
|
Title: "WebDAV Sign-In",
|
||||||
|
Username: "tjulian",
|
||||||
|
Path: []string{"Crew", "Internet"},
|
||||||
|
}},
|
||||||
|
RemoteProfiles: []vault.RemoteProfile{{
|
||||||
|
ID: "family-webdav",
|
||||||
|
Name: "Family Vault",
|
||||||
|
Backend: vault.RemoteBackendWebDAV,
|
||||||
|
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||||
|
Path: "files/family/keepass.kdbx",
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
u.selectedVaultRemoteSyncMode = appstate.SyncModeAutomaticOnOpenSave
|
||||||
|
|
||||||
|
_, _, syncLabel, ok := u.savedRemoteBindingSummary()
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
|
||||||
|
}
|
||||||
|
if syncLabel != "Syncs automatically on open and save." {
|
||||||
|
t.Fatalf("syncLabel = %q, want automatic sync summary", syncLabel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUISavedRemoteBindingHeadingUsesSyncLanguageForSingleChoice(t *testing.T) {
|
func TestUISavedRemoteBindingHeadingUsesSyncLanguageForSingleChoice(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user