prioritize service name and port, truncate path or hide when necessary

This commit is contained in:
findthelorax
2026-04-22 00:24:24 -04:00
committed by Remy
parent 16adff5cff
commit 1a978c5e51
@@ -665,13 +665,11 @@ function ServiceBadge({ svc, host, onEdit, onRemove }: { svc: ServiceInfo; host?
const portLabel = hasPort ? String(svc.port) : '';
const pathLabel = svc.path?.trim() ? svc.path.trim() : '';
// Calculate available width for path: if name is long, path gets less or no space
// We'll use a ref to measure the name width, but for minimal change, estimate by string length
const maxTotalWidth = 220; // px, total badge width minus paddings/buttons
const nameCharWidth = 7.2; // px per char (approx for font-size 12px)
const nameWidth = Math.min(svc.service_name.length * nameCharWidth, maxTotalWidth - 60); // reserve 60px for port/buttons
const pathMaxWidth = Math.max(0, maxTotalWidth - nameWidth - 60); // 60px for port/buttons
const showPath = pathLabel && pathMaxWidth > 30; // hide path if not enough space
const maxTotalWidth = 220;
const nameCharWidth = 7.2;
const nameWidth = Math.min(svc.service_name.length * nameCharWidth, maxTotalWidth - 60);
const pathMaxWidth = Math.max(0, maxTotalWidth - nameWidth - 60);
const showPath = pathLabel && pathMaxWidth > 30;
return (
<div