Skip to content

Commit

Permalink
Fixed small bugs in explorer (opensearch-project#1559) (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#1580)

* disable ppl direct query autocomplete

* disable sorting for s3

* fix pagination for s3

* fix flyout to use actual row doc

* fix surrounding events

* allow for surrounding fields to work on s3

* fix lint complaint

* const instead of let

* changed naming for isDataSource bool

* update snapshot

---------

(cherry picked from commit 3cec4dc)

Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shenoy Pratik <[email protected]>
(cherry picked from commit 75e91db)
  • Loading branch information
opensearch-trigger-bot[bot] authored and A9 Swift Project User committed Apr 9, 2024
1 parent e5fde87 commit a6b0dc4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "d14447eccc9fa0e6751b984b2f2c1455807ee502",
"last_gitfarm_commit": "038a37edccbbb64c47c98fb0072156defa9fb608"
"last_github_commit": "75e91db98299f00603e19ddb031f14394861c212",
"last_gitfarm_commit": "73bbb64f651d8ac7554927d07c07c8cc68cfdab7"
}
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 @@ -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 @@ -42,6 +42,7 @@ export interface DataGridProps {
requestParams: any;
startTime: string;
endTime: string;
isDefaultDataSource: boolean;
storedSelectedColumns: IField[];
formatGridColumn?: (columns: EuiDataGridColumn[]) => EuiDataGridColumn[];
OuiDataGridProps?: Partial<EuiDataGridProps>;
Expand All @@ -61,6 +62,7 @@ export function DataGrid(props: DataGridProps) {
requestParams,
startTime,
endTime,
isDefaultDataSource,
formatGridColumn = defaultFormatGrid,
OuiDataGridProps,
} = props;
Expand Down Expand Up @@ -104,6 +106,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 @@ -116,6 +120,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 @@ -131,6 +144,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 @@ -141,7 +155,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 @@ -179,19 +193,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 @@ -202,7 +216,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 @@ -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

0 comments on commit a6b0dc4

Please sign in to comment.