Skip to content

Commit

Permalink
Merge pull request #2325 from flanksource/2324-In-`catalogconfig_type…
Browse files Browse the repository at this point in the history
…=<config_type>`-page-which-calls-`apidbconfigs`-the-changes-and-analysis-returned-will-be-of-the-same-typeschema-as-catalog-summ

fix: update UI to reflect to configs view changes
  • Loading branch information
mainawycliffe authored Oct 3, 2024
2 parents 8001260 + 1d46b2a commit 48c74ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/api/types/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface ConfigItem extends Timestamped, Avatar, Agent, Costs {
external_id?: string;
config_class?: string;
type: string;
changes?: Change[];
changes?: number;
analysis?: Record<string, any>;
tags?: Record<string, any>;
labels?: Record<string, any>;
Expand Down
14 changes: 3 additions & 11 deletions src/components/Configs/ConfigList/Cells/ConfigListChangeCell.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import ChangeCountIcon from "@flanksource-ui/ui/Icons/ChangeCount";
import { CellContext } from "@tanstack/react-table";
import { useMemo } from "react";
import { ConfigItem } from "../../../../api/types/configs";
import ChangeCountIcon from "@flanksource-ui/ui/Icons/ChangeCount";

export default function ConfigListChangeCell({
row,
column
}: CellContext<ConfigItem, any>) {
const changes = row?.getValue<ConfigItem["changes"]>(column.id);
const totalChanges = useMemo(() => {
let total = 0;
(changes || []).forEach((change) => {
total += change.total || 0;
});
return total;
}, [changes]);

if (changes == null) {
if (!changes) {
return null;
}

return <ChangeCountIcon count={totalChanges} />;
return <ChangeCountIcon count={changes} />;
}
5 changes: 1 addition & 4 deletions src/components/Configs/Graph/ConfigItemReactFlowNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export function ConfigItemReactFlowNode({
if (data.data.type === "intermediary") {
return undefined;
}
return data.data.config.changes?.reduce(
(acc, change) => acc + change.total,
0
);
return data.data.config.changes;
}, [data]);

if (data.data.type === "intermediary") {
Expand Down

0 comments on commit 48c74ae

Please sign in to comment.