From b1dc68df2aa3ad1c1e6e55cc324d34c3fa1fa293 Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Wed, 28 Aug 2024 10:19:30 +0300 Subject: [PATCH] fix: show two columns when no none headline properties chore: remove console.log chore: update spacing --- src/components/Canary/HealthChecksSummary.tsx | 2 +- src/components/StatusLine/StatusLine.tsx | 18 +++++++---- .../Topology/TopologyCard/TopologyCard.tsx | 31 +++++++++++++------ .../TopologyCard/Utils/FormatProperties.tsx | 1 - src/ui/CustomScroll/index.tsx | 2 +- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/components/Canary/HealthChecksSummary.tsx b/src/components/Canary/HealthChecksSummary.tsx index 34f7a850d..b095e9121 100644 --- a/src/components/Canary/HealthChecksSummary.tsx +++ b/src/components/Canary/HealthChecksSummary.tsx @@ -23,7 +23,7 @@ export function HealthChecksSummary({ const data: StatusLineProps = { label: "Health Checks", - icon: , + icon: , url: "/health", statuses: [ ...(checks.healthy > 0 diff --git a/src/components/StatusLine/StatusLine.tsx b/src/components/StatusLine/StatusLine.tsx index ec0cfed48..618d9ede9 100644 --- a/src/components/StatusLine/StatusLine.tsx +++ b/src/components/StatusLine/StatusLine.tsx @@ -20,15 +20,21 @@ export type StatusLineData = { export type StatusLineProps = React.HTMLProps & StatusLineData; -const renderIcon = (icon: string | React.ReactNode) => { +interface RenderIconProps { + icon: string | React.ReactNode; +} + +const RenderIcon: React.FC = ({ icon }) => { if (!icon) { return null; } if (typeof icon === "object") { - return icon; + // eslint-disable-next-line react/jsx-no-useless-fragment + return <>{icon}; } else if (typeof icon === "string") { - return ; + return ; } + return null; }; const StatusInfoEntry = ({ @@ -46,14 +52,14 @@ const StatusInfoEntry = ({ to={statusInfo.url} target={target || ""} > - {statusInfo.icon && renderIcon(statusInfo.icon)} + {statusInfo.icon && } ); } else { return ( - {statusInfo.icon && renderIcon(statusInfo.icon)} + {statusInfo.icon && } ); @@ -74,7 +80,7 @@ export function StatusLine({ className={clsx("flex flex-row items-center space-x-1", className)} {...rest} > - {icon && renderIcon(icon)} + {icon && } {url && ( { + const allProperties = topology?.properties || []; + const properties = allProperties.filter((i) => !i.headline); + + const heading = allProperties.filter( + (i) => i.headline && (!!i.value || !!i.text || !!i.url) + ); + + const hasNoneHeadlineProperties = + properties.filter( + (i) => !i.headline && i.type !== "hidden" && (i.text || i.value) + ).length > 0; + + return { heading, properties, hasNoneHeadlineProperties }; + }, [topology?.properties]); + if (topology == null) { return ; } - const allProperties = topology.properties || []; - const properties = allProperties.filter((i) => !i.headline); - - const heading = allProperties.filter( - (i) => i.headline && (!!i.value || !!i.text || !!i.url) - ); - return (
{canShowChildHealth() && ( diff --git a/src/components/Topology/TopologyCard/Utils/FormatProperties.tsx b/src/components/Topology/TopologyCard/Utils/FormatProperties.tsx index 6dd023cd9..9bfbbe138 100644 --- a/src/components/Topology/TopologyCard/Utils/FormatProperties.tsx +++ b/src/components/Topology/TopologyCard/Utils/FormatProperties.tsx @@ -14,7 +14,6 @@ type FormatPropertyProps = { }; export function FormatPropertyURL({ property }: FormatPropertyProps) { - console.log("property", property); if (property == null) { return null; } diff --git a/src/ui/CustomScroll/index.tsx b/src/ui/CustomScroll/index.tsx index 607007411..feaa0cbcd 100644 --- a/src/ui/CustomScroll/index.tsx +++ b/src/ui/CustomScroll/index.tsx @@ -53,7 +53,7 @@ export const CustomScroll = ({ setHasScroll(true); }} className={clsx( - "bottom-0 m-auto w-full hover:underline", + "bottom-0 col-span-2 m-auto w-full hover:underline", showMoreClass )} >