Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UnifiedDataTable] Add gridStyle override support #166994

Merged

Conversation

opauloh
Copy link
Contributor

@opauloh opauloh commented Sep 21, 2023

Summary

It closes #166978

This PR adds support to override the default gridStyle of the EuiGrid component used by the UnifiedDataTable component, so the same style customizations supported by EuiGrid can be added as well by other plugins that want to reuse the UnifiedDataTable.

It achieves this by adding an optional gridStyleOverride component on the UnifiedDataTable, if gridStyleOverride is passed it overrides the default style, otherwise it fallbacks to the default defined in the GRID_STYLE constant.

@opauloh opauloh requested a review from a team as a code owner September 21, 2023 22:12
@opauloh opauloh added release_note:skip Skip the PR/issue when compiling release notes v8.11.0 labels Sep 21, 2023
Comment on lines 725 to 728
const gridStyle = useMemo(() => {
return gridStyleOverride ?? GRID_STYLE;
}, [gridStyleOverride]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, yes memoization is very important to the grid's usage, we have to omit re-renderings, since they are expensive. However in this case I'm curious, what's the benefit of this memoization? GRID_STYLE is a constant, and gridStyleOverride should also be (unless the consumer uses it like this gridStyleOverride={{stripes: false}}, but then useMemo like here wouldn't help)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right on that, I was considering the last example usage, but in fact, useMemo wouldn't give any benefit at all since the checking it does would end up being more expensive than just checking if the variable exists

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM, and I did a quick test in Discover just to be sure, and all worked as expected 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 558.0KB 558.0KB +33.0B
Unknown metric groups

API count

id before after diff
@kbn/unified-data-table 92 93 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@opauloh opauloh merged commit a338dd8 into elastic:main Sep 26, 2023
@opauloh opauloh deleted the unified-datatable/add-style-override-support branch September 26, 2023 21:42
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Sep 26, 2023
opauloh added a commit that referenced this pull request Oct 5, 2023
## Summary

This PR introduces the Cloud Security DataTable component, meant to
replace and consolidate the tables used in the Cloud Security plugin

The CloudSecurityDataTable component is a wrapper over the
`<UnifiedDataTable/>` component. We made that decision based on the
number of features it provides for the users plus support from the most
common features such as Flyout, Sort, Filtering, and Pagination to the
most advanced features like Virtualization and DataView integration.

- **Virtualization**: Thanks to Virtualization, users can fetch more
data on the table than the limit of `500`, and also use larger items per
page if desired.
- **DataView integration**: This option allows users to rename Columns
as needed by setting custom labels in the DataView.
- **Column control**: Users can move columns and resize it as needed,
and that settings is saved on the local storage.
- **Row Height control**: Users can modify in the Advanced Settings ->
`discover:rowHeight` the height of the row.

Below is a Matrix comparing the features between the current Findings
table, the Vulnerabilities Data Grid and the new CloudSecurityDataTable.

Feature | CloudSecurity DataTable (new >= 8.11) | Findings Table
(current <= 8.10) | Vulnerabilities Data Grid (current <= 8.10)
-- | -- | -- | --
Tooltip on Cell Hover | ❌ | ✅ | ❌
Column Sorting | ✅ | ✅ | ✅
Multi Column Sorting | ✅ | ❌ | ✅
Column filtering | ✅ | ✅ | ✅
Pagination | ✅ | ✅ | ✅
Rows per page | ✅ | ✅ | ✅
Virtualization (Support to load more data) | ✅ | ❌ | ❌
Custom component on Column Header | ❌ (only custom text) | ✅ | ❌
Additional controls on the left | ✅ | ❌ | ✅
Text truncation | ✅ | ✅ | ✅
Override Style | ✅ (#166994) | ✅ |
✅
Load more button | ✅ | ❌ | ❌
Resize column | ✅ | ❌ | ✅
Reorder column | ✅ | ❌ | ✅
FullScreen button | ✅ | ❌ | ✅
User-defined row height | ✅ | ❌ | ❌
external pagination control (enables Flyout pagination) | ❌ | ✅ | ✅
user-defined column renaming | ✅ (using DataViews) | ❌ | ❌


### Regressions

There are some regressions such as losing the ability to paginate on the
Flyout and the table pagination is no longer controlled by URL params,
that's because pagination is controlled by an internal state in the
`<UnifiedDataTable/>` component, and we plan to re-enable those features
again in the future by contributing to the `<UnifiedDataTable/>`
component.

### Screenshots


![image](https://github.com/elastic/kibana/assets/19270322/a0d1f95a-adcc-4e58-9d3e-0adec3df8b3b)

### Videos

Basic Features + Virtualization


https://github.com/elastic/kibana/assets/19270322/b1a61592-e1ae-4baf-9610-3e24c473c17d



https://github.com/elastic/kibana/assets/19270322/d8e6106c-0ca3-4277-b78b-5ca482095ae1


DataView integration



https://github.com/elastic/kibana/assets/19270322/0d583243-bb86-45e4-baa5-dc63253da8f6

Row Height Control



https://github.com/elastic/kibana/assets/19270322/b1d43609-7c8a-4855-ab2f-624c18663579

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Jordan <[email protected]>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 5, 2023
## Summary

This PR introduces the Cloud Security DataTable component, meant to
replace and consolidate the tables used in the Cloud Security plugin

The CloudSecurityDataTable component is a wrapper over the
`<UnifiedDataTable/>` component. We made that decision based on the
number of features it provides for the users plus support from the most
common features such as Flyout, Sort, Filtering, and Pagination to the
most advanced features like Virtualization and DataView integration.

- **Virtualization**: Thanks to Virtualization, users can fetch more
data on the table than the limit of `500`, and also use larger items per
page if desired.
- **DataView integration**: This option allows users to rename Columns
as needed by setting custom labels in the DataView.
- **Column control**: Users can move columns and resize it as needed,
and that settings is saved on the local storage.
- **Row Height control**: Users can modify in the Advanced Settings ->
`discover:rowHeight` the height of the row.

Below is a Matrix comparing the features between the current Findings
table, the Vulnerabilities Data Grid and the new CloudSecurityDataTable.

Feature | CloudSecurity DataTable (new >= 8.11) | Findings Table
(current <= 8.10) | Vulnerabilities Data Grid (current <= 8.10)
-- | -- | -- | --
Tooltip on Cell Hover | ❌ | ✅ | ❌
Column Sorting | ✅ | ✅ | ✅
Multi Column Sorting | ✅ | ❌ | ✅
Column filtering | ✅ | ✅ | ✅
Pagination | ✅ | ✅ | ✅
Rows per page | ✅ | ✅ | ✅
Virtualization (Support to load more data) | ✅ | ❌ | ❌
Custom component on Column Header | ❌ (only custom text) | ✅ | ❌
Additional controls on the left | ✅ | ❌ | ✅
Text truncation | ✅ | ✅ | ✅
Override Style | ✅ (elastic#166994) | ✅ |
✅
Load more button | ✅ | ❌ | ❌
Resize column | ✅ | ❌ | ✅
Reorder column | ✅ | ❌ | ✅
FullScreen button | ✅ | ❌ | ✅
User-defined row height | ✅ | ❌ | ❌
external pagination control (enables Flyout pagination) | ❌ | ✅ | ✅
user-defined column renaming | ✅ (using DataViews) | ❌ | ❌

### Regressions

There are some regressions such as losing the ability to paginate on the
Flyout and the table pagination is no longer controlled by URL params,
that's because pagination is controlled by an internal state in the
`<UnifiedDataTable/>` component, and we plan to re-enable those features
again in the future by contributing to the `<UnifiedDataTable/>`
component.

### Screenshots

![image](https://github.com/elastic/kibana/assets/19270322/a0d1f95a-adcc-4e58-9d3e-0adec3df8b3b)

### Videos

Basic Features + Virtualization

https://github.com/elastic/kibana/assets/19270322/b1a61592-e1ae-4baf-9610-3e24c473c17d

https://github.com/elastic/kibana/assets/19270322/d8e6106c-0ca3-4277-b78b-5ca482095ae1

DataView integration

https://github.com/elastic/kibana/assets/19270322/0d583243-bb86-45e4-baa5-dc63253da8f6

Row Height Control

https://github.com/elastic/kibana/assets/19270322/b1d43609-7c8a-4855-ab2f-624c18663579

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Jordan <[email protected]>
(cherry picked from commit 8d5dfaf)
kibanamachine added a commit that referenced this pull request Oct 5, 2023
…168056)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[Cloud Security] CloudSecurityDataTable component
(#167587)](#167587)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Paulo
Henrique","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-05T03:57:17Z","message":"[Cloud
Security] CloudSecurityDataTable component (#167587)\n\n##
Summary\r\n\r\nThis PR introduces the Cloud Security DataTable
component, meant to\r\nreplace and consolidate the tables used in the
Cloud Security plugin\r\n\r\nThe CloudSecurityDataTable component is a
wrapper over the\r\n`<UnifiedDataTable/>` component. We made that
decision based on the\r\nnumber of features it provides for the users
plus support from the most\r\ncommon features such as Flyout, Sort,
Filtering, and Pagination to the\r\nmost advanced features like
Virtualization and DataView integration.\r\n\r\n- **Virtualization**:
Thanks to Virtualization, users can fetch more\r\ndata on the table than
the limit of `500`, and also use larger items per\r\npage if
desired.\r\n- **DataView integration**: This option allows users to
rename Columns\r\nas needed by setting custom labels in the
DataView.\r\n- **Column control**: Users can move columns and resize it
as needed,\r\nand that settings is saved on the local storage.\r\n-
**Row Height control**: Users can modify in the Advanced Settings
->\r\n`discover:rowHeight` the height of the row.\r\n\r\nBelow is a
Matrix comparing the features between the current Findings\r\ntable, the
Vulnerabilities Data Grid and the new
CloudSecurityDataTable.\r\n\r\nFeature | CloudSecurity DataTable (new >=
8.11) | Findings Table\r\n(current <= 8.10) | Vulnerabilities Data Grid
(current <= 8.10)\r\n-- | -- | -- | --\r\nTooltip on Cell Hover | ❌ | ✅
| ❌\r\nColumn Sorting | ✅ | ✅ | ✅\r\nMulti Column Sorting | ✅ | ❌ |
✅\r\nColumn filtering | ✅ | ✅ | ✅\r\nPagination | ✅ | ✅ | ✅\r\nRows per
page | ✅ | ✅ | ✅\r\nVirtualization (Support to load more data) | ✅ | ❌ |
❌\r\nCustom component on Column Header | ❌ (only custom text) | ✅ |
❌\r\nAdditional controls on the left | ✅ | ❌ | ✅\r\nText truncation | ✅
| ✅ | ✅\r\nOverride Style |
✅ (#166994) | ✅ |\r\n✅\r\nLoad
more button | ✅ | ❌ | ❌\r\nResize column | ✅ | ❌ | ✅\r\nReorder column |
✅ | ❌ | ✅\r\nFullScreen button | ✅ | ❌ | ✅\r\nUser-defined row height |
✅ | ❌ | ❌\r\nexternal pagination control (enables Flyout pagination) | ❌
| ✅ | ✅\r\nuser-defined column renaming | ✅ (using DataViews) | ❌ |
❌\r\n\r\n\r\n### Regressions\r\n\r\nThere are some regressions such as
losing the ability to paginate on the\r\nFlyout and the table pagination
is no longer controlled by URL params,\r\nthat's because pagination is
controlled by an internal state in the\r\n`<UnifiedDataTable/>`
component, and we plan to re-enable those features\r\nagain in the
future by contributing to the
`<UnifiedDataTable/>`\r\ncomponent.\r\n\r\n###
Screenshots\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/19270322/a0d1f95a-adcc-4e58-9d3e-0adec3df8b3b)\r\n\r\n###
Videos\r\n\r\nBasic Features +
Virtualization\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1a61592-e1ae-4baf-9610-3e24c473c17d\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/d8e6106c-0ca3-4277-b78b-5ca482095ae1\r\n\r\n\r\nDataView
integration\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/0d583243-bb86-45e4-baa5-dc63253da8f6\r\n\r\nRow
Height
Control\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1d43609-7c8a-4855-ab2f-624c18663579\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Jordan
<[email protected]>","sha":"8d5dfafd8d06cc3096f9b72325032510aa498eab","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Cloud
Security","backport:prev-minor","v8.11.0","v8.12.0"],"number":167587,"url":"https://github.com/elastic/kibana/pull/167587","mergeCommit":{"message":"[Cloud
Security] CloudSecurityDataTable component (#167587)\n\n##
Summary\r\n\r\nThis PR introduces the Cloud Security DataTable
component, meant to\r\nreplace and consolidate the tables used in the
Cloud Security plugin\r\n\r\nThe CloudSecurityDataTable component is a
wrapper over the\r\n`<UnifiedDataTable/>` component. We made that
decision based on the\r\nnumber of features it provides for the users
plus support from the most\r\ncommon features such as Flyout, Sort,
Filtering, and Pagination to the\r\nmost advanced features like
Virtualization and DataView integration.\r\n\r\n- **Virtualization**:
Thanks to Virtualization, users can fetch more\r\ndata on the table than
the limit of `500`, and also use larger items per\r\npage if
desired.\r\n- **DataView integration**: This option allows users to
rename Columns\r\nas needed by setting custom labels in the
DataView.\r\n- **Column control**: Users can move columns and resize it
as needed,\r\nand that settings is saved on the local storage.\r\n-
**Row Height control**: Users can modify in the Advanced Settings
->\r\n`discover:rowHeight` the height of the row.\r\n\r\nBelow is a
Matrix comparing the features between the current Findings\r\ntable, the
Vulnerabilities Data Grid and the new
CloudSecurityDataTable.\r\n\r\nFeature | CloudSecurity DataTable (new >=
8.11) | Findings Table\r\n(current <= 8.10) | Vulnerabilities Data Grid
(current <= 8.10)\r\n-- | -- | -- | --\r\nTooltip on Cell Hover | ❌ | ✅
| ❌\r\nColumn Sorting | ✅ | ✅ | ✅\r\nMulti Column Sorting | ✅ | ❌ |
✅\r\nColumn filtering | ✅ | ✅ | ✅\r\nPagination | ✅ | ✅ | ✅\r\nRows per
page | ✅ | ✅ | ✅\r\nVirtualization (Support to load more data) | ✅ | ❌ |
❌\r\nCustom component on Column Header | ❌ (only custom text) | ✅ |
❌\r\nAdditional controls on the left | ✅ | ❌ | ✅\r\nText truncation | ✅
| ✅ | ✅\r\nOverride Style |
✅ (#166994) | ✅ |\r\n✅\r\nLoad
more button | ✅ | ❌ | ❌\r\nResize column | ✅ | ❌ | ✅\r\nReorder column |
✅ | ❌ | ✅\r\nFullScreen button | ✅ | ❌ | ✅\r\nUser-defined row height |
✅ | ❌ | ❌\r\nexternal pagination control (enables Flyout pagination) | ❌
| ✅ | ✅\r\nuser-defined column renaming | ✅ (using DataViews) | ❌ |
❌\r\n\r\n\r\n### Regressions\r\n\r\nThere are some regressions such as
losing the ability to paginate on the\r\nFlyout and the table pagination
is no longer controlled by URL params,\r\nthat's because pagination is
controlled by an internal state in the\r\n`<UnifiedDataTable/>`
component, and we plan to re-enable those features\r\nagain in the
future by contributing to the
`<UnifiedDataTable/>`\r\ncomponent.\r\n\r\n###
Screenshots\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/19270322/a0d1f95a-adcc-4e58-9d3e-0adec3df8b3b)\r\n\r\n###
Videos\r\n\r\nBasic Features +
Virtualization\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1a61592-e1ae-4baf-9610-3e24c473c17d\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/d8e6106c-0ca3-4277-b78b-5ca482095ae1\r\n\r\n\r\nDataView
integration\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/0d583243-bb86-45e4-baa5-dc63253da8f6\r\n\r\nRow
Height
Control\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1d43609-7c8a-4855-ab2f-624c18663579\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Jordan
<[email protected]>","sha":"8d5dfafd8d06cc3096f9b72325032510aa498eab"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167587","number":167587,"mergeCommit":{"message":"[Cloud
Security] CloudSecurityDataTable component (#167587)\n\n##
Summary\r\n\r\nThis PR introduces the Cloud Security DataTable
component, meant to\r\nreplace and consolidate the tables used in the
Cloud Security plugin\r\n\r\nThe CloudSecurityDataTable component is a
wrapper over the\r\n`<UnifiedDataTable/>` component. We made that
decision based on the\r\nnumber of features it provides for the users
plus support from the most\r\ncommon features such as Flyout, Sort,
Filtering, and Pagination to the\r\nmost advanced features like
Virtualization and DataView integration.\r\n\r\n- **Virtualization**:
Thanks to Virtualization, users can fetch more\r\ndata on the table than
the limit of `500`, and also use larger items per\r\npage if
desired.\r\n- **DataView integration**: This option allows users to
rename Columns\r\nas needed by setting custom labels in the
DataView.\r\n- **Column control**: Users can move columns and resize it
as needed,\r\nand that settings is saved on the local storage.\r\n-
**Row Height control**: Users can modify in the Advanced Settings
->\r\n`discover:rowHeight` the height of the row.\r\n\r\nBelow is a
Matrix comparing the features between the current Findings\r\ntable, the
Vulnerabilities Data Grid and the new
CloudSecurityDataTable.\r\n\r\nFeature | CloudSecurity DataTable (new >=
8.11) | Findings Table\r\n(current <= 8.10) | Vulnerabilities Data Grid
(current <= 8.10)\r\n-- | -- | -- | --\r\nTooltip on Cell Hover | ❌ | ✅
| ❌\r\nColumn Sorting | ✅ | ✅ | ✅\r\nMulti Column Sorting | ✅ | ❌ |
✅\r\nColumn filtering | ✅ | ✅ | ✅\r\nPagination | ✅ | ✅ | ✅\r\nRows per
page | ✅ | ✅ | ✅\r\nVirtualization (Support to load more data) | ✅ | ❌ |
❌\r\nCustom component on Column Header | ❌ (only custom text) | ✅ |
❌\r\nAdditional controls on the left | ✅ | ❌ | ✅\r\nText truncation | ✅
| ✅ | ✅\r\nOverride Style |
✅ (#166994) | ✅ |\r\n✅\r\nLoad
more button | ✅ | ❌ | ❌\r\nResize column | ✅ | ❌ | ✅\r\nReorder column |
✅ | ❌ | ✅\r\nFullScreen button | ✅ | ❌ | ✅\r\nUser-defined row height |
✅ | ❌ | ❌\r\nexternal pagination control (enables Flyout pagination) | ❌
| ✅ | ✅\r\nuser-defined column renaming | ✅ (using DataViews) | ❌ |
❌\r\n\r\n\r\n### Regressions\r\n\r\nThere are some regressions such as
losing the ability to paginate on the\r\nFlyout and the table pagination
is no longer controlled by URL params,\r\nthat's because pagination is
controlled by an internal state in the\r\n`<UnifiedDataTable/>`
component, and we plan to re-enable those features\r\nagain in the
future by contributing to the
`<UnifiedDataTable/>`\r\ncomponent.\r\n\r\n###
Screenshots\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/19270322/a0d1f95a-adcc-4e58-9d3e-0adec3df8b3b)\r\n\r\n###
Videos\r\n\r\nBasic Features +
Virtualization\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1a61592-e1ae-4baf-9610-3e24c473c17d\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/d8e6106c-0ca3-4277-b78b-5ca482095ae1\r\n\r\n\r\nDataView
integration\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/0d583243-bb86-45e4-baa5-dc63253da8f6\r\n\r\nRow
Height
Control\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/19270322/b1d43609-7c8a-4855-ab2f-624c18663579\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Jordan
<[email protected]>","sha":"8d5dfafd8d06cc3096f9b72325032510aa498eab"}}]}]
BACKPORT-->

Co-authored-by: Paulo Henrique <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:UnifiedDataTable release_note:skip Skip the PR/issue when compiling release notes v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UnifiedDataTable] Add gridStyle override support
5 participants