Skip to content

Commit 19f36ae

Browse files
eokoneyokibanamachineryankeairns
authored
Document cascade component implementation (elastic#226927)
## Summary Culled from elastic#220119, Closes elastic/kibana-team#1791 This PR extracts the generic data cascade component implementation into a standalone PR, This component allows displaying a large set of grouped data without loading the entire data set at once, only the starting point for the data is required, then the rest of the data is loaded on demand by the user, this component also employs virtualisations techniques so that regardless of the number of data being browsed by the user only the data the user is viewing is being rendered. Furthermore as much as this component is in a way a skeleton, it is opinionated about how data is fetched and because of this, the loading state and the UI element rendered during these states are also opinionated. This component exposes parts that are composed into the data cascade experience, like so; ```tsx <DataCascade {...dataCascadeProps}> <DataCascadeRow {...dataCascadeRowProps}> <DataCascadeRowCell {...dataCascadeRowCellProps}> {({ data }) => { // your cell component }} </DataCascadeRowCell> </DataCascadeRow> </DataCascade> ``` ### Testing - Spin up the shared ux storybook like so; `yarn storybook shared_ux`, then look for the data cascade component - Alternatively, you could use this [link](https://ci-artifacts.kibana.dev/storybooks/pr-226927/shared_ux/index.html?path=/docs/data-cascade-configuration-examples--docs) ### Visuals https://github.com/user-attachments/assets/d04cd77d-46df-425e-a3f3-e85798e6f0eb ## Accessibility - The defined spec for [tree grids ](https://www.w3.org/WAI/ARIA/apg/patterns/treegrid/) informed the existing approach to ensure that the same visual experience presented to users is translated to the accessibility tree generated. This work doesn't purport to fulfil all the expectations of a standard treegrid experience. ## Note for reviewer This PR is the preliminary PR for the data cascade component, to help land the cascade experience in discover, whilst there's a laundry list of functionality that the cascade component should support, already supports them for the most part, the goal of this PR is to land the component in Kibana with the base case for the cascade experience working. ## Note on new packages The `@tanstack/react-virtual` & `@tanstack/table` packages have been added to provide base functionality to manage virtualisation and data structuring respectively in the cascade component, whilst there already exist another package (react-window) that does virtualization in Kibana, it doesn't quite provide the same flexibility that `@tanstack/react-virtual` provides and has a much larger footprint, for this reason it was selected, and for what it's worth there's an ongoing exploration for deciding on the package we should default to for virtualization in Kibana, [see here](elastic#224197). <!-- ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Ryan Keairns <contactryank@gmail.com>
1 parent c2ab8cc commit 19f36ae

63 files changed

Lines changed: 6346 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.buildkite/scripts/steps/security/third_party_packages.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ canvas-confetti
1313
@types/canvas-confetti
1414
undici
1515
liquidjs
16+
@tanstack/react-table
17+
@tanstack/react-virtual
18+
@storybook/addon-docs

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ src/platform/packages/shared/shared-ux/card/no_data/mocks @elastic/appex-sharedu
663663
src/platform/packages/shared/shared-ux/card/no_data/types @elastic/appex-sharedux
664664
src/platform/packages/shared/shared-ux/code_editor/impl @elastic/appex-sharedux
665665
src/platform/packages/shared/shared-ux/code_editor/mocks @elastic/appex-sharedux
666+
src/platform/packages/shared/shared-ux/document_data_cascade/impl @elastic/appex-sharedux
666667
src/platform/packages/shared/shared-ux/error_boundary @elastic/appex-sharedux
667668
src/platform/packages/shared/shared-ux/feedback_snippet @elastic/appex-sharedux
668669
src/platform/packages/shared/shared-ux/file/context @elastic/appex-sharedux

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@
989989
"@kbn/shared-ux-button-toolbar": "link:src/platform/packages/shared/shared-ux/button_toolbar",
990990
"@kbn/shared-ux-card-no-data": "link:src/platform/packages/shared/shared-ux/card/no_data/impl",
991991
"@kbn/shared-ux-card-no-data-types": "link:src/platform/packages/shared/shared-ux/card/no_data/types",
992+
"@kbn/shared-ux-document-data-cascade": "link:src/platform/packages/shared/shared-ux/document_data_cascade/impl",
992993
"@kbn/shared-ux-error-boundary": "link:src/platform/packages/shared/shared-ux/error_boundary",
993994
"@kbn/shared-ux-feedback-snippet": "link:src/platform/packages/shared/shared-ux/feedback_snippet",
994995
"@kbn/shared-ux-file-context": "link:src/platform/packages/shared/shared-ux/file/context",
@@ -1192,6 +1193,8 @@
11921193
"@smithy/util-utf8": "^4.0.0",
11931194
"@tanstack/react-query": "^4.29.12",
11941195
"@tanstack/react-query-devtools": "^4.29.12",
1196+
"@tanstack/react-table": "^8.21.3",
1197+
"@tanstack/react-virtual": "^3.13.9",
11951198
"@turf/along": "6.0.1",
11961199
"@turf/area": "6.0.1",
11971200
"@turf/bbox": "6.0.1",

renovate.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,14 @@
723723
],
724724
"enabled": true,
725725
"minimumReleaseAge": "14 days"
726+
},{
727+
"groupName": "virtualized",
728+
"matchDepNames": ["@tanstack/react-table", "@tanstack/react-virtual"],
729+
"reviewers": ["team:appex-sharedux"],
730+
"matchBaseBranches": ["main"],
731+
"labels": ["Team:SharedUX", "release_note:skip", "backport:all-open"],
732+
"enabled": true,
733+
"minimumReleaseAge": "14 days"
726734
},
727735
{
728736
"groupName": "@reduxjs/toolkit",

src/platform/packages/private/shared-ux/storybook/config/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ module.exports = {
1414
stories: [
1515
'../../**/*.stories.+(tsx|mdx)',
1616
'../../../../shared/shared-ux/**/*.stories.+(tsx|mdx)',
17+
'../../../../shared/shared-ux/**/guide.mdx',
1718
'../../../../../../core/packages/chrome/**/*.stories.+(tsx|mdx)',
1819
],
20+
typescript: {
21+
reactDocgen: 'react-docgen-typescript',
22+
},
1923
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## @kbn/shared-ux-document-data-cascade
2+
3+
This package provides a React component and associated state management for displaying and interacting
4+
with hierarchical data in a tabular format. It is designed to be flexible and customizable,
5+
allowing developers to tailor the component to their specific needs.
6+
7+
## Usage
8+
9+
Here's a basic example of how to use the `DataCascade` component:
10+
11+
```tsx
12+
import { DataCascade, DataCascadeRow, DataCascadeRowCell } from '@kbn/shared-ux-document-data-cascade';
13+
14+
<DataCascade {...dataCascadeProps}>
15+
<DataCascadeRow {...dataCascadeRowProps}>
16+
<DataCascadeRowCell {...dataCascadeRowCellProps}>
17+
{({ data }) => {
18+
// your cell component
19+
}}
20+
</DataCascadeRowCell>
21+
</DataCascadeRow>
22+
</DataCascade>
23+
```
24+
25+
For more detailed usage instructions and examples, please refer to the storybook implementation.
26+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export { DataCascade, DataCascadeRow, DataCascadeRowCell } from './src/components';
11+
export type {
12+
GroupNode,
13+
LeafNode,
14+
DataCascadeProps,
15+
DataCascadeRowProps,
16+
DataCascadeRowCellProps,
17+
CascadeRowCellNestedVirtualizationAnchorProps,
18+
} from './src/components';
19+
export * from './src/lib';
20+
export { NumberBadge } from './src/components/helpers';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
module.exports = {
11+
preset: '@kbn/test',
12+
rootDir: '../../../../../../..',
13+
roots: ['<rootDir>/src/platform/packages/shared/shared-ux/document_data_cascade/impl'],
14+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "shared-common",
3+
"id": "@kbn/shared-ux-document-data-cascade",
4+
"owner": [
5+
"@elastic/appex-sharedux"
6+
],
7+
"group": "platform",
8+
"visibility": "shared"
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "@kbn/shared-ux-document-data-cascade",
3+
"private": true,
4+
"version": "1.0.0",
5+
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0",
6+
"sideEffects": false
7+
}

0 commit comments

Comments
 (0)