mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 23:37:01 -06:00
Revert "DashboardScene: prevent panel hovel header crop with scenes" (#85865)
Revert "DashboardScene: prevent panel hovel header crop with scenes (#85780)"
This reverts commit 23f1732855
.
This commit is contained in:
parent
2fc8342248
commit
33b6f45a9e
@ -255,7 +255,7 @@
|
||||
"@grafana/prometheus": "workspace:*",
|
||||
"@grafana/runtime": "workspace:*",
|
||||
"@grafana/saga-icons": "workspace:*",
|
||||
"@grafana/scenes": "^4.5.6",
|
||||
"@grafana/scenes": "^4.5.4",
|
||||
"@grafana/schema": "workspace:*",
|
||||
"@grafana/sql": "workspace:*",
|
||||
"@grafana/ui": "workspace:*",
|
||||
|
@ -7,18 +7,16 @@ import {
|
||||
FieldType,
|
||||
LoadingState,
|
||||
PanelData,
|
||||
getDefaultTimeRange,
|
||||
TimeRange,
|
||||
standardTransformersRegistry,
|
||||
toDataFrame,
|
||||
} from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { SceneDataTransformer, SceneQueryRunner, VizPanel } from '@grafana/scenes';
|
||||
import { SceneDataTransformer, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
||||
import { getStandardTransformers } from 'app/features/transformers/standardTransformers';
|
||||
import { DashboardDataDTO } from 'app/types';
|
||||
|
||||
import { DashboardGridItem } from '../../scene/DashboardGridItem';
|
||||
import { DashboardScene } from '../../scene/DashboardScene';
|
||||
import { transformSaveModelToScene } from '../../serialization/transformSaveModelToScene';
|
||||
import { DashboardModelCompatibilityWrapper } from '../../utils/DashboardModelCompatibilityWrapper';
|
||||
import { findVizPanelByKey } from '../../utils/utils';
|
||||
@ -31,29 +29,17 @@ function createModelMock(
|
||||
panelData: PanelData,
|
||||
transformations?: DataTransformerConfig[],
|
||||
onChangeTransformationsMock?: Function
|
||||
): PanelDataTransformationsTab {
|
||||
const panel = new VizPanel({
|
||||
$data: new SceneDataTransformer({
|
||||
$data: new SceneQueryRunner({ queries: [] }),
|
||||
transformations: transformations || [],
|
||||
}),
|
||||
});
|
||||
const gridItem = new DashboardGridItem({ body: panel });
|
||||
const vizPanelManager = VizPanelManager.createFor(panel);
|
||||
const scene = new DashboardScene({ body: gridItem });
|
||||
|
||||
// @ts-expect-error
|
||||
getDashboardSrv().setCurrent(new DashboardModelCompatibilityWrapper(scene));
|
||||
|
||||
const transformationTab = new PanelDataTransformationsTab(vizPanelManager);
|
||||
// @ts-expect-error
|
||||
transformationTab.onChangeTransformations = onChangeTransformationsMock || transformationTab.onChangeTransformations;
|
||||
return transformationTab;
|
||||
) {
|
||||
return {
|
||||
getDataTransformer: () => new SceneDataTransformer({ data: panelData, transformations: transformations || [] }),
|
||||
getQueryRunner: () => new SceneQueryRunner({ queries: [], data: panelData }),
|
||||
onChangeTransformations: onChangeTransformationsMock,
|
||||
} as unknown as PanelDataTransformationsTab;
|
||||
}
|
||||
|
||||
const mockData = {
|
||||
timeRange: getDefaultTimeRange(),
|
||||
state: LoadingState.Done,
|
||||
timeRange: {} as unknown as TimeRange,
|
||||
state: {} as unknown as LoadingState,
|
||||
series: [
|
||||
toDataFrame({
|
||||
name: 'A',
|
||||
|
@ -22,13 +22,6 @@ jest.mock('react-router-dom', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...jest.requireActual('@grafana/runtime'),
|
||||
getPluginImportUtils: () => ({
|
||||
getPanelPluginFromCache: jest.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
// Needed when the panel is not part of an DashboardScene
|
||||
jest.spyOn(utils, 'getDashboardSceneFor').mockReturnValue(new DashboardScene({}));
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
import { VizPanel } from '@grafana/scenes';
|
||||
|
||||
import { DashboardGridItem } from './DashboardGridItem';
|
||||
|
||||
export const hoverHeaderOffsetBehavior = (grid: DashboardGridItem) => {
|
||||
const sub = grid.subscribeToState((newState, prevState) => {
|
||||
if ([newState.y, prevState.y].includes(0) && newState.y !== prevState.y) {
|
||||
grid.forEachChild((child) => {
|
||||
if (child instanceof VizPanel && child.state.hoverHeader) {
|
||||
child.setState({ hoverHeaderOffset: grid.state.y === 0 ? 0 : undefined });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
};
|
||||
};
|
@ -47,7 +47,6 @@ import { panelLinksBehavior, panelMenuBehavior } from '../scene/PanelMenuBehavio
|
||||
import { PanelNotices } from '../scene/PanelNotices';
|
||||
import { PanelTimeRange } from '../scene/PanelTimeRange';
|
||||
import { RowRepeaterBehavior } from '../scene/RowRepeaterBehavior';
|
||||
import { hoverHeaderOffsetBehavior } from '../scene/hoverHeaderOffsetBehavior';
|
||||
import { RowActions } from '../scene/row-actions/RowActions';
|
||||
import { setDashboardPanelContext } from '../scene/setDashboardPanelContext';
|
||||
import { createPanelDataProvider } from '../utils/createPanelDataProvider';
|
||||
@ -507,7 +506,6 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
displayMode: panel.transparent ? 'transparent' : undefined,
|
||||
// To be replaced with it's own option persited option instead derived
|
||||
hoverHeader: !panel.title && !panel.timeFrom && !panel.timeShift,
|
||||
hoverHeaderOffset: (panel.gridPos?.y ?? 0) === 0 ? 0 : undefined,
|
||||
$data: createPanelDataProvider(panel),
|
||||
titleItems,
|
||||
|
||||
@ -541,7 +539,6 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
body,
|
||||
maxPerRow: panel.maxPerRow,
|
||||
...repeatOptions,
|
||||
$behaviors: [hoverHeaderOffsetBehavior],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ describe('TrailStore', () => {
|
||||
['to', 'now-30m'],
|
||||
['var-ds', '1234'],
|
||||
['var-groupby', 'job'],
|
||||
['var-filters', 'cluster|=|dev-eu-west-2'],
|
||||
['var-filters', 'test'],
|
||||
])(`new recent trails with a different '%p' value should insert new entry`, (key, differentValue) => {
|
||||
const store = getTrailStore();
|
||||
// We expect the initialized trail to be there
|
||||
|
10
yarn.lock
10
yarn.lock
@ -4183,9 +4183,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@grafana/scenes@npm:^4.5.6":
|
||||
version: 4.5.7
|
||||
resolution: "@grafana/scenes@npm:4.5.7"
|
||||
"@grafana/scenes@npm:^4.5.4":
|
||||
version: 4.5.4
|
||||
resolution: "@grafana/scenes@npm:4.5.4"
|
||||
dependencies:
|
||||
"@grafana/e2e-selectors": "npm:10.3.3"
|
||||
react-grid-layout: "npm:1.3.4"
|
||||
@ -4199,7 +4199,7 @@ __metadata:
|
||||
"@grafana/ui": ^10.0.3
|
||||
react: ^18.0.0
|
||||
react-dom: ^18.0.0
|
||||
checksum: 10/b977bf6b65e519c51f8616674137ded9216bbdc16c1feaa87ca219dd83def2767314ee1540af904a8a960c984f3cc51ad1cb55e64fc0895894ac2f46d034c4d2
|
||||
checksum: 10/db483dfd204b5b3f2d61b72e1a4209137734ed20d860f823e48a549fee2f2ef490ab26ed239a13aed095d74f929200cb18a666bb995aad6ef785fb806cac65ce
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -18671,7 +18671,7 @@ __metadata:
|
||||
"@grafana/prometheus": "workspace:*"
|
||||
"@grafana/runtime": "workspace:*"
|
||||
"@grafana/saga-icons": "workspace:*"
|
||||
"@grafana/scenes": "npm:^4.5.6"
|
||||
"@grafana/scenes": "npm:^4.5.4"
|
||||
"@grafana/schema": "workspace:*"
|
||||
"@grafana/sql": "workspace:*"
|
||||
"@grafana/tsconfig": "npm:^1.3.0-rc1"
|
||||
|
Loading…
Reference in New Issue
Block a user