mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
27 lines
743 B
TypeScript
27 lines
743 B
TypeScript
import { SceneDeactivationHandler, SceneObject } from '@grafana/scenes';
|
|
|
|
export function getVizPanelKeyForPanelId(panelId: number) {
|
|
return `panel-${panelId}`;
|
|
}
|
|
|
|
/**
|
|
* Useful from tests to simulate mounting a full scene. Children are activated before parents to simulate the real order
|
|
* of React mount order and useEffect ordering.
|
|
*
|
|
*/
|
|
export function activateFullSceneTree(scene: SceneObject): SceneDeactivationHandler {
|
|
const deactivationHandlers: SceneDeactivationHandler[] = [];
|
|
|
|
scene.forEachChild((child) => {
|
|
deactivationHandlers.push(activateFullSceneTree(child));
|
|
});
|
|
|
|
deactivationHandlers.push(scene.activate());
|
|
|
|
return () => {
|
|
for (const handler of deactivationHandlers) {
|
|
handler();
|
|
}
|
|
};
|
|
}
|