Skip to content
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

fix: fix column size and padding in configs tables #2374

Open
wants to merge 2 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: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/api/types/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface ConfigAnalysis extends Analysis, CreatedAt, Avatar {
export type ConfigSummary = {
type: string;
analysis?: Record<string, any>;
changes?: string;
changes?: number;
count: number;
health: {
healthy: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
import { CellContext, Row } from "@tanstack/react-table";
import { MRT_Row } from "mantine-react-table";
import {
Expand All @@ -9,7 +10,7 @@ import ConfigCostValue from "../../ConfigCosts/ConfigCostValue";

export default function ConfigListCostCell({
row
}: CellContext<ConfigItem, any> | CellContext<ConfigSummary, any>) {
}: MRTCellProps<ConfigItem> | MRTCellProps<ConfigSummary>) {
return <ConfigCostValue config={row.original} popover={false} />;
}
/**
Expand Down
30 changes: 11 additions & 19 deletions src/components/Configs/ConfigList/MRTConfigListColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
</div>
);
},
minSize: 200,
size: 270,
minSize: 300,
size: 400,
enableGrouping: true,
enableSorting: true,
enableHiding: false,
Expand Down Expand Up @@ -78,7 +78,7 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
{
header: "Type",
accessorKey: "type",
size: 170,
size: 250,
enableSorting: true,
enableHiding: true,
enableColumnActions: false,
Expand All @@ -89,8 +89,6 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
{
header: "Status",
accessorKey: "health",
minSize: 100,
maxSize: 180,
enableSorting: true,
enableColumnActions: false,
Cell: ({ cell, row }) => {
Expand Down Expand Up @@ -133,7 +131,6 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [

return <ChangeCountIcon count={value} />;
},
size: 70,
meta: {
cellClassName: "overflow-hidden"
},
Expand All @@ -149,9 +146,7 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
enableFilterByTag
filterByTagParamKey="labels"
/>
),
maxSize: 300,
minSize: 100
)
},
{
header: "Analysis",
Expand Down Expand Up @@ -212,9 +207,7 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
/>
</div>
);
},
minSize: 50,
maxSize: 100
}
},
{
header: "Cost",
Expand All @@ -231,38 +224,37 @@ export const mrtConfigListColumns: MRT_ColumnDef<ConfigItem>[] = [
},
Cell: ({ row }) => {
return <ConfigCostValue config={row.original} popover={false} />;
},
maxSize: 60
}
},
{
header: "Created",
accessorKey: "created_at",
enableColumnActions: false,
Cell: MRTConfigListDateCell,
maxSize: 70
maxSize: 100
},
{
header: "Updated",
accessorKey: "updated_at",
enableColumnActions: false,
Cell: MRTConfigListDateCell,
maxSize: 70
maxSize: 100
},
{
header: "Deleted At",
accessorKey: "deleted_at",
enableColumnActions: false,
Cell: MRTConfigListDateCell,
size: 90,
enableHiding: true
enableHiding: true,
maxSize: 100
},
{
header: "Changed",
enableColumnActions: false,
accessorFn: changeColumnAccessorFN,
id: "changed",
maxSize: 100
// sortingFn: changeColumnSortingFN,
size: 180
}
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { ConfigSummary } from "@flanksource-ui/api/types/configs";

import { CellContext } from "@tanstack/react-table";
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
import { getConfigStatusColor } from "../ConfigSummaryList";
import {
Count,
CountBar,
OrderByColor
} from "@flanksource-ui/ui/Icons/ChangeCount";
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
import { getConfigStatusColor } from "../ConfigSummaryList";

export function ConfigSummaryHealthCell({
getValue,
cell,
row
}: CellContext<ConfigSummary, any>) {
}: MRTCellProps<ConfigSummary>) {
const [searchParams] = useSearchParams();

const value = getValue<ConfigSummary["health"]>();
const value = cell.getValue<ConfigSummary["health"]>();
const type = row.original.type;
const groupBy = searchParams.get("groupBy");

Expand Down Expand Up @@ -59,8 +59,8 @@ export function ConfigSummaryHealthCell({

export function ConfigSummaryHealthAggregateCell({
row
}: CellContext<ConfigSummary, any>) {
const value = row.subRows.reduce(
}: Pick<MRTCellProps<ConfigSummary>, "row">) {
const value = row.subRows?.reduce(
(acc, row) => {
const health = row.original.health;
if (health) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { ConfigSummary } from "@flanksource-ui/api/types/configs";
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
import { CellContext } from "@tanstack/react-table";
import { IoChevronDown, IoChevronForward } from "react-icons/io5";
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
import ConfigsTypeIcon from "../../ConfigsTypeIcon";

export function ConfigSummaryTableVirtualAggregateColumn({
row
}: CellContext<ConfigSummary, any>) {
}: Pick<MRTCellProps<ConfigSummary>, "row">) {
if (row.getCanExpand()) {
const groupingValue = row.getGroupingValue(row.groupingColumnId!) as string;
const count = row.subRows.reduce((acc, row) => acc + row.original.count, 0);
const count = row.subRows?.reduce(
(acc, row) => acc + row.original.count,
0
);
return (
<div
className="flex flex-row items-center gap-1"
style={{
marginLeft: row.depth * 20
}}
>
{row.getIsExpanded() ? <IoChevronDown /> : <IoChevronForward />}
{row.groupingColumnId === "type" ||
row.groupingColumnId === "config_class" ? (
<ConfigsTypeIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { ConfigSummary } from "@flanksource-ui/api/types/configs";
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
import { CellContext } from "@tanstack/react-table";
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
import { BiLabel } from "react-icons/bi";

export function ConfigSummaryVirtualColumnCell({
getValue,
row,
groupByTags,
columnId
}: CellContext<ConfigSummary, any> & {
columnId,
cell
}: MRTCellProps<ConfigSummary> & {
groupByTags: string[];
columnId: string;
}) {
const isTag = groupByTags.includes(columnId);
const value = getValue();
const value = cell.getValue<any>();

return (
<div
Expand Down
Loading
Loading