The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
fix tasks table (#67964)
Aleksandr Lesnenko13ec0f6fc8f7
diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/ErrorsCell/ErrorsCell.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/ErrorsCell/ErrorsCell.tsxindex bae9d2db070..a3671d16e08 100644--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/ErrorsCell/ErrorsCell.tsx+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/ErrorsCell/ErrorsCell.tsx@@ -1,3 +1,4 @@+import { Ellipsified } from "metabase/common/components/Ellipsified";import type { DependencyNode } from "metabase-types/api";import { getDependencyErrorInfo } from "../../../../utils";@@ -14,10 +15,14 @@ export function ErrorsCell({ node }: ErrorsCellProps) {return null;}+ const fullText = errorsInfo.detail+ ? `${errorsInfo.label} ${errorsInfo.detail}`+ : errorsInfo.label;+return (- <div>+ <Ellipsified tooltip={fullText}><span>{errorsInfo.label}</span>{" "}{errorsInfo.detail && <strong>{errorsInfo.detail}</strong>}- </div>+ </Ellipsified>);}diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/LocationCell/LocationCell.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/LocationCell/LocationCell.tsxindex 2c3e943d890..690a41a89cd 100644--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/LocationCell/LocationCell.tsx+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/LocationCell/LocationCell.tsx@@ -1,6 +1,5 @@-import { Fragment } from "react";--import { Box, FixedSizeIcon, Flex } from "metabase/ui";+import { Ellipsified } from "metabase/common/components/Ellipsified";+import { FixedSizeIcon, Flex } from "metabase/ui";import type { DependencyNode } from "metabase-types/api";import { getNodeLocationInfo } from "../../../../utils";@@ -11,23 +10,18 @@ type LocationCellProps = {export function LocationCell({ node }: LocationCellProps) {const location = getNodeLocationInfo(node);+if (location == null) {return null;}const { icon, links } = location;+ const path = links.map((link) => link.label).join(" / ");return (- <Flex align="center" gap="sm">- {links.map((link, linkIndex) => (- <Fragment key={linkIndex}>- {linkIndex > 0 && <Box>/</Box>}- <Flex align="center" gap="sm">- {linkIndex === 0 && icon && <FixedSizeIcon name={icon} />}- {link.label}- </Flex>- </Fragment>- ))}+ <Flex align="center" gap="sm" miw={0}>+ {icon && <FixedSizeIcon name={icon} />}+ <Ellipsified>{path}</Ellipsified></Flex>);}diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/NameCell/NameCell.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/NameCell/NameCell.tsxindex 2174b829f4e..6a2dd4a6ce2 100644--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/NameCell/NameCell.tsx+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/NameCell/NameCell.tsx@@ -1,3 +1,4 @@+import { Ellipsified } from "metabase/common/components/Ellipsified";import { FixedSizeIcon, Flex } from "metabase/ui";import type { DependencyNode } from "metabase-types/api";@@ -12,9 +13,9 @@ export function NameCell({ node }: NameCellProps) {const icon = getNodeIcon(node);return (- <Flex align="center" gap="sm">+ <Flex align="center" gap="sm" miw={0}>{icon && <FixedSizeIcon name={icon} />}- {label}+ <Ellipsified>{label}</Ellipsified></Flex>);}diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/utils.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/utils.tsxindex efce4b30de8..752bd3fe675 100644--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/utils.tsx+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyList/ListBody/utils.tsx@@ -17,9 +17,7 @@ function getNodeNameColumn(): TreeTableColumnDef<DependencyNode> {return {id: "name",header: t`Name`,- meta: {- width: "auto",- },+ minWidth: "auto",accessorFn: (node) => getNodeLabel(node),cell: ({ row }) => {const node = row.original;@@ -32,9 +30,7 @@ function getNodeLocationColumn(): TreeTableColumnDef<DependencyNode> {return {id: "location",header: t`Location`,- meta: {- width: "auto",- },+ minWidth: "auto",accessorFn: (node) => {const location = getNodeLocationInfo(node);const links = location?.links ?? [];@@ -51,9 +47,7 @@ function getNodeErrorsColumn(): TreeTableColumnDef<DependencyNode> {return {id: "error",header: t`Errors`,- meta: {- width: "auto",- },+ minWidth: "auto",accessorFn: (node) => node.errors?.length ?? 0,cell: ({ row }) => {const node = row.original;@@ -70,6 +64,7 @@ function getNodeDependentsCountColumn(): TreeTableColumnDef<DependencyNode> {return {id: "dependents-count",header: t`Downstream dependents`,+ width: "auto",accessorFn: (node) => getNodeDependentsCount(node),cell: ({ row }) => {const node = row.original;diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.module.css b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.module.cssindex 868833ac3b4..4f69aef0154 100644--- a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.module.css+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.module.css@@ -7,6 +7,9 @@flex-shrink: 0;font-size: 12.5px;background-color: var(--mb-color-background-primary);+}++.headerRow {border-bottom: 1px solid var(--mb-color-border);}diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.tsx b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.tsxindex adac6bd4d66..5dfe50887ea 100644--- a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.tsx+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableHeader/TreeTableHeader.tsx@@ -35,7 +35,7 @@ function TreeTableHeaderInner<TData extends TreeNodeData>({{headerGroups.map((headerGroup) => (<Flexkey={headerGroup.id}- className={classNames?.headerRow}+ className={cx(S.headerRow, classNames?.headerRow)}w="100%"style={{ minWidth: totalContentWidth, ...styles?.headerRow }}>diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/constants.ts b/frontend/src/metabase/ui/components/data-display/TreeTable/constants.tsindex 09e58add4d4..1eb6bf8986a 100644--- a/frontend/src/metabase/ui/components/data-display/TreeTable/constants.ts+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/constants.ts@@ -5,5 +5,6 @@ export const CHECKBOX_COLUMN_WIDTH = 32;export const EXPAND_BUTTON_WIDTH = 24;export const MIN_COLUMN_WIDTH = 50;export const MEASUREMENT_ROW_COUNT = 10;+export const LONGEST_VALUES_SAMPLE_COUNT = 3;export const CELL_HORIZONTAL_PADDING = 24;export const TREE_CELL_BASE_PADDING = 16;diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/hooks/useColumnSizing.tsx b/frontend/src/metabase/ui/components/data-display/TreeTable/hooks/useColumnSizing.tsxindex b0e08d9cfb4..39d4085fb89 100644--- a/frontend/src/metabase/ui/components/data-display/TreeTable/hooks/useColumnSizing.tsx+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/hooks/useColumnSizing.tsx@@ -14,6 +14,7 @@ import {CELL_HORIZONTAL_PADDING,DEFAULT_INDENT_WIDTH,EXPAND_BUTTON_WIDTH,+ LONGEST_VALUES_SAMPLE_COUNT,MEASUREMENT_ROW_COUNT,MIN_COLUMN_WIDTH,TREE_CELL_BASE_PADDING,@@ -36,20 +37,68 @@ export function needsMeasurement<TData extends TreeNodeData>(return column.minWidth === "auto" || column.width === "auto";}-function pickTreeRowsToMeasure<TData>(+// Find K rows with longest string values to measure content width for the column.+function getRowsWithLongestValues<TData extends TreeNodeData>(rows: Row<TData>[],- columnId: string,+ column: TreeTableColumnDef<TData>,+ excludeIds: Set<string>,+): Row<TData>[] {+ const topK: Array<{ row: Row<TData>; length: number }> = [];++ for (const row of rows) {+ if (excludeIds.has(row.id)) {+ continue;+ }++ const value = row.getValue(column.id);+ if (value == null) {+ continue;+ }++ const length = String(value).length;++ if (topK.length < LONGEST_VALUES_SAMPLE_COUNT) {+ topK.push({ row, length });+ continue;+ }++ let minIndex = 0;+ for (let i = 1; i < topK.length; i++) {+ if (topK[i].length < topK[minIndex].length) {+ minIndex = i;+ }+ }++ if (length > topK[minIndex].length) {+ topK[minIndex] = { row, length };+ }+ }++ return topK.map((c) => c.row);+}++// Pick rows to measure for column width: first N rows + rows with longest stringified values.+// Combining both catches typical content and outliers without measuring all rows.+function pickTreeRowsToMeasure<TData extends TreeNodeData>(+ rows: Row<TData>[],+ column: TreeTableColumnDef<TData>,count: number = MEASUREMENT_ROW_COUNT,): Row<TData>[] {const result: Row<TData>[] = [];+for (const row of rows) {- if (row.getValue(columnId) != null) {+ if (row.getValue(column.id) != null) {result.push(row);if (result.length >= count) {break;}}}++ const sampledIds = new Set(result.map((r) => r.id));+ const longestRows = getRowsWithLongestValues(rows, column, sampledIds);+ result.push(...longestRows);+return result;}@@ -216,7 +265,7 @@ function MeasureContent<TData extends TreeNodeData>({cellEls.forEach((cellEl) => {const depth = parseInt(cellEl.getAttribute("data-depth") ?? "0", 10);- let cellWidth = (cellEl as HTMLElement).offsetWidth;+ let cellWidth = Math.ceil(cellEl.getBoundingClientRect().width);cellWidth += CELL_HORIZONTAL_PADDING;@@ -234,7 +283,8 @@ function MeasureContent<TData extends TreeNodeData>({const headerEl = columnEl.querySelector("[data-measure-header]");if (headerEl) {const headerWidth =- (headerEl as HTMLElement).offsetWidth + CELL_HORIZONTAL_PADDING;+ Math.ceil(headerEl.getBoundingClientRect().width) ++ CELL_HORIZONTAL_PADDING;maxWidth = Math.max(maxWidth, headerWidth);}@@ -252,7 +302,7 @@ function MeasureContent<TData extends TreeNodeData>({<div ref={handleRef} style={{ display: "flex" }}>{columnsToMeasure.map((column) => {const colIndex = columns.findIndex((c) => c.id === column.id);- const rowsToMeasure = pickTreeRowsToMeasure(rows, column.id);+ const rowsToMeasure = pickTreeRowsToMeasure(rows, column);return (<div