[Discover] [ES|QL] Disables sorting for Document view (#187553)

## Summary

Disables the `@timestamp` sorting for ES|QL Document view. 

The sorting doesnt work currently. I could enable it but this causes 2
problems:

- The fix is here
https://github.com/elastic/kibana/blob/main/packages/kbn-unified-data-table/src/components/data_table.tsx#L962
The timestamp column is a special column for Discover so the
columns.length is 0 here even if the timestamp column is being rendered.
As a result the inMemory is false and the client side sorting doesnt
work. Removing the columns.length fixes it but it makes Discover
significantly slower.
- As the data are not by default sorted by timestamp even if we enable
it client side, it won't be of great help. I think that for the
timestamp column it would be better to enable server side sorting but
this needs discussion

I think that hiding this for now it will fix the confusion and is a good
temporary decision before we decide what to do with sorting in general.
This commit is contained in:
Stratoula Kalafateli 2024-07-08 11:14:59 +02:00 committed by GitHub
parent e320935594
commit ab3c76dde0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -828,6 +828,12 @@ export const UnifiedDataTable = ({
const sorting = useMemo(() => {
if (isSortEnabled) {
// in ES|QL mode, sorting is disabled when in Document view
// ideally we want the @timestamp column to be sortable server side
// but it needs discussion before moving forward like this
if (isPlainRecord && !columns.length) {
return undefined;
}
return {
columns: sortingColumns,
onSort: onTableSort,
@ -837,7 +843,7 @@ export const UnifiedDataTable = ({
columns: sortingColumns,
onSort: () => {},
};
}, [isSortEnabled, sortingColumns, onTableSort]);
}, [isSortEnabled, sortingColumns, isPlainRecord, columns.length, onTableSort]);
const canSetExpandedDoc = Boolean(setExpandedDoc && !!renderDocumentView);

View file

@ -85,7 +85,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(await testSubjects.exists('discoverQueryHits')).to.be(true);
expect(await testSubjects.exists('discoverAlertsButton')).to.be(true);
expect(await testSubjects.exists('shareTopNavButton')).to.be(true);
expect(await testSubjects.exists('dataGridColumnSortingButton')).to.be(true);
// we don't sort for the Document view
expect(await testSubjects.exists('dataGridColumnSortingButton')).to.be(false);
expect(await testSubjects.exists('docTableExpandToggleColumn')).to.be(true);
expect(await testSubjects.exists('fieldListFiltersFieldTypeFilterToggle')).to.be(true);
await testSubjects.click('field-@message-showDetails');

View file

@ -84,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await testSubjects.existOrFail('discoverQueryHits');
await testSubjects.existOrFail('discoverAlertsButton');
await testSubjects.existOrFail('shareTopNavButton');
await testSubjects.existOrFail('dataGridColumnSortingButton');
await testSubjects.missingOrFail('dataGridColumnSortingButton');
await testSubjects.existOrFail('docTableExpandToggleColumn');
await testSubjects.existOrFail('fieldListFiltersFieldTypeFilterToggle');
await testSubjects.click('field-@message-showDetails');