-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discover][ES|QL] No legacy table for ES|QL mode #180370
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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
24 changes: 24 additions & 0 deletions
24
packages/kbn-discover-utils/src/utils/is_legacy_table_enabled.ts
This file contains 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,24 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; | ||
import { DOC_TABLE_LEGACY } from '../constants'; | ||
|
||
export function isLegacyTableEnabled({ | ||
uiSettings, | ||
isTextBasedQueryMode, | ||
}: { | ||
uiSettings: IUiSettingsClient; | ||
isTextBasedQueryMode: boolean; | ||
}): boolean { | ||
if (isTextBasedQueryMode) { | ||
return false; // only show the new data grid | ||
} | ||
|
||
return uiSettings.get(DOC_TABLE_LEGACY); | ||
} |
This file contains 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 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -10,9 +10,10 @@ import React, { useState } from 'react'; | |||||
import { i18n } from '@kbn/i18n'; | ||||||
import { EuiFormRow, EuiSwitch } from '@elastic/eui'; | ||||||
import { FormattedMessage } from '@kbn/i18n-react'; | ||||||
import { isOfAggregateQueryType } from '@kbn/es-query'; | ||||||
import { SavedObjectSaveModal, showSaveModal, OnSaveProps } from '@kbn/saved-objects-plugin/public'; | ||||||
import { SavedSearch, SaveSavedSearchOptions } from '@kbn/saved-search-plugin/public'; | ||||||
import { DOC_TABLE_LEGACY } from '@kbn/discover-utils'; | ||||||
import { isLegacyTableEnabled } from '@kbn/discover-utils'; | ||||||
import { DiscoverServices } from '../../../../build_services'; | ||||||
import { DiscoverStateContainer } from '../../services/discover_state'; | ||||||
import { getAllowedSampleSize } from '../../../../utils/get_allowed_sample_size'; | ||||||
|
@@ -123,7 +124,10 @@ export async function onSaveSearch({ | |||||
savedSearch.title = newTitle; | ||||||
savedSearch.description = newDescription; | ||||||
savedSearch.timeRestore = newTimeRestore; | ||||||
savedSearch.rowsPerPage = uiSettings.get(DOC_TABLE_LEGACY) | ||||||
savedSearch.rowsPerPage = isLegacyTableEnabled({ | ||||||
uiSettings, | ||||||
isTextBasedQueryMode: isOfAggregateQueryType(savedSearch.searchSource.getField('query')), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Nit: similar suggestion here |
||||||
}) | ||||||
? currentRowsPerPage | ||||||
: state.appState.getState().rowsPerPage; | ||||||
|
||||||
|
This file contains 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 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 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 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 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,95 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const kibanaServer = getService('kibanaServer'); | ||
const testSubjects = getService('testSubjects'); | ||
const security = getService('security'); | ||
const dataGrid = getService('dataGrid'); | ||
const dashboardAddPanel = getService('dashboardAddPanel'); | ||
const dashboardPanelActions = getService('dashboardPanelActions'); | ||
const PageObjects = getPageObjects([ | ||
'common', | ||
'discover', | ||
'dashboard', | ||
'header', | ||
'timePicker', | ||
'unifiedFieldList', | ||
]); | ||
|
||
const defaultSettings = { | ||
defaultIndex: 'logstash-*', | ||
'doc_table:legacy': true, | ||
}; | ||
|
||
describe('discover esql grid with legacy setting', async function () { | ||
before(async () => { | ||
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); | ||
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); | ||
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.uiSettings.replace(defaultSettings); | ||
await PageObjects.common.navigateToApp('discover'); | ||
await PageObjects.timePicker.setDefaultAbsoluteRange(); | ||
}); | ||
|
||
after(async () => { | ||
await kibanaServer.savedObjects.cleanStandardList(); | ||
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); | ||
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.uiSettings.replace({}); | ||
}); | ||
|
||
it('should render esql view correctly', async function () { | ||
const savedSearchESQL = 'testESQLWithLegacySetting'; | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.discover.waitUntilSearchingHasFinished(); | ||
|
||
await testSubjects.existOrFail('docTableHeader'); | ||
await testSubjects.missingOrFail('euiDataGridBody'); | ||
|
||
await PageObjects.discover.selectTextBaseLang(); | ||
|
||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.discover.waitUntilSearchingHasFinished(); | ||
|
||
await testSubjects.missingOrFail('docTableHeader'); | ||
await testSubjects.existOrFail('euiDataGridBody'); | ||
|
||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
|
||
await testSubjects.existOrFail('docTableDetailsFlyout'); | ||
|
||
await PageObjects.discover.saveSearch(savedSearchESQL); | ||
|
||
await PageObjects.common.navigateToApp('dashboard'); | ||
await PageObjects.dashboard.clickNewDashboard(); | ||
await PageObjects.timePicker.setDefaultAbsoluteRange(); | ||
await dashboardAddPanel.clickOpenAddPanel(); | ||
await dashboardAddPanel.addSavedSearch(savedSearchESQL); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
|
||
await testSubjects.missingOrFail('docTableHeader'); | ||
await testSubjects.existOrFail('euiDataGridBody'); | ||
|
||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
|
||
await testSubjects.existOrFail('docTableDetailsFlyout'); | ||
|
||
await dashboardPanelActions.removePanelByTitle(savedSearchESQL); | ||
|
||
await dashboardAddPanel.addSavedSearch('A Saved Search'); | ||
|
||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await testSubjects.existOrFail('docTableHeader'); | ||
await testSubjects.missingOrFail('euiDataGridBody'); | ||
}); | ||
}); | ||
} |
This file contains 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 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
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.
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: I know this was just moved up a couple of lines, but it might be a good opportunity to switch to the
isTextBasedQuery
util fromsrc/plugins/discover/public/application/main/utils/is_text_based_query.ts
.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.
Tbh I think we should delete
isTextBasedQuery
discover wrapper and useisOfAggregateQueryType
directly instead.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.
@davismcphee
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.
That would work for me too, my main concern is really just around consistency in the utils we use. Personally I find
isOfAggregateQueryType
harder to grok thanisTextBasedQuery
sinceaggregate query
is an unclear term to me, but that's more of a nit than anything as long as we're consistent.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.
Something for a later cleanup. I would like minimize extra refactoring shortly before FF as it's unrelated to the current ticket.