From f28476fd16fa473a411a0e31cb20c17b6a57b97f Mon Sep 17 00:00:00 2001 From: "andrii.dudar" Date: Tue, 19 Nov 2024 12:12:02 +0100 Subject: [PATCH] [OPIK-378] Update styling of table row items --- .../CompareExperimentsCell.tsx | 4 ++-- .../ExperimentItemsTab/ExperimentItemsTab.tsx | 5 ++++ .../DatasetItemRowActionsCell.tsx | 14 ++++++----- .../DatasetsPage/DatasetRowActionsCell.tsx | 14 ++++++----- .../ExperimentRowActionsCell.tsx | 14 ++++++----- .../pages/ExperimentsShared/table.tsx | 4 ++-- .../FeedbackDefinitionsRowActionsCell.tsx | 14 ++++++----- .../FeedbackDefinitionsValueCell.tsx | 1 - .../ProjectsPage/ProjectRowActionsCell.tsx | 18 ++++++++------- .../PromptsPage/PromptRowActionsCell.tsx | 14 ++++++----- .../components/shared/DataTable/DataTable.tsx | 1 + .../DataTable/DataTableColumnResizer.tsx | 2 +- .../src/components/shared/DataTable/utils.tsx | 23 ++++++++++++------- .../shared/DataTableCells/CellWrapper.tsx | 19 +++++++++++---- .../shared/DataTableCells/CodeCell.tsx | 15 ++++++------ .../DataTableCells/FeedbackScoresCell.tsx | 1 - .../shared/DataTableCells/LinkCell.tsx | 2 +- .../shared/DataTableCells/ListCell.tsx | 1 - .../shared/DataTableCells/ResourceCell.tsx | 1 + .../shared/DataTableHeaders/TypeHeader.tsx | 2 +- .../opik-frontend/src/components/ui/table.tsx | 2 +- apps/opik-frontend/src/constants/shared.ts | 4 ++-- apps/opik-frontend/src/lib/table.ts | 3 +++ apps/opik-frontend/src/types/shared.ts | 1 + 24 files changed, 107 insertions(+), 72 deletions(-) diff --git a/apps/opik-frontend/src/components/pages/CompareExperimentsPage/ExperimentItemsTab/CompareExperimentsCell.tsx b/apps/opik-frontend/src/components/pages/CompareExperimentsPage/ExperimentItemsTab/CompareExperimentsCell.tsx index 6d69c63c0f..e37959e4e0 100644 --- a/apps/opik-frontend/src/components/pages/CompareExperimentsPage/ExperimentItemsTab/CompareExperimentsCell.tsx +++ b/apps/opik-frontend/src/components/pages/CompareExperimentsPage/ExperimentItemsTab/CompareExperimentsCell.tsx @@ -79,11 +79,11 @@ const CompareExperimentsCell: React.FunctionComponent< })} {isSmall ? ( -
+
{JSON.stringify(item.output, null, 2)}
) : ( -
+
{item.output && ( = ({ type: columnType, accessorFn: (row) => get(row, ["data", label], ""), cell: AutodetectCell as never, + verticalAlignment: CELL_VERTICAL_ALIGNMENT.start, + overrideRowHeight: ROW_HEIGHT.large, }) as ColumnData, ); @@ -211,6 +214,7 @@ const ExperimentItemsTab: React.FunctionComponent = ({ label: "Created", type: COLUMN_TYPE.time, accessorFn: (row) => formatDate(row.created_at), + verticalAlignment: CELL_VERTICAL_ALIGNMENT.start, }); return retVal; @@ -231,6 +235,7 @@ const ExperimentItemsTab: React.FunctionComponent = ({ type: COLUMN_TYPE.string, size: columnsWidth[COLUMN_ID_ID], cell: LinkCell as never, + verticalAlignment: CELL_VERTICAL_ALIGNMENT.start, customMeta: { callback: handleRowClick, asId: true, diff --git a/apps/opik-frontend/src/components/pages/DatasetItemsPage/DatasetItemRowActionsCell.tsx b/apps/opik-frontend/src/components/pages/DatasetItemsPage/DatasetItemRowActionsCell.tsx index 3904049c94..65ce5d9064 100644 --- a/apps/opik-frontend/src/components/pages/DatasetItemsPage/DatasetItemRowActionsCell.tsx +++ b/apps/opik-frontend/src/components/pages/DatasetItemsPage/DatasetItemRowActionsCell.tsx @@ -13,13 +13,14 @@ import { useDatasetIdFromURL } from "@/hooks/useDatasetIdFromURL"; import useAppStore from "@/store/AppStore"; import useDatasetItemDeleteMutation from "@/api/datasets/useDatasetItemDeleteMutation"; import ConfirmDialog from "@/components/shared/ConfirmDialog/ConfirmDialog"; +import CellWrapper from "@/components/shared/DataTableCells/CellWrapper"; export const DatasetItemRowActionsCell: React.FunctionComponent< CellContext -> = ({ row }) => { +> = (context) => { const datasetId = useDatasetIdFromURL(); const resetKeyRef = useRef(0); - const datasetItem = row.original; + const datasetItem = context.row.original; const [open, setOpen] = useState(false); const workspaceName = useAppStore((state) => state.activeWorkspaceName); @@ -36,9 +37,10 @@ export const DatasetItemRowActionsCell: React.FunctionComponent< }, [datasetItem.id, datasetId, workspaceName]); return ( -
e.stopPropagation()} + -
+ ); }; diff --git a/apps/opik-frontend/src/components/pages/DatasetsPage/DatasetRowActionsCell.tsx b/apps/opik-frontend/src/components/pages/DatasetsPage/DatasetRowActionsCell.tsx index 2ef9037bca..66095a96f0 100644 --- a/apps/opik-frontend/src/components/pages/DatasetsPage/DatasetRowActionsCell.tsx +++ b/apps/opik-frontend/src/components/pages/DatasetsPage/DatasetRowActionsCell.tsx @@ -11,12 +11,13 @@ import { CellContext } from "@tanstack/react-table"; import ConfirmDialog from "@/components/shared/ConfirmDialog/ConfirmDialog"; import { Dataset } from "@/types/datasets"; import useDatasetDeleteMutation from "@/api/datasets/useDatasetDeleteMutation"; +import CellWrapper from "@/components/shared/DataTableCells/CellWrapper"; export const DatasetRowActionsCell: React.FunctionComponent< CellContext -> = ({ row }) => { +> = (context) => { const resetKeyRef = useRef(0); - const dataset = row.original; + const dataset = context.row.original; const [open, setOpen] = useState(false); const datasetDeleteMutation = useDatasetDeleteMutation(); @@ -29,9 +30,10 @@ export const DatasetRowActionsCell: React.FunctionComponent< }, [dataset.id]); return ( -
e.stopPropagation()} + -
+ ); }; diff --git a/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentRowActionsCell.tsx b/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentRowActionsCell.tsx index d22079672f..f596078465 100644 --- a/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentRowActionsCell.tsx +++ b/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentRowActionsCell.tsx @@ -11,12 +11,13 @@ import { CellContext } from "@tanstack/react-table"; import ConfirmDialog from "@/components/shared/ConfirmDialog/ConfirmDialog"; import useExperimentBatchDeleteMutation from "@/api/datasets/useExperimentBatchDeleteMutation"; import { GroupedExperiment } from "@/hooks/useGroupedExperimentsList"; +import CellWrapper from "@/components/shared/DataTableCells/CellWrapper"; const ExperimentRowActionsCell: React.FunctionComponent< CellContext -> = ({ row }) => { +> = (context) => { const resetKeyRef = useRef(0); - const experiment = row.original; + const experiment = context.row.original; const [open, setOpen] = useState(false); const experimentBatchDeleteMutation = useExperimentBatchDeleteMutation(); @@ -29,9 +30,10 @@ const ExperimentRowActionsCell: React.FunctionComponent< }, [experiment]); return ( -
e.stopPropagation()} + -
+ ); }; diff --git a/apps/opik-frontend/src/components/pages/ExperimentsShared/table.tsx b/apps/opik-frontend/src/components/pages/ExperimentsShared/table.tsx index 9ec26d80d1..ae52b38f19 100644 --- a/apps/opik-frontend/src/components/pages/ExperimentsShared/table.tsx +++ b/apps/opik-frontend/src/components/pages/ExperimentsShared/table.tsx @@ -108,7 +108,7 @@ export const generateGroupedCellDef = ( cell: (context: CellContext) => { const { row, cell } = context; return ( -
+
event.stopPropagation()} @@ -189,7 +189,7 @@ export const renderCustomRow = ( } else { return ( - +