feat(desktop): add connection-level database browser
This commit is contained in:
46 files changed
+781
-29
No files matched your search
@@ -40,6 +40,20 @@ describe("queryStore database open state", () => {
|
||||
expect(store.isDatabaseOpen("pg-1", "analytics")).toBe(false);
|
||||
}, 10_000);
|
||||
|
||||
it("reuses one database browser tab per connection", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
|
||||
const firstId = store.openDatabaseBrowser("pg-1");
|
||||
const secondId = store.openDatabaseBrowser("pg-1");
|
||||
const otherConnectionId = store.openDatabaseBrowser("pg-2");
|
||||
|
||||
expect(secondId).toBe(firstId);
|
||||
expect(otherConnectionId).not.toBe(firstId);
|
||||
expect(store.tabs.filter((tab) => tab.mode === "databases")).toHaveLength(2);
|
||||
expect(store.tabs.find((tab) => tab.id === firstId)).toMatchObject({ connectionId: "pg-1", database: "", mode: "databases" });
|
||||
});
|
||||
|
||||
it("keeps object browser viewport per tab and clears it on schema change", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
|
||||
@@ -1702,6 +1702,29 @@ export const useQueryStore = defineStore("query", () => {
|
||||
return id;
|
||||
}
|
||||
|
||||
function openDatabaseBrowser(connectionId: string) {
|
||||
const existing = tabs.value.find((tab) => tab.mode === "databases" && tab.connectionId === connectionId);
|
||||
if (existing) {
|
||||
switchTab(existing.id);
|
||||
return existing.id;
|
||||
}
|
||||
|
||||
const id = uuid();
|
||||
tabs.value.push({
|
||||
id,
|
||||
title: "Databases",
|
||||
connectionId,
|
||||
database: "",
|
||||
sql: "",
|
||||
isExecuting: false,
|
||||
isCancelling: false,
|
||||
isExplaining: false,
|
||||
mode: "databases",
|
||||
});
|
||||
activeTabId.value = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
function switchTab(tabId: string) {
|
||||
activeTabId.value = tabId;
|
||||
settingsStore.settingsPageActive = false;
|
||||
@@ -5736,6 +5759,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
commitTransaction,
|
||||
rollbackTransaction,
|
||||
renameTab,
|
||||
openDatabaseBrowser,
|
||||
openObjectBrowser,
|
||||
openMongoGridFs,
|
||||
openMongoBucket,
|
||||
|
||||
Reference in new issue
Block a user