Skip to content

Commit ee2aaa3

Browse files
committed
fix: use mantine react table for config summary
1 parent 0e0ad7d commit ee2aaa3

10 files changed

+117
-100
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/types/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export interface ConfigAnalysis extends Analysis, CreatedAt, Avatar {
128128
export type ConfigSummary = {
129129
type: string;
130130
analysis?: Record<string, any>;
131-
changes?: string;
131+
changes?: number;
132132
count: number;
133133
health: {
134134
healthy: number;

src/components/Configs/ConfigList/Cells/ConfigListCostCell.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
12
import { CellContext, Row } from "@tanstack/react-table";
23
import { MRT_Row } from "mantine-react-table";
34
import {
@@ -9,7 +10,7 @@ import ConfigCostValue from "../../ConfigCosts/ConfigCostValue";
910

1011
export default function ConfigListCostCell({
1112
row
12-
}: CellContext<ConfigItem, any> | CellContext<ConfigSummary, any>) {
13+
}: MRTCellProps<ConfigItem> | MRTCellProps<ConfigSummary>) {
1314
return <ConfigCostValue config={row.original} popover={false} />;
1415
}
1516
/**

src/components/Configs/ConfigList/MRTConfigListColumn.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
8989
{
9090
header: "Status",
9191
accessorKey: "health",
92-
minSize: 200,
9392
enableSorting: true,
9493
enableColumnActions: false,
9594
Cell: ({ cell, row }) => {
@@ -132,7 +131,6 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
132131

133132
return <ChangeCountIcon count={value} />;
134133
},
135-
size: 200,
136134
meta: {
137135
cellClassName: "overflow-hidden"
138136
},
@@ -148,8 +146,7 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
148146
enableFilterByTag
149147
filterByTagParamKey="labels"
150148
/>
151-
),
152-
minSize: 100
149+
)
153150
},
154151
{
155152
header: "Analysis",
@@ -248,16 +245,16 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
248245
accessorKey: "deleted_at",
249246
enableColumnActions: false,
250247
Cell: MRTConfigListDateCell,
251-
size: 90,
252-
enableHiding: true
248+
enableHiding: true,
249+
maxSize: 100
253250
},
254251
{
255252
header: "Changed",
256253
enableColumnActions: false,
257254
accessorFn: changeColumnAccessorFN,
258255
id: "changed",
256+
maxSize: 100
259257
// sortingFn: changeColumnSortingFN,
260-
size: 180
261258
}
262259
];
263260

src/components/Configs/ConfigSummary/Cells/ConfigSummaryHealthCells.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { ConfigSummary } from "@flanksource-ui/api/types/configs";
22

3-
import { CellContext } from "@tanstack/react-table";
4-
import { useMemo } from "react";
5-
import { useSearchParams } from "react-router-dom";
6-
import { getConfigStatusColor } from "../ConfigSummaryList";
73
import {
84
Count,
95
CountBar,
106
OrderByColor
117
} from "@flanksource-ui/ui/Icons/ChangeCount";
8+
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
9+
import { useMemo } from "react";
10+
import { useSearchParams } from "react-router-dom";
11+
import { getConfigStatusColor } from "../ConfigSummaryList";
1212

1313
export function ConfigSummaryHealthCell({
14-
getValue,
14+
cell,
1515
row
16-
}: CellContext<ConfigSummary, any>) {
16+
}: MRTCellProps<ConfigSummary>) {
1717
const [searchParams] = useSearchParams();
1818

19-
const value = getValue<ConfigSummary["health"]>();
19+
const value = cell.getValue<ConfigSummary["health"]>();
2020
const type = row.original.type;
2121
const groupBy = searchParams.get("groupBy");
2222

@@ -59,8 +59,8 @@ export function ConfigSummaryHealthCell({
5959

6060
export function ConfigSummaryHealthAggregateCell({
6161
row
62-
}: CellContext<ConfigSummary, any>) {
63-
const value = row.subRows.reduce(
62+
}: Pick<MRTCellProps<ConfigSummary>, "row">) {
63+
const value = row.subRows?.reduce(
6464
(acc, row) => {
6565
const health = row.original.health;
6666
if (health) {

src/components/Configs/ConfigSummary/Cells/ConfigSummaryTableVirtualAggregateColumn.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import { ConfigSummary } from "@flanksource-ui/api/types/configs";
22
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
3-
import { CellContext } from "@tanstack/react-table";
4-
import { IoChevronDown, IoChevronForward } from "react-icons/io5";
3+
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
54
import ConfigsTypeIcon from "../../ConfigsTypeIcon";
65

76
export function ConfigSummaryTableVirtualAggregateColumn({
87
row
9-
}: CellContext<ConfigSummary, any>) {
8+
}: Pick<MRTCellProps<ConfigSummary>, "row">) {
109
if (row.getCanExpand()) {
1110
const groupingValue = row.getGroupingValue(row.groupingColumnId!) as string;
12-
const count = row.subRows.reduce((acc, row) => acc + row.original.count, 0);
11+
const count = row.subRows?.reduce(
12+
(acc, row) => acc + row.original.count,
13+
0
14+
);
1315
return (
1416
<div
1517
className="flex flex-row items-center gap-1"
1618
style={{
1719
marginLeft: row.depth * 20
1820
}}
1921
>
20-
{row.getIsExpanded() ? <IoChevronDown /> : <IoChevronForward />}
2122
{row.groupingColumnId === "type" ||
2223
row.groupingColumnId === "config_class" ? (
2324
<ConfigsTypeIcon

src/components/Configs/ConfigSummary/Cells/ConfigSummaryVirtualColumnCell.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { ConfigSummary } from "@flanksource-ui/api/types/configs";
22
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
3-
import { CellContext } from "@tanstack/react-table";
3+
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
44
import { BiLabel } from "react-icons/bi";
55

66
export function ConfigSummaryVirtualColumnCell({
7-
getValue,
87
row,
98
groupByTags,
10-
columnId
11-
}: CellContext<ConfigSummary, any> & {
9+
columnId,
10+
cell
11+
}: MRTCellProps<ConfigSummary> & {
1212
groupByTags: string[];
1313
columnId: string;
1414
}) {
1515
const isTag = groupByTags.includes(columnId);
16-
const value = getValue();
16+
const value = cell.getValue<any>();
1717

1818
return (
1919
<div

0 commit comments

Comments
 (0)