mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 04:02:30 +08:00
TableNG: Restructure panel implementation swapping (#102956)
This commit is contained in:
@ -6,7 +6,7 @@ import { applyFieldOverrides, createTheme, DataFrame, FieldType, toDataFrame } f
|
||||
import { Icon } from '../Icon/Icon';
|
||||
|
||||
import { Table } from './TableRT/Table';
|
||||
import { CustomHeaderRendererProps, BaseTableProps } from './types';
|
||||
import { CustomHeaderRendererProps, TableRTProps } from './types';
|
||||
|
||||
// mock transition styles to ensure consistent behaviour in unit tests
|
||||
jest.mock('@floating-ui/react', () => ({
|
||||
@ -101,11 +101,11 @@ function applyOverrides(dataFrame: DataFrame) {
|
||||
return dataFrames[0];
|
||||
}
|
||||
|
||||
function getTestContext(propOverrides: Partial<BaseTableProps> = {}) {
|
||||
function getTestContext(propOverrides: Partial<TableRTProps> = {}) {
|
||||
const onSortByChange = jest.fn();
|
||||
const onCellFilterAdded = jest.fn();
|
||||
const onColumnResize = jest.fn();
|
||||
const props: BaseTableProps = {
|
||||
const props: TableRTProps = {
|
||||
ariaLabel: 'aria-label',
|
||||
data: getDataFrame(fullDataFrame),
|
||||
height: 600,
|
||||
@ -415,7 +415,7 @@ describe('Table', () => {
|
||||
const onSortByChange = jest.fn();
|
||||
const onCellFilterAdded = jest.fn();
|
||||
const onColumnResize = jest.fn();
|
||||
const props: BaseTableProps = {
|
||||
const props: TableRTProps = {
|
||||
ariaLabel: 'aria-label',
|
||||
data: getDataFrame(fullDataFrame),
|
||||
height: 600,
|
||||
@ -557,7 +557,7 @@ describe('Table', () => {
|
||||
const onSortByChange = jest.fn();
|
||||
const onCellFilterAdded = jest.fn();
|
||||
const onColumnResize = jest.fn();
|
||||
const props: BaseTableProps = {
|
||||
const props: TableRTProps = {
|
||||
ariaLabel: 'aria-label',
|
||||
data: getDataFrame(fullDataFrame),
|
||||
height: 600,
|
||||
|
@ -1,8 +1 @@
|
||||
import { TableNG } from './TableNG/TableNG';
|
||||
import { Table as TableRT } from './TableRT/Table';
|
||||
import { GeneralTableProps } from './types';
|
||||
|
||||
export function Table(props: GeneralTableProps) {
|
||||
let table = props.useTableNg ? <TableNG {...props} /> : <TableRT {...props} />;
|
||||
return table;
|
||||
}
|
||||
export { Table } from './TableRT/Table';
|
||||
|
@ -21,7 +21,7 @@ import { Pagination } from '../../Pagination/Pagination';
|
||||
import { TableCellInspector } from '../TableCellInspector';
|
||||
import { useFixScrollbarContainer, useResetVariableListSizeCache } from '../hooks';
|
||||
import { getInitialState, useTableStateReducer } from '../reducer';
|
||||
import { FooterItem, GrafanaTableState, InspectCell, BaseTableProps as Props } from '../types';
|
||||
import { FooterItem, GrafanaTableState, InspectCell, TableRTProps as Props } from '../types';
|
||||
import {
|
||||
getColumns,
|
||||
sortCaseInsensitive,
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
GrafanaTableColumn,
|
||||
GrafanaTableState,
|
||||
TableStateReducerProps,
|
||||
GeneralTableProps,
|
||||
TableRTProps,
|
||||
} from './types';
|
||||
|
||||
export interface ActionType {
|
||||
@ -69,7 +69,7 @@ export function useTableStateReducer({ onColumnResize, onSortByChange, data }: T
|
||||
}
|
||||
|
||||
export function getInitialState(
|
||||
initialSortBy: GeneralTableProps['initialSortBy'],
|
||||
initialSortBy: TableRTProps['initialSortBy'],
|
||||
columns: GrafanaTableColumn[]
|
||||
): Partial<GrafanaTableState> {
|
||||
const state: Partial<GrafanaTableState> = {};
|
||||
|
@ -97,7 +97,7 @@ export interface TableStateReducerProps {
|
||||
}
|
||||
|
||||
// export interface Props {
|
||||
export interface BaseTableProps {
|
||||
export interface TableRTProps {
|
||||
ariaLabel?: string;
|
||||
data: DataFrame;
|
||||
width: number;
|
||||
@ -126,22 +126,6 @@ export interface BaseTableProps {
|
||||
replaceVariables?: InterpolateFunction;
|
||||
}
|
||||
|
||||
export interface GeneralTableProps extends BaseTableProps {
|
||||
// Should the next generation table based off of react-data-grid be used
|
||||
// 🗻 BIG 🗻 if true
|
||||
useTableNg?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Props for the react-data-grid based table.
|
||||
*/
|
||||
export interface TableNGProps extends BaseTableProps {}
|
||||
|
||||
/**
|
||||
* Props for the react-table based table.
|
||||
*/
|
||||
export interface TableRTProps extends BaseTableProps {}
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* Props that will be passed to the TableCustomCellOptions.cellComponent when rendered.
|
||||
|
@ -101,6 +101,7 @@ export {
|
||||
type TableImageCellOptions,
|
||||
type TableJsonViewCellOptions,
|
||||
} from './Table/types';
|
||||
|
||||
export { TableInputCSV } from './TableInputCSV/TableInputCSV';
|
||||
export { TabsBar } from './Tabs/TabsBar';
|
||||
export { Tab, type TabProps } from './Tabs/Tab';
|
||||
|
@ -10,3 +10,5 @@
|
||||
*/
|
||||
|
||||
export * from './utils/skeleton';
|
||||
|
||||
export { TableNG } from './components/Table/TableNG/TableNG';
|
||||
|
Reference in New Issue
Block a user