Skip to content

Topology-card-improvements #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pages/organizations/orgs-switched.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export default function OrgsSwitchedPage() {
const { push } = useRouter();

useEffect(() => {
console.log("Attempting to clear cache");
client.clear();
console.log("Cleared cache, redirecting to /topology");
push("/topology");
}, [client, push]);

Expand Down
1 change: 0 additions & 1 deletion src/components/Authentication/Kratos/KratosLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ const KratosLogin = () => {
}
}, [flow, submitFlow, credentials]);


return (
<div className="w-96">
<ToasterWithCloseButton />
Expand Down
1 change: 0 additions & 1 deletion src/components/Canary/CanaryTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export function generateTabs(tabBy: string, checks: HealthCheck[]) {
)
};
}
console.log("tabs", tabs);
return tabs;
}

Expand Down
59 changes: 0 additions & 59 deletions src/components/Canary/HealthChecksSummary.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Connections/TestConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export function TestConnection({ connectionId }: TestConnectionProps) {
}>
) => {
if (res?.code === "ERR_BAD_REQUEST") {
console.log(res?.response?.data.error);
if (res?.response?.data.error) {
try {
const error = JSON.parse(res.response.data.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ConfigDetailsChanges } from "@flanksource-ui/components/Configs/Changes
import ConfigLink from "@flanksource-ui/components/Configs/ConfigLink/ConfigLink";
import { ConfigAnalysisLink } from "@flanksource-ui/components/Configs/Insights/ConfigAnalysisLink/ConfigAnalysisLink";
import { LogsTable } from "@flanksource-ui/components/Logs/Table/LogsTable";
import { TopologyCard } from "@flanksource-ui/components/Topology/TopologyCard";
import { TopologyCard } from "@flanksource-ui/components/Topology/TopologyCard/TopologyCard";
import { Size, ViewType } from "@flanksource-ui/types";
import { Age } from "@flanksource-ui/ui/Age";
import { Button } from "@flanksource-ui/ui/Buttons/Button";
Expand Down
91 changes: 0 additions & 91 deletions src/components/Incidents/IncidentCardSummary/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import {
} from "@flanksource-ui/api/query-hooks";
import { getCanaries } from "@flanksource-ui/api/services/topology";
import { Evidence, EvidenceType } from "@flanksource-ui/api/types/evidence";
import { CardMetrics } from "@flanksource-ui/components/Topology/TopologyCard/CardMetrics";
import { StatusStyles } from "@flanksource-ui/components/Topology/TopologyCard/TopologyCard";
import { Size, ViewType } from "@flanksource-ui/types";
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
import { ConfigIcon } from "@flanksource-ui/ui/Icons/ConfigIcon";
import { Icon } from "@flanksource-ui/ui/Icons/Icon";
import TextSkeletonLoader from "@flanksource-ui/ui/SkeletonLoader/TextSkeletonLoader";
import { useQuery } from "@tanstack/react-query";
import clsx from "clsx";
import { useMemo } from "react";
import { BsFillCircleFill, BsPersonFill } from "react-icons/bs";
import { Link } from "react-router-dom";
import { ConfigIcon } from "../../../../../ui/Icons/ConfigIcon";
import { Icon } from "../../../../../ui/Icons/Icon";
import { StatusStyles } from "../../../../Topology/TopologyCard";
import { CardMetrics } from "../../../../Topology/TopologyCard/CardMetrics";
import {
ConfigAnalysisEvidence,
ConfigChangeEvidence
Expand Down
68 changes: 41 additions & 27 deletions src/components/StatusLine/StatusLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@ export type StatusLineData = {
statuses: StatusInfo[];
};

export type StatusLineProps = React.HTMLProps<HTMLDivElement> & StatusLineData;
export type StatusLineProps = React.HTMLProps<HTMLDivElement> &
StatusLineData & {
hideName?: boolean;
};

const renderIcon = (icon: string | React.ReactNode) => {
interface RenderIconProps {
icon: string | React.ReactNode;
}

const RenderIcon: React.FC<RenderIconProps> = ({ 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 <Icon name={icon} className="h-4 w-4" />;
return <Icon name={icon} className="h-4 w-4 min-w-max" />;
}
return null;
};

const StatusInfoEntry = ({
Expand All @@ -46,14 +55,14 @@ const StatusInfoEntry = ({
to={statusInfo.url}
target={target || ""}
>
{statusInfo.icon && renderIcon(statusInfo.icon)}
{statusInfo.icon && <RenderIcon icon={statusInfo.icon} />}
<Chip text={statusInfo.label} color={statusInfo.color} />
</Link>
);
} else {
return (
<span className="inline-flex cursor-pointer space-x-1">
{statusInfo.icon && renderIcon(statusInfo.icon)}
{statusInfo.icon && <RenderIcon icon={statusInfo.icon} />}
<Chip text={statusInfo.label} color={statusInfo.color} />
</span>
);
Expand All @@ -66,34 +75,39 @@ export function StatusLine({
label,
url,
statuses,
className = "py-1",
className = "py-0.5",
hideName = false,
...rest
}: StatusLineProps) {
return (
<div
className={clsx("flex flex-row items-center space-x-1", className)}
className={clsx("flex flex-row items-center space-x-0.5", className)}
{...rest}
>
{icon && renderIcon(icon)}
{url && (
<Link
title={label}
target={target || ""}
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
to={url}
>
{label}
</Link>
)}
{!url && (
<span
title={label}
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
>
{label}
</span>
{!hideName && (
<>
{icon && <RenderIcon icon={icon} />}
{url && (
<Link
title={label}
target={target || ""}
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
to={url}
>
{label}
</Link>
)}
{!url && (
<span
title={label}
className="h-4 cursor-pointer overflow-hidden truncate text-xs"
>
{label}
</span>
)}
</>
)}
<div className="flex flex-row space-x-1.5">
<div className="flex flex-row space-x-0.5 text-xs">
{statuses.map((status, index) => {
return <StatusInfoEntry statusInfo={status} key={index} />;
})}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Topology/TopologyCard/CardMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const CardMetrics = ({
labelClasses = "text-gray-600 font-semibold text-xs mb-0.5",
metricsClasses = "font-bold text-xs leading-1.21rel flex flex-center justify-center"
}: IProps) => {
if (!items || items.length === 0) {
return null;
}

return (
<div className="flex flex-1 items-center justify-between divide-x rounded-b-8px">
{items.map((item) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Topology } from "../../../api/types/topology";
import { Size } from "../../../types";
import { TopologyCard } from "./index";
import { TopologyCard } from "./TopologyCard";

export default {
title: "TopologyCard",
Expand Down
Loading
Loading