mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Expand table height to show sub-tables (#60359)
* Expand table height to show sub-tables when there isn't enough space * Fix after merge
This commit is contained in:
@@ -41,6 +41,7 @@ export const Table = memo((props: Props) => {
|
|||||||
data,
|
data,
|
||||||
subData,
|
subData,
|
||||||
height,
|
height,
|
||||||
|
maxHeight,
|
||||||
onCellFilterAdded,
|
onCellFilterAdded,
|
||||||
width,
|
width,
|
||||||
columnMinWidth = COLUMN_MIN_WIDTH,
|
columnMinWidth = COLUMN_MIN_WIDTH,
|
||||||
@@ -189,6 +190,18 @@ export const Table = memo((props: Props) => {
|
|||||||
|
|
||||||
const pageSize = Math.round(listHeight / tableStyles.rowHeight) - 1;
|
const pageSize = Math.round(listHeight / tableStyles.rowHeight) - 1;
|
||||||
|
|
||||||
|
// Make sure we have room to show the sub-table
|
||||||
|
const expandedIndices = Object.keys(extendedState.expanded);
|
||||||
|
if (expandedIndices.length) {
|
||||||
|
const subTablesHeight = expandedIndices.reduce((sum, index) => {
|
||||||
|
const subLength = subData?.find((frame) => frame.meta?.custom?.parentRowIndex === parseInt(index, 10))?.length;
|
||||||
|
return subLength ? sum + tableStyles.rowHeight * (subLength + 1) : sum;
|
||||||
|
}, 0);
|
||||||
|
if (listHeight < subTablesHeight) {
|
||||||
|
listHeight = Math.min(listHeight + subTablesHeight, maxHeight || Number.MAX_SAFE_INTEGER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Don't update the page size if it is less than 1
|
// Don't update the page size if it is less than 1
|
||||||
if (pageSize <= 0) {
|
if (pageSize <= 0) {
|
||||||
@@ -213,6 +226,7 @@ export const Table = memo((props: Props) => {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={subTableStyle}>
|
<div style={subTableStyle}>
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export interface Props {
|
|||||||
data: DataFrame;
|
data: DataFrame;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
maxHeight?: number;
|
||||||
/** Minimal column width specified in pixels */
|
/** Minimal column width specified in pixels */
|
||||||
columnMinWidth?: number;
|
columnMinWidth?: number;
|
||||||
noHeader?: boolean;
|
noHeader?: boolean;
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ export class TableContainer extends PureComponent<Props> {
|
|||||||
subData={subFrames}
|
subData={subFrames}
|
||||||
width={tableWidth}
|
width={tableWidth}
|
||||||
height={height}
|
height={height}
|
||||||
|
maxHeight={600}
|
||||||
onCellFilterAdded={onCellFilterAdded}
|
onCellFilterAdded={onCellFilterAdded}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user