[release-12.0.1] DashboardEditPane: Fix source viz panel selection (#104868)
DashboardEditPane: Fix source viz panel selection (#104686)
* revert ae86746
* extract source viz panel for edit pane select
This commit is contained in:
@@ -3,7 +3,14 @@ import { Resizable } from 're-resizable';
|
||||
import { useLocalStorage } from 'react-use';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { SceneObjectState, SceneObjectBase, SceneObject, sceneGraph, useSceneObjectState } from '@grafana/scenes';
|
||||
import {
|
||||
SceneObjectState,
|
||||
SceneObjectBase,
|
||||
SceneObject,
|
||||
sceneGraph,
|
||||
useSceneObjectState,
|
||||
VizPanel,
|
||||
} from '@grafana/scenes';
|
||||
import {
|
||||
ElementSelectionContextItem,
|
||||
ElementSelectionContextState,
|
||||
@@ -17,8 +24,8 @@ import {
|
||||
} from '@grafana/ui';
|
||||
import { t, Trans } from 'app/core/internationalization';
|
||||
|
||||
import { containsCloneKey, getOriginalKey, isInCloneChain } from '../utils/clone';
|
||||
import { getDashboardSceneFor } from '../utils/utils';
|
||||
import { containsCloneKey, getLastKeyFromClone, isInCloneChain } from '../utils/clone';
|
||||
import { findEditPanel, getDashboardSceneFor } from '../utils/utils';
|
||||
|
||||
import { DashboardOutline } from './DashboardOutline';
|
||||
import { ElementEditPane } from './ElementEditPane';
|
||||
@@ -101,10 +108,14 @@ export class DashboardEditPane extends SceneObjectBase<DashboardEditPaneState> {
|
||||
return;
|
||||
}
|
||||
|
||||
const elementId = containsCloneKey(element.id) ? getOriginalKey(element.id) : element.id;
|
||||
|
||||
const obj = sceneGraph.findByKey(this, elementId);
|
||||
let obj = sceneGraph.findByKey(this, element.id);
|
||||
if (obj) {
|
||||
if (obj instanceof VizPanel && containsCloneKey(getLastKeyFromClone(element.id))) {
|
||||
const sourceVizPanel = findEditPanel(this, element.id);
|
||||
if (sourceVizPanel) {
|
||||
obj = sourceVizPanel;
|
||||
}
|
||||
}
|
||||
this.selectObject(obj, element.id, options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user