Skip to content

Commit 7a5b5d5

Browse files
committed
fix: move self topology status to subtitle
1 parent 58bfb76 commit 7a5b5d5

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

src/components/StatusLine/StatusLine.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export type StatusLineData = {
1818
statuses: StatusInfo[];
1919
};
2020

21-
export type StatusLineProps = React.HTMLProps<HTMLDivElement> & StatusLineData;
21+
export type StatusLineProps = React.HTMLProps<HTMLDivElement> &
22+
StatusLineData & {
23+
hideName?: boolean;
24+
};
2225

2326
interface RenderIconProps {
2427
icon: string | React.ReactNode;
@@ -73,31 +76,36 @@ export function StatusLine({
7376
url,
7477
statuses,
7578
className = "py-1",
79+
hideName = false,
7680
...rest
7781
}: StatusLineProps) {
7882
return (
7983
<div
8084
className={clsx("flex flex-row items-center space-x-1", className)}
8185
{...rest}
8286
>
83-
{icon && <RenderIcon icon={icon} />}
84-
{url && (
85-
<Link
86-
title={label}
87-
target={target || ""}
88-
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
89-
to={url}
90-
>
91-
{label}
92-
</Link>
93-
)}
94-
{!url && (
95-
<span
96-
title={label}
97-
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
98-
>
99-
{label}
100-
</span>
87+
{!hideName && (
88+
<>
89+
{icon && <RenderIcon icon={icon} />}
90+
{url && (
91+
<Link
92+
title={label}
93+
target={target || ""}
94+
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
95+
to={url}
96+
>
97+
{label}
98+
</Link>
99+
)}
100+
{!url && (
101+
<span
102+
title={label}
103+
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
104+
>
105+
{label}
106+
</span>
107+
)}
108+
</>
101109
)}
102110
<div className="flex flex-row space-x-1.5">
103111
{statuses.map((status, index) => {

src/components/Topology/TopologyCard/TopologCardStatuses.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function getTopologyHealthStatuses(topology: Topology) {
169169
return data;
170170
}
171171

172-
function getTopologyHealthSummary(
172+
export function getTopologyHealthSummary(
173173
topology: Topology,
174174
viewType: "individual_level" | "children_level"
175175
) {
@@ -277,15 +277,13 @@ export default function TopologyCardStatuses({
277277
return [];
278278
}
279279

280-
const healthSummary =
281-
getTopologyHealthSummary(topology, "individual_level") ?? [];
282280
const healthChecks = getTopologyHealthStatuses(topology);
283281
const insights = insightStatuses(topology);
284282
const incidents = incidentsStatuses(topology) ?? [];
285283
const components = topologiesHealthSummaries(topology) ?? [];
286284

287285
return (
288-
[healthSummary, healthChecks, insights, ...incidents, ...components]
286+
[healthChecks, insights, ...incidents, ...components]
289287
.filter((status) => status)
290288
// remove empty statuses
291289
.filter((status) => status!.statuses.length > 0)

src/components/Topology/TopologyCard/TopologyCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { CardMetrics } from "./CardMetrics";
1313
import TopologyCardStatuses from "./TopologCardStatuses";
1414
import TopologyCardPropertiesColumn from "./TopologyCardPropertiesColumn";
1515
import { TopologyDropdownMenu } from "./TopologyDropdownMenu";
16+
import TopologyItemHealthSummary from "./TopologyItemHealthSummary";
1617

1718
export enum ComponentHealth {
1819
unhealthy = "unhealthy",
@@ -214,6 +215,7 @@ export function TopologyCard({
214215
{topology.status_reason}
215216
</div>
216217
)}
218+
<TopologyItemHealthSummary topology={topology} />
217219
</div>
218220
</div>
219221
</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Topology } from "@flanksource-ui/api/types/topology";
2+
import { StatusLine } from "@flanksource-ui/components/StatusLine/StatusLine";
3+
import { useMemo } from "react";
4+
import { getTopologyHealthSummary } from "./TopologCardStatuses";
5+
6+
type TopologyItemHealthSummaryProps = {
7+
topology: Topology;
8+
};
9+
10+
export default function TopologyItemHealthSummary({
11+
topology
12+
}: TopologyItemHealthSummaryProps) {
13+
const statusLines = useMemo(() => {
14+
return getTopologyHealthSummary(topology, "individual_level");
15+
}, [topology]);
16+
17+
if (!statusLines || statusLines.statuses.length === 0) {
18+
return null;
19+
}
20+
21+
return (
22+
<div className="flex flex-col gap-1">
23+
<StatusLine {...statusLines} hideName />
24+
</div>
25+
);
26+
}

0 commit comments

Comments
 (0)