Skip to content
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

[Visualize] Fix embeddable panel title behavior #200548

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
}