mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Canvas: Update connection info on element rename (#62532)
This commit is contained in:
parent
e7ace4ed62
commit
58c9618160
@ -10,6 +10,7 @@ import {
|
||||
} from 'app/features/canvas';
|
||||
import { notFoundItem } from 'app/features/canvas/elements/notFound';
|
||||
import { DimensionContext } from 'app/features/dimensions';
|
||||
import { getConnectionsByTarget, isConnectionTarget } from 'app/plugins/panel/canvas/utils';
|
||||
|
||||
import { Constraint, HorizontalConstraint, Placement, VerticalConstraint } from '../types';
|
||||
|
||||
@ -382,6 +383,12 @@ export class ElementState implements LayerElement {
|
||||
|
||||
const scene = this.getScene();
|
||||
if (oldName !== newName && scene) {
|
||||
if (isConnectionTarget(this, scene.byName)) {
|
||||
getConnectionsByTarget(this, scene).forEach((connection) => {
|
||||
connection.info.targetName = newName;
|
||||
});
|
||||
}
|
||||
|
||||
scene.byName.delete(oldName);
|
||||
scene.byName.set(newName, this);
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ export class Connections {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.connectionTarget = undefined;
|
||||
this.connectionAnchorDiv!.style.display = 'none';
|
||||
return true;
|
||||
};
|
||||
|
@ -157,3 +157,7 @@ export function getConnections(sceneByName: Map<string, ElementState>) {
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
export function getConnectionsByTarget(element: ElementState, scene: Scene) {
|
||||
return getConnections(scene.byName).filter((connection) => connection.target === element);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user