mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
Fully clear topology edge port labels when hide-ports is enabled.
Stop falling back to stale labels and pass hidePorts into link aggregation so only ×N remains for bundles. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1d742e58a1
commit
14251f4698
2 changed files with 18 additions and 17 deletions
|
|
@ -819,26 +819,19 @@ export function TopologyPage() {
|
|||
[hideIp, hideVendor, hidePorts, toolMode],
|
||||
);
|
||||
const displayEdges = useMemo(() => {
|
||||
const built = buildLinkDisplayEdges(edges, expandPhysicalLinks).map((e) =>
|
||||
const built = buildLinkDisplayEdges(edges, expandPhysicalLinks, hidePorts).map((e) =>
|
||||
withEdgeVisual(e, edgeDefaults),
|
||||
);
|
||||
return built.map((e) => {
|
||||
const d = (e.data || {}) as EdgeStyleData;
|
||||
const count = Number(d.member_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,
|
||||
// Empty string clears RF's previous edge-text; undefined can leave a stale label.
|
||||
label: e.label ? String(e.label) : "",
|
||||
animated: edgeFlow,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,7 +85,11 @@ function pickPrimary(list: Edge[]): Edge {
|
|||
* Default: one logical edge per NE pair (bundle parallel links).
|
||||
* Expanded: all physical edges, offset when count > 1.
|
||||
*/
|
||||
export function buildLinkDisplayEdges(edges: Edge[], expandPhysical: boolean): Edge[] {
|
||||
export function buildLinkDisplayEdges(
|
||||
edges: Edge[],
|
||||
expandPhysical: boolean,
|
||||
hidePorts = false,
|
||||
): Edge[] {
|
||||
const groups = new Map<string, Edge[]>();
|
||||
for (const e of edges) {
|
||||
const k = pairKey(e.source, e.target);
|
||||
|
|
@ -108,10 +112,12 @@ export function buildLinkDisplayEdges(edges: Edge[], expandPhysical: boolean): E
|
|||
parallelIndex: i,
|
||||
parallelCount: count,
|
||||
};
|
||||
const portLabel = formatPortPairLabel(data.source_port || "", data.target_port || "");
|
||||
out.push({
|
||||
...e,
|
||||
type: count > 1 ? "topoParallel" : e.type || "straight",
|
||||
label: formatPortPairLabel(data.source_port || "", data.target_port || "") || e.label,
|
||||
// Never fall back to a stale e.label — it may still contain ports.
|
||||
label: hidePorts ? undefined : portLabel || undefined,
|
||||
data,
|
||||
});
|
||||
});
|
||||
|
|
@ -127,10 +133,11 @@ export function buildLinkDisplayEdges(edges: Edge[], expandPhysical: boolean): E
|
|||
member_count: 1,
|
||||
members: [memberFrom(e)],
|
||||
};
|
||||
const portLabel = formatPortPairLabel(data.source_port || "", data.target_port || "");
|
||||
out.push({
|
||||
...e,
|
||||
type: "straight",
|
||||
label: formatPortPairLabel(data.source_port || "", data.target_port || "") || e.label,
|
||||
label: hidePorts ? undefined : portLabel || undefined,
|
||||
data,
|
||||
});
|
||||
continue;
|
||||
|
|
@ -153,10 +160,11 @@ export function buildLinkDisplayEdges(edges: Edge[], expandPhysical: boolean): E
|
|||
...primary,
|
||||
id: aggregateIdForPair(primary.source, primary.target),
|
||||
type: "straight",
|
||||
label: formatBundleLabel(list.length, {
|
||||
a_port: data.source_port,
|
||||
b_port: data.target_port,
|
||||
}),
|
||||
label: formatBundleLabel(
|
||||
list.length,
|
||||
{ a_port: data.source_port, b_port: data.target_port },
|
||||
{ hidePorts },
|
||||
) || undefined,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue