Skip to content

Commit

Permalink
Fixed small bugs in explorer (#1559)
Browse files Browse the repository at this point in the history
* disable ppl direct query autocomplete

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* disable sorting for s3

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* fix pagination for s3

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* fix flyout to use actual row doc

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* fix surrounding events

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* allow for surrounding fields to work on s3

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* fix lint complaint

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* const instead of let

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* changed naming for isDataSource bool

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* update snapshot

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

---------

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
  • Loading branch information
paulstn authored Mar 19, 2024
1 parent 46c23ee commit 3cec4dc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
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 {
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,7 +55,6 @@ import { formatError } from '../../event_analytics/utils';
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;
Expand Down Expand Up @@ -384,7 +384,7 @@ export const DirectSearch = (props: any) => {
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 @@ -40,6 +40,7 @@ export interface DataGridProps {
requestParams: any;
startTime: string;
endTime: string;
isDefaultDataSource: boolean;
storedSelectedColumns: IField[];
formatGridColumn?: (columns: EuiDataGridColumn[]) => EuiDataGridColumn[];
OuiDataGridProps?: Partial<EuiDataGridProps>;
Expand All @@ -59,6 +60,7 @@ export function DataGrid(props: DataGridProps) {
requestParams,
startTime,
endTime,
isDefaultDataSource,
formatGridColumn = defaultFormatGrid,
OuiDataGridProps,
} = props;
Expand Down Expand Up @@ -100,6 +102,8 @@ export function DataGrid(props: DataGridProps) {

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 @@ export function DataGrid(props: DataGridProps) {
);
};

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 @@ -127,6 +140,7 @@ export function DataGrid(props: DataGridProps) {
...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 @@ export function DataGrid(props: DataGridProps) {
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 @@ export function DataGrid(props: DataGridProps) {
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 @@ export function DataGrid(props: DataGridProps) {

// 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 @@ -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

0 comments on commit 3cec4dc

Please sign in to comment.