fix(connection): refresh and display connection notes
This commit is contained in:
19 files changed
+199
-19
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { alignedCommentLeadingWidth, alignedSidebarCommentLabelWidths, canTreeNodeShowExpander, sidebarTreeNaturalContentWidth, trailingCommentAvailableWidth, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
import { alignedCommentLeadingWidth, alignedSidebarCommentLabelWidths, canTreeNodeShowExpander, sidebarTreeNaturalContentWidth, sidebarTreeNodeComment, trailingCommentAvailableWidth, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
import type { TreeNode } from "@/types/database";
|
||||
|
||||
describe("sidebar tree item layout", () => {
|
||||
it("keeps a table row constrained when it displays a comment", () => {
|
||||
@@ -7,6 +8,12 @@ describe("sidebar tree item layout", () => {
|
||||
expect(usesFullWidthTreeLabel("table", true, true)).toBe(false);
|
||||
});
|
||||
|
||||
it("shows connection notes only after the user opts in", () => {
|
||||
const connection: TreeNode = { id: "connection-1", label: "MySQL", type: "connection", comment: "Production" };
|
||||
expect(sidebarTreeNodeComment(connection, false)).toBeNull();
|
||||
expect(sidebarTreeNodeComment(connection, true)).toBe("Production");
|
||||
});
|
||||
|
||||
it("lets a table name consume the available row width before truncating when aligned", () => {
|
||||
expect(treeLabelWidthClass({ fullWidth: false, hasTrailingComment: true, alignLeading: true })).toBe("min-w-0 flex-1 truncate");
|
||||
// inline/right 模式 label 不撑满,让 comment 紧跟
|
||||
|
||||
@@ -127,8 +127,9 @@ export function alignedSidebarCommentLabelWidths(items: readonly SidebarCommentA
|
||||
return widths;
|
||||
}
|
||||
|
||||
export function sidebarTreeNodeComment(node: TreeNode): string | null {
|
||||
export function sidebarTreeNodeComment(node: TreeNode, showConnectionNotes: boolean): string | null {
|
||||
if (!commentTypes.has(node.type)) return null;
|
||||
if (node.type === "connection" && !showConnectionNotes) return null;
|
||||
if (node.type === "column" && node.meta && "comment" in node.meta) {
|
||||
const comment = node.meta.comment;
|
||||
return typeof comment === "string" && comment ? comment : null;
|
||||
|
||||
Reference in new issue
Block a user