package appui import ( "runtime" "strings" "git.julianfamily.org/keepassgo/internal/appstate" appuiactions "git.julianfamily.org/keepassgo/internal/appui/actions" ) func (u *ui) buildSyncMenuModel() appuiactions.SyncMenuModel { model := appuiactions.SyncMenuModel{ HasOpenVault: u.hasOpenVault(), ShowSelectors: u.shouldShowSavedRemoteBindingSelectors(), ShowShare: supportsVaultShare(runtime.GOOS) && u.vaultSharer != nil && strings.TrimSpace(u.currentShareableVaultPath()) != "", RemoteBaseURL: strings.TrimSpace(u.remoteBaseURL.Text()), RemotePath: strings.TrimSpace(u.remotePath.Text()), RemoteUsername: strings.TrimSpace(u.remoteUsername.Text()), RemotePassword: u.remotePassword.Text(), SelectedVaultSyncMode: normalizeUISyncMode(u.selectedVaultRemoteSyncMode), } _, model.HasSelectedBinding = u.selectedVaultRemoteBinding() model.SavedBindingSummary = u.computeSavedRemoteBindingSummary() model.ShowSaveCurrentBinding = model.HasOpenVault && model.RemoteBaseURL != "" && model.RemotePath != "" && model.RemoteUsername != "" && model.RemotePassword != "" return model } func (u *ui) computeSavedRemoteBindingSummary() appuiactions.SyncMenuBindingSummary { profile, ok := u.selectedVaultRemoteProfile() if !ok { return appuiactions.SyncMenuBindingSummary{} } entry, ok := u.selectedVaultRemoteCredentialEntry() if !ok { return appuiactions.SyncMenuBindingSummary{} } credentialLabel := entry.Title if strings.TrimSpace(entry.Username) != "" { credentialLabel += " ยท " + strings.TrimSpace(entry.Username) } syncLabel := "Sync manually when you choose Use Remote Sync." if normalizeUISyncMode(u.selectedVaultRemoteSyncMode) == appstate.SyncModeAutomaticOnOpenSave { syncLabel = "Syncs automatically on open and save." } return appuiactions.SyncMenuBindingSummary{ ProfileLabel: profile.Name, CredentialLabel: credentialLabel, SyncLabel: syncLabel, OK: true, } }