Scenes: Fix incorrect panel context.app during panel edit (#101567)

This commit is contained in:
Leon Sorokin 2025-03-06 06:48:16 -06:00 committed by GitHub
parent 6accf13597
commit a604602b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -11,7 +11,16 @@ import { getDashboardSceneFor, getPanelIdForVizPanel, getQueryRunnerFor } from '
import { DashboardScene } from './DashboardScene';
export function setDashboardPanelContext(vizPanel: VizPanel, context: PanelContext) {
context.app = CoreApp.Dashboard;
const dashboard = getDashboardSceneFor(vizPanel);
context.app = dashboard.state.isEditing ? CoreApp.PanelEditor : CoreApp.Dashboard;
dashboard.subscribeToState((state) => {
if (state.isEditing) {
context.app = CoreApp.PanelEditor;
} else {
context.app = CoreApp.Dashboard;
}
});
context.canAddAnnotations = () => {
const dashboard = getDashboardSceneFor(vizPanel);