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

[Backport 2.13] Fixed small bugs in explorer #1580

Merged
merged 2 commits into from
Mar 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions public/components/common/search/direct_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { isEmpty, isEqual } from 'lodash';
import React, { useEffect, useState } from 'react';
import { batch, useDispatch, useSelector } from 'react-redux';
import { i18n } from '@osd/i18n';
import { ASYNC_POLLING_INTERVAL, QUERY_LANGUAGE } from '../../../../common/constants/data_sources';
import {
APP_ANALYTICS_TAB_ID_REGEX,
Expand Down Expand Up @@ -54,13 +55,12 @@
import { usePolling } from '../../hooks/use_polling';
import { PPLReferenceFlyout } from '../helpers';
import { Autocomplete } from './autocomplete';
import { i18n } from '@osd/i18n';
export interface IQueryBarProps {
query: string;
tempQuery: string;
handleQueryChange: (query: string) => void;
handleQuerySearch: () => void;
dslService: any;

Check warning on line 63 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface IDatePickerProps {
Expand All @@ -70,11 +70,11 @@
setEndTime: () => void;
setTimeRange: () => void;
setIsOutputStale: () => void;
handleTimePickerChange: (timeRange: string[]) => any;

Check warning on line 73 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
handleTimeRangePickerRefresh: () => any;

Check warning on line 74 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export const DirectSearch = (props: any) => {

Check warning on line 77 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const {
query,
tempQuery,
Expand Down Expand Up @@ -115,7 +115,7 @@
error: pollingError,
startPolling,
stopPolling,
} = usePolling<any, any>((params) => {

Check warning on line 118 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 118 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return sqlService.fetchWithJobId(params);
}, ASYNC_POLLING_INTERVAL);

Expand Down Expand Up @@ -329,20 +329,20 @@
})
);
}
}, [pollingResult, pollingError]);

Check warning on line 332 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'dispatch', 'dispatchOnGettingHis', 'stopPollingWithStatus', and 'tabId'. Either include them or remove the dependency array

useEffect(() => {
return () => {
stopPolling();
};
}, []);

Check warning on line 338 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'stopPolling'. Either include it or remove the dependency array

useEffect(() => {
if (!explorerSearchMetadata.isPolling) {
stopPolling();
setIsQueryRunning(false);
}
}, [explorerSearchMetadata.isPolling]);

Check warning on line 345 in public/components/common/search/direct_search.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'setIsQueryRunning' and 'stopPolling'. Either include them or remove the dependency array

return (
<div className="globalQueryBar">
Expand Down Expand Up @@ -384,7 +384,7 @@
getSuggestions={getSuggestions}
onItemSelect={onItemSelect}
tabId={tabId}
isSuggestionDisabled={queryLang === 'SQL'}
isSuggestionDisabled={true}
isDisabled={explorerSearchMetadata.isPolling}
/>
{queryLang === QUERY_LANGUAGE.PPL && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ exports[`Datagrid component Renders data grid component 1`] = `
"display": "Time (timestamp)",
"id": "timestamp",
"initialWidth": 200,
"isSortable": true,
"isSortable": undefined,
"schema": "datetime",
},
Object {
Expand Down Expand Up @@ -775,7 +775,7 @@ exports[`Datagrid component renders data grid with different timestamp 1`] = `
"display": "Time (utc_time)",
"id": "utc_time",
"initialWidth": 200,
"isSortable": true,
"isSortable": undefined,
"schema": "datetime",
},
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
export interface DataGridProps {
http: HttpSetup;
pplService: PPLService;
rows: any[];

Check warning on line 37 in public/components/event_analytics/explorer/events_views/data_grid.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
explorerFields: IExplorerFields;
timeStampField: string;
rawQuery: string;
Expand All @@ -42,6 +42,7 @@
requestParams: any;
startTime: string;
endTime: string;
isDefaultDataSource: boolean;
storedSelectedColumns: IField[];
formatGridColumn?: (columns: EuiDataGridColumn[]) => EuiDataGridColumn[];
OuiDataGridProps?: Partial<EuiDataGridProps>;
Expand All @@ -61,6 +62,7 @@
requestParams,
startTime,
endTime,
isDefaultDataSource,
formatGridColumn = defaultFormatGrid,
OuiDataGridProps,
} = props;
Expand Down Expand Up @@ -104,6 +106,8 @@

const setPage = (page: number[]) => {
pageFields.current = page;
if (!isDefaultDataSource) return; // avoid adjusting query if using s3

redoQuery(
startTime,
endTime,
Expand All @@ -116,6 +120,15 @@
);
};

const findTrueIndex = (rowIndex: number) => {
// if using default ds, data given to dg will be per page, need to adjust dg expected index and actual data index
if (isDefaultDataSource) {
// modulo of row length, i.e. pos on current page
rowIndex = rowIndex % pageFields.current[1];
}
return rowIndex;
};

const columnNameTranslate = (name: string) => {
return i18n.translate(`discover.events.dataGrid.${name.toLowerCase()}Column`, {
defaultMessage: name,
Expand All @@ -131,6 +144,7 @@
...DEFAULT_TIMESTAMP_COLUMN,
display: `${columnNameTranslate('Time')} (${timeStampField})`,
id: timeStampField,
isSortable: isDefaultDataSource, // allow sorting for default ds, dont otherwise
});
} else if (name === '_source') {
columns.push({
Expand All @@ -141,7 +155,7 @@
columns.push({
id: name,
display: name,
isSortable: true, // TODO: add functionality here based on type
isSortable: isDefaultDataSource,
});
}
});
Expand Down Expand Up @@ -179,19 +193,19 @@
http={http}
key={null}
docId={'undefined'}
doc={rows[rowIndex % pageFields.current[1]]}
doc={data[findTrueIndex(rowIndex)]}
selectedCols={explorerFields.queriedFields}
timeStampField={timeStampField}
explorerFields={explorerFields}
pplService={pplService}
rawQuery={rawQuery}
onFlyoutOpen={() => {}}
dataGridColumns={dataGridColumns}
dataGridColumnVisibility={dataGridColumnVisibility}
dataGridColumns={dataGridColumns()}
dataGridColumnVisibility={dataGridColumnVisibility()}
selectedIndex={rowIndex}
sortingFields={sortingFields}
rowHeightsOptions={rowHeightsOptions}
rows={rows}
rowHeightsOptions={rowHeightsOptions()}
rows={data}
/>
);
},
Expand All @@ -202,7 +216,8 @@

// renders what is shown in each cell, i.e. the content of each row
const dataGridCellRender = ({ rowIndex, columnId }: { rowIndex: number; columnId: string }) => {
const trueIndex = rowIndex % pageFields.current[1]; // modulo of row length, i.e. pos on current page
const trueIndex = findTrueIndex(rowIndex);

if (trueIndex < data.length) {
if (columnId === '_source') {
return (
Expand Down
3 changes: 3 additions & 0 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ export const Explorer = ({
requestParams={requestParams}
startTime={startTime}
endTime={endTime}
isDefaultDataSource={
explorerSearchMeta.datasources[0].type === DEFAULT_DATA_SOURCE_TYPE
}
/>
)}
<a tabIndex={0} id="discoverBottomMarker">
Expand Down
Loading