Move remote sync actions into sync menu
This commit is contained in:
@@ -2764,6 +2764,23 @@ func (u *ui) remoteSyncSetupShortcutLabel() string {
|
||||
return "Set Up Remote Sync"
|
||||
}
|
||||
|
||||
func (u *ui) syncMenuActionLabels() []string {
|
||||
labels := []string{"Open Advanced Sync"}
|
||||
if u.shouldShowRemoteSyncSetupShortcut() {
|
||||
labels = append(labels, u.remoteSyncSetupShortcutLabel())
|
||||
}
|
||||
if u.shouldShowDirectRemoteSyncShortcut() {
|
||||
labels = append(labels, u.directRemoteSyncShortcutLabel())
|
||||
}
|
||||
if u.shouldShowRemoteSyncSettingsShortcut() {
|
||||
labels = append(labels, u.remoteSyncSettingsShortcutLabel())
|
||||
}
|
||||
if u.shouldShowRemoveRemoteSyncShortcut() {
|
||||
labels = append(labels, u.removeRemoteSyncShortcutLabel())
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
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])
|
||||
@@ -5663,6 +5680,38 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.openAdvancedSync, "Open Advanced Sync")
|
||||
}),
|
||||
}
|
||||
if u.shouldShowRemoteSyncSetupShortcut() {
|
||||
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.useSavedAdvancedSyncRemote, u.remoteSyncSetupShortcutLabel())
|
||||
}),
|
||||
)
|
||||
}
|
||||
if u.shouldShowDirectRemoteSyncShortcut() {
|
||||
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, u.directRemoteSyncShortcutLabel())
|
||||
}),
|
||||
)
|
||||
}
|
||||
if u.shouldShowRemoteSyncSettingsShortcut() {
|
||||
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.useSavedAdvancedSyncRemote, u.remoteSyncSettingsShortcutLabel())
|
||||
}),
|
||||
)
|
||||
}
|
||||
if u.shouldShowRemoveRemoteSyncShortcut() {
|
||||
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.removeSelectedRemoteBinding, u.removeRemoteSyncShortcutLabel())
|
||||
}),
|
||||
)
|
||||
}
|
||||
if u.hasOpenVault() && len(profiles) > 0 && len(credentials) > 0 {
|
||||
rows = append(rows,
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
|
||||
@@ -7021,43 +7070,7 @@ func (u *ui) pathBar(gtx layout.Context) layout.Dimensions {
|
||||
return children
|
||||
}()...)
|
||||
}
|
||||
if !u.shouldShowDirectRemoteSyncShortcut() && !u.shouldShowRemoteSyncSetupShortcut() && !u.shouldShowRemoteSyncSettingsShortcut() && !u.shouldShowRemoveRemoteSyncShortcut() {
|
||||
return crumbBar(gtx)
|
||||
}
|
||||
children := []layout.FlexChild{
|
||||
layout.Rigid(crumbBar),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
|
||||
}
|
||||
if u.shouldShowDirectRemoteSyncShortcut() {
|
||||
children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.openSelectedVaultRemote, u.directRemoteSyncShortcutLabel())
|
||||
}))
|
||||
}
|
||||
if u.shouldShowRemoteSyncSetupShortcut() {
|
||||
if u.shouldShowDirectRemoteSyncShortcut() {
|
||||
children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout))
|
||||
}
|
||||
children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSetupShortcutLabel())
|
||||
}))
|
||||
}
|
||||
if u.shouldShowRemoteSyncSettingsShortcut() {
|
||||
if u.shouldShowDirectRemoteSyncShortcut() || u.shouldShowRemoteSyncSetupShortcut() {
|
||||
children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout))
|
||||
}
|
||||
children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSettingsShortcutLabel())
|
||||
}))
|
||||
}
|
||||
if u.shouldShowRemoveRemoteSyncShortcut() {
|
||||
if u.shouldShowDirectRemoteSyncShortcut() || u.shouldShowRemoteSyncSetupShortcut() || u.shouldShowRemoteSyncSettingsShortcut() {
|
||||
children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout))
|
||||
}
|
||||
children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return tonedButton(gtx, u.theme, &u.removeSelectedRemoteBinding, u.removeRemoteSyncShortcutLabel())
|
||||
}))
|
||||
}
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, children...)
|
||||
return crumbBar(gtx)
|
||||
}
|
||||
|
||||
func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) {
|
||||
|
||||
@@ -5953,6 +5953,55 @@ func TestUIRemoteSetupShortcutHasParityAcrossModes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncMenuActionLabelsIncludeRemoteSetupForUnboundVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "entry-1",
|
||||
Title: "Mint Console",
|
||||
Path: []string{"Crew", "Signals"},
|
||||
}},
|
||||
})
|
||||
u.state.Section = appstate.SectionEntries
|
||||
|
||||
got := u.syncMenuActionLabels()
|
||||
if !slices.Contains(got, "Set Up Remote Sync") {
|
||||
t.Fatalf("syncMenuActionLabels() = %v, want Set Up Remote Sync", got)
|
||||
}
|
||||
if slices.Contains(got, "Use Remote Sync") {
|
||||
t.Fatalf("syncMenuActionLabels() = %v, want no Use Remote Sync without saved binding", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncMenuActionLabelsIncludeSavedRemoteActionsForBoundVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "remote-creds-1",
|
||||
Title: "Bellagio WebDAV Sign-In",
|
||||
Username: "linuscaldwell",
|
||||
Path: []string{"Crew", "Signals"},
|
||||
}},
|
||||
RemoteProfiles: []vault.RemoteProfile{{
|
||||
ID: "bellagio-webdav",
|
||||
Name: "Bellagio Vault",
|
||||
Backend: vault.RemoteBackendWebDAV,
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/bellagio/keepass.kdbx",
|
||||
}},
|
||||
})
|
||||
u.state.Section = appstate.SectionEntries
|
||||
|
||||
got := u.syncMenuActionLabels()
|
||||
for _, want := range []string{"Use Remote Sync", "Remote Sync Settings", "Stop Using Remote Sync"} {
|
||||
if !slices.Contains(got, want) {
|
||||
t.Fatalf("syncMenuActionLabels() = %v, want %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldHideRemoteSyncSetupShortcutWhenSavedBindingExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user