(cherry picked from commit f0b191c1c8)
Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com>
This commit is contained in:
co-authored by
Victor Marin
parent
50c729c23e
commit
36a622cf22
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { HeaderGroup, Column } from 'react-table';
|
import { HeaderGroup, Column } from 'react-table';
|
||||||
|
|
||||||
import { DataFrame, Field } from '@grafana/data';
|
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
|
||||||
import { useStyles2 } from '../../themes';
|
import { useStyles2 } from '../../themes';
|
||||||
@@ -13,12 +12,11 @@ import { getTableStyles, TableStyles } from './styles';
|
|||||||
|
|
||||||
export interface HeaderRowProps {
|
export interface HeaderRowProps {
|
||||||
headerGroups: HeaderGroup[];
|
headerGroups: HeaderGroup[];
|
||||||
data: DataFrame;
|
|
||||||
showTypeIcons?: boolean;
|
showTypeIcons?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HeaderRow = (props: HeaderRowProps) => {
|
export const HeaderRow = (props: HeaderRowProps) => {
|
||||||
const { headerGroups, data, showTypeIcons } = props;
|
const { headerGroups, showTypeIcons } = props;
|
||||||
const e2eSelectorsTable = selectors.components.Panels.Visualization.Table;
|
const e2eSelectorsTable = selectors.components.Panels.Visualization.Table;
|
||||||
const tableStyles = useStyles2(getTableStyles);
|
const tableStyles = useStyles2(getTableStyles);
|
||||||
|
|
||||||
@@ -35,7 +33,7 @@ export const HeaderRow = (props: HeaderRowProps) => {
|
|||||||
role="row"
|
role="row"
|
||||||
>
|
>
|
||||||
{headerGroup.headers.map((column: Column, index: number) =>
|
{headerGroup.headers.map((column: Column, index: number) =>
|
||||||
renderHeaderCell(column, tableStyles, data.fields[index], showTypeIcons)
|
renderHeaderCell(column, tableStyles, showTypeIcons)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -44,8 +42,9 @@ export const HeaderRow = (props: HeaderRowProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderHeaderCell(column: any, tableStyles: TableStyles, field?: Field, showTypeIcons?: boolean) {
|
function renderHeaderCell(column: any, tableStyles: TableStyles, showTypeIcons?: boolean) {
|
||||||
const headerProps = column.getHeaderProps();
|
const headerProps = column.getHeaderProps();
|
||||||
|
const field = column.field ?? null;
|
||||||
|
|
||||||
if (column.canResize) {
|
if (column.canResize) {
|
||||||
headerProps.style.userSelect = column.isResizing ? 'none' : 'auto'; // disables selecting text while resizing
|
headerProps.style.userSelect = column.isResizing ? 'none' : 'auto'; // disables selecting text while resizing
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ export const Table: FC<Props> = memo((props: Props) => {
|
|||||||
<div {...getTableProps()} className={tableStyles.table} aria-label={ariaLabel} role="table">
|
<div {...getTableProps()} className={tableStyles.table} aria-label={ariaLabel} role="table">
|
||||||
<CustomScrollbar hideVerticalTrack={true}>
|
<CustomScrollbar hideVerticalTrack={true}>
|
||||||
<div className={tableStyles.tableContentWrapper(totalColumnsWidth)}>
|
<div className={tableStyles.tableContentWrapper(totalColumnsWidth)}>
|
||||||
{!noHeader && <HeaderRow data={data} headerGroups={headerGroups} showTypeIcons={showTypeIcons} />}
|
{!noHeader && <HeaderRow headerGroups={headerGroups} showTypeIcons={showTypeIcons} />}
|
||||||
{itemCount > 0 ? (
|
{itemCount > 0 ? (
|
||||||
<FixedSizeList
|
<FixedSizeList
|
||||||
height={listHeight}
|
height={listHeight}
|
||||||
|
|||||||
Reference in New Issue
Block a user