From 44c471d10ca1d7c7035f648d3278aacbc1c99507 Mon Sep 17 00:00:00 2001 From: Oscar Kilhed Date: Wed, 26 Mar 2025 17:03:10 +0100 Subject: [PATCH] Dashboards: Limit panel title length (#102911) Limit panel title length --- .../dashboard-scene/serialization/layoutSerializers/utils.ts | 2 +- .../dashboard-scene/serialization/transformSaveModelToScene.ts | 2 +- public/app/features/dashboard/dashgrid/DashboardGrid.tsx | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard-scene/serialization/layoutSerializers/utils.ts b/public/app/features/dashboard-scene/serialization/layoutSerializers/utils.ts index d34169c680a..d3de9dd2354 100644 --- a/public/app/features/dashboard-scene/serialization/layoutSerializers/utils.ts +++ b/public/app/features/dashboard-scene/serialization/layoutSerializers/utils.ts @@ -59,7 +59,7 @@ export function buildVizPanel(panel: PanelKind): VizPanel { const vizPanelState: VizPanelState = { key: getVizPanelKeyForPanelId(panel.spec.id), - title: panel.spec.title, + title: panel.spec.title?.substring(0, 5000), description: panel.spec.description, pluginId: panel.spec.vizConfig.kind, options: panel.spec.vizConfig.spec.options, diff --git a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts index 0c139f9fc11..a8fd71f4047 100644 --- a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts +++ b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts @@ -323,7 +323,7 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem { const vizPanelState: VizPanelState = { key: getVizPanelKeyForPanelId(panel.id), - title: panel.title, + title: panel.title?.substring(0, 5000), description: panel.description, pluginId: panel.type ?? 'timeseries', options: panel.options ?? {}, diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index 397dfc30c33..a8cd9720e22 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -111,6 +111,7 @@ export class DashboardGrid extends PureComponent { if (!panel.key) { panel.key = `panel-${panel.id}-${Date.now()}`; } + panel.title = panel.title?.substring(0, 5000); this.panelMap[panel.key] = panel; if (!panel.gridPos) {