Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DASHBOARD_PANEL_GROUP_ORDER = [
'legacyGroup',
];

const DASHBOARD_PANEL_TYPE_COUNT = 24;
const DASHBOARD_PANEL_TYPE_COUNT = 25;

spaceTest.describe(
'Dashboard panel listing (includes observability group)',
Expand Down
9 changes: 8 additions & 1 deletion src/platform/plugins/shared/discover/public/plugin.tsx
Comment thread
Bluefinger marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
import { i18n } from '@kbn/i18n';
import { once } from 'lodash';
import { DISCOVER_ESQL_LOCATOR } from '@kbn/deeplinks-analytics';
import { ON_OPEN_PANEL_MENU } from '@kbn/ui-actions-plugin/common/trigger_ids';
import { ADD_PANEL_TRIGGER, ON_OPEN_PANEL_MENU } from '@kbn/ui-actions-plugin/common/trigger_ids';
import type { DrilldownTransforms } from '@kbn/embeddable-plugin/common';
import { ProjectRoutingAccess } from '@kbn/cps-utils';
import { DISCOVER_APP_LOCATOR, PLUGIN_ID, type DiscoverAppLocator } from '../common';
Expand Down Expand Up @@ -248,6 +248,13 @@ export class DiscoverPlugin
}
);

plugins.uiActions.registerActionAsync('addDiscoverByValuePanelAction', async () => {
Comment thread
Bluefinger marked this conversation as resolved.
Outdated
const { getAddDiscoverByValuePanelAction } = await import('./plugin_imports/ui_actions');
Comment thread
Bluefinger marked this conversation as resolved.
Outdated
return getAddDiscoverByValuePanelAction(this.locator!, plugins);
});

plugins.uiActions.attachAction(ADD_PANEL_TRIGGER, 'addDiscoverByValuePanelAction');

const isEsqlEnabled = core.uiSettings.get(ENABLE_ESQL);

if (plugins.share && this.locator && isEsqlEnabled) {
Expand Down
Comment thread
Bluefinger marked this conversation as resolved.
Outdated
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,
Comment thread
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',
Comment thread
davismcphee marked this conversation as resolved.
Outdated
}),
sort: [],
columns: [],
isTextBasedQuery: true,
grid: {},
hideChart: false,
serializedSearchSource: {},
};

stateTransfer.navigateToEditor(app, {
path,
state: {
valueInput,
originatingApp: apiHasAppContext(embeddable)
Comment thread
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: () => '',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
]);

// Any changes to the number of panels needs to be audited by @elastic/kibana-presentation
expect(panelTypes.length).to.eql(14);
expect(panelTypes.length).to.eql(15);
});
});
}
Comment thread
davismcphee marked this conversation as resolved.
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',
});
Comment thread
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']);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./multiple_data_views'));
loadTestFile(require.resolve('./_log_stream_embeddable.ts'));
loadTestFile(require.resolve('./_esql_embeddable.ts'));
loadTestFile(require.resolve('./_new_panel_embeddable.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export class DashboardAddPanelService extends FtrService {
await this.clickAddNewPanelFromUIActionLink('ES|QL');
}

async clickAddDiscoverPanel() {
this.log.debug('DashboardAddPanel.clickAddDiscoverPanel');
await this.openAddPanelFlyout();
await this.clickAddNewPanelFromUIActionLink('Discover session');
}

async openAddPanelFlyout() {
this.log.debug('DashboardAddPanel.openAddPanelFlyout');
await this.clickTopNavAddMenu();
Expand Down
Loading