Hide port names on aggregated topology links when hide-ports is on.

Bundle edges only keep a ×N count label; single-link ports stay fully hidden.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-04 14:11:46 +08:00
parent bee86eea0d
commit 1d742e58a1
2 changed files with 17 additions and 4 deletions

View file

@ -43,8 +43,15 @@ export function formatPortPairLabel(aPort: string, bPort: string): string {
return a || b || "";
}
export function formatBundleLabel(count: number, sample?: { a_port?: string; b_port?: string }): string {
if (count <= 1) return formatPortPairLabel(sample?.a_port || "", sample?.b_port || "");
export function formatBundleLabel(
count: number,
sample?: { a_port?: string; b_port?: string },
opts?: { hidePorts?: boolean },
): string {
if (count <= 1) {
return opts?.hidePorts ? "" : formatPortPairLabel(sample?.a_port || "", sample?.b_port || "");
}
if (opts?.hidePorts) return `×${count}`;
const sampleLabel = formatPortPairLabel(sample?.a_port || "", sample?.b_port || "");
return sampleLabel ? `×${count} · ${sampleLabel}` : `×${count}`;
}