feat(toolbar): add immediate sync shortcut

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-10-04 16:42:42 +08:00
1 parent 8ca612d1f7
commit b66d7313f1
17 files changed
+100 -5

No files matched your search

@@ -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<SyncMethod>(readSyncMethod());
const syncSelectionOpen = ref(false);
const syncSelectionMode = ref<"upload" | "restore">("upload");
const syncSelectionCatalog = ref<SyncSnapshotCatalog | null>(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));
@@ -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(() => {
</Tooltip>
</template>
<Tooltip v-if="toolbarItems.immediateSync">
<TooltipTrigger as-child>
<Button v-show="isRightItemVisible('immediateSync')" variant="ghost" size="icon" class="toolbar-action-button h-8 w-8 shrink-0" :aria-label="t('toolbar.immediateSync')" :aria-busy="immediateSyncing" :disabled="immediateSyncing" @click="emit('immediate-sync')">
<RefreshCw class="toolbar-action-icon h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>{{ t("toolbar.immediateSync") }}</TooltipContent>
</Tooltip>
<Tooltip v-if="showAlwaysOnTopButton">
<TooltipTrigger as-child>
<Button
@@ -142,6 +142,7 @@ const toolbarProps = {
hasConnections: false,
canNewQuery: false,
hasSqlFileConnections: false,
immediateSyncing: false,
};
describe("always-on-top button visibility", () => {
@@ -247,6 +248,19 @@ describe("always-on-top button visibility", () => {
unmount();
});
it("disables the immediate sync action while syncing", async () => {
const settingsStore = useSettingsStore();
settingsStore.editorSettings.toolbarItems.immediateSync = true;
const { host, unmount } = mount(AppToolbar, { ...toolbarProps, immediateSyncing: true });
await settled();
const button = host.querySelector('[aria-label="toolbar.immediateSync"]');
expect(button?.getAttribute("aria-busy")).toBe("true");
expect((button as HTMLButtonElement | null)?.disabled).toBe(true);
unmount();
});
it("renders shortcut hints in toolbar button tooltips", async () => {
const settingsStore = useSettingsStore();
settingsStore.updateEditorSettings({