From a3bfe7cb0c7a67cd336fdaab1a30fbda7cf473c3 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:55:37 +1200 Subject: [PATCH] fix(logs): improve log rendering performance [r8s-437] (#993) --- .../ApplicationsDatatable/columns.tsx | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/app/react/kubernetes/applications/ListView/ApplicationsDatatable/columns.tsx b/app/react/kubernetes/applications/ListView/ApplicationsDatatable/columns.tsx index a60d48072..fdcd58de8 100644 --- a/app/react/kubernetes/applications/ListView/ApplicationsDatatable/columns.tsx +++ b/app/react/kubernetes/applications/ListView/ApplicationsDatatable/columns.tsx @@ -1,11 +1,13 @@ import { CellContext, Row } from '@tanstack/react-table'; +import { useRef } from 'react'; -import { isoDate, truncate } from '@/portainer/filters/filters'; +import { isoDate } from '@/portainer/filters/filters'; import { useIsSystemNamespace } from '@/react/kubernetes/namespaces/queries/useIsSystemNamespace'; import { Link } from '@@/Link'; import { SystemBadge } from '@@/Badge/SystemBadge'; import { filterHOC } from '@@/datatables/Filter'; +import { TooltipWithChildren } from '@@/Tip/TooltipWithChildren'; import { Application } from './types'; import { helper } from './columns.helper'; @@ -40,15 +42,45 @@ function NamespaceCell({ row, getValue }: CellContext) { export const image = helper.accessor('Image', { header: 'Image', cell: ({ row: { original: item } }) => ( - <> - {truncate(item.Image, 64)} - {item.Containers && item.Containers?.length > 1 && ( - <>+ {item.Containers.length - 1} - )} - + ), }); +function ImageCell({ + image, + imageCount, +}: { + image: string; + imageCount: number; +}) { + const contentRef = useRef(null); + const isTruncated = isWidthTruncated(); + + const imageElement = ( +
+ {image} +
+ ); + + if (isTruncated) { + return ( + {imageElement} + ); + } + + return ( +
+ {imageElement} + {imageCount > 1 && <> + {imageCount - 1}} +
+ ); + + function isWidthTruncated() { + const el = contentRef.current; + return el && el.scrollWidth > el.clientWidth; + } +} + export const appType = helper.accessor('ApplicationType', { header: 'Application type', meta: {