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: Fixing major row repeat issues #87800

Merged
merged 1 commit into from
May 14, 2024

Conversation

torkelo
Copy link
Member

@torkelo torkelo commented May 14, 2024

Backport 9cd7c87 from #87539


Noticed several bugs with row repeats.

See issues here: https://ops.grafana-ops.net/d/ddl5wm680ka2of/repeating-row-t?orgId=1&scenes&var-server=A&var-server=B&var-server=C&tab=queries

Bugs noticed (all fixed)

  • Adding new viz breaks layout / repeated rows
  • Moving panel inside repeated row does not work, panel disappears
  • Removing row repeats does not remove the local value scope (so panels do get the full multi value, only the last repeated scoped value)
  • Cannot edit panel inside row after removing repeating from row
  • Excessive queries, when changing variable value (say removing a value) all panels first issue new queries (even with the row that is getting removed), then repeat happens and new queries are issued (even for panels inside rows where nothing changed).
  • When going into dashboard settings (or panel edit) and back triggers new repeat process and new queries

Changes / Fixes

  • Adding a visualization completely messes up the layout. This is caused by the row repeat sources positions are never updated when new panels are added (as the sources are only part of the row repeat behavior). Major change in this PR is to move to something more similar to what we do in old architecture. We treat the first row of children as sources. This should simplify other things.
  • Use deterministic repeat clone keys based on local variable value (Will do the same to panel repeats in a future PR)
  • Fixes moving a panel inside a repeated row (did not work, as the row repeater only repeated it's sources and moving a panel inside a repeated row never updated it's sources)
  • Fixed panel edit issue where the local value scope is lost (So the queries get the full multi var value). Now we use the first repeat scope.
  • When setting row repeat we manually activate the row repeat behavior this causes bugs as the behavior is no longer deactivated / re-activated. Needs fix in scenes lib to activate new behaviors. Fixed in SceneObject: Handle new or removed behaviors scenes#731
  • When cloning sources the sources can now contain data, so no new queries are issued even though the variable scope for the SceneQueryRunner is different. Fixed in SceneQueryRunner: Detect new variable values when cloned scenes#727
  • When changing variable value the notification was also passed to all SceneQueryRunners inside all the repeated panels trigging new queries (even when their local value did not change). Fixed in SceneVariableSet: Do not propagate variable value changes when a local variable has the same name scenes#729. This fix required a big work around to how the RowRepeatBehavior get's notified of the top level variable change as the behavior itself is nested under a local variable value after the first repeat process.
  • Skip repeat process when values are the same as last time

Unsolved bugs that I do not know how to fix right now, I think we can fix later

  • Doing a full page reload of editing a panel inside a repeated row leads to unscoped state (ie full multi value variable value). That is because we go into panel edit before repeat process
  • Doing a full page reload of the "view panel" view on panels inside the first row results in unscoped full multi value value (same reason as above).

Both those two bugs are because the first row (The template source) all all referenced by their plain ids / keys. Not really sure how to fix them yet. But given the bugs this PR fixes that are much more critical I think we can wait to fix them separately.

Maybe in a future PR (this was what I originally started working on this morning)

  • Reuse row clone instances when possible

Fixes: #87536

* DashboardScene: Fixing major row repeat issues

* Fixing edit scope

* Use dashboard variableDependendency to notify row repeat behaviors

* update scenes lib

* Do not repeat if values are the same

* Update public/app/features/dashboard-scene/scene/DashboardScene.tsx

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>

* Updated scenes

* Update

* Update

* Do not render row actions for repeated rows

* Fixed e2e

---------

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
(cherry picked from commit 9cd7c87)
@torkelo torkelo added this to the 11.0.x milestone May 14, 2024
@torkelo torkelo requested review from a team as code owners May 14, 2024 10:44
@torkelo torkelo requested review from oscarkilhed, dprokop, ashharrison90 and JoaoSilvaGrafana and removed request for a team May 14, 2024 10:44
@torkelo torkelo merged commit 8083c41 into v11.0.x May 14, 2024
22 checks passed
@torkelo torkelo deleted the backport-87539-to-v11.0.x branch May 14, 2024 11:40
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