fix(rack-planner): ensure SFP/WAN ports render even when ethernet port count is zero
This commit is contained in:
@@ -49,15 +49,20 @@ export function ModuleBlock({ module }: ModuleBlockProps) {
|
|||||||
|
|
||||||
// Split Main ports into rows
|
// Split Main ports into rows
|
||||||
const portRows: (typeof module.ports)[] = [];
|
const portRows: (typeof module.ports)[] = [];
|
||||||
for (let i = 0; i < mainPorts.length; i += PORTS_PER_ROW) {
|
if (mainPorts.length > 0) {
|
||||||
portRows.push(mainPorts.slice(i, i + PORTS_PER_ROW));
|
for (let i = 0; i < mainPorts.length; i += PORTS_PER_ROW) {
|
||||||
|
portRows.push(mainPorts.slice(i, i + PORTS_PER_ROW));
|
||||||
|
}
|
||||||
|
} else if (sidePorts.length > 0) {
|
||||||
|
// If only special ports exist, create an empty first row to hold them
|
||||||
|
portRows.push([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate vertical space
|
// Calculate vertical space
|
||||||
const availableForPorts = height - 16;
|
const availableForPorts = height - 16;
|
||||||
const maxRows = Math.max(1, Math.floor(availableForPorts / 14));
|
const maxRows = Math.max(1, Math.floor(availableForPorts / 14));
|
||||||
const visibleRows = portRows.slice(0, maxRows);
|
const visibleRows = portRows.length > 0 ? portRows.slice(0, maxRows) : [];
|
||||||
const hiddenPortCount = mainPorts.length - visibleRows.flat().length;
|
const hiddenPortCount = mainPorts.length - (visibleRows.length > 0 ? visibleRows.flat().length : 0);
|
||||||
|
|
||||||
// SFP/WAN ports often sit on the far right of the module
|
// SFP/WAN ports often sit on the far right of the module
|
||||||
// We'll show them on the first row if possible
|
// We'll show them on the first row if possible
|
||||||
|
|||||||
Reference in New Issue
Block a user