Skip to content

Commit

Permalink
Fix the FT
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Oct 17, 2024
1 parent fa41916 commit 569bb1d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,29 @@ export const DashboardAppNoDataPage = ({
}, [lensService]);

const onTryESQL = useCallback(async () => {
const { dataViews } = dataService;
const indexName = (await getIndexForESQLQuery({ dataViews })) ?? '*';
const dataView = await getESQLAdHocDataview(`from ${indexName}`, dataViews);
const esqlQuery = getInitialESQLQuery(dataView);
const abortController = new AbortController();
const columns = await getESQLQueryColumns({
esqlQuery,
search: dataService.search.search,
signal: abortController.signal,
timeRange: dataService.query.timefilter.timefilter.getAbsoluteTime(),
});

const context = {
dataViewSpec: dataView?.toSpec(false),
fieldName: '',
textBasedColumns: columns,
query: { esql: esqlQuery },
};

if (lensHelpersAsync.value) {
const chartSuggestions = lensHelpersAsync.value.suggestions(context, dataView, []);
const { dataViews } = dataService;
const indexName = (await getIndexForESQLQuery({ dataViews })) ?? '*';
const dataView = await getESQLAdHocDataview(`from ${indexName}`, dataViews);
const esqlQuery = getInitialESQLQuery(dataView);
const abortController = new AbortController();

const columns = await getESQLQueryColumns({
esqlQuery,
search: dataService.search.search,
signal: abortController.signal,
timeRange: dataService.query.timefilter.timefilter.getAbsoluteTime(),
});

// lens suggestions api context
const context = {
dataViewSpec: dataView?.toSpec(false),
fieldName: '',
textBasedColumns: columns,
query: { esql: esqlQuery },
};

const chartSuggestions = lensHelpersAsync.value.suggestions(context, dataView);
if (chartSuggestions?.length) {
const [suggestion] = chartSuggestions;

Expand Down Expand Up @@ -112,6 +114,7 @@ export const DashboardAppNoDataPage = ({
}
}
}, [lensHelpersAsync.value]);

const AnalyticsNoDataPage = withSuspense(
React.lazy(() =>
importPromise.then(({ AnalyticsNoDataPage: NoDataPage }) => {
Expand Down
14 changes: 10 additions & 4 deletions test/functional/apps/dashboard/group6/dashboard_esql_no_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* 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 { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const esql = getService('esql');
const PageObjects = getPageObjects(['discover', 'dashboard']);
const panelActions = getService('dashboardPanelActions');
const monacoEditor = getService('monacoEditor');
const PageObjects = getPageObjects(['dashboard']);

describe('No Data Views: Try ES|QL', () => {
before(async () => {
Expand All @@ -26,8 +28,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await testSubjects.existOrFail('noDataViewsPrompt');
await testSubjects.click('tryESQLLink');

await PageObjects.discover.expectOnDiscover();
await esql.expectEsqlStatement('FROM logs* | LIMIT 10');
await PageObjects.dashboard.expectOnDashboard('New Dashboard');
expect(await testSubjects.exists('lnsVisualizationContainer')).to.be(true);

await panelActions.clickInlineEdit();
const editorValue = await monacoEditor.getCodeEditorValue();
expect(editorValue).to.eql(`FROM logs* | LIMIT 10`);
});
});
}

0 comments on commit 569bb1d

Please sign in to comment.