mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 03:10:46 +08:00
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:
parent
bee86eea0d
commit
1d742e58a1
2 changed files with 17 additions and 4 deletions
|
|
@ -825,14 +825,20 @@ export function TopologyPage() {
|
|||
return built.map((e) => {
|
||||
const d = (e.data || {}) as EdgeStyleData;
|
||||
const count = Number(d.member_count || 1);
|
||||
const keepCountLabel = !expandPhysicalLinks && count > 1;
|
||||
const selected =
|
||||
e.id === selectedEdgeId ||
|
||||
Boolean(d.members?.some((m: LinkMember) => m.id === selectedEdgeId));
|
||||
let label: string | undefined;
|
||||
if (hidePorts) {
|
||||
// Keep only the bundle count when ports are hidden — never leak port names.
|
||||
label = !expandPhysicalLinks && count > 1 ? `×${count}` : undefined;
|
||||
} else {
|
||||
label = e.label ? String(e.label) : undefined;
|
||||
}
|
||||
return {
|
||||
...e,
|
||||
selected,
|
||||
label: hidePorts && !keepCountLabel ? undefined : e.label,
|
||||
label,
|
||||
animated: edgeFlow,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue