Skip to content

Commit

Permalink
[Visualize] Fix embeddable panel title behavior (elastic#200548)
Browse files Browse the repository at this point in the history
## Summary

This PR adds a fix for a regression bug introduced with the new
embeddable refactor in 8.16 .
I've added an extra 8.16 FTR test to ensure it works.

### Checklist

- [x] [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

(cherry picked from commit 5102b50)
  • Loading branch information
dej611 committed Nov 18, 2024
1 parent 922afd9 commit cdfd6c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/plugins/visualizations/public/embeddable/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export const deserializeSavedObjectState = async ({
enhancements,
uiState,
timeRange,
title: embeddableTitle,
description: embeddableDescription,
hidePanelTitles,
}: VisualizeSavedObjectInputState) => {
// Load a saved visualization from the library
const {
Expand All @@ -137,6 +140,8 @@ export const deserializeSavedObjectState = async ({
},
savedObjectId
);
const panelTitle = embeddableTitle ?? title;
const panelDescription = embeddableDescription ?? description;
return {
savedVis: {
title,
Expand All @@ -149,8 +154,9 @@ export const deserializeSavedObjectState = async ({
savedSearchId,
},
},
title,
description,
title: panelTitle,
description: panelDescription,
hidePanelTitles,
savedObjectId,
savedObjectProperties,
linkedToLibrary: true,
Expand Down Expand Up @@ -188,6 +194,7 @@ export const serializeState: (props: {
if (linkedToLibrary) {
return {
rawState: {
...titlesWithDefaults,
savedObjectId: id,
...(enhancements ? { enhancements } : {}),
...(!isEmpty(serializedVis.uiState) ? { uiState: serializedVis.uiState } : {}),
Expand Down
20 changes: 20 additions & 0 deletions test/functional/apps/visualize/group3/_add_to_dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardExpect = getService('dashboardExpect');
const dashboardPanelActions = getService('dashboardPanelActions');
const dashboardCustomizePanel = getService('dashboardCustomizePanel');
const testSubjects = getService('testSubjects');
const listingTable = getService('listingTable');

Expand Down Expand Up @@ -287,5 +288,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await dashboardPanelActions.expectLinkedToLibrary('Neat Saved Vis 2 Copy');
});

it('should persist correctly panel title on a by reference visualization', async () => {
await dashboard.navigateToApp();

await dashboard.clickNewDashboard();
await dashboard.addVisualizations(['Visualization AreaChart']);

await dashboardPanelActions.customizePanel();
await dashboardCustomizePanel.setCustomPanelTitle('My New panel title');
await dashboardCustomizePanel.clickSaveButton();

await dashboard.saveDashboard('My Very Entitled Dashboard');

await dashboard.gotoDashboardLandingPage();
await listingTable.clickItemLink('dashboard', 'My Very Entitled Dashboard');

const [newPanelTitle] = await dashboard.getPanelTitles();
expect(newPanelTitle).to.equal('My New panel title');
});
});
}

0 comments on commit cdfd6c2

Please sign in to comment.