fix(sidebar): preserve expansion after object rename
This commit is contained in:
@@ -844,14 +844,7 @@ function dropTable() {
|
||||
|
||||
async function refreshTableList(node: TreeNode) {
|
||||
if (!node.connectionId || !node.database) return;
|
||||
const config = connectionStore.getConfig(node.connectionId);
|
||||
if (config?.db_type === "sqlserver" && node.schema?.toLowerCase() === "dbo") {
|
||||
await connectionStore.loadSqlServerDatabaseObjects(node.connectionId, node.database, { force: true });
|
||||
} else if (node.schema) {
|
||||
await connectionStore.loadTables(node.connectionId, node.database, node.schema, { force: true });
|
||||
} else {
|
||||
await connectionStore.loadTables(node.connectionId, node.database, undefined, { force: true });
|
||||
}
|
||||
await connectionStore.refreshObjectListTreeNode(node.connectionId, node.database, node.schema);
|
||||
}
|
||||
|
||||
async function confirmDropTable() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
const treeItemSource = readFileSync(join(process.cwd(), "apps/desktop/src/components/sidebar/TreeItem.vue"), "utf8");
|
||||
|
||||
function extractRefreshTableListBody(): string {
|
||||
const match = treeItemSource.match(/async function refreshTableList\(node: TreeNode\) \{([\s\S]*?)\n\}/);
|
||||
assert.ok(match, "TreeItem.vue should define refreshTableList");
|
||||
return match[1]!;
|
||||
}
|
||||
|
||||
test("object mutations refresh through the expansion-preserving object list path", () => {
|
||||
const body = extractRefreshTableListBody();
|
||||
|
||||
assert.match(body, /refreshObjectListTreeNode/);
|
||||
assert.doesNotMatch(body, /loadTables\(/);
|
||||
assert.doesNotMatch(body, /loadSqlServerDatabaseObjects\(/);
|
||||
});
|
||||
Reference in New Issue
Block a user