diff --git a/main.go b/main.go index 1a35597..4fb1ef6 100644 --- a/main.go +++ b/main.go @@ -2301,6 +2301,35 @@ func (u *ui) prefillAdvancedSyncRemoteFromSavedBinding() { u.applyAdvancedSyncRemoteCredentialEntry(resolved.Credentials) } +func (u *ui) syncDialogTitle() string { + if u.syncDialogPurpose == syncDialogPurposeRemoteSetup { + return "Set Up Remote Sync" + } + return "Advanced Sync" +} + +func (u *ui) syncDialogDescription() string { + if u.syncDialogPurpose == syncDialogPurposeRemoteSetup { + return "Send this local vault to a WebDAV target, then use that target for future sync." + } + return "Pick direction, choose the other vault, and then run the merge. Saved source and direction defaults now live in Settings." +} + +func (u *ui) syncDialogConfirmButtonLabel() string { + if u.syncDialogPurpose == syncDialogPurposeRemoteSetup { + return "Set Up Remote Sync" + } + return "Synchronize" +} + +func (u *ui) shouldShowSyncDirectionChoices() bool { + return u.syncDialogPurpose != syncDialogPurposeRemoteSetup +} + +func (u *ui) shouldShowSyncSourceChoices() bool { + return u.syncDialogPurpose != syncDialogPurposeRemoteSetup +} + func (u *ui) selectVaultRemoteProfile(id string) { id = strings.TrimSpace(id) u.selectedVaultRemoteProfileID = id @@ -4920,45 +4949,69 @@ func (u *ui) syncDialogContent(gtx layout.Context) layout.Dimensions { return material.List(u.theme, &u.lifecycleList).Layout(gtx, 1, func(gtx layout.Context, _ int) 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(20), "Advanced Sync") + lbl := material.Label(u.theme, unit.Sp(20), u.syncDialogTitle()) lbl.Color = accentColor return lbl.Layout(gtx) }), layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - lbl := material.Label(u.theme, unit.Sp(14), "Pick direction, choose the other vault, and then run the merge. Saved source and direction defaults now live in Settings.") + lbl := material.Label(u.theme, unit.Sp(14), u.syncDialogDescription()) lbl.Color = mutedColor return lbl.Layout(gtx) }), layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout), - layout.Rigid(syncDialogSectionLabel(u.theme, "Direction")), - layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx, + if !u.shouldShowSyncDirectionChoices() { + return layout.Dimensions{} + } + return layout.Flex{Axis: layout.Vertical}.Layout(gtx, + layout.Rigid(syncDialogSectionLabel(u.theme, "Direction")), + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return syncChoiceButton(gtx, u.theme, &u.showSyncPull, "Pull Into Current Vault", u.syncDirection == syncDirectionPull) - }), - layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout), - layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return syncChoiceButton(gtx, u.theme, &u.showSyncPush, "Push Current Vault Out", u.syncDirection == syncDirectionPush) + return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx, + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return syncChoiceButton(gtx, u.theme, &u.showSyncPull, "Pull Into Current Vault", u.syncDirection == syncDirectionPull) + }), + layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return syncChoiceButton(gtx, u.theme, &u.showSyncPush, "Push Current Vault Out", u.syncDirection == syncDirectionPush) + }), + ) }), ) }), - layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout), - layout.Rigid(syncDialogSectionLabel(u.theme, "Other Source")), - layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx, + if !u.shouldShowSyncDirectionChoices() { + return layout.Dimensions{} + } + return layout.Spacer{Height: unit.Dp(12)}.Layout(gtx) + }), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + if !u.shouldShowSyncSourceChoices() { + return layout.Dimensions{} + } + return layout.Flex{Axis: layout.Vertical}.Layout(gtx, + layout.Rigid(syncDialogSectionLabel(u.theme, "Other Source")), + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return syncChoiceButton(gtx, u.theme, &u.showSyncLocal, "Local File", u.syncSourceMode == syncSourceLocal) - }), - layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout), - layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return syncChoiceButton(gtx, u.theme, &u.showSyncRemote, "Remote WebDAV", u.syncSourceMode == syncSourceRemote) + return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx, + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return syncChoiceButton(gtx, u.theme, &u.showSyncLocal, "Local File", u.syncSourceMode == syncSourceLocal) + }), + layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return syncChoiceButton(gtx, u.theme, &u.showSyncRemote, "Remote WebDAV", u.syncSourceMode == syncSourceRemote) + }), + ) }), ) }), - layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + if !u.shouldShowSyncSourceChoices() { + return layout.Dimensions{} + } + return layout.Spacer{Height: unit.Dp(12)}.Layout(gtx) + }), layout.Rigid(func(gtx layout.Context) layout.Dimensions { return syncDialogSummaryCard(gtx, u.theme, u.syncSourceMode, u.syncDirection) }), @@ -5020,7 +5073,7 @@ func (u *ui) syncDialogContent(gtx layout.Context) layout.Dimensions { layout.Rigid(func(gtx layout.Context) layout.Dimensions { return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx, layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return tonedButton(gtx, u.theme, &u.runAdvancedSync, "Synchronize") + return tonedButton(gtx, u.theme, &u.runAdvancedSync, u.syncDialogConfirmButtonLabel()) }), layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { diff --git a/main_test.go b/main_test.go index 3ab66ff..76f4a6d 100644 --- a/main_test.go +++ b/main_test.go @@ -5931,6 +5931,49 @@ func TestUISelectedLocalVaultRemoteSyncSummaryMentionsSetup(t *testing.T) { } } +func TestUISyncDialogUsesRemoteSetupCopy(t *testing.T) { + t.Parallel() + + u := newUIWithSession("desktop", &session.Manager{}) + u.syncDialogPurpose = syncDialogPurposeRemoteSetup + + if got := u.syncDialogTitle(); got != "Set Up Remote Sync" { + t.Fatalf("syncDialogTitle() = %q, want Set Up Remote Sync", got) + } + if got := u.syncDialogDescription(); got != "Send this local vault to a WebDAV target, then use that target for future sync." { + t.Fatalf("syncDialogDescription() = %q, want remote setup guidance", got) + } + if got := u.syncDialogConfirmButtonLabel(); got != "Set Up Remote Sync" { + t.Fatalf("syncDialogConfirmButtonLabel() = %q, want Set Up Remote Sync", got) + } + if u.shouldShowSyncDirectionChoices() { + t.Fatal("shouldShowSyncDirectionChoices() = true, want false for remote setup") + } + if u.shouldShowSyncSourceChoices() { + t.Fatal("shouldShowSyncSourceChoices() = true, want false for remote setup") + } +} + +func TestUISyncDialogUsesAdvancedCopy(t *testing.T) { + t.Parallel() + + u := newUIWithSession("desktop", &session.Manager{}) + u.syncDialogPurpose = syncDialogPurposeAdvanced + + if got := u.syncDialogTitle(); got != "Advanced Sync" { + t.Fatalf("syncDialogTitle() = %q, want Advanced Sync", got) + } + if got := u.syncDialogConfirmButtonLabel(); got != "Synchronize" { + t.Fatalf("syncDialogConfirmButtonLabel() = %q, want Synchronize", got) + } + if !u.shouldShowSyncDirectionChoices() { + t.Fatal("shouldShowSyncDirectionChoices() = false, want true for advanced sync") + } + if !u.shouldShowSyncSourceChoices() { + t.Fatal("shouldShowSyncSourceChoices() = false, want true for advanced sync") + } +} + func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) { t.Parallel()