Skip to content

Commit 793e7ea

Browse files
committed
fix: show two columns when no none headline properties
1 parent 7583a85 commit 793e7ea

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

src/components/Canary/HealthChecksSummary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function HealthChecksSummary({
2323

2424
const data: StatusLineProps = {
2525
label: "Health Checks",
26-
icon: <AiFillHeart className="mr-1 inline-block h-3.5 w-3.5" />,
26+
icon: <AiFillHeart className="inline-block h-4 w-4" />,
2727
url: "/health",
2828
statuses: [
2929
...(checks.healthy > 0

src/components/StatusLine/StatusLine.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ export type StatusLineData = {
2020

2121
export type StatusLineProps = React.HTMLProps<HTMLDivElement> & StatusLineData;
2222

23-
const renderIcon = (icon: string | React.ReactNode) => {
23+
interface RenderIconProps {
24+
icon: string | React.ReactNode;
25+
}
26+
27+
const RenderIcon: React.FC<RenderIconProps> = ({ icon }) => {
2428
if (!icon) {
2529
return null;
2630
}
2731
if (typeof icon === "object") {
28-
return icon;
32+
// eslint-disable-next-line react/jsx-no-useless-fragment
33+
return <>{icon}</>;
2934
} else if (typeof icon === "string") {
30-
return <Icon name={icon} className="h-4 w-4" />;
35+
return <Icon name={icon} className="h-4 w-4 min-w-max" />;
3136
}
37+
return null;
3238
};
3339

3440
const StatusInfoEntry = ({
@@ -46,14 +52,14 @@ const StatusInfoEntry = ({
4652
to={statusInfo.url}
4753
target={target || ""}
4854
>
49-
{statusInfo.icon && renderIcon(statusInfo.icon)}
55+
{statusInfo.icon && <RenderIcon icon={statusInfo.icon} />}
5056
<Chip text={statusInfo.label} color={statusInfo.color} />
5157
</Link>
5258
);
5359
} else {
5460
return (
5561
<span className="inline-flex cursor-pointer space-x-1">
56-
{statusInfo.icon && renderIcon(statusInfo.icon)}
62+
{statusInfo.icon && <RenderIcon icon={statusInfo.icon} />}
5763
<Chip text={statusInfo.label} color={statusInfo.color} />
5864
</span>
5965
);
@@ -74,7 +80,7 @@ export function StatusLine({
7480
className={clsx("flex flex-row items-center space-x-1", className)}
7581
{...rest}
7682
>
77-
{icon && renderIcon(icon)}
83+
{icon && <RenderIcon icon={icon} />}
7884
{url && (
7985
<Link
8086
title={label}

src/components/Topology/TopologyCard/TopologyCard.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,26 @@ export function TopologyCard({
156156
[topology?.components]
157157
);
158158

159+
const { heading, properties, hasNoneHeadlineProperties } = useMemo(() => {
160+
const allProperties = topology?.properties || [];
161+
const properties = allProperties.filter((i) => !i.headline);
162+
163+
const heading = allProperties.filter(
164+
(i) => i.headline && (!!i.value || !!i.text || !!i.url)
165+
);
166+
167+
const hasNoneHeadlineProperties =
168+
properties.filter(
169+
(i) => !i.headline && i.type !== "hidden" && (i.text || i.value)
170+
).length > 0;
171+
172+
return { heading, properties, hasNoneHeadlineProperties };
173+
}, [topology?.properties]);
174+
159175
if (topology == null) {
160176
return <TopologyCardSkeletonLoader />;
161177
}
162178

163-
const allProperties = topology.properties || [];
164-
const properties = allProperties.filter((i) => !i.headline);
165-
166-
const heading = allProperties.filter(
167-
(i) => i.headline && (!!i.value || !!i.text || !!i.url)
168-
);
169-
170179
return (
171180
<div
172181
style={{ width: CardWidth[size as Size] || size }}
@@ -245,10 +254,14 @@ export function TopologyCard({
245254
<>
246255
<TopologyCardPropertiesColumn properties={properties} />
247256
<CustomScroll
248-
className="flex-1 space-y-1.5 py-2 pl-2 pr-2"
257+
className={clsx(
258+
"flex-1 space-y-1.5 py-2 pl-2 pr-2",
259+
!hasNoneHeadlineProperties ? "grid grid-cols-2 gap-1" : ""
260+
)}
249261
showMoreClass="text-xs linear-1.21rel mr-1 cursor-pointer"
250262
maxHeight="200px"
251-
minChildCount={5}
263+
// When we showing two columns, we need to show more items
264+
minChildCount={hasNoneHeadlineProperties ? 5 : 10}
252265
>
253266
<TopologyConfigAnalysisLine topology={topology} />
254267
{canShowChildHealth() && (

src/ui/CustomScroll/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const CustomScroll = ({
5353
setHasScroll(true);
5454
}}
5555
className={clsx(
56-
"bottom-0 m-auto w-full hover:underline",
56+
"bottom-0 col-span-2 m-auto w-full hover:underline",
5757
showMoreClass
5858
)}
5959
>

0 commit comments

Comments
 (0)