[Discover] Initial tabs implementation (disabled in main) (#214861)

## Summary

This PR restructures Discover's state management to support tabs as
outlined in #215398, including the Redux store and
`RuntimeStateManager`. It also adds the initial tabs implementation to
the UI to start building on, but they're disabled by default with a
hardcoded flag. Tabs can be enabled by setting `TABS_ENABLED = true` in
`discover_main_route`, but they don't need to be thoroughly tested in
this PR since most of the functionality is incomplete.

There's also a flaw in the state management approach with `currentId`
since depending on it can cause state to leak across tabs when switching
tabs during async operations (e.g. data fetching). This shouldn't be an
issue while tabs are disabled, and there will be a followup PR #215620
to address it.


https://github.com/user-attachments/assets/ebbb9fa7-a3bc-4e82-9b5c-0d29cd0575f0

Part of #215398.

### Checklist

- [ ] 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
- [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)
This commit is contained in:
Davis McPhee 2025-03-28 15:38:53 -03:00 committed by GitHub
parent 2cd777d969
commit 0bb73eec2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 775 additions and 314 deletions

View file

@ -240,9 +240,10 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
ControlGroupRendererApi | undefined
>();
const stateStorage = stateContainer.stateStorage;
const currentTabId = stateContainer.internalState.getState().tabs.currentId;
const dataView = useObservable(
stateContainer.runtimeStateManager.currentDataView$,
stateContainer.runtimeStateManager.currentDataView$.getValue()
stateContainer.runtimeStateManager.tabs.byId[currentTabId].currentDataView$,
stateContainer.runtimeStateManager.tabs.byId[currentTabId].currentDataView$.getValue()
);
useEffect(() => {