-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover Tabs] Extend the discover locator to allow opening in a new tab #234912
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
Conversation
…ing saved search" This reverts commit 42f403d.
| if (searchSessionId) { | ||
| newDefaultTab.dataRequestParams = { | ||
| ...newDefaultTab.dataRequestParams, | ||
| searchSessionId, |
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.
It would still need additional handling to sync it to the search session manager.
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 PR extends the Discover locator to support opening searches in new tabs by adding tabId and tabLabel parameters. When tabId is set to "new", it signals to create a new Discover tab with the specified configuration.
Key changes:
- Added
NEW_TAB_IDconstant and tab-related parameters to the locator interface - Implemented logic to handle new tab creation via URL parameters
- Added
openInNewTabRedux action for programmatic tab creation - Updated search session management to optionally open restored sessions in new tabs
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/platform/plugins/shared/discover/common/constants.ts |
Added NEW_TAB_ID constant and updated TABS_STATE_URL_KEY |
src/platform/plugins/shared/discover/common/app_locator.ts |
Extended locator interface with tabId and tabLabel parameters |
src/platform/plugins/shared/discover/common/app_locator_get_location.ts |
Added URL state handling for tab parameters |
src/platform/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts |
Implemented new tab creation logic and URL state management |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/actions/tabs.ts |
Added openInNewTab action and updated tab restoration logic |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/index.ts |
Exported new openInNewTab action |
src/platform/plugins/shared/discover/public/application/main/state_management/redux/internal_state.test.ts |
Added test coverage for the new tab functionality |
src/platform/plugins/shared/discover/public/application/main/state_management/hooks/use_state_managers.ts |
Updated comments to reflect correct URL parameter name |
src/platform/plugins/shared/discover/public/application/main/components/top_nav/app_menu_actions/get_share.tsx |
Added TODO comment for future tab ID integration |
src/platform/plugins/shared/discover/common/app_locator.test.ts |
Added test cases for new tab functionality |
src/platform/plugins/shared/data/public/search/session/sessions_mgmt/components/table/utils/map_to_ui_session.ts |
Added support for opening search sessions in new tabs |
src/platform/plugins/shared/data/public/search/session/sessions_mgmt/components/table/table.tsx |
Added feature flag check for new tab functionality |
...orm/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts
Show resolved
Hide resolved
...tform/plugins/shared/discover/public/application/main/state_management/redux/actions/tabs.ts
Show resolved
Hide resolved
…tate_management/tabs_storage_manager.ts Co-authored-by: Copilot <[email protected]>
…tate_management/redux/actions/tabs.ts Co-authored-by: Copilot <[email protected]>
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
| ); | ||
| const enableOpeningInNewTab = useMemo( | ||
| () => | ||
| core.featureFlags.getBooleanValue(BACKGROUND_SEARCH_FEATURE_FLAG_KEY, false) && |
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.
nit: do we need to check both feature flags for this?
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.
@AlexGPlay Good question! How would you recommend to change it?
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.
i was thinking that maybe the tabs one is enough since it's the feature this is truly targeting, wdyt?
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.
Updated in 1f6aa3d
AlexGPlay
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.
tested from a bgs perspective and lgtm 🚀
dej611
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.
@elastic/kibana-visualizations code review 👍
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.
Code changes LGTM, also tested locally and it seems to work as expected! Left some minor feedback, but nothing blocking.
Thanks for adding the expected outcome matrix to the summary, it helped a lot with testing. I agree it would be best to use the Redux action for restoring background searches within the flyout (not sure it'll make it for 9.2 though).
The expected outcomes are fairly complex, but I'm not sure what else you could have done here either given the current background search implementation. We'll at least have the unsaved changes modal and recently closed tabs to limit the impact for 9.2.
We should continue discussing this either async or in the office hours this Thursday, but I think we're good to merge the current implementation for now. If we figure out a way to resolve the conflicts better, IMO it could be treated as a fix and backported to 9.2 post FF.
| refreshInterval, | ||
| }; | ||
|
|
||
| // TODO: for a persisted saved search, add the current tab ID to the params |
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.
Probably worth creating an issue for this one if we don't do it in this PR, since we should do it for 9.2. Could be a good smaller task for one of the newer team members.
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.
Created #235320
...tform/plugins/shared/discover/public/application/main/state_management/redux/actions/tabs.ts
Show resolved
Hide resolved
| ); | ||
| }); | ||
|
|
||
| it('should append a new tab to the tabs list', async () => { |
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 adding a unit test here! Would have liked to add more of these initially if I wasn't rushing through so much of it early on 🙂
...orm/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts
Show resolved
Hide resolved
jughosta
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 reviews, @davismcphee and @AlexGPlay!
Updated the code.
...tform/plugins/shared/discover/public/application/main/state_management/redux/actions/tabs.ts
Show resolved
Hide resolved
| ); | ||
| const enableOpeningInNewTab = useMemo( | ||
| () => | ||
| core.featureFlags.getBooleanValue(BACKGROUND_SEARCH_FEATURE_FLAG_KEY, false) && |
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.
Updated in 1f6aa3d
...orm/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts
Show resolved
Hide resolved
| refreshInterval, | ||
| }; | ||
|
|
||
| // TODO: for a persisted saved search, add the current tab ID to the params |
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.
Created #235320
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
History
cc @jughosta |
… tab (elastic#234912) - Closes elastic#230829 ## Summary This PR extends the Discover locator with a new param `tabId` (and `tabLabel`). Passing `new` value to it will signal to open the search in a new Discover tab. | Was a persisted Discover Session (A) open when a search session was triggered? | Was user previously viewing a persisted Discover session (B) in Discover | Outcome after opening a search session link from Stack Management | | ------------- | ------------- | ------------- | | no | no | non-persisted Discover session | | no | yes | non-persisted Discover session (previous tabs cleared) | | yes | no | the persisted Discover session A (previous tabs cleared) | | yes | yes (A discover session Id is the same as B) | the persisted Discover session A | | yes | yes (A discover session Id is different from B) | the persisted Discover session A (previous tabs cleared) | Let me know if it's too complex or you have ideas on how to append to a persisted session tabs without reseting previous tabs. The main problem comes from the fact that it also depends from where you saved a search session: it might include the notion of `savedSearchId` and it might not => this result in getting either `/view/<saved search id>?searchSessionId=<id>` route or `/?searchSessionId=<id>`. And Discover reacts to saved search id value in URL. From the other side tabs gets cleared if ids don't match https://github.com/elastic/kibana/blob/17f697055f699438ca84eae3c0230a54d4ad8170/src/platform/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts#L393-L396 (non-persisted Discover session means no id). Additionally, this PR adds `openInNewTab` redux action. I think we should use it from Background Search flyout as it would append to tabs without the mentioned problems. ### Checklist - [x] [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 - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Copilot <[email protected]>
… tab (#234912) - Closes #230829 ## Summary This PR extends the Discover locator with a new param `tabId` (and `tabLabel`). Passing `new` value to it will signal to open the search in a new Discover tab. | Was a persisted Discover Session (A) open when a search session was triggered? | Was user previously viewing a persisted Discover session (B) in Discover | Outcome after opening a search session link from Stack Management | | ------------- | ------------- | ------------- | | no | no | non-persisted Discover session | | no | yes | non-persisted Discover session (previous tabs cleared) | | yes | no | the persisted Discover session A (previous tabs cleared) | | yes | yes (A discover session Id is the same as B) | the persisted Discover session A | | yes | yes (A discover session Id is different from B) | the persisted Discover session A (previous tabs cleared) | Let me know if it's too complex or you have ideas on how to append to a persisted session tabs without reseting previous tabs. The main problem comes from the fact that it also depends from where you saved a search session: it might include the notion of `savedSearchId` and it might not => this result in getting either `/view/<saved search id>?searchSessionId=<id>` route or `/?searchSessionId=<id>`. And Discover reacts to saved search id value in URL. From the other side tabs gets cleared if ids don't match https://github.com/elastic/kibana/blob/17f697055f699438ca84eae3c0230a54d4ad8170/src/platform/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts#L393-L396 (non-persisted Discover session means no id). Additionally, this PR adds `openInNewTab` redux action. I think we should use it from Background Search flyout as it would append to tabs without the mentioned problems. ### Checklist - [x] [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 - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Copilot <[email protected]>
… tab (elastic#234912) - Closes elastic#230829 ## Summary This PR extends the Discover locator with a new param `tabId` (and `tabLabel`). Passing `new` value to it will signal to open the search in a new Discover tab. | Was a persisted Discover Session (A) open when a search session was triggered? | Was user previously viewing a persisted Discover session (B) in Discover | Outcome after opening a search session link from Stack Management | | ------------- | ------------- | ------------- | | no | no | non-persisted Discover session | | no | yes | non-persisted Discover session (previous tabs cleared) | | yes | no | the persisted Discover session A (previous tabs cleared) | | yes | yes (A discover session Id is the same as B) | the persisted Discover session A | | yes | yes (A discover session Id is different from B) | the persisted Discover session A (previous tabs cleared) | Let me know if it's too complex or you have ideas on how to append to a persisted session tabs without reseting previous tabs. The main problem comes from the fact that it also depends from where you saved a search session: it might include the notion of `savedSearchId` and it might not => this result in getting either `/view/<saved search id>?searchSessionId=<id>` route or `/?searchSessionId=<id>`. And Discover reacts to saved search id value in URL. From the other side tabs gets cleared if ids don't match https://github.com/elastic/kibana/blob/17f697055f699438ca84eae3c0230a54d4ad8170/src/platform/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts#L393-L396 (non-persisted Discover session means no id). Additionally, this PR adds `openInNewTab` redux action. I think we should use it from Background Search flyout as it would append to tabs without the mentioned problems. ### Checklist - [x] [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 - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Copilot <[email protected]>
Summary
This PR extends the Discover locator with a new param
tabId(andtabLabel). Passingnewvalue to it will signal to open the search in a new Discover tab.Let me know if it's too complex or you have ideas on how to append to a persisted session tabs without reseting previous tabs.
The main problem comes from the fact that it also depends from where you saved a search session: it might include the notion of
savedSearchIdand it might not => this result in getting either/view/<saved search id>?searchSessionId=<id>route or/?searchSessionId=<id>. And Discover reacts to saved search id value in URL.From the other side tabs gets cleared if ids don't match
kibana/src/platform/plugins/shared/discover/public/application/main/state_management/tabs_storage_manager.ts
Lines 393 to 396 in 17f6970
Additionally, this PR adds
openInNewTabredux action. I think we should use it from Background Search flyout as it would append to tabs without the mentioned problems.Checklist
release_note:*label is applied per the guidelinesbackport:*labels.