[Discover] Could not expand cell content in DiscoverGrid (#91289)

Closes: #90796

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alexey Antonov 2021-02-15 20:17:21 +03:00 committed by GitHub
parent 643794eb9f
commit 4d01440012
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 36 deletions

View file

@ -9,7 +9,6 @@
// data types
export const kibanaJSON = 'kibana-json';
export const geoPoint = 'geo-point';
export const unknownType = 'unknown';
export const gridStyle = {
border: 'all',
fontSize: 's',

View file

@ -28,7 +28,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "extension",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
Object {
"actions": Object {
@ -43,7 +43,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "message",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
]
`);
@ -68,7 +68,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "extension",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
Object {
"actions": Object {
@ -80,7 +80,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "message",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
]
`);
@ -106,7 +106,7 @@ describe('Discover grid columns ', function () {
"id": "timestamp",
"initialWidth": 180,
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
Object {
"actions": Object {
@ -121,7 +121,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "extension",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
Object {
"actions": Object {
@ -136,7 +136,7 @@ describe('Discover grid columns ', function () {
"display": undefined,
"id": "message",
"isSortable": undefined,
"schema": "unknown",
"schema": "kibana-json",
},
]
`);

View file

@ -6,9 +6,9 @@
* Side Public License, v 1.
*/
import React, { ReactNode } from 'react';
import { EuiCodeBlock } from '@elastic/eui';
import { geoPoint, kibanaJSON, unknownType } from './constants';
import React from 'react';
import { EuiCodeBlock, EuiDataGridPopoverContents } from '@elastic/eui';
import { geoPoint, kibanaJSON } from './constants';
import { KBN_FIELD_TYPES } from '../../../../../data/common';
export function getSchemaByKbnType(kbnType: string | undefined) {
@ -24,12 +24,10 @@ export function getSchemaByKbnType(kbnType: string | undefined) {
return 'string';
case KBN_FIELD_TYPES.DATE:
return 'datetime';
case KBN_FIELD_TYPES._SOURCE:
return kibanaJSON;
case KBN_FIELD_TYPES.GEO_POINT:
return geoPoint;
default:
return unknownType;
return kibanaJSON;
}
}
@ -45,16 +43,6 @@ export function getSchemaDetectors() {
icon: '',
color: '',
},
{
type: unknownType,
detector() {
return 0; // this schema is always explicitly defined
},
sortTextAsc: '',
sortTextDesc: '',
icon: '',
color: '',
},
{
type: geoPoint,
detector() {
@ -70,19 +58,12 @@ export function getSchemaDetectors() {
/**
* Returns custom popover content for certain schemas
*/
export function getPopoverContents() {
export function getPopoverContents(): EuiDataGridPopoverContents {
return {
[geoPoint]: ({ children }: { children: ReactNode }) => {
[geoPoint]: ({ children }) => {
return <span className="geo-point">{children}</span>;
},
[unknownType]: ({ children }: { children: ReactNode }) => {
return (
<EuiCodeBlock isCopyable language="json" paddingSize="none" transparentBackground={true}>
{children}
</EuiCodeBlock>
);
},
[kibanaJSON]: ({ children }: { children: ReactNode }) => {
[kibanaJSON]: ({ children }) => {
return (
<EuiCodeBlock isCopyable language="json" paddingSize="none" transparentBackground={true}>
{children}

View file

@ -78,7 +78,13 @@ describe('Discover grid cell rendering', function () {
);
expect(component.html()).toMatchInlineSnapshot(`
"<span>{
&quot;bytes&quot;: 100
&quot;_id&quot;: &quot;1&quot;,
&quot;_index&quot;: &quot;test&quot;,
&quot;_type&quot;: &quot;test&quot;,
&quot;_score&quot;: 1,
&quot;_source&quot;: {
&quot;bytes&quot;: 100
}
}</span>"
`);
});

View file

@ -55,7 +55,7 @@ export const getRenderCellValueFn = (
if (field && field.type === '_source') {
if (isDetails) {
// nicely formatted JSON for the expanded view
return <span>{JSON.stringify(row[columnId], null, 2)}</span>;
return <span>{JSON.stringify(row, null, 2)}</span>;
}
const formatted = indexPattern.formatHit(row);