-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Data Frames: Fixes crash of the source table for complex field v…
…alues. (#39878) The data frame wizard's source index preview table would crash with some field values more complex than strings. This PR fixes it by adding the following "special treatment" for these values: Arrays of strings will be concatenated to a comma separated string in table rows. Arrays of objects will be rendered as a badge with the label array and a tooltip that says that the full value is available in the expanded row. In the expanded row, every value that's not a string will be rendered using JSON.stringify().
- Loading branch information
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...ublic/data_frame/components/source_index_preview/__snapshots__/expanded_row.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
...legacy/plugins/ml/public/data_frame/components/source_index_preview/expanded_row.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { ExpandedRow } from './expanded_row'; | ||
|
||
describe('Data Frame: <ExpandedRow />', () => { | ||
test('Test against strings, objects and arrays.', () => { | ||
const props = { | ||
item: { | ||
_id: 'the-id', | ||
_source: { | ||
name: 'the-name', | ||
nested: { | ||
inner1: 'the-inner-1', | ||
inner2: 'the-inner-2', | ||
}, | ||
arrayString: ['the-array-string-1', 'the-array-string-2'], | ||
arrayObject: [{ object1: 'the-object-1' }, { object2: 'the-objects-2' }], | ||
}, | ||
}, | ||
}; | ||
|
||
// Using a wrapping <div> element because shallow() would fail | ||
// with the Provider being the outer most component. | ||
const wrapper = shallow(<ExpandedRow {...props} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters