-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover] Tab scoped retainable flyout #246612
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
[Discover] Tab scoped retainable flyout #246612
Conversation
davismcphee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the right direction to me!
In fact, if we can get it to a point where the doc viewer remains open when switching back to a Discover tab and defaults to the last doc viewer tab, that's probably enough for an initial PR. Then we could tackle the full state restoration piece as a followup since it'll be more complicated.
To default to the last doc viewer tab when switching Discover tabs, we may have to set initialDocViewerTabId when switching tabs or similar. Otherwise it may just default to the last doc viewer tab from local storage.
...orm/plugins/shared/discover/public/application/main/state_management/redux/internal_state.ts
Show resolved
Hide resolved
...orm/plugins/shared/discover/public/application/main/state_management/redux/selectors/tabs.ts
Outdated
Show resolved
Hide resolved
|
@davismcphee thanks for the review! I've addressed code comments and I'll work on doc viewer tab now |
|
/ci |
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#10383[✅] src/platform/test/functional/apps/discover/tabs/config.ts: 75/75 tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors the expanded document state management in Discover to be tab-scoped rather than global. The main purpose is to maintain separate document viewer states (including flyout open state and selected doc viewer tab) for each Discover tab, allowing users to switch between tabs without losing their document viewer context.
Changes:
- Moved
expandedDocandinitialDocViewerTabIdfrom global state to per-tab state in Redux store - Added
onUpdateSelectedTabIdcallback to document viewer components to track selected doc viewer tabs - Updated all dispatches of
setExpandedDocto includetabIdparameter for tab-scoped state management
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/platform/plugins/shared/discover/public/application/main/state_management/redux/types.ts |
Moved expandedDoc and initialDocViewerTabId from global DiscoverInternalState to per-tab TabState |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/internal_state.ts |
Changed setExpandedDoc to use TabAction and removed discardFlyoutsOnTabChange from slice actions |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/constants.ts |
Added expandedDoc: undefined to default tab state |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/actions/tabs.ts |
Updated to use new discardFlyoutsOnTabChange action creator |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/actions/data_views.ts |
Updated setExpandedDoc dispatch to include tabId parameter |
src/platform/plugins/shared/discover/public/application/main/state_management/utils/change_data_view.ts |
Updated to access expandedDoc from current tab instead of global state |
src/platform/plugins/shared/discover/public/application/main/hooks/use_inspector.ts |
Updated setExpandedDoc dispatches to include currentTabId parameter |
src/platform/plugins/shared/discover/public/application/main/components/layout/discover_documents.tsx |
Added tab selection tracking with useUnmount hook and updated to use tab-scoped state selectors |
src/platform/plugins/shared/discover/public/components/discover_grid_flyout/discover_grid_flyout.tsx |
Added onUpdateSelectedTabId prop to component interface |
src/platform/plugins/shared/unified_doc_viewer/public/components/doc_viewer_flyout/doc_viewer_flyout.tsx |
Added onUpdateSelectedTabId prop and passed it through to doc viewer |
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts |
Added onUpdateSelectedTabId callback to DocViewRenderProps interface |
src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.tsx |
Implemented onUpdateSelectedTabId callback invocation and updated tab key generation |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/internal_state.test.ts |
Added comprehensive unit tests for tab-scoped expanded doc state management |
src/platform/plugins/shared/discover/public/application/main/hooks/use_inspector.test.tsx |
Updated test to work with tab-scoped state |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/tab_mapping_utils.test.ts |
Updated test snapshots to include new expandedDoc field |
src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.test.tsx |
Added tests for initialTabId priority and onUpdateSelectedTabId callback |
src/platform/test/functional/apps/discover/tabs/_on_tab_change.ts |
Updated functional test to verify tab-scoped flyout state retention |
...orm/plugins/shared/discover/public/application/main/components/layout/discover_documents.tsx
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good and it worked well when testing! Left a bit of minor feedback, but otherwise this looks good on my end.
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
...orm/plugins/shared/discover/public/application/main/components/layout/discover_documents.tsx
Outdated
Show resolved
Hide resolved
src/platform/plugins/shared/discover/public/application/main/hooks/use_inspector.ts
Outdated
Show resolved
Hide resolved
...lugins/shared/discover/public/application/main/state_management/redux/internal_state.test.ts
Outdated
Show resolved
Hide resolved
src/platform/test/functional/apps/discover/tabs/_on_tab_change.ts
Outdated
Show resolved
Hide resolved
src/platform/test/functional/apps/discover/tabs/_on_tab_change.ts
Outdated
Show resolved
Hide resolved
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]
History
|
davismcphee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, LGTM!
src/platform/plugins/shared/discover/public/application/main/hooks/use_inspector.ts
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
## Summary A-la-carte: https://akowalska622-pr-246612-retainable-flyout-poc.kbndev.co/ This pull request refactors how the expanded document state and the selected tab in the document viewer are managed in Discover. The main improvement is that these states are now tracked per tab, rather than globally, which leads to more predictable and isolated behavior when working with multiple tabs. Additionally, the document viewer now provides an `onUpdateSelectedTabId` callback to notify parent components of tab changes, and the state is synchronized with localStorage and Redux accordingly. ### Visuals The flyout open state should be scoped to the tab and remain intact while switching tabs. Example: user has 2 or more tabs open. They open a flyout in tab A, then switch to tab B and come back to tab A. The flyout in tab A should remain open.  Moreover, the tab selected within the doc viewer (e.g. `Table` or `JSON` — not to be confused with the Discover tab itself) should also be scoped to the Discover tab. Example: user has 2 or more tabs open. They open a flyout in tab A with the Table doc viewer tab selected. They then switch to tab B, open a flyout, and select the `JSON `doc viewer tab. When switching between tab A and tab B, the doc viewer tab selection should remain scoped to each respective tab.  ### 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: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
Summary
A-la-carte: https://akowalska622-pr-246612-retainable-flyout-poc.kbndev.co/
This pull request refactors how the expanded document state and the selected tab in the document viewer are managed in Discover. The main improvement is that these states are now tracked per tab, rather than globally, which leads to more predictable and isolated behavior when working with multiple tabs. Additionally, the document viewer now provides an
onUpdateSelectedTabIdcallback to notify parent components of tab changes, and the state is synchronized with localStorage and Redux accordingly.Visuals
The flyout open state should be scoped to the tab and remain intact while switching tabs.
Example: user has 2 or more tabs open. They open a flyout in tab A, then switch to tab B and come back to tab A. The flyout in tab A should remain open.
Moreover, the tab selected within the doc viewer (e.g.
TableorJSON— not to be confused with the Discover tab itself) should also be scoped to the Discover tab.Example: user has 2 or more tabs open. They open a flyout in tab A with the Table doc viewer tab selected. They then switch to tab B, open a flyout, and select the
JSONdoc viewer tab. When switching between tab A and tab B, the doc viewer tab selection should remain scoped to each respective tab.Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*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.