Label sole saved remote as sync path
This commit is contained in:
@@ -2269,6 +2269,20 @@ func (u *ui) savedRemoteBindingSummary() (profileLabel, credentialLabel string,
|
||||
return profile.Name, credentialLabel, true
|
||||
}
|
||||
|
||||
func (u *ui) savedRemoteBindingHeading() string {
|
||||
if !u.shouldShowSavedRemoteBindingSelectors() {
|
||||
return "Use this vault's saved remote sync target"
|
||||
}
|
||||
return "Use a saved remote profile from this vault"
|
||||
}
|
||||
|
||||
func (u *ui) openSelectedVaultRemoteButtonLabel() string {
|
||||
if !u.shouldShowSavedRemoteBindingSelectors() {
|
||||
return "Use Remote Sync"
|
||||
}
|
||||
return "Open Saved Remote"
|
||||
}
|
||||
|
||||
func remoteBindingSuffix(baseURL, path, username string) string {
|
||||
sum := sha256.Sum256([]byte(strings.TrimSpace(baseURL) + "\n" + strings.TrimSpace(path) + "\n" + strings.TrimSpace(username)))
|
||||
return hex.EncodeToString(sum[:8])
|
||||
@@ -4934,7 +4948,7 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
|
||||
rows = append(rows,
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(11), "Use a saved remote profile from this vault")
|
||||
lbl := material.Label(u.theme, unit.Sp(11), u.savedRemoteBindingHeading())
|
||||
lbl.Color = mutedColor
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
@@ -5014,7 +5028,7 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
|
||||
rows = append(rows,
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.openSelectedVaultRemote, "Open Saved Remote")
|
||||
return tonedButton(gtx, u.theme, &u.openSelectedVaultRemote, u.openSelectedVaultRemoteButtonLabel())
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5355,6 +5355,73 @@ func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISavedRemoteBindingHeadingUsesSyncLanguageForSingleChoice(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",
|
||||
}},
|
||||
})
|
||||
|
||||
if got := u.savedRemoteBindingHeading(); got != "Use this vault's saved remote sync target" {
|
||||
t.Fatalf("savedRemoteBindingHeading() = %q, want sync-target guidance", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenSelectedVaultRemoteButtonLabelUsesSyncLanguageForSingleChoice(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",
|
||||
}},
|
||||
})
|
||||
|
||||
if got := u.openSelectedVaultRemoteButtonLabel(); got != "Use Remote Sync" {
|
||||
t.Fatalf("openSelectedVaultRemoteButtonLabel() = %q, want Use Remote Sync", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenSelectedVaultRemoteButtonLabelUsesSavedRemoteLanguageForMultipleChoices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "remote-creds-1", Title: "Alpha Sign-In", Username: "auser", Path: []string{"Crew", "Internet"}},
|
||||
{ID: "remote-creds-2", Title: "Bravo Sign-In", Username: "buser", Path: []string{"Crew", "Internet"}},
|
||||
},
|
||||
RemoteProfiles: []vault.RemoteProfile{
|
||||
{ID: "profile-1", Name: "Bellagio Vault", Backend: vault.RemoteBackendWebDAV, BaseURL: "https://dav1.example.invalid", Path: "files/bellagio.kdbx"},
|
||||
{ID: "profile-2", Name: "Vault Console", Backend: vault.RemoteBackendWebDAV, BaseURL: "https://dav2.example.invalid", Path: "files/console.kdbx"},
|
||||
},
|
||||
})
|
||||
|
||||
if got := u.openSelectedVaultRemoteButtonLabel(); got != "Open Saved Remote" {
|
||||
t.Fatalf("openSelectedVaultRemoteButtonLabel() = %q, want Open Saved Remote", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user