diff --git a/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx b/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx index 46b8bb32708e..3f99c009e56a 100644 --- a/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx +++ b/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx @@ -4,7 +4,7 @@ */ import React, { useState, useMemo, useCallback } from 'react'; -import { EuiDataGrid, EuiPanel } from '@elastic/eui'; +import { EuiDataGrid, EuiDataGridSorting, EuiPanel } from '@elastic/eui'; import { IndexPattern } from '../../../opensearch_dashboards_services'; import { fetchTableDataCell } from './data_grid_table_cell_value'; import { buildDataGridColumns, computeVisibleColumns } from './data_grid_table_columns'; @@ -23,10 +23,10 @@ export interface DataGridTableProps { onAddColumn: (column: string) => void; onFilter: DocViewFilterFn; onRemoveColumn: (column: string) => void; - onSort: (sort: Array<[string, string]>) => void; + onSort: (sort: Array<[string, 'asc' | 'desc']>) => void; rows: OpenSearchSearchHit[]; onSetColumns: (columns: string[]) => void; - sort: Array<[string, string]>; + sort: Array<[string, 'asc' | 'desc']>; displayTimeColumn: boolean; services: DiscoverServices; isToolbarVisible?: boolean; @@ -43,7 +43,6 @@ export const DataGridTable = ({ sort, rows, displayTimeColumn, - services, isToolbarVisible = true, }: DataGridTableProps) => { const [expandedHit, setExpandedHit] = useState(); @@ -51,10 +50,18 @@ export const DataGridTable = ({ const pagination = usePagination(rowCount); const sortingColumns = useMemo(() => sort.map(([id, direction]) => ({ id, direction })), [sort]); + const rowHeightsOptions = useMemo( + () => ({ + defaultHeight: { + lineCount: columns.includes('_source') ? 3 : 1, + }, + }), + [columns] + ); const onColumnSort = useCallback( - (cols) => { - onSort(cols.map(({ id, direction }: any) => [id, direction])); + (cols: EuiDataGridSorting['columns']) => { + onSort(cols.map(({ id, direction }) => [id, direction])); }, [onSort] ); @@ -79,10 +86,10 @@ export const DataGridTable = ({ [columns, indexPattern, displayTimeColumn, onSetColumns] ); - const sorting = useMemo(() => ({ columns: sortingColumns, onSort: onColumnSort }), [ - sortingColumns, - onColumnSort, - ]); + const sorting: EuiDataGridSorting = useMemo( + () => ({ columns: sortingColumns, onSort: onColumnSort }), + [sortingColumns, onColumnSort] + ); const leadingControlColumns = useMemo(() => { return [ @@ -95,6 +102,35 @@ export const DataGridTable = ({ ]; }, []); + const table = useMemo( + () => ( + + ), + [ + dataGridTableColumns, + dataGridTableColumnsVisibility, + leadingControlColumns, + pagination, + renderCellValue, + rowCount, + sorting, + isToolbarVisible, + rowHeightsOptions, + ] + ); + return ( - + {table} {expandedHit && ( @@ -131,7 +156,6 @@ export const DataGridTable = ({ onAddColumn={onAddColumn} onFilter={onFilter} onClose={() => setExpandedHit(undefined)} - services={services} /> )} diff --git a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.scss b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.scss new file mode 100644 index 000000000000..051ab642c1cf --- /dev/null +++ b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.scss @@ -0,0 +1,4 @@ +.discoverNoResults { + display: flex; + align-items: center; +} diff --git a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx index 697c7a136d60..dc12ba4581fc 100644 --- a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx +++ b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx @@ -28,20 +28,24 @@ * under the License. */ +import './loading_spinner.scss'; import React from 'react'; -import { EuiLoadingSpinner, EuiTitle, EuiSpacer } from '@elastic/eui'; +import { EuiTitle, EuiPanel, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui'; import { FormattedMessage } from '@osd/i18n/react'; export function LoadingSpinner() { return ( - <> - -

- -

-
- - - + + } + title={ + +

+ +

+
+ } + /> +
); } diff --git a/src/plugins/discover/public/application/components/no_results/no_results.tsx b/src/plugins/discover/public/application/components/no_results/no_results.tsx index 79b3191e5eda..ad7bab0e81e9 100644 --- a/src/plugins/discover/public/application/components/no_results/no_results.tsx +++ b/src/plugins/discover/public/application/components/no_results/no_results.tsx @@ -28,23 +28,26 @@ * under the License. */ -import React, { Component, Fragment } from 'react'; +import React, { Fragment } from 'react'; import { FormattedMessage, I18nProvider } from '@osd/i18n/react'; -import PropTypes from 'prop-types'; import { EuiCallOut, EuiCode, EuiDescriptionList, - EuiFlexGroup, - EuiFlexItem, EuiLink, + EuiPanel, EuiSpacer, EuiText, } from '@elastic/eui'; import { getServices } from '../../../opensearch_dashboards_services'; -export const DiscoverNoResults = (timeFieldName: string, queryLanguage: any) => { +interface Props { + timeFieldName?: string; + queryLanguage?: string; +} + +export const DiscoverNoResults = ({ timeFieldName, queryLanguage }: Props) => { let timeFieldMessage; if (timeFieldName) { @@ -189,27 +192,21 @@ export const DiscoverNoResults = (timeFieldName: string, queryLanguage: any) => return ( - - - - - - - } - color="warning" - iconType="help" - data-test-subj="discoverNoResults" + + - {timeFieldMessage} - {luceneQueryMessage} - - - + } + color="warning" + iconType="help" + data-test-subj="discoverNoResults" + /> + {timeFieldMessage} + {luceneQueryMessage} + ); }; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx index 98789598713c..73dc40a262e0 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx @@ -153,7 +153,6 @@ export const DiscoverField = ({ > ) => { if (ev.type === 'click') { ev.currentTarget.focus(); @@ -178,7 +177,6 @@ export const DiscoverField = ({ ) => { if (ev.type === 'click') { ev.currentTarget.focus(); diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index f547dbe9deeb..63e8720f2c59 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -1,3 +1,3 @@ -.dscFieldListHeader { +.dscSideBarFieldListHeader { padding-left: $euiSizeS; } diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index b4ed88e02ed9..f5e091e6ab82 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -204,7 +204,7 @@ export function DiscoverSidebar({ {fields.length > 0 && ( <> - +

- +

- +