feat(dolt): add database-aware version control workspace

This commit is contained in:
hanxuanyu authored and GitHub committed 2026-08-18 11:30:20 +08:00
1 parent 3e6e43c57c
commit cf1476a6dc
29 files changed
+5411 -6

No files matched your search

@@ -54,6 +54,32 @@ describe("queryStore database open state", () => {
expect(store.tabs.find((tab) => tab.id === firstId)).toMatchObject({ connectionId: "pg-1", database: "", mode: "databases" });
});
it("retargets a connection-scoped driver workspace to a database branch", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
const firstId = store.openDriverProfileWorkspace("dolt-1", "inventory", "Version Control", "dolt-version-control", "connection");
const branchId = store.openDriverProfileWorkspace("dolt-1", "analytics", "Version Control", "dolt-version-control", "connection", "feature/orders");
expect(branchId).toBe(firstId);
expect(store.tabs.find((tab) => tab.id === firstId)).toMatchObject({
database: "analytics",
workspaceBranch: "feature/orders",
mode: "dolt-version-control",
});
});
it("keeps database-scoped driver workspaces isolated", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
const inventoryId = store.openDriverProfileWorkspace("profile-1", "inventory", "Workspace", "dolt-version-control", "database");
const analyticsId = store.openDriverProfileWorkspace("profile-1", "analytics", "Workspace", "dolt-version-control", "database");
expect(analyticsId).not.toBe(inventoryId);
expect(store.tabs.filter((tab) => tab.mode === "dolt-version-control")).toHaveLength(2);
});
it("keeps object browser viewport per tab and clears it on schema change", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
+28
View File
@@ -77,6 +77,7 @@ import type { SavedSqlFile } from "@/types/database";
import i18n from "@/i18n";
import { translateBackendError } from "@/i18n/backend-errors";
import type { SqlExecutionTargetContext } from "@/lib/database/sqlExecutionTargetRegistry";
import type { DriverProfileWorkspaceScope } from "@/lib/database/driverProfileExtensions";
import type { MultiDbExecutionTarget, MultiDbResultRunExecution } from "@/types/sqlExecution";
const ORACLE_LIKE_METADATA_TYPES = new Set<string>(["oracle", "dameng", "oceanbase-oracle"]);
@@ -1809,6 +1810,32 @@ export const useQueryStore = defineStore("query", () => {
return id;
}
function openDriverProfileWorkspace(connectionId: string, database: string, title: string, mode: QueryTab["mode"], tabScope: DriverProfileWorkspaceScope = "database", workspaceBranch?: string) {
const existing = tabs.value.find((tab) => tab.mode === mode && tab.connectionId === connectionId && (tabScope === "connection" || tab.database === database));
if (existing) {
if (existing.database !== database) updateDatabase(existing.id, database);
existing.workspaceBranch = workspaceBranch;
switchTab(existing.id);
return existing.id;
}
const id = uuid();
tabs.value.push({
id,
title,
connectionId,
database,
workspaceBranch,
sql: "",
isExecuting: false,
isCancelling: false,
isExplaining: false,
mode,
});
activeTabId.value = id;
return id;
}
function switchTab(tabId: string) {
activeTabId.value = tabId;
settingsStore.settingsPageActive = false;
@@ -6095,6 +6122,7 @@ export const useQueryStore = defineStore("query", () => {
rollbackTransaction,
renameTab,
openDatabaseBrowser,
openDriverProfileWorkspace,
openObjectBrowser,
openMongoGridFs,
openMongoBucket,