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