diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index eacf0e6d92..1b404ed6f9 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -68,6 +68,7 @@ import { disposeAllSqlServerActivityTraces } from "@/lib/sqlserver/sqlServerActi import { useVisibilityChange } from "@/composables/useVisibilityChange"; import { useExternalSqlFileChanges } from "@/composables/useExternalSqlFileChanges"; import { useWebDavAutoUpload } from "@/composables/useWebDavAutoUpload"; +import { readSyncMethod, readWebDavAutoUploadConfig, readWebDavBackupSelection } from "@/lib/webdav/webdavAutoUploadConfig"; import { useScheduledDatabaseBackups } from "@/composables/useScheduledDatabaseBackups"; import { shouldDrawDesktopWindowFrame } from "@/composables/useWindowControls"; import { createOpenTabsRestorationBarrier, initializeDesktopOpenTabs, initializeOpenTabs, type OpenTabsRestorationBarrier } from "@/lib/app/openTabsStartup"; @@ -397,6 +398,7 @@ const pluginCenterActive = ref(false); const pluginCenterFocus = ref(null); const connectionPluginProvider = ref(null); const settingsReturnSurface = ref<"query" | "driverStore" | "pluginCenter" | "welcome">("welcome"); +const immediateSyncing = ref(false); const showDriverStore = computed(() => driverStoreTabOpen.value && driverStoreActive.value); const showPluginCenter = computed(() => pluginCenterTabOpen.value && pluginCenterActive.value); const showSettingsPage = computed(() => Boolean(settingsPageTabOpen.value && settingsStore.settingsPageActive)); @@ -1177,6 +1179,35 @@ function openSettings(initialTab = "appearance", initialSection?: string) { activateSettingsPage(); } +async function openImmediateSync() { + const syncMethod = readSyncMethod(); + if (syncMethod !== "webdav") { + openSettings("sync", syncMethod === "snippet" ? "sync-snippet" : "sync-local"); + return; + } + const autoUploadConfig = readWebDavAutoUploadConfig(); + if (!autoUploadConfig.webDavConfig) { + openSettings("sync", "sync-webdav"); + return; + } + const webDavConfig = autoUploadConfig.webDavConfig; + if (immediateSyncing.value) return; + immediateSyncing.value = true; + await nextTick(); + + try { + const secretsStatus = await api.webdavSyncSecretsStatus(); + const selection = readWebDavBackupSelection(); + const includeSecrets = Boolean((selection?.includeSecrets ?? secretsStatus.enabled) && secretsStatus.enabled && secretsStatus.hasSavedPassphrase); + const summary = await api.webdavSyncUpload(webDavConfig, settingsStore.editorSettings, undefined, includeSecrets, selection); + toast(t("settings.syncUploadSuccess", { bytes: summary.bytes, path: summary.remotePath }), 3000); + } catch (error: any) { + toast(error?.message || String(error), 5000); + } finally { + immediateSyncing.value = false; + } +} + type MainContentSurface = "query" | "settings" | "driverStore" | "pluginCenter"; function activateMainContentSurface(surface: MainContentSurface) { @@ -4403,6 +4434,7 @@ onUnmounted(() => { :has-connections="connectionStore.connections.length > 0" :can-new-query="canCreateNewQuery" :has-sql-file-connections="hasSqlFileConnections" + :immediate-syncing="immediateSyncing" :show-logout="!isDesktop && needsAuth" @new-connection="showConnectionDialog = true" @expand-sidebar="setSidebarOpen(true)" @@ -4417,6 +4449,7 @@ onUnmounted(() => { @open-driver-store="openDriverStorePage" @open-plugin-center="openPluginCenterPage()" @check-updates="handleToolbarUpdateClick" + @immediate-sync="openImmediateSync" @open-transfer="dialogs.showTransferDialog.value = true" @open-sql-file="dialogs.showSqlFileDialog.value = true" @open-schema-diff="dialogs.showSchemaDiffDialog.value = true" diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue index 73efe9b9af..80890c700a 100644 --- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue +++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue @@ -333,7 +333,7 @@ import { type ToolbarVisibilityItem, } from "@/lib/settings/settingsSearch"; import { LOCALE_OPTIONS } from "@/lib/app/localeOptions"; -import { DEFAULT_WEB_DAV_AUTO_UPLOAD_INTERVAL_MINUTES, DEFAULT_WEB_DAV_REMOTE_PATH, normalizedWebDavAutoUploadInterval, writeWebDavAutoUploadFields, writeWebDavBackupSelection } from "@/lib/webdav/webdavAutoUploadConfig"; +import { DEFAULT_WEB_DAV_AUTO_UPLOAD_INTERVAL_MINUTES, DEFAULT_WEB_DAV_REMOTE_PATH, normalizedWebDavAutoUploadInterval, readSyncMethod, writeWebDavAutoUploadFields, writeWebDavBackupSelection, writeSyncMethod, type SyncMethod } from "@/lib/webdav/webdavAutoUploadConfig"; import { apiUrl, webPath } from "@/lib/common/webPath"; import { DEFAULT_DATA_GRID_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY, normalizeCustomFontFamilyInput, readableFontFamily, SYSTEM_UI_FONT_FAMILY } from "@/lib/app/appFonts"; import { buildFontFamilyOptions, displayFontFamily, isPresetFontFamily, loadSystemFontNames } from "@/lib/app/fontFamilyOptions"; @@ -4399,7 +4399,7 @@ const localBackupError = ref(false); const localBackupPath = ref(""); const localBackupDirectoryStorageKey = "dbx-local-backup-directory"; const localBackupDirectory = ref(localStorage.getItem(localBackupDirectoryStorageKey) || ""); -const syncMethodTab = ref<"webdav" | "snippet" | "local">("webdav"); +const syncMethodTab = ref(readSyncMethod()); const syncSelectionOpen = ref(false); const syncSelectionMode = ref<"upload" | "restore">("upload"); const syncSelectionCatalog = ref(null); @@ -4424,6 +4424,8 @@ const legacySnippetId = ref(""); const pendingLegacyCleanupId = ref(""); const snippetSyncSettingsLoading = ref(true); +watch(syncMethodTab, (value) => writeSyncMethod(value), { immediate: true }); + const webdavReady = computed(() => !!webdavEndpoint.value.trim() && !webdavBusy.value); const localBackupCanIncludeSecrets = computed(() => !!localBackupSecretsPassphrase.value.trim()); const snippetReady = computed(() => !snippetSyncSettingsLoading.value && !snippetBusy.value && (snippetProvider.value !== "gitlab" || (!snippetInstanceError.value && snippetInstanceUrl.value === activeSnippetInstanceUrl.value)) && (!!snippetToken.value.trim() || snippetHasSavedToken.value)); diff --git a/apps/desktop/src/components/layout/AppToolbar.vue b/apps/desktop/src/components/layout/AppToolbar.vue index 5f1654b74a..02c6e61c50 100644 --- a/apps/desktop/src/components/layout/AppToolbar.vue +++ b/apps/desktop/src/components/layout/AppToolbar.vue @@ -2,7 +2,7 @@ import { computed, ref, onMounted, onBeforeUnmount, h, nextTick, watch } from "vue"; import { useI18n } from "vue-i18n"; import { invoke } from "@tauri-apps/api/core"; -import { ChevronsRight, DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, LogOut, CloudDownload, Package, PlugZap, FileDown, FolderTree, Pin, PinOff, CalendarClock, Waypoints } from "@lucide/vue"; +import { ChevronsRight, DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, LogOut, CloudDownload, Package, PlugZap, FileDown, FolderTree, Pin, PinOff, CalendarClock, Waypoints, RefreshCw } from "@lucide/vue"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import LightDropdown, { type LightDropdownItem } from "@/components/ui/LightDropdown.vue"; @@ -55,6 +55,7 @@ const props = defineProps<{ hasConnections: boolean; canNewQuery: boolean; hasSqlFileConnections: boolean; + immediateSyncing: boolean; showLogout?: boolean; }>(); @@ -78,6 +79,7 @@ const emit = defineEmits<{ "open-data-compare": []; "open-backups": []; "open-mcp-settings": []; + "immediate-sync": []; logout: []; }>(); @@ -214,6 +216,15 @@ const collapsibleRightItemDefs = computed(() => { disabled: boolean; } const items: ItemDef[] = []; + if (toolbarItems.value.immediateSync) { + items.push({ + key: "immediateSync", + label: t("toolbar.immediateSync"), + icon: RefreshCw, + action: () => emit("immediate-sync"), + disabled: props.immediateSyncing, + }); + } if (showToolbarUpdateEntry.value) { items.push({ key: "checkUpdates", @@ -672,6 +683,15 @@ const toolbarStyle = computed(() => { + + + + + {{ t("toolbar.immediateSync") }} + +