Chore: Rename activateInActiveParents -> activateSceneObjectAndParentTree (#95534)

* Activate parents of query runner when using dashboard ds

* Set plugin loading util to fix test because activating the ancestors of the query runner needs to be able to load the plugin for the panel

* Rename activateInActiveParents -> activateSceneObjectAndParentTree

* Add back but deprecate activeInActiveParents
This commit is contained in:
Oscar Kilhed 2024-10-30 09:55:16 +01:00 committed by GitHub
parent a20c9db6b7
commit 5673fafbfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 11 deletions

View File

@ -24,7 +24,7 @@ import { getPanelChanges } from '../saving/getDashboardChanges';
import { DashboardGridItem, DashboardGridItemState } from '../scene/DashboardGridItem';
import { vizPanelToPanel } from '../serialization/transformSceneToSaveModel';
import {
activateInActiveParents,
activateSceneObjectAndParentTree,
getDashboardSceneFor,
getLibraryPanelBehavior,
getPanelIdForVizPanel,
@ -68,7 +68,7 @@ export class PanelEditor extends SceneObjectBase<PanelEditorState> {
private _activationHandler() {
const panel = this.state.panelRef.resolve();
const deactivateParents = activateInActiveParents(panel);
const deactivateParents = activateSceneObjectAndParentTree(panel);
const layoutElement = panel.parent;
this.waitForPlugin();

View File

@ -7,7 +7,7 @@ import { SceneGridRow, VizPanel, sceneGraph } from '@grafana/scenes';
import { useStyles2 } from '@grafana/ui';
import { Trans } from 'app/core/internationalization';
import { activateInActiveParents } from '../utils/utils';
import { activateSceneObjectAndParentTree } from '../utils/utils';
import { DashboardGridItem } from './DashboardGridItem';
import { DashboardScene } from './DashboardScene';
@ -65,7 +65,7 @@ export function PanelSearchLayout({ dashboard, panelSearch = '', panelsPerRow }:
}
function PanelSearchHit({ panel }: { panel: VizPanel }) {
useEffect(() => activateInActiveParents(panel), [panel]);
useEffect(() => activateSceneObjectAndParentTree(panel), [panel]);
return <panel.Component model={panel} />;
}

View File

@ -1,6 +1,6 @@
import { SceneComponentProps, SceneObjectBase, SceneObjectRef, SceneObjectState, VizPanel } from '@grafana/scenes';
import { activateInActiveParents } from '../utils/utils';
import { activateSceneObjectAndParentTree } from '../utils/utils';
interface ViewPanelSceneState extends SceneObjectState {
panelRef: SceneObjectRef<VizPanel>;
@ -15,7 +15,7 @@ export class ViewPanelScene extends SceneObjectBase<ViewPanelSceneState> {
public _activationHandler() {
const panel = this.state.panelRef.resolve();
return activateInActiveParents(panel);
return activateSceneObjectAndParentTree(panel);
}
public getUrlKey() {

View File

@ -249,11 +249,11 @@ export function getLibraryPanelBehavior(vizPanel: VizPanel): LibraryPanelBehavio
}
/**
* Activates any inactive parents of the scene object.
* Activates any inactive ancestors of the scene object.
* Useful when rendering a scene object out of context of it's parent
* @returns
*/
export function activateInActiveParents(so: SceneObject): CancelActivationHandler | undefined {
export function activateSceneObjectAndParentTree(so: SceneObject): CancelActivationHandler | undefined {
let cancel: CancelActivationHandler | undefined;
let parentCancel: CancelActivationHandler | undefined;
@ -262,7 +262,7 @@ export function activateInActiveParents(so: SceneObject): CancelActivationHandle
}
if (so.parent) {
parentCancel = activateInActiveParents(so.parent);
parentCancel = activateSceneObjectAndParentTree(so.parent);
}
cancel = so.activate();
@ -272,3 +272,10 @@ export function activateInActiveParents(so: SceneObject): CancelActivationHandle
cancel();
};
}
/**
* @deprecated use activateSceneObjectAndParentTree instead.
* Activates any inactive ancestors of the scene object.
* Useful when rendering a scene object out of context of it's parent
*/
export const activateInActiveParents = activateSceneObjectAndParentTree;

View File

@ -10,7 +10,7 @@ import {
} from '@grafana/data';
import { SceneDataProvider, SceneDataTransformer, SceneObject } from '@grafana/scenes';
import {
activateInActiveParents,
activateSceneObjectAndParentTree,
findVizPanelByKey,
getVizPanelKeyForPanelId,
} from 'app/features/dashboard-scene/utils/utils';
@ -73,7 +73,7 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> {
sourceDataProvider?.setContainerWidth(500);
}
const cleanUp = activateInActiveParents(sourceDataProvider!);
const cleanUp = activateSceneObjectAndParentTree(sourceDataProvider!);
return sourceDataProvider!.getResultsStream!().pipe(
map((result) => {