Skip to content

Commit 4ede812

Browse files
committed
CodeRabbit suggestions
1 parent d1278ba commit 4ede812

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

frontend/src/app/components/TopologyChart.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ export function TopologyChart({
171171
id: edgeId,
172172
to: targetCDP,
173173
label: "",
174-
title: portCDP,
175-
color: "#BBBBBB",
174+
title: htmlTitle(escapeHtml(String(portCDP ?? ""))),
176175
} as Edge);
177176
} else if (targetLLDP) {
178177
const edgeId = `e_${sysName}__${targetLLDP}__${
@@ -186,8 +185,7 @@ export function TopologyChart({
186185
from: sysName,
187186
to: targetLLDP,
188187
label: "",
189-
title: portLLDP,
190-
color: "#BBBBBB",
188+
title: htmlTitle(escapeHtml(String(portLLDP ?? ""))),
191189
} as Edge);
192190
}
193191
}
@@ -231,7 +229,11 @@ export function TopologyChart({
231229
</div>
232230
</div>
233231
<div style="margin-top: 0.5rem; font-size: 1.2em; font-weight: bold; color: white;">
234-
${formatUptime(device.sysUptime) ?? "N/A"}
232+
${
233+
typeof device.sysUptime === "number"
234+
? formatUptime(device.sysUptime)
235+
: "N/A"
236+
}
235237
<span style="font-size: 0.4em; font-weight: normal;">Uptime</span>
236238
</div>
237239
`.trim()
@@ -347,8 +349,8 @@ export function TopologyChart({
347349
// Reset edges color
348350
initialGraph.current.edges.forEach((originalEdge) => {
349351
edgesData.current!.update({
350-
id: originalEdge.id,
351-
color: originalEdge.color || (isDark ? "#444" : "#BBBBBB"),
352+
id: originalEdge.id!,
353+
color: isDark ? "#444" : "#BBBBBB",
352354
});
353355
});
354356
});
@@ -389,8 +391,8 @@ export function TopologyChart({
389391

390392
initialGraph.current.edges.forEach((originalEdge) => {
391393
edgesData.current!.update({
392-
id: originalEdge.id,
393-
color: originalEdge.color || (isDark ? "#444" : "#BBBBBB"),
394+
id: originalEdge.id!,
395+
color: isDark ? "#444" : "#BBBBBB",
394396
arrows: { to: false },
395397
});
396398
});
@@ -546,9 +548,9 @@ export function TopologyChart({
546548

547549
{suggestions.length > 0 && (
548550
<ul className="absolute bg-bg shadow-md mt-1 rounded border w-full z-50 topology-suggestions-list">
549-
{suggestions.map((suggestion, index) => (
551+
{suggestions.map((suggestion) => (
550552
<li
551-
key={index}
553+
key={suggestion}
552554
onClick={() => {
553555
setSearchTerm(suggestion);
554556
setInputTerm("");

0 commit comments

Comments
 (0)