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

Fixed small bugs in explorer #1559

Merged
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 @@ -293,7 +293,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 @@ -783,7 +783,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 @@ -32,7 +32,7 @@
export interface DataGridProps {
http: HttpSetup;
pplService: PPLService;
rows: any[];

Check warning on line 35 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 @@ -40,6 +40,7 @@
requestParams: any;
startTime: string;
endTime: string;
isDefaultDataSource: boolean;
storedSelectedColumns: IField[];
formatGridColumn?: (columns: EuiDataGridColumn[]) => EuiDataGridColumn[];
OuiDataGridProps?: Partial<EuiDataGridProps>;
Expand All @@ -59,6 +60,7 @@
requestParams,
startTime,
endTime,
isDefaultDataSource,
formatGridColumn = defaultFormatGrid,
OuiDataGridProps,
} = props;
Expand Down Expand Up @@ -100,6 +102,8 @@

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

redoQuery(
startTime,
endTime,
Expand All @@ -112,6 +116,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];

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

View check run for this annotation

Codecov / codecov/patch

public/components/event_analytics/explorer/events_views/data_grid.tsx#L123

Added line #L123 was not covered by tests
}
return rowIndex;

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

View check run for this annotation

Codecov / codecov/patch

public/components/event_analytics/explorer/events_views/data_grid.tsx#L125

Added line #L125 was not covered by tests
};

const columnNameTranslate = (name: string) => {
return i18n.translate(`discover.events.dataGrid.${name.toLowerCase()}Column`, {
defaultMessage: name,
Expand All @@ -127,6 +140,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 @@ -137,7 +151,7 @@
columns.push({
id: name,
display: name,
isSortable: true, // TODO: add functionality here based on type
isSortable: isDefaultDataSource,
});
}
});
Expand Down Expand Up @@ -175,19 +189,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 @@ -198,7 +212,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);

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

View check run for this annotation

Codecov / codecov/patch

public/components/event_analytics/explorer/events_views/data_grid.tsx#L215

Added line #L215 was not covered by tests

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 @@ -650,6 +650,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