fix(desktop): allow multiple new table structure tabs
This commit is contained in:
parent
90c618dac6
commit
8058c238b8
|
|
@ -234,16 +234,18 @@ export const useQueryStore = defineStore("query", () => {
|
|||
|
||||
function openTableStructure(connectionId: string, database: string, schema?: string, tableName?: string) {
|
||||
const resolvedTableName = tableName || "";
|
||||
const existing = tabs.value.find(
|
||||
(tab) =>
|
||||
tab.mode === "structure" &&
|
||||
tab.connectionId === connectionId &&
|
||||
tab.database === database &&
|
||||
(tab.structureTableName || "") === resolvedTableName,
|
||||
);
|
||||
if (existing) {
|
||||
activeTabId.value = existing.id;
|
||||
return existing.id;
|
||||
if (resolvedTableName) {
|
||||
const existing = tabs.value.find(
|
||||
(tab) =>
|
||||
tab.mode === "structure" &&
|
||||
tab.connectionId === connectionId &&
|
||||
tab.database === database &&
|
||||
(tab.structureTableName || "") === resolvedTableName,
|
||||
);
|
||||
if (existing) {
|
||||
activeTabId.value = existing.id;
|
||||
return existing.id;
|
||||
}
|
||||
}
|
||||
|
||||
const title = resolvedTableName
|
||||
|
|
|
|||
|
|
@ -748,3 +748,22 @@ test("tab reuse is scoped by mode and schema instead of title alone", () => {
|
|||
restoreStorage();
|
||||
}
|
||||
});
|
||||
|
||||
test("new table structure tabs can open multiple drafts while existing tables still reuse tabs", () => {
|
||||
const restoreStorage = installMemoryStorage();
|
||||
try {
|
||||
setActivePinia(createPinia());
|
||||
const store = useQueryStore();
|
||||
|
||||
const firstDraftId = store.openTableStructure("conn-1", "db", "public", "");
|
||||
const secondDraftId = store.openTableStructure("conn-1", "db", "public", "");
|
||||
const firstEditId = store.openTableStructure("conn-1", "db", "public", "users");
|
||||
const secondEditId = store.openTableStructure("conn-1", "db", "public", "users");
|
||||
|
||||
assert.notEqual(secondDraftId, firstDraftId);
|
||||
assert.equal(secondEditId, firstEditId);
|
||||
assert.equal(store.tabs.length, 3);
|
||||
} finally {
|
||||
restoreStorage();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue