mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Scenes: Update scenes to v6 (#67110)
* Scenes: Update scenes to v6 * Fix test
This commit is contained in:
parent
6e4fe51fe8
commit
926abcf6aa
@ -262,7 +262,7 @@
|
||||
"@grafana/lezer-logql": "0.1.3",
|
||||
"@grafana/monaco-logql": "^0.0.7",
|
||||
"@grafana/runtime": "workspace:*",
|
||||
"@grafana/scenes": "^0.3.0",
|
||||
"@grafana/scenes": "^0.6.0",
|
||||
"@grafana/schema": "workspace:*",
|
||||
"@grafana/ui": "workspace:*",
|
||||
"@kusto/monaco-kusto": "5.3.6",
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Libraries
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { getUrlSyncManager } from '@grafana/scenes';
|
||||
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
||||
|
||||
import { getSceneByTitle } from './scenes';
|
||||
@ -13,7 +14,7 @@ export const ScenePage = (props: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (scene && !isInitialized) {
|
||||
scene.initUrlSync();
|
||||
getUrlSyncManager().initSync(scene);
|
||||
setInitialized(true);
|
||||
}
|
||||
}, [isInitialized, scene]);
|
||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||
|
||||
import { GrafanaTheme2, PageLayoutType } from '@grafana/data';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { UrlSyncManager, SceneObjectBase, SceneComponentProps, SceneObject, SceneObjectState } from '@grafana/scenes';
|
||||
import { SceneObjectBase, SceneComponentProps, SceneObject, SceneObjectState } from '@grafana/scenes';
|
||||
import { ToolbarButton, useStyles2 } from '@grafana/ui';
|
||||
import { AppChromeUpdate } from 'app/core/components/AppChrome/AppChromeUpdate';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
@ -18,18 +18,6 @@ interface DashboardSceneState extends SceneObjectState {
|
||||
|
||||
export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
||||
public static Component = DashboardSceneRenderer;
|
||||
private urlSyncManager?: UrlSyncManager;
|
||||
|
||||
/**
|
||||
* It's better to do this before activate / mount to not trigger unnessary re-renders
|
||||
*/
|
||||
public initUrlSync() {
|
||||
if (!this.urlSyncManager) {
|
||||
this.urlSyncManager = new UrlSyncManager(this);
|
||||
}
|
||||
|
||||
this.urlSyncManager.initSync();
|
||||
}
|
||||
}
|
||||
|
||||
function DashboardSceneRenderer({ model }: SceneComponentProps<DashboardScene>) {
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
SceneDataTransformer,
|
||||
SceneGridItem,
|
||||
SceneDataProvider,
|
||||
getUrlSyncManager,
|
||||
} from '@grafana/scenes';
|
||||
import { StateManagerBase } from 'app/core/services/StateManagerBase';
|
||||
import { dashboardLoaderSrv } from 'app/features/dashboard/services/DashboardLoaderSrv';
|
||||
@ -75,7 +76,7 @@ export class DashboardLoader extends StateManagerBase<DashboardLoaderState> {
|
||||
|
||||
// We initialize URL sync here as it better to do that before mounting and doing any rendering.
|
||||
// But would be nice to have a conditional around this so you can pre-load dashboards without url sync.
|
||||
dashboard.initUrlSync();
|
||||
getUrlSyncManager().initSync(dashboard);
|
||||
|
||||
this.cache[rsp.dashboard.uid] = dashboard;
|
||||
this.setState({ dashboard, isLoading: false });
|
||||
|
12
yarn.lock
12
yarn.lock
@ -3342,9 +3342,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@grafana/scenes@npm:^0.3.0":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@grafana/scenes@npm:0.3.0"
|
||||
"@grafana/scenes@npm:^0.6.0":
|
||||
version: 0.6.0
|
||||
resolution: "@grafana/scenes@npm:0.6.0"
|
||||
dependencies:
|
||||
"@grafana/e2e-selectors": canary
|
||||
"@grafana/experimental": 1.0.1
|
||||
@ -3352,9 +3352,9 @@ __metadata:
|
||||
react-use: 17.4.0
|
||||
react-virtualized-auto-sizer: 1.0.7
|
||||
uuid: ^9.0.0
|
||||
checksum: 3610cedcc150b9d6e3d6948056bb1bbbfe58d7fa0ff6e762eec6619bb0940504db867ea87e56160f27e4d93772f6203493bf87d353a1b18d2664e74a03f03a05
|
||||
checksum: 7197abac93ba84711900b526f0caa648b0b9f0c0e2edea2fbc125c1f192d6a3dae52389007cf82cbdf06a7b8019e5c03b5efa635f12ebc51eab5852cddf6427e
|
||||
languageName: node
|
||||
linkType: soft
|
||||
linkType: hard
|
||||
|
||||
"@grafana/schema@10.0.0-pre, @grafana/schema@workspace:*, @grafana/schema@workspace:packages/grafana-schema":
|
||||
version: 0.0.0-use.local
|
||||
@ -20169,7 +20169,7 @@ __metadata:
|
||||
"@grafana/lezer-logql": 0.1.3
|
||||
"@grafana/monaco-logql": ^0.0.7
|
||||
"@grafana/runtime": "workspace:*"
|
||||
"@grafana/scenes": ^0.3.0
|
||||
"@grafana/scenes": ^0.6.0
|
||||
"@grafana/schema": "workspace:*"
|
||||
"@grafana/toolkit": "workspace:*"
|
||||
"@grafana/tsconfig": ^1.2.0-rc1
|
||||
|
Loading…
Reference in New Issue
Block a user