From 30cd13a7daa84f295b039eeb5ee01986658b8b71 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 14 Jun 2024 14:30:32 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(tableComponent):=20re?= =?UTF-8?q?move=20toTitleCase=20utility=20function=20to=20simplify=20heade?= =?UTF-8?q?rName=20assignment=20=F0=9F=92=A1=20(utils.ts):=20remove=20unne?= =?UTF-8?q?cessary=20commas=20and=20improve=20code=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/tableComponent/index.tsx | 14 +++++++------- src/frontend/src/utils/utils.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/components/tableComponent/index.tsx b/src/frontend/src/components/tableComponent/index.tsx index 4ca1bb22e..d849b8a7b 100644 --- a/src/frontend/src/components/tableComponent/index.tsx +++ b/src/frontend/src/components/tableComponent/index.tsx @@ -8,7 +8,7 @@ import { } from "../../constants/constants"; import { useDarkStore } from "../../stores/darkStore"; import "../../style/ag-theme-shadcn.css"; // Custom CSS applied to the grid -import { cn, toTitleCase } from "../../utils/utils"; +import { cn } from "../../utils/utils"; import ForwardedIconComponent from "../genericIconComponent"; import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import TableOptions from "./components/TableOptions"; @@ -35,12 +35,12 @@ const TableComponent = forwardRef< alertDescription = DEFAULT_TABLE_ALERT_MSG, ...props }, - ref + ref, ) => { let colDef = props.columnDefs.map((col, index) => { let newCol = { ...col, - headerName: toTitleCase(col.headerName), + headerName: col.headerName, }; if (index === props.columnDefs.length - 1) { newCol = { @@ -111,7 +111,7 @@ const TableComponent = forwardRef< }; const onColumnMoved = (params) => { const updatedColumnDefs = makeLastColumnNonResizable( - params.columnApi.getAllGridColumns().map((col) => col.getColDef()) + params.columnApi.getAllGridColumns().map((col) => col.getColDef()), ); params.api.setGridOption("columnDefs", updatedColumnDefs); if (props.onColumnMoved) props.onColumnMoved(params); @@ -135,7 +135,7 @@ const TableComponent = forwardRef< className={cn( dark ? "ag-theme-quartz-dark" : "ag-theme-quartz", "ag-theme-shadcn flex h-full flex-col", - "relative" + "relative", )} // applying the grid theme > source.includes("column"))) { localStorage.setItem( storeReference, - JSON.stringify(realRef.current?.api?.getColumnState()) + JSON.stringify(realRef.current?.api?.getColumnState()), ); setColumnStateChange(true); } @@ -176,7 +176,7 @@ const TableComponent = forwardRef< )} ); - } + }, ); export default TableComponent; diff --git a/src/frontend/src/utils/utils.ts b/src/frontend/src/utils/utils.ts index 0a1f99692..cec2804cb 100644 --- a/src/frontend/src/utils/utils.ts +++ b/src/frontend/src/utils/utils.ts @@ -364,7 +364,7 @@ export function extractColumnsFromRows( function intersection() { for (const key in rows[0]) { columnsKeys[key] = { - headerName: toTitleCase(key), + headerName: key, field: key, cellRenderer: TableAutoCellRender, filter: true, @@ -382,7 +382,7 @@ export function extractColumnsFromRows( for (const row of rows) { for (const key in row) { columnsKeys[key] = { - headerName: toTitleCase(key), + headerName: key, field: key, filter: true, cellRenderer: TableAutoCellRender, From 2ca258e31af5f9471736906d3684c878a4eed383 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 14 Jun 2024 15:48:52 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(tableComponent):=20re?= =?UTF-8?q?move=20unnecessary=20comma=20and=20autoHeight=20property=20?= =?UTF-8?q?=E2=9C=A8=20(ShortcutsPage):=20add=20conditional=20rendering=20?= =?UTF-8?q?for=20TableComponent=20to=20handle=20empty=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/tableComponent/index.tsx | 1 - .../pages/ShortcutsPage/index.tsx | 26 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/frontend/src/components/tableComponent/index.tsx b/src/frontend/src/components/tableComponent/index.tsx index d849b8a7b..0bd0cc97d 100644 --- a/src/frontend/src/components/tableComponent/index.tsx +++ b/src/frontend/src/components/tableComponent/index.tsx @@ -142,7 +142,6 @@ const TableComponent = forwardRef< {...props} defaultColDef={{ minWidth: 100, - autoHeight: true, }} animateRows={false} columnDefs={colDef} diff --git a/src/frontend/src/pages/SettingsPage/pages/ShortcutsPage/index.tsx b/src/frontend/src/pages/SettingsPage/pages/ShortcutsPage/index.tsx index 90e442897..8d7036924 100644 --- a/src/frontend/src/pages/SettingsPage/pages/ShortcutsPage/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/ShortcutsPage/index.tsx @@ -40,7 +40,7 @@ export default function ShortcutsPage() { const combinationToEdit = shortcuts.filter((s) => s.name === selectedRows[0]); const [open, setOpen] = useState(false); const updateUniqueShortcut = useShortcutsStore( - (state) => state.updateUniqueShortcut + (state) => state.updateUniqueShortcut, ); function handleRestore() { @@ -97,17 +97,19 @@ export default function ShortcutsPage() {
- { - setSelectedRows([e.data.name]); - setOpen(true); - }} - /> + {colDefs && nodesRowData.length > 0 && ( + { + setSelectedRows([e.data.name]); + setOpen(true); + }} + /> + )}