-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TSVB][Lens] Navigate to Lens with your current configuration #114794
Changes from 100 commits
76628e0
74f262a
065a9b1
6da7fac
b62ef23
502036f
f132aad
6e17315
8dd3b87
e70ab64
089163d
ff1cf81
5976aee
313871b
1a0959d
5ecaa0f
ea05e70
40b8b36
99a4a70
5d67077
3e9b1c5
f7ca582
580ec72
fd38926
c784cbe
5a0d721
b35a5b5
0ce5f89
d44bbea
0f1b990
ef6d4b5
da1e2c8
73fcb51
528f05c
9d86330
4272ef1
956d942
31162dc
a5e8a23
62ee1a0
8794034
d4f7ccc
2716076
9f6e116
9b3da9c
11932e5
79df1fc
7ed8901
84ece5f
0773170
60f50d7
d1e3fb2
ad4c2fd
7c74b98
a581dd5
ba02a9f
6433b30
e13b1c2
7311e67
99d9211
e2024b7
51de080
03c4383
ae62c6c
3aa983c
26e842b
20b91ce
429ed12
7040f38
b039c0a
465f7db
331b965
a3e57cb
467d4e0
8a1065e
ede6341
a6ce30d
185df2e
d870fb6
4202ff5
68c6274
d45e5ba
a7fc4fe
943df02
2d7cafc
3f50a21
5126fc1
29c9a9f
3c015da
3b3a25c
274b139
5124288
91bcecc
c210669
f08fa3c
b655f4e
c49bc52
3ff4105
1dd2d87
06f1ac1
27af228
25f6ced
4d65168
cde3576
208d1f5
0454f91
a8d8fa5
2f8a4e6
dc703f0
0e3644f
5afd257
879fd21
b71296e
3f2d615
f2268b5
5f10a22
c01d3d7
df9eaa0
cce1e32
0f305b3
878c83f
2423d2b
7701b58
93f7449
fca4ebc
5d85886
70237f9
59d3183
c5f3124
de999b5
be11016
8065703
82deb26
c47ffae
068b077
6047c9d
bd9340d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,7 @@ | |
.kbnTopNavMenu__badgeGroup { | ||
margin-right: $euiSizeM; | ||
} | ||
|
||
.kbnTopNavMenu__betaBadgeGroup { | ||
align-self: center; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,12 @@ | |
import { CoreStart, CoreSetup, Plugin, PluginInitializerContext } from 'src/core/public'; | ||
import { PublicMethodsOf } from '@kbn/utility-types'; | ||
import { UiActionsService } from './service'; | ||
import { rowClickTrigger, visualizeFieldTrigger, visualizeGeoFieldTrigger } from './triggers'; | ||
import { | ||
rowClickTrigger, | ||
visualizeFieldTrigger, | ||
visualizeGeoFieldTrigger, | ||
visualizeEditorTrigger, | ||
} from './triggers'; | ||
import { setTheme } from './services'; | ||
|
||
export type UiActionsSetup = Pick< | ||
|
@@ -33,6 +38,7 @@ export class UiActionsPlugin implements Plugin<UiActionsSetup, UiActionsStart> { | |
setTheme(core.theme); | ||
this.service.registerTrigger(rowClickTrigger); | ||
this.service.registerTrigger(visualizeFieldTrigger); | ||
this.service.registerTrigger(visualizeEditorTrigger); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason this is not registered from visualize editor plugin ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ppisljar I added this here to be consistent with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it to the visualizations plugin :) |
||
this.service.registerTrigger(visualizeGeoFieldTrigger); | ||
return this.service; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Trigger } from '.'; | ||
|
||
export const VISUALIZE_EDITOR_TRIGGER = 'VISUALIZE_EDITOR_TRIGGER'; | ||
export const visualizeEditorTrigger: Trigger = { | ||
id: VISUALIZE_EDITOR_TRIGGER, | ||
title: 'Convert legacy visualizations to Lens', | ||
description: 'Triggered when user navigates from a legacy visualization to Lens.', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import type { DataView } from '../../../../data/common'; | ||
import { getDataSourceInfo } from './get_datasource_info'; | ||
const dataViewsMap: Record<string, DataView> = { | ||
test1: { id: 'test1', title: 'test1', timeFieldName: 'timeField1' } as DataView, | ||
test2: { | ||
id: 'test2', | ||
title: 'test2', | ||
timeFieldName: 'timeField2', | ||
} as DataView, | ||
test3: { id: 'test3', title: 'test3', timeFieldName: 'timeField3' } as DataView, | ||
}; | ||
|
||
const getDataview = (id: string): DataView | undefined => dataViewsMap[id]; | ||
jest.mock('../services', () => { | ||
return { | ||
getDataStart: jest.fn(() => { | ||
return { | ||
dataViews: { | ||
getDefault: jest.fn(() => { | ||
return { id: '12345', title: 'default', timeFieldName: '@timestamp' }; | ||
}), | ||
get: getDataview, | ||
}, | ||
}; | ||
}), | ||
}; | ||
}); | ||
|
||
describe('getDataSourceInfo', () => { | ||
test('should return the default dataview if model_indexpattern is string', async () => { | ||
const { indexPatternId, timeField } = await getDataSourceInfo( | ||
'test', | ||
undefined, | ||
false, | ||
undefined | ||
); | ||
expect(indexPatternId).toBe('12345'); | ||
expect(timeField).toBe('@timestamp'); | ||
}); | ||
|
||
test('should return the correct dataview if model_indexpattern is object', async () => { | ||
const { indexPatternId, timeField } = await getDataSourceInfo( | ||
{ id: 'dataview-1-id' }, | ||
'timeField-1', | ||
false, | ||
undefined | ||
); | ||
expect(indexPatternId).toBe('dataview-1-id'); | ||
expect(timeField).toBe('timeField-1'); | ||
}); | ||
|
||
test('should fetch the correct data if overwritten dataview is provided', async () => { | ||
const { indexPatternId, timeField } = await getDataSourceInfo( | ||
{ id: 'dataview-1-id' }, | ||
'timeField-1', | ||
true, | ||
{ id: 'test2' } | ||
); | ||
expect(indexPatternId).toBe('test2'); | ||
expect(timeField).toBe('timeField2'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { fetchIndexPattern, isStringTypeIndexPattern } from '../../common/index_patterns_utils'; | ||
import type { IndexPatternValue } from '../../common/types'; | ||
import { getDataStart } from '../services'; | ||
|
||
export const getDataSourceInfo = async ( | ||
modelIndexPattern: IndexPatternValue, | ||
modelTimeField: string | undefined, | ||
isOverwritten: boolean, | ||
overwrittenIndexPattern: IndexPatternValue | undefined | ||
) => { | ||
const { dataViews } = getDataStart(); | ||
let indexPatternId = | ||
modelIndexPattern && !isStringTypeIndexPattern(modelIndexPattern) ? modelIndexPattern.id : ''; | ||
|
||
let timeField = modelTimeField; | ||
// handle override index pattern | ||
if (isOverwritten) { | ||
const { indexPattern } = await fetchIndexPattern(overwrittenIndexPattern, dataViews); | ||
if (indexPattern) { | ||
indexPatternId = indexPattern.id ?? ''; | ||
timeField = indexPattern.timeFieldName; | ||
} | ||
} | ||
if (!timeField) { | ||
if (indexPatternId) { | ||
const indexPattern = await dataViews.get(indexPatternId); | ||
timeField = indexPattern.timeFieldName; | ||
} else { | ||
const defaultIndex = await dataViews.getDefault(); | ||
timeField = defaultIndex?.timeFieldName; | ||
} | ||
} | ||
if (!indexPatternId) { | ||
const defaultIndex = await dataViews.getDefault(); | ||
indexPatternId = defaultIndex?.id ?? ''; | ||
} | ||
stratoula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return { | ||
indexPatternId, | ||
timeField, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ Not needed, allows a TSVB library panel to be replaced by a Lens by value panel