mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[UnifiedDataTable] Add gridStyle override support (#166994)
This commit is contained in:
parent
22029b50e8
commit
a338dd8b38
2 changed files with 40 additions and 1 deletions
|
@ -432,4 +432,37 @@ describe('UnifiedDataTable', () => {
|
||||||
expect(tourStep).toEqual('test-expand');
|
expect(tourStep).toEqual('test-expand');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('gridStyleOverride', () => {
|
||||||
|
it('should render the grid with the default style if no gridStyleOverride is provided', async () => {
|
||||||
|
const component = await getComponent({
|
||||||
|
...getProps(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const grid = findTestSubject(component, 'docTable');
|
||||||
|
|
||||||
|
expect(grid.hasClass('euiDataGrid--bordersHorizontal')).toBeTruthy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--fontSizeSmall')).toBeTruthy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--paddingLarge')).toBeTruthy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--rowHoverHighlight')).toBeTruthy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--headerUnderline')).toBeTruthy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--stripes')).toBeTruthy();
|
||||||
|
});
|
||||||
|
it('should render the grid with style override if gridStyleOverride is provided', async () => {
|
||||||
|
const component = await getComponent({
|
||||||
|
...getProps(),
|
||||||
|
gridStyleOverride: {
|
||||||
|
stripes: false,
|
||||||
|
rowHover: 'none',
|
||||||
|
border: 'none',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const grid = findTestSubject(component, 'docTable');
|
||||||
|
|
||||||
|
expect(grid.hasClass('euiDataGrid--stripes')).toBeFalsy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--rowHoverHighlight')).toBeFalsy();
|
||||||
|
expect(grid.hasClass('euiDataGrid--bordersNone')).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {
|
||||||
EuiDataGridControlColumn,
|
EuiDataGridControlColumn,
|
||||||
EuiDataGridCustomBodyProps,
|
EuiDataGridCustomBodyProps,
|
||||||
EuiDataGridCellValueElementProps,
|
EuiDataGridCellValueElementProps,
|
||||||
|
EuiDataGridStyle,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||||
import {
|
import {
|
||||||
|
@ -282,6 +283,10 @@ export interface UnifiedDataTableProps {
|
||||||
* Optional key/value pairs to set guided onboarding steps ids for a data table components included to guided tour.
|
* Optional key/value pairs to set guided onboarding steps ids for a data table components included to guided tour.
|
||||||
*/
|
*/
|
||||||
componentsTourSteps?: Record<string, string>;
|
componentsTourSteps?: Record<string, string>;
|
||||||
|
/**
|
||||||
|
* Optional gridStyle override.
|
||||||
|
*/
|
||||||
|
gridStyleOverride?: EuiDataGridStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EuiDataGridMemoized = React.memo(EuiDataGrid);
|
export const EuiDataGridMemoized = React.memo(EuiDataGrid);
|
||||||
|
@ -335,6 +340,7 @@ export const UnifiedDataTable = ({
|
||||||
externalCustomRenderers,
|
externalCustomRenderers,
|
||||||
consumer = 'discover',
|
consumer = 'discover',
|
||||||
componentsTourSteps,
|
componentsTourSteps,
|
||||||
|
gridStyleOverride,
|
||||||
}: UnifiedDataTableProps) => {
|
}: UnifiedDataTableProps) => {
|
||||||
const { fieldFormats, toastNotifications, dataViewFieldEditor, uiSettings, storage, data } =
|
const { fieldFormats, toastNotifications, dataViewFieldEditor, uiSettings, storage, data } =
|
||||||
services;
|
services;
|
||||||
|
@ -789,7 +795,7 @@ export const UnifiedDataTable = ({
|
||||||
toolbarVisibility={toolbarVisibility}
|
toolbarVisibility={toolbarVisibility}
|
||||||
rowHeightsOptions={rowHeightsOptions}
|
rowHeightsOptions={rowHeightsOptions}
|
||||||
inMemory={inMemory}
|
inMemory={inMemory}
|
||||||
gridStyle={GRID_STYLE}
|
gridStyle={gridStyleOverride ?? GRID_STYLE}
|
||||||
renderCustomGridBody={renderCustomGridBody}
|
renderCustomGridBody={renderCustomGridBody}
|
||||||
trailingControlColumns={trailingControlColumns}
|
trailingControlColumns={trailingControlColumns}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue