Clarify remote setup feedback
This commit is contained in:
@@ -1537,6 +1537,7 @@ func (u *ui) advancedSyncToAction() error {
|
||||
if err := u.persistSyncDialogRemoteBinding(baseURL, remotePath); err != nil {
|
||||
return err
|
||||
}
|
||||
u.showStatusMessage("Remote sync is set up for this vault.")
|
||||
}
|
||||
default:
|
||||
path := strings.TrimSpace(u.syncLocalPath.Text())
|
||||
@@ -4736,7 +4737,7 @@ func (u *ui) securityDialogContent(gtx layout.Context) layout.Dimensions {
|
||||
},
|
||||
layout.Spacer{Height: unit.Dp(8)}.Layout,
|
||||
func(gtx layout.Context) layout.Dimensions {
|
||||
return syncDialogSummaryCard(gtx, u.theme, u.settingsDraft.Sync.SourceDefault, u.settingsDraft.Sync.DirectionDefault)
|
||||
return syncDialogSummaryCard(gtx, u.theme, syncDialogPurposeAdvanced, u.settingsDraft.Sync.SourceDefault, u.settingsDraft.Sync.DirectionDefault)
|
||||
},
|
||||
layout.Spacer{Height: unit.Dp(8)}.Layout,
|
||||
func(gtx layout.Context) layout.Dimensions {
|
||||
@@ -5062,7 +5063,7 @@ func (u *ui) syncDialogContent(gtx layout.Context) 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)
|
||||
return syncDialogSummaryCard(gtx, u.theme, u.syncDialogPurpose, u.syncSourceMode, u.syncDirection)
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
@@ -7164,7 +7165,10 @@ func syncDialogSectionLabel(th *material.Theme, text string) layout.Widget {
|
||||
}
|
||||
}
|
||||
|
||||
func syncDialogSummaryCard(gtx layout.Context, th *material.Theme, source syncSourceMode, direction syncDirection) layout.Dimensions {
|
||||
func syncDialogSummaryText(purpose syncDialogPurpose, source syncSourceMode, direction syncDirection) string {
|
||||
if purpose == syncDialogPurposeRemoteSetup {
|
||||
return "Push this local vault to a WebDAV target and save that target for future sync."
|
||||
}
|
||||
sourceLabel := "another local vault file"
|
||||
if source == syncSourceRemote {
|
||||
sourceLabel = "another WebDAV-backed vault"
|
||||
@@ -7173,6 +7177,10 @@ func syncDialogSummaryCard(gtx layout.Context, th *material.Theme, source syncSo
|
||||
if direction == syncDirectionPush {
|
||||
action = "Push the current vault into"
|
||||
}
|
||||
return action + " " + sourceLabel + "."
|
||||
}
|
||||
|
||||
func syncDialogSummaryCard(gtx layout.Context, th *material.Theme, purpose syncDialogPurpose, source syncSourceMode, direction syncDirection) layout.Dimensions {
|
||||
return layout.Background{}.Layout(gtx, fill(color.NRGBA{R: 242, G: 245, B: 240, A: 255}), func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.UniformInset(unit.Dp(10)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
@@ -7183,7 +7191,7 @@ func syncDialogSummaryCard(gtx layout.Context, th *material.Theme, source syncSo
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(th, unit.Sp(14), action+" "+sourceLabel+".")
|
||||
lbl := material.Label(th, unit.Sp(14), syncDialogSummaryText(purpose, source, direction))
|
||||
lbl.Color = th.Palette.Fg
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
|
||||
@@ -5958,6 +5958,9 @@ func TestUISyncDialogUsesRemoteSetupCopy(t *testing.T) {
|
||||
if u.shouldShowSyncSourceChoices() {
|
||||
t.Fatal("shouldShowSyncSourceChoices() = true, want false for remote setup")
|
||||
}
|
||||
if got := syncDialogSummaryText(syncDialogPurposeRemoteSetup, syncSourceRemote, syncDirectionPush); got != "Push this local vault to a WebDAV target and save that target for future sync." {
|
||||
t.Fatalf("syncDialogSummaryText(remote setup) = %q, want setup-specific summary", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncDialogUsesAdvancedCopy(t *testing.T) {
|
||||
@@ -5978,6 +5981,9 @@ func TestUISyncDialogUsesAdvancedCopy(t *testing.T) {
|
||||
if !u.shouldShowSyncSourceChoices() {
|
||||
t.Fatal("shouldShowSyncSourceChoices() = false, want true for advanced sync")
|
||||
}
|
||||
if got := syncDialogSummaryText(syncDialogPurposeAdvanced, syncSourceRemote, syncDirectionPush); got != "Push the current vault into another WebDAV-backed vault." {
|
||||
t.Fatalf("syncDialogSummaryText(advanced) = %q, want advanced summary", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteSyncSetupPersistsBindingAfterSuccessfulPush(t *testing.T) {
|
||||
@@ -6050,6 +6056,9 @@ func TestUIRemoteSyncSetupPersistsBindingAfterSuccessfulPush(t *testing.T) {
|
||||
if got := u.recentRemotes[0].LocalVaultPath; got != currentPath {
|
||||
t.Fatalf("recentRemotes[0].LocalVaultPath = %q, want %q", got, currentPath)
|
||||
}
|
||||
if got := u.state.StatusMessage; got != "Remote sync is set up for this vault." {
|
||||
t.Fatalf("StatusMessage = %q, want setup success message", got)
|
||||
}
|
||||
|
||||
var reopened session.Manager
|
||||
if err := reopened.Open(currentPath, key); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user