Skip to content
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] Remove the "newExperience" table option in Discover #9531

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions changelogs/fragments/9531.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breaking:
- Remove the deprecated "newExperience" table option in discover ([#9531](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9531))

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useState } from 'react';
import React from 'react';
import { EuiPanel } from '@elastic/eui';
import { QUERY_ENHANCEMENT_ENABLED_SETTING } from '../../../../common';
import { IndexPattern, getServices } from '../../../opensearch_dashboards_services';
import { DataGridFlyout } from './data_grid_table_flyout';
import { DiscoverGridContextProvider } from './data_grid_table_context';
import { IndexPattern } from '../../../opensearch_dashboards_services';
import { DocViewFilterFn, OpenSearchSearchHit } from '../../doc_views/doc_views_types';
import { buildColumns } from '../../utils/columns';
import { DefaultDiscoverTable } from '../default_discover_table/default_discover_table';
import { DataGrid } from './data_grid';
import { getNewDiscoverSetting } from '../utils/local_storage';
import { SortOrder } from '../../../saved_searches/types';

export interface DataGridTableProps {
Expand All @@ -26,12 +21,9 @@ export interface DataGridTableProps {
hits?: number;
onSort: (s: SortOrder[]) => void;
rows: OpenSearchSearchHit[];
onSetColumns: (columns: string[]) => void;
sort: SortOrder[];
title?: string;
description?: string;
isToolbarVisible?: boolean;
isContextView?: boolean;
isLoading?: boolean;
showPagination?: boolean;
scrollToTop?: () => void;
Expand All @@ -44,22 +36,16 @@ export const DataGridTable = ({
onFilter,
onMoveColumn,
onRemoveColumn,
onSetColumns,
onSort,
sort,
hits,
rows,
title = '',
description = '',
isToolbarVisible = true,
isContextView = false,
isLoading = false,
showPagination,
scrollToTop,
}: DataGridTableProps) => {
const services = getServices();
const [inspectedHit, setInspectedHit] = useState<OpenSearchSearchHit | undefined>();

let adjustedColumns = buildColumns(columns);
// Handle the case where all fields/columns are removed except the time-field one
if (
Expand All @@ -70,83 +56,39 @@ export const DataGridTable = ({
adjustedColumns = [...adjustedColumns, '_source'];
}

/**
* deprecated - we will no longer support newDiscoveredEnabled
*/
const newDiscoverEnabled = getNewDiscoverSetting(services.storage);
const isQueryEnhancementEnabled = services.uiSettings.get(QUERY_ENHANCEMENT_ENABLED_SETTING);

const panelContent =
isQueryEnhancementEnabled || !newDiscoverEnabled ? (
<DefaultDiscoverTable
columns={adjustedColumns}
indexPattern={indexPattern}
sort={sort}
onSort={onSort}
rows={rows}
hits={hits}
onAddColumn={onAddColumn}
onMoveColumn={onMoveColumn}
onRemoveColumn={onRemoveColumn}
onFilter={onFilter}
onClose={() => setInspectedHit(undefined)}
showPagination={showPagination}
scrollToTop={scrollToTop}
/>
) : (
<DataGrid
columns={columns}
indexPattern={indexPattern}
sort={sort}
onSort={onSort}
rows={rows}
onSetColumns={onSetColumns}
isToolbarVisible={isToolbarVisible}
isContextView={isContextView}
/>
);

const tablePanelProps = {
paddingSize: 'none' as const,
style: {
margin: newDiscoverEnabled ? '8px' : '0px',
margin: '0px',
},
color: 'transparent' as const,
};

return (
<DiscoverGridContextProvider
value={{
inspectedHit,
onFilter,
setInspectedHit,
rows: rows || [],
indexPattern,
}}
<div
data-render-complete={!isLoading}
data-shared-item=""
data-title={title}
data-description={description}
data-test-subj="discoverTable"
className="eui-xScrollWithShadows"
>
<div
data-render-complete={!isLoading}
data-shared-item=""
data-title={title}
data-description={description}
data-test-subj="discoverTable"
className="eui-xScrollWithShadows"
>
<EuiPanel hasBorder={false} hasShadow={false} {...tablePanelProps}>
{panelContent}
</EuiPanel>
{newDiscoverEnabled && inspectedHit && (
<DataGridFlyout
indexPattern={indexPattern}
hit={inspectedHit}
columns={adjustedColumns}
onRemoveColumn={onRemoveColumn}
onAddColumn={onAddColumn}
onFilter={onFilter}
onClose={() => setInspectedHit(undefined)}
/>
)}
</div>
</DiscoverGridContextProvider>
<EuiPanel hasBorder={false} hasShadow={false} {...tablePanelProps}>
<DefaultDiscoverTable
columns={adjustedColumns}
indexPattern={indexPattern}
sort={sort}
onSort={onSort}
rows={rows}
hits={hits}
onAddColumn={onAddColumn}
onMoveColumn={onMoveColumn}
onRemoveColumn={onRemoveColumn}
onFilter={onFilter}
showPagination={showPagination}
scrollToTop={scrollToTop}
/>
</EuiPanel>
</div>
);
};
Loading
Loading