Skip to content

Commit

Permalink
fixing sorting and schema detection and other bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Yasonik committed Feb 28, 2020
1 parent 2bc70e9 commit 1702235
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export function createDiscoverGridDirective(reactDirective: any) {
['onRemoveColumn', { watchDepth: 'reference', wrapApply: false }],
['onAddColumn', { watchDepth: 'reference', wrapApply: false }],
['getContextAppHref', { watchDepth: 'reference', wrapApply: false }],
['onSort', { watchDepth: 'reference', wrapApply: false }],
['onSort', { watchDepth: 'reference' }],
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
EuiSpacer,
EuiDataGridColumn,
EuiDataGridCellValueElementProps,
EuiScreenReaderOnly,
} from '@elastic/eui';
import { DocViewer } from '../doc_viewer/doc_viewer';
import { IndexPattern } from '../../../kibana_services';
Expand All @@ -44,7 +45,8 @@ import { shortenDottedString } from '../../../../../../../../plugins/data/common

type Direction = 'asc' | 'desc';
type SortArr = [string, Direction];
const KibanaJSON = 'kibana-json';
const kibanaJSON = 'kibana-json';
const geoPoint = 'geo-point';
interface SortObj {
id: string;
direction: Direction;
Expand Down Expand Up @@ -137,7 +139,7 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
onAddColumn,
}: Props) {
const actionColumnId = 'uniqueString'; // TODO should be guaranteed unique...
const lowestPageSize = 500;
const lowestPageSize = 50;
const timeString = i18n.translate('kbn.discover.timeLabel', {
defaultMessage: 'Time',
});
Expand All @@ -162,12 +164,18 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
case 'date':
column.schema = 'datetime';
break;
case 'numeric':
column.schema = 'number';
case 'number':
column.schema = 'numeric';
break;
case '_source':
case 'object':
column.schema = KibanaJSON;
column.schema = kibanaJSON;
break;
case 'geo_point':
column.schema = geoPoint;
break;
default:
column.schema = undefined;
break;
}

Expand Down Expand Up @@ -277,6 +285,7 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
value = formattedField(row, fieldName);

if (showFilterActions(isDetails, fieldName)) {
// console.log(dataGridColumns[fieldName].schema)
return (
<CellPopover
value={value}
Expand Down Expand Up @@ -338,7 +347,7 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
...pagination,
onChangeItemsPerPage,
onChangePage,
pageSizeOptions: [lowestPageSize],
pageSizeOptions: [lowestPageSize, 100, 500],
}}
toolbarVisibility={{
showColumnSelector: false,
Expand All @@ -351,7 +360,7 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
}}
schemaDetectors={[
{
type: KibanaJSON,
type: kibanaJSON,
detector() {
return 0; // this schema is always explicitly defined
},
Expand All @@ -364,7 +373,27 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623
color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623
},
{
type: geoPoint,
detector() {
return 0; // this schema is always explicitly defined
},
comparator(a, b, direction) {
// TODO @myasonik this column is not sortable
return 1;
},
sortTextAsc: '',
sortTextDesc: '',
icon: 'tokenGeo',
},
]}
// TODO @dsnide can make edits here per type
// Types [geoPoint], [kibanaJSON], numeric, datetime
popoverContents={{
[geoPoint]: ({ children, cellContentsElement }) => {
return <span className="geo-point">{children}</span>;
},
}}
/>
{showDisclaimer && (
<>
Expand All @@ -382,7 +411,11 @@ export const DiscoverGrid = React.memo(function DiscoverGridInner({
</p>
</>
)}
{searchString && <p id={randomId}>{searchString}</p>}
{searchString && (
<EuiScreenReaderOnly>
<p id={randomId}>{searchString}</p>
</EuiScreenReaderOnly>
)}
{typeof flyoutRow !== 'undefined' && (
<EuiPortal>
<EuiFlyout onClose={() => setFlyoutRow(undefined)} size="l" ownFocus>
Expand Down

0 comments on commit 1702235

Please sign in to comment.