mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Graph] Disable runtime fields showing up in Graph (#90010)
* [Graph] Disable runtime fields * Fix jest test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
9bee677f68
commit
72cb883d80
3 changed files with 28 additions and 6 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { GraphWorkspaceSavedObject, IndexPatternSavedObject, Workspace } from '../../types';
|
||||
import { migrateLegacyIndexPatternRef, savedWorkspaceToAppState } from './deserialize';
|
||||
import { migrateLegacyIndexPatternRef, savedWorkspaceToAppState, mapFields } from './deserialize';
|
||||
import { createWorkspace } from '../../angular/graph_client_workspace';
|
||||
import { outlinkEncoders } from '../../helpers/outlink_encoders';
|
||||
import { IndexPattern } from '../../../../../../src/plugins/data/public';
|
||||
|
@ -119,9 +119,9 @@ describe('deserialize', () => {
|
|||
savedWorkspace,
|
||||
{
|
||||
getNonScriptedFields: () => [
|
||||
{ name: 'field1', type: 'string', aggregatable: true },
|
||||
{ name: 'field2', type: 'string', aggregatable: true },
|
||||
{ name: 'field3', type: 'string', aggregatable: true },
|
||||
{ name: 'field1', type: 'string', aggregatable: true, isMapped: true },
|
||||
{ name: 'field2', type: 'string', aggregatable: true, isMapped: true },
|
||||
{ name: 'field3', type: 'string', aggregatable: true, isMapped: true },
|
||||
],
|
||||
} as IndexPattern,
|
||||
workspace
|
||||
|
@ -236,4 +236,22 @@ describe('deserialize', () => {
|
|||
expect(workspacePayload).toEqual(savedWorkspace);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapFields', () => {
|
||||
it('should not include unmapped fields', () => {
|
||||
const indexPattern = {
|
||||
getNonScriptedFields: () => [
|
||||
{ name: 'field1', type: 'string', aggregatable: true, isMapped: true },
|
||||
{ name: 'field2', type: 'string', aggregatable: true, isMapped: true },
|
||||
{ name: 'runtimeField', type: 'string', aggregatable: true, isMapped: false },
|
||||
{ name: 'field3', type: 'string', aggregatable: true, isMapped: true },
|
||||
],
|
||||
} as IndexPattern;
|
||||
expect(mapFields(indexPattern).map(({ name }) => name)).toEqual([
|
||||
'field1',
|
||||
'field2',
|
||||
'field3',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -104,7 +104,11 @@ export function mapFields(indexPattern: IndexPattern): WorkspaceField[] {
|
|||
return indexPattern
|
||||
.getNonScriptedFields()
|
||||
.filter(
|
||||
(field) => !blockedFieldNames.includes(field.name) && !indexPatternsUtils.isNestedField(field)
|
||||
(field) =>
|
||||
// Make sure to only include mapped fields, e.g. no index pattern runtime fields
|
||||
field.isMapped &&
|
||||
!blockedFieldNames.includes(field.name) &&
|
||||
!indexPatternsUtils.isNestedField(field)
|
||||
)
|
||||
.map((field, index) => ({
|
||||
name: field.name,
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('datasource saga', () => {
|
|||
get: jest.fn(() =>
|
||||
Promise.resolve({
|
||||
title: 'test-pattern',
|
||||
getNonScriptedFields: () => [{ name: 'field1', type: 'string' }],
|
||||
getNonScriptedFields: () => [{ name: 'field1', type: 'string', isMapped: true }],
|
||||
} as IndexPattern)
|
||||
),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue