Skip to content

Commit

Permalink
feat: when a catalog has one topology, show only topology card
Browse files Browse the repository at this point in the history
Fixes #2174
  • Loading branch information
mainawycliffe committed Aug 29, 2024
1 parent 55276c7 commit 3e9d682
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/api/services/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ConfigChange,
ConfigHealthCheckView,
ConfigItem,
ConfigItemDetails,
ConfigSummary,
ConfigTypeRelationships
} from "../types/configs";
Expand Down Expand Up @@ -138,7 +139,7 @@ export const getAllChanges = (
};

export const getConfig = (id: string) =>
resolvePostGrestRequestWithPagination<ConfigItem[]>(
resolvePostGrestRequestWithPagination<ConfigItemDetails[]>(
ConfigDB.get(`/config_detail?id=eq.${id}&select=*,config_scrapers(id,name)`)
);

Expand Down
19 changes: 12 additions & 7 deletions src/api/types/configs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Agent, Avatar, CreatedAt, Timestamped } from "../traits";
import { HealthCheckSummary } from "./health";
import { Topology } from "./topology";

export interface ConfigChange extends CreatedAt {
id: string;
Expand Down Expand Up @@ -69,13 +70,6 @@ export interface ConfigItem extends Timestamped, Avatar, Agent, Costs {
id: string;
name: string;
};
summary?: {
relationships?: number;
analysis?: number;
changes?: number;
playbook_runs?: number;
checks?: number;
};
properties?: {
icon: string;
name: string;
Expand All @@ -87,6 +81,17 @@ export interface ConfigItem extends Timestamped, Avatar, Agent, Costs {
last_scraped_time?: string;
}

export interface ConfigItemDetails extends ConfigItem {
summary?: {
relationships?: number;
analysis?: number;
changes?: number;
playbook_runs?: number;
checks?: number;
};
component?: Topology[];
}

export interface ConfigItemGraphData extends ConfigItem {
expanded?: boolean;
expandable?: boolean;
Expand Down
9 changes: 8 additions & 1 deletion src/components/Configs/ConfigDetailsTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Head } from "../../ui/Head";
import { refreshButtonClickedTrigger } from "../../ui/SlidingSideBar/SlidingSideBar";
import TabbedLinks from "../../ui/Tabs/TabbedLinks";
import { ErrorBoundary } from "../ErrorBoundary";
import { TopologyCard } from "../Topology/TopologyCard";
import { useConfigDetailsTabs } from "./ConfigTabsLinks";
import ConfigSidebar from "./Sidebar/ConfigSidebar";

Expand Down Expand Up @@ -69,8 +70,14 @@ export function ConfigDetailsTabs({
loading={isLoading}
contentClass="p-0 h-full overflow-y-hidden"
>
<div className={`flex h-full flex-row`}>
<div className={`flex h-full flex-row bg-gray-100`}>
<div className="flex flex-1 flex-col">
{configItem?.component && configItem.component.length === 1 && (
<div className="flex w-full flex-row items-center justify-between p-4">
<TopologyCard topology={configItem.component[0]} />
</div>
)}

<TabbedLinks
activeTabName={activeTabName}
tabLinks={configTabList}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Configs/ConfigTabsLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
import { useParams } from "react-router-dom";
import { ConfigItem } from "../../api/types/configs";
import { ConfigItemDetails } from "../../api/types/configs";

export function useConfigDetailsTabs(countSummary?: ConfigItem["summary"]) {
export function useConfigDetailsTabs(
countSummary?: ConfigItemDetails["summary"]
) {
const { id } = useParams<{ id: string }>();

return [
Expand Down
15 changes: 14 additions & 1 deletion src/components/Topology/TopologyCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ export const StatusStyles: Record<keyof typeof ComponentStatus, string> = {
interface IProps {
size?: Size | string;
topologyId?: string;
topology?: Topology;
topology?: Pick<
Topology,
| "summary"
| "is_leaf"
| "id"
| "properties"
| "components"
| "agent_id"
| "status"
| "status_reason"
| "text"
| "name"
| "icon"
>;
selectionMode?: boolean;
hideMenu?: boolean;
// where to open new links
Expand Down

0 comments on commit 3e9d682

Please sign in to comment.