Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v11.0.x] DashboardScene: Fixes issues with relative time range in panel edit #87026

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

grafana-delivery-bot[bot]
Copy link
Contributor

Backport a4bb4c8 from #86862


Fixes #86420 '

This one was very hard to solve, tried so many different ways that all ended up with some dead end.

The original problem was the "Table view" toggle in panel edit, this switching the rendering of the visualization from the main VizPanel to a temporary table view. But for this temporary table VizPanel to get the data we moved the SceneQueryRunner from VizPanelManager.state.panel to VizPanelManager level (so that it's children all get the data). We could of course clone the main VizPanel SceneQueryRunner to this temporary table VizPanel but this disconnects the queries tab from the table view as the queries tab is subscribing to the main viz scene query runner (and we want changes to queries to reflect in the table view).

But moving SceneQueryRunner to VizPanelManager level left the time range on the main VizPanel level, so the SceneQueryRunner did not get local panel time range. I tried moving the time range also to VizPanelManager level but then we do not get any rendering of the local time range in the panel chrome header (Which only happens when VizPanel render detects $timeRange on it's local level).

Ok, lets revert back to SceneQueryRunner living on the main VizPanel level (same as time range), so back to square one. How to switch to Table view and maintain the same SceneQueryRunner between main viz and queries tab? Well, we could break the rule of reusing the same SceneObject instance, when we switch to TableView I use the same instance of the SceneQueryRunner as the main VizPanel.

One last issue, the SceneQueryRunner is deactivated because it's attached to the main VizPanel and this is not rendered when the table view is rendered, when deactivated it clears all subscriptions so the queries tab which is subscribing to it via useState() no longer get's any updates after this.

To fix this I make sure the queries tab calls the queryRunner activate function (which increments the refCount for main viz SceneQueryRunner so that it does not deactivate during the transition from main VizPane and Table VizPanel).

I know, messy, complex, don't like it, but best I can come up with for now.

…86862)

* DashboardScene: Fixes deleting dirty dashboard

* Update

* Progress

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Update

(cherry picked from commit a4bb4c8)
@grafana-delivery-bot grafana-delivery-bot bot requested a review from a team as a code owner April 29, 2024 08:55
@grafana-delivery-bot grafana-delivery-bot bot requested review from axelavargas and mdvictor and removed request for a team April 29, 2024 08:55
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Apr 29, 2024
@torkelo torkelo merged commit e5e6981 into v11.0.x Apr 29, 2024
21 checks passed
@torkelo torkelo deleted the backport-86862-to-v11.0.x branch April 29, 2024 13:33
@fabrizio-grafana fabrizio-grafana modified the milestones: 11.0.x, 11.0.0 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants