-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Discover][Embeddable] Add New Discover session for Dashboards #256293
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
Merged
Bluefinger
merged 14 commits into
elastic:main
from
Bluefinger:discover-dashboard-add-new-session
Mar 13, 2026
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f1630d
[Discover][Embeddable] Add New Discover session for Dashboards
Bluefinger 5234bd5
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger 1c12eb9
Add label for new session
Bluefinger bdbb4ae
Add initial pass at functional tests
Bluefinger 40ac12d
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger 5cd10ba
Update dashboard panel type count assertions
Bluefinger 4496413
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger 5406544
Refactor action, add cancel test
Bluefinger f4b142e
Better transfer API
Bluefinger cad5d6f
Don't forget resets
Bluefinger 259b249
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger db85bf2
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger 0615576
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger e205918
Merge branch 'main' into discover-dashboard-add-new-session
Bluefinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/platform/plugins/shared/discover/public/plugin_imports/ui_actions.ts
|
Bluefinger marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import { v4 as uuidv4 } from 'uuid'; | ||
| import { type EmbeddableApiContext, apiHasAppContext } from '@kbn/presentation-publishing'; | ||
| import { ADD_PANEL_VISUALIZATION_GROUP } from '@kbn/embeddable-plugin/public'; | ||
| import type { DiscoverSessionTab } from '@kbn/saved-search-plugin/common'; | ||
| import type { DiscoverStartPlugins } from '../types'; | ||
| import type { DiscoverAppLocator } from '../../common'; | ||
|
|
||
| export function getAddDiscoverByValuePanelAction( | ||
| locator: DiscoverAppLocator, | ||
| discoverServices: DiscoverStartPlugins | ||
| ) { | ||
| return { | ||
| id: 'addDiscoverByValuePanelAction', | ||
| getIconType: () => 'discoverApp', | ||
| order: 45, | ||
|
MiloszRadzynski marked this conversation as resolved.
Outdated
|
||
| isCompatible: async () => true, | ||
| execute: async ({ embeddable }: EmbeddableApiContext) => { | ||
| const { app, path } = await locator.getLocation({}); | ||
| const stateTransfer = discoverServices.embeddable.getStateTransfer(); | ||
|
|
||
| const valueInput: DiscoverSessionTab = { | ||
| id: uuidv4(), | ||
| label: i18n.translate('discover.uiActions.addPanel.byValueTabName', { | ||
| defaultMessage: 'New By-value Discover session', | ||
|
davismcphee marked this conversation as resolved.
Outdated
|
||
| }), | ||
| sort: [], | ||
| columns: [], | ||
| isTextBasedQuery: true, | ||
| grid: {}, | ||
| hideChart: false, | ||
| serializedSearchSource: {}, | ||
| }; | ||
|
|
||
| stateTransfer.navigateToEditor(app, { | ||
| path, | ||
| state: { | ||
| valueInput, | ||
| originatingApp: apiHasAppContext(embeddable) | ||
|
Bluefinger marked this conversation as resolved.
Outdated
|
||
| ? embeddable.getAppContext().currentAppId | ||
| : '', | ||
| originatingPath: apiHasAppContext(embeddable) | ||
| ? embeddable.getAppContext().getCurrentPath?.() | ||
| : undefined, | ||
| }, | ||
| }); | ||
| }, | ||
| grouping: [ADD_PANEL_VISUALIZATION_GROUP], | ||
| getDisplayName: () => | ||
| i18n.translate('discover.uiActions.addPanel.displayName', { | ||
| defaultMessage: 'Discover session', | ||
| }), | ||
| getDisplayNameTooltip: () => '', | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/platform/test/functional/apps/discover/embeddable/_new_panel_embeddable.ts
|
davismcphee marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import expect from '@kbn/expect'; | ||
| import type { FtrProviderContext } from '../ftr_provider_context'; | ||
|
|
||
| export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
| const dashboardAddPanel = getService('dashboardAddPanel'); | ||
| const filterBar = getService('filterBar'); | ||
| const queryBar = getService('queryBar'); | ||
| const esArchiver = getService('esArchiver'); | ||
| const kibanaServer = getService('kibanaServer'); | ||
| const testSubjects = getService('testSubjects'); | ||
| const globalNav = getService('globalNav'); | ||
| const { common, dashboard, header, discover } = getPageObjects([ | ||
| 'common', | ||
| 'dashboard', | ||
| 'header', | ||
| 'discover', | ||
| ]); | ||
|
|
||
| describe('new discover panel embeddable', () => { | ||
| before(async () => { | ||
| await esArchiver.loadIfNeeded( | ||
| 'src/platform/test/functional/fixtures/es_archiver/logstash_functional' | ||
| ); | ||
| await esArchiver.loadIfNeeded( | ||
| 'src/platform/test/functional/fixtures/es_archiver/dashboard/current/data' | ||
| ); | ||
| await kibanaServer.savedObjects.cleanStandardList(); | ||
| await kibanaServer.importExport.load( | ||
| 'src/platform/test/functional/fixtures/kbn_archiver/dashboard/current/kibana' | ||
| ); | ||
| await kibanaServer.uiSettings.replace({ | ||
| defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', | ||
| }); | ||
|
davismcphee marked this conversation as resolved.
|
||
| await common.setTime({ | ||
| from: 'Sep 22, 2015 @ 00:00:00.000', | ||
| to: 'Sep 23, 2015 @ 00:00:00.000', | ||
| }); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await kibanaServer.savedObjects.cleanStandardList(); | ||
| await common.unsetTime(); | ||
| }); | ||
|
|
||
| beforeEach(async () => { | ||
| await dashboard.navigateToApp(); | ||
| await filterBar.ensureFieldEditorModalIsClosed(); | ||
| await dashboard.gotoDashboardLandingPage(); | ||
| await dashboard.clickNewDashboard(); | ||
| }); | ||
|
|
||
| it('can add a new Discover session panel to the dashboard', async () => { | ||
| await dashboardAddPanel.clickAddDiscoverPanel(); | ||
| await header.waitUntilLoadingHasFinished(); | ||
| await Promise.all([ | ||
| globalNav | ||
| .getFirstBreadcrumb() | ||
| .then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Dashboards')), | ||
| discover | ||
| .getSavedSearchTitle() | ||
| .then((lastBreadcrumb) => | ||
| expect(lastBreadcrumb).to.be('Editing New By-value Discover session') | ||
| ), | ||
| testSubjects | ||
| .exists('unifiedTabs_tabsBar', { timeout: 1000 }) | ||
| .then((unifiedTabs) => expect(unifiedTabs).not.to.be(true)), | ||
| discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(true)), | ||
| ]); | ||
|
|
||
| await queryBar.setQuery('test'); | ||
| await queryBar.submitQuery(); | ||
| await discover.waitUntilTabIsLoaded(); | ||
| await discover.clickSaveSearchButton(); | ||
| await dashboard.waitForRenderComplete(); | ||
| await dashboard.verifyNoRenderErrors(); | ||
| expect(await discover.getAllSavedSearchDocumentCount()).to.eql(['13 documents']); | ||
| }); | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.