-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update T-Grid to use DataGrid pagination * It also improves the Gtid loading state * DataGrid pagination makes sure that we display the grid with the proper height. * Add DataGrid height hack to t-grid HUGE HACK!!! DataGrtid height isn't properly calculated when the grid has horizontal scroll. elastic/eui#5030 In order to get around this bug we are calculating `DataGrid` height here and setting it as a prop. Please revert this commit and allow DataGrid to calculate its height when the bug is fixed. * Apply DataGrid laoding and pagination changes to observability * Fix cypress tests * Fix t-grid page render bug on Observability * some pagination fixes * hide table when analyzer active * isolate exported function Co-authored-by: semd <sergi.massaneda@elastic.co> Co-authored-by: Pablo Machado <pablo.nevesmachado@elastic.co>
- Loading branch information
Showing
17 changed files
with
448 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/** | ||
* rowIndex is bigger than `data.length` for pages with page numbers bigger than one. | ||
* For that reason, we must calculate `rowIndex % itemsPerPage`. | ||
* | ||
* Ex: | ||
* Given `rowIndex` is `13` and `itemsPerPage` is `10`. | ||
* It means that the `activePage` is `2` and the `pageRowIndex` is `3` | ||
* | ||
* **Warning**: | ||
* Be careful with array out of bounds. `pageRowIndex` can be bigger or equal to `data.length` | ||
* in the scenario where the user changes the event status (Open, Acknowledged, Closed). | ||
*/ | ||
|
||
export const getPageRowIndex = (rowIndex: number, itemsPerPage: number) => rowIndex % itemsPerPage; |
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/timelines/public/components/t_grid/body/height_hack.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useState, useLayoutEffect } from 'react'; | ||
|
||
// That could be different from security and observability. Get it as parameter? | ||
const INITIAL_DATA_GRID_HEIGHT = 967; | ||
|
||
// It will recalculate DataGrid height after this time interval. | ||
const TIME_INTERVAL = 50; | ||
|
||
/** | ||
* You are probably asking yourself "Why 3?". But that is the wrong mindset. You should be asking yourself "why not 3?". | ||
* 3 (three) is a number, numeral and digit. It is the natural number following 2 and preceding 4, and is the smallest | ||
* odd prime number and the only prime preceding a square number. It has religious or cultural significance in many societies. | ||
*/ | ||
const MAGIC_GAP = 3; | ||
|
||
/** | ||
* HUGE HACK!!! | ||
* DataGrtid height isn't properly calculated when the grid has horizontal scroll. | ||
* https://github.com/elastic/eui/issues/5030 | ||
* | ||
* In order to get around this bug we are calculating `DataGrid` height here and setting it as a prop. | ||
* | ||
* Please delete me and allow DataGrid to calculate its height when the bug is fixed. | ||
*/ | ||
export const useDataGridHeightHack = (pageSize: number, rowCount: number) => { | ||
const [height, setHeight] = useState(INITIAL_DATA_GRID_HEIGHT); | ||
|
||
useLayoutEffect(() => { | ||
setTimeout(() => { | ||
const gridVirtualized = document.querySelector('#body-data-grid .euiDataGrid__virtualized'); | ||
|
||
if ( | ||
gridVirtualized && | ||
gridVirtualized.children[0].clientHeight !== gridVirtualized.clientHeight // check if it has vertical scroll | ||
) { | ||
setHeight( | ||
height + | ||
gridVirtualized.children[0].clientHeight - | ||
gridVirtualized.clientHeight + | ||
MAGIC_GAP | ||
); | ||
} | ||
}, TIME_INTERVAL); | ||
}, [pageSize, rowCount, height]); | ||
|
||
return height; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.