From ee96b08f4bf87a187e2d19a8c0441f6da237c294 Mon Sep 17 00:00:00 2001 From: Joey <90795735+joey-grafana@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:16:02 +0100 Subject: [PATCH] Table: Add dataframe name to single table (#74584) * Add dataframe name to single table * Extract method * Update name --- public/app/features/explore/Table/TableContainer.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/app/features/explore/Table/TableContainer.tsx b/public/app/features/explore/Table/TableContainer.tsx index 3019fbff83e..8bbaa02ec7e 100644 --- a/public/app/features/explore/Table/TableContainer.tsx +++ b/public/app/features/explore/Table/TableContainer.tsx @@ -50,6 +50,14 @@ export class TableContainer extends PureComponent { return Math.min(600, Math.max(rowCount * 36, hasSubFrames ? 300 : 0) + 40 + 46); } + getTableTitle(dataFrames: DataFrame[] | null, data: DataFrame, i: number) { + let title = data.name ? `Table - ${data.name}` : 'Table'; + if (dataFrames && dataFrames.length > 1) { + title = `Table - ${data.name || data.refId || i}`; + } + return title; + } + render() { const { loading, onCellFilterAdded, tableResult, width, splitOpenFn, range, ariaLabel, timeZone } = this.props; @@ -88,7 +96,7 @@ export class TableContainer extends PureComponent { frames.map((data, i) => ( 1 ? `Table - ${data.name || data.refId || i}` : 'Table'} + title={this.getTableTitle(dataFrames, data, i)} width={width} height={this.getTableHeight(data.length, this.hasSubFrames(data))} loadingState={loading ? LoadingState.Loading : undefined}