mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[TSVB][AggBased] Transfer panel title and description to the converted Lens panels (#154713)
## Summary Closes https://github.com/elastic/kibana/issues/153913 There are 2 ways to convert a legacy visualizations to Lens 1. Go to the legacy editor and click the Visualize in Lens top nav button 2. Open the panel menu on the dashboard level and click Convert to Lens On the first case the panel title and description was not passed to the converted panel On the second case the panel title was passed but not the description This PR fixes all the aforementioned scenarios  ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
10f2015d17
commit
07a7e765f6
8 changed files with 22 additions and 6 deletions
|
@ -87,6 +87,7 @@ export class EditInLensAction implements Action<EditInLensContext> {
|
|||
searchFilters,
|
||||
searchQuery,
|
||||
isEmbeddable: true,
|
||||
description: vis.description || embeddable.getOutput().description,
|
||||
};
|
||||
if (navigateToLensConfig) {
|
||||
if (this.currentAppId) {
|
||||
|
|
|
@ -120,6 +120,8 @@ export interface VisInstance {
|
|||
savedVis: VisSavedObject;
|
||||
savedSearch?: SavedSearch;
|
||||
embeddableHandler: VisualizeEmbeddableContract;
|
||||
panelTitle?: string;
|
||||
panelDescription?: string;
|
||||
}
|
||||
|
||||
export type SavedVisInstance = VisInstance;
|
||||
|
|
|
@ -312,6 +312,10 @@ export const getTopNavConfig = (
|
|||
embeddableId,
|
||||
vizEditorOriginatingAppUrl: getVizEditorOriginatingAppUrl(history),
|
||||
originatingApp,
|
||||
title: visInstance?.panelTitle || vis.title,
|
||||
visTypeTitle: vis.type.title,
|
||||
description: visInstance?.panelDescription || vis.description,
|
||||
isEmbeddable: Boolean(originatingApp),
|
||||
};
|
||||
if (navigateToLensConfig) {
|
||||
hideLensBadge();
|
||||
|
|
|
@ -168,6 +168,8 @@ describe('getVisualizationInstanceInput', () => {
|
|||
test('should create new instances of savedVis, vis and embeddableHandler', async () => {
|
||||
const input = {
|
||||
id: 'test-id',
|
||||
description: 'description',
|
||||
title: 'title',
|
||||
savedVis: {
|
||||
title: '',
|
||||
description: '',
|
||||
|
@ -194,7 +196,7 @@ describe('getVisualizationInstanceInput', () => {
|
|||
},
|
||||
},
|
||||
} as unknown as VisualizeInput;
|
||||
const { savedVis, savedSearch, vis, embeddableHandler } =
|
||||
const { savedVis, savedSearch, vis, embeddableHandler, panelDescription, panelTitle } =
|
||||
await getVisualizationInstanceFromInput(mockServices, input);
|
||||
|
||||
expect(getSavedVisualization).toHaveBeenCalled();
|
||||
|
@ -212,5 +214,7 @@ describe('getVisualizationInstanceInput', () => {
|
|||
expect(savedVis.uiStateJSON).toBe(JSON.stringify(input.savedVis?.uiState));
|
||||
expect(embeddableHandler).toBeDefined();
|
||||
expect(savedSearch).toBeUndefined();
|
||||
expect(panelDescription).toBe('description');
|
||||
expect(panelTitle).toBe('title');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -119,6 +119,8 @@ export const getVisualizationInstanceFromInput = async (
|
|||
savedVis,
|
||||
embeddableHandler,
|
||||
savedSearch,
|
||||
panelTitle: input?.title ?? '',
|
||||
panelDescription: input?.description ?? '',
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -646,9 +646,7 @@ export const LensTopNavMenu = ({
|
|||
{
|
||||
newTitle:
|
||||
title ||
|
||||
(initialContext &&
|
||||
'isEmbeddable' in initialContext &&
|
||||
initialContext.isEmbeddable
|
||||
(contextFromEmbeddable
|
||||
? i18n.translate('xpack.lens.app.convertedLabel', {
|
||||
defaultMessage: '{title} (converted)',
|
||||
values: {
|
||||
|
@ -661,6 +659,7 @@ export const LensTopNavMenu = ({
|
|||
newCopyOnSave: false,
|
||||
isTitleDuplicateConfirmed: false,
|
||||
returnToOrigin: true,
|
||||
newDescription: contextFromEmbeddable ? initialContext.description : '',
|
||||
},
|
||||
{
|
||||
saveToLibrary:
|
||||
|
|
|
@ -244,6 +244,7 @@ export type VisualizeEditorContext<T extends Configuration = Configuration> = {
|
|||
searchQuery?: Query;
|
||||
searchFilters?: Filter[];
|
||||
title?: string;
|
||||
description?: string;
|
||||
visTypeTitle?: string;
|
||||
isEmbeddable?: boolean;
|
||||
} & NavigateToLensContext<T>;
|
||||
|
|
|
@ -57,6 +57,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
const embeddableCount = await canvas.getEmbeddableCount();
|
||||
expect(embeddableCount).to.eql(originalEmbeddableCount);
|
||||
});
|
||||
const titles = await dashboard.getPanelTitles();
|
||||
expect(titles[0]).to.be('My TSVB to Lens viz 1 (converted)');
|
||||
await panelActions.removePanel();
|
||||
});
|
||||
|
||||
|
@ -85,13 +87,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
const embeddableCount = await canvas.getEmbeddableCount();
|
||||
expect(embeddableCount).to.eql(originalEmbeddableCount);
|
||||
});
|
||||
|
||||
const panel = await testSubjects.find(`embeddablePanelHeading-`);
|
||||
const panel = await testSubjects.find(`embeddablePanelHeading-MyTSVBtoLensviz2(converted)`);
|
||||
const descendants = await testSubjects.findAllDescendant(
|
||||
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
|
||||
panel
|
||||
);
|
||||
expect(descendants.length).to.equal(0);
|
||||
const titles = await dashboard.getPanelTitles();
|
||||
expect(titles[0]).to.be('My TSVB to Lens viz 2 (converted)');
|
||||
|
||||
await panelActions.removePanel();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue