Skip to content

Commit

Permalink
[Discover] Remove the legacy table (#201254)
Browse files Browse the repository at this point in the history
- Closes #167582

## Summary

This PR removes the code related to the legacy doc table and 2 Advanced
Settings: `doc_table:legacy` and `truncate:maxHeight`.

The legacy table in Discover was replaced by the new data grid in v8.3.
The `doc_table:legacy` Advanced Setting was added to let users switch
back to the legacy table if necessary. The removal of the setting and
the legacy table entirely would allow us to reduce bundle size,
maintenance burden, and code complexity.

Also the legacy table does not support many new features which were
added to the grid only (e.g. comparing selected documents, context-aware
UI based on current solution project, column resizing, bulk row
selection, copy actions, new doc viewer flyout, and more).

Since v8.15 `doc_table:legacy` is marked as deprecated on Advanced
Settings page via #179899

Since v8.16 `truncate:maxHeight` is marked as deprecated too via
#183736

The removal of these 2 settings and the associated code is planned for
v9.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent c1d976b commit 14bdd8d
Show file tree
Hide file tree
Showing 128 changed files with 234 additions and 7,875 deletions.
1 change: 0 additions & 1 deletion .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ enabled:
- test/functional/apps/dashboard/group5/config.ts
- test/functional/apps/dashboard/group6/config.ts
- test/functional/apps/discover/ccs_compatibility/config.ts
- test/functional/apps/discover/classic/config.ts
- test/functional/apps/discover/embeddable/config.ts
- test/functional/apps/discover/esql/config.ts
- test/functional/apps/discover/group1/config.ts
Expand Down
12 changes: 0 additions & 12 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ The default refresh interval for the time filter. Example:
[[timepicker-timedefaults]]`timepicker:timeDefaults`::
The default selection in the time filter.

[[truncate-maxheight]]`truncate:maxHeight`::
deprecated:[8.16.0]The maximum height that a cell occupies in a table. Set to 0 to disable
truncation.

[[enableESQL]]`enableESQL`::
This setting enables ES|QL in Kibana.

Expand Down Expand Up @@ -340,14 +336,6 @@ Hides the "Time" column in *Discover* and in all saved searches on dashboards.
Highlights results in *Discover* and saved searches on dashboards. Highlighting
slows requests when working on big documents.

[[doctable-legacy]]`doc_table:legacy`::
deprecated:[8.15.0] Controls the way the document table looks and works.
To use the new *Document Explorer* instead of the classic view, turn off this option.
The *Document Explorer* offers better data sorting, resizable columns, and a full screen view.

[[truncate-max-height]]`truncate:maxHeight`::
The maximum height that a cell in a table can occupy. To disable truncation, set to 0.


[float]
[[kibana-ml-settings]]
Expand Down
4 changes: 0 additions & 4 deletions packages/kbn-discover-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export {
DEFAULT_ALLOWED_LOGS_BASE_PATTERNS,
DEFAULT_COLUMNS_SETTING,
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
FIELDS_LIMIT_SETTING,
HIDE_ANNOUNCEMENTS,
MAX_DOC_FIELDS_DISPLAYED,
Expand All @@ -28,8 +27,6 @@ export {
SHOW_FIELD_STATISTICS,
SHOW_MULTIFIELDS,
SORT_DEFAULT_ORDER_SETTING,
TRUNCATE_MAX_HEIGHT,
TRUNCATE_MAX_HEIGHT_DEFAULT_VALUE,
IgnoredReason,
buildDataTableRecord,
buildDataTableRecordList,
Expand All @@ -45,7 +42,6 @@ export {
getMessageFieldWithFallbacks,
getShouldShowFieldHandler,
isNestedFieldParent,
isLegacyTableEnabled,
usePager,
calcFieldCounts,
getLogLevelColor,
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-discover-utils/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const CONTEXT_STEP_SETTING = 'context:step';
export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields';
export const DEFAULT_COLUMNS_SETTING = 'defaultColumns';
export const DOC_HIDE_TIME_COLUMN_SETTING = 'doc_table:hideTimeColumn';
export const DOC_TABLE_LEGACY = 'doc_table:legacy';
export const FIELDS_LIMIT_SETTING = 'fields:popularLimit';
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements';
export const MAX_DOC_FIELDS_DISPLAYED = 'discover:maxDocFieldsDisplayed';
Expand All @@ -26,5 +25,3 @@ export const SEARCH_ON_PAGE_LOAD_SETTING = 'discover:searchOnPageLoad';
export const SHOW_FIELD_STATISTICS = 'discover:showFieldStatistics';
export const SHOW_MULTIFIELDS = 'discover:showMultiFields';
export const SORT_DEFAULT_ORDER_SETTING = 'discover:sort:defaultOrder';
export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight';
export const TRUNCATE_MAX_HEIGHT_DEFAULT_VALUE = 115;
2 changes: 1 addition & 1 deletion packages/kbn-discover-utils/src/utils/build_data_record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { DataTableRecord, EsHitRecord } from '../types';
import { getDocId } from './get_doc_id';

/**
* Build a record for data table, explorer + classic one
* Build a record for data grid
* @param doc the document returned from Elasticsearch
* @param dataView this current data view
* @param isAnchor determines if the given doc is the anchor doc when viewing surrounding documents
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-discover-utils/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ export * from './nested_fields';
export * from './get_field_value';
export * from './calc_field_counts';
export * from './get_visible_columns';
export { isLegacyTableEnabled } from './is_legacy_table_enabled';
export { DiscoverFlyouts, dismissAllFlyoutsExceptFor, dismissFlyouts } from './dismiss_flyouts';
25 changes: 0 additions & 25 deletions packages/kbn-discover-utils/src/utils/is_legacy_table_enabled.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/kbn-discover-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@kbn/field-formats-plugin",
"@kbn/field-types",
"@kbn/i18n",
"@kbn/core-ui-settings-browser",
"@kbn/expressions-plugin",
"@kbn/logs-data-access-plugin",
"@kbn/i18n-react",
Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-management/settings/setting_ids/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ export const DISCOVER_SHOW_MULTI_FIELDS_ID = 'discover:showMultiFields';
export const DISCOVER_SORT_DEFAULT_ORDER_ID = 'discover:sort:defaultOrder';
export const DOC_TABLE_HIDE_TIME_COLUMNS_ID = 'doc_table:hideTimeColumn';
export const DOC_TABLE_HIGHLIGHT_ID = 'doc_table:highlight';
export const DOC_TABLE_LEGACY_ID = 'doc_table:legacy';
export const TRUNCATE_MAX_HEIGHT_ID = 'truncate:maxHeight';

// Machine learning settings
export const ML_ANOMALY_DETECTION_RESULTS_ENABLE_TIME_DEFAULTS_ID =
Expand Down
4 changes: 0 additions & 4 deletions packages/kbn-unified-doc-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

This package contains components and services for the unified doc viewer component.

Discover (Classic view → Expanded document)

![image](https://github.com/elastic/kibana/assets/1178348/a0a360bf-2697-4427-a32e-c728f06f5a7e)

Discover (Document explorer → Toggle dialog with details)

![image](https://github.com/elastic/kibana/assets/1178348/c9c11587-c53f-4bcd-8d48-aaceb64981ea)
Expand Down
28 changes: 2 additions & 26 deletions packages/kbn-unified-doc-viewer/src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { AggregateQuery, Query } from '@kbn/es-query';
import type {
DataTableRecord,
DataTableColumnsMeta,
IgnoredReason,
} from '@kbn/discover-utils/types';
import type { DataTableRecord, DataTableColumnsMeta } from '@kbn/discover-utils/types';
import { DocViewsRegistry } from './doc_views_registry';

export interface FieldMapping {
Expand Down Expand Up @@ -77,23 +73,3 @@ interface ComponentDocViewInput extends BaseDocViewInput {
export type DocView = ComponentDocViewInput | RenderDocViewInput;

export type DocViewFactory = () => DocView;

export interface FieldRecordLegacy {
action: {
isActive: boolean;
onFilter?: DocViewFilterFn;
onToggleColumn: ((field: string) => void) | undefined;
flattenedField: unknown;
};
field: {
displayName: string;
field: string;
scripted: boolean;
fieldType?: string;
fieldMapping?: DataViewField;
};
value: {
formattedValue: string;
ignored?: IgnoredReason;
};
}
1 change: 0 additions & 1 deletion packages/kbn-unified-doc-viewer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export type {
DocViewFilterFn,
DocViewRenderFn,
DocViewRenderProps,
FieldRecordLegacy,
} from './services/types';
2 changes: 1 addition & 1 deletion packages/kbn-unified-doc-viewer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

export type { ElasticRequestState } from '.';
export type { DocViewFilterFn, DocViewRenderProps, FieldRecordLegacy } from './src/types';
export type { DocViewFilterFn, DocViewRenderProps } from './src/types';
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { identity } from 'lodash';
import { IUiSettingsClient } from '@kbn/core/public';
import {
DEFAULT_COLUMNS_SETTING,
DOC_TABLE_LEGACY,
MAX_DOC_FIELDS_DISPLAYED,
ROW_HEIGHT_OPTION,
SAMPLE_SIZE_SETTING,
Expand All @@ -39,8 +38,6 @@ export const uiSettingsMock = {
return 10;
} else if (key === DEFAULT_COLUMNS_SETTING) {
return ['default_column'];
} else if (key === DOC_TABLE_LEGACY) {
return false;
} else if (key === SEARCH_FIELDS_FROM_SOURCE) {
return false;
} else if (key === SHOW_MULTIFIELDS) {
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/discover/public/__mocks__/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { IUiSettingsClient } from '@kbn/core/public';
import {
CONTEXT_TIE_BREAKER_FIELDS_SETTING,
DEFAULT_COLUMNS_SETTING,
DOC_TABLE_LEGACY,
SAMPLE_SIZE_SETTING,
SAMPLE_ROWS_PER_PAGE_SETTING,
SHOW_MULTIFIELDS,
Expand All @@ -27,8 +26,6 @@ export const uiSettingsMock = {
return 100;
} else if (key === DEFAULT_COLUMNS_SETTING) {
return ['default_column'];
} else if (key === DOC_TABLE_LEGACY) {
return true;
} else if (key === CONTEXT_TIE_BREAKER_FIELDS_SETTING) {
return ['_doc'];
} else if (key === SEARCH_FIELDS_FROM_SOURCE) {
Expand Down
11 changes: 2 additions & 9 deletions src/plugins/discover/public/application/context/context_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import React, { Fragment, memo, useEffect, useRef, useMemo, useCallback } from 'react';
import './context_app.scss';
import classNames from 'classnames';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiText, EuiPage, EuiPageBody, EuiSpacer, useEuiPaddingSize } from '@elastic/eui';
import { css } from '@emotion/react';
Expand All @@ -19,11 +18,7 @@ import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
import { generateFilters } from '@kbn/data-plugin/public';
import { i18n } from '@kbn/i18n';
import { reportPerformanceMetricEvent } from '@kbn/ebt-tools';
import {
DOC_TABLE_LEGACY,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '@kbn/discover-utils';
import { SEARCH_FIELDS_FROM_SOURCE, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { UseColumnsProps, popularizeField, useColumns } from '@kbn/unified-data-table';
import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import { DiscoverGridSettings } from '@kbn/saved-search-plugin/common';
Expand Down Expand Up @@ -60,7 +55,6 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) =>
fieldsMetadata,
} = services;

const isLegacy = useMemo(() => uiSettings.get(DOC_TABLE_LEGACY), [uiSettings]);
const useNewFieldsApi = useMemo(() => !uiSettings.get(SEARCH_FIELDS_FROM_SOURCE), [uiSettings]);

/**
Expand Down Expand Up @@ -266,7 +260,7 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) =>
})}
</h1>
<TopNavMenu {...getNavBarProps()} />
<EuiPage className={classNames({ dscDocsPage: !isLegacy })}>
<EuiPage className="dscDocsPage">
<EuiPageBody
panelled
paddingSize="none"
Expand All @@ -291,7 +285,6 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) =>
<ContextAppContentMemoized
dataView={dataView}
useNewFieldsApi={useNewFieldsApi}
isLegacy={isLegacy}
columns={columns}
grid={appState.grid}
onAddColumn={onAddColumnWithTracking}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import React from 'react';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { ActionBar } from './components/action_bar/action_bar';
import { GetStateReturn } from './services/context_state';
import { SortDirection } from '@kbn/data-plugin/public';
import { UnifiedDataTable } from '@kbn/unified-data-table';
import { ContextAppContent, ContextAppContentProps } from './context_app_content';
import { LoadingStatus } from './services/context_query_state';
import { discoverServiceMock } from '../../__mocks__/services';
import { DocTableWrapper } from '../../components/doc_table/doc_table_wrapper';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { buildDataTableRecord } from '@kbn/discover-utils';
import { act } from 'react-dom/test-utils';
Expand All @@ -29,13 +27,7 @@ const dataViewMock = buildDataViewMock({
});

describe('ContextAppContent test', () => {
const mountComponent = async ({
anchorStatus,
isLegacy,
}: {
anchorStatus?: LoadingStatus;
isLegacy?: boolean;
}) => {
const mountComponent = async ({ anchorStatus }: { anchorStatus?: LoadingStatus }) => {
const hit = {
_id: '123',
_index: 'test_index',
Expand Down Expand Up @@ -75,7 +67,6 @@ describe('ContextAppContent test', () => {
onRemoveColumn: () => {},
onSetColumns: () => {},
sort: [['order_date', 'desc']] as Array<[string, SortDirection]>,
isLegacy: isLegacy ?? true,
setAppState: () => {},
addFilter: () => {},
interceptedWarnings: [],
Expand All @@ -93,29 +84,14 @@ describe('ContextAppContent test', () => {
return component;
};

it('should render legacy table correctly', async () => {
const component = await mountComponent({});
expect(component.find(DocTableWrapper).length).toBe(1);
const loadingIndicator = findTestSubject(component, 'contextApp_loadingIndicator');
expect(loadingIndicator.length).toBe(0);
expect(component.find(ActionBar).length).toBe(2);
});

it('renders loading indicator', async () => {
const component = await mountComponent({ anchorStatus: LoadingStatus.LOADING });
const loadingIndicator = findTestSubject(component, 'contextApp_loadingIndicator');
expect(component.find(DocTableWrapper).length).toBe(1);
expect(loadingIndicator.length).toBe(1);
});

it('should render discover grid correctly', async () => {
const component = await mountComponent({ isLegacy: false });
const component = await mountComponent({});
expect(component.find(UnifiedDataTable).length).toBe(1);
expect(findTestSubject(component, 'unifiedDataTableToolbar').exists()).toBe(true);
});

it('should not show display options button', async () => {
const component = await mountComponent({ isLegacy: false });
const component = await mountComponent({});
expect(findTestSubject(component, 'unifiedDataTableToolbar').exists()).toBe(true);
expect(findTestSubject(component, 'dataGridDisplaySelectorButton').exists()).toBe(false);
});
Expand Down
Loading

0 comments on commit 14bdd8d

Please sign in to comment.