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

Ensure grafana is always loaded within the SLE iframe #56

Merged
merged 7 commits into from
Feb 12, 2025

Conversation

mollykreis
Copy link

In multiple places throughout grafana, it's possible to link between dashboards. With the way that grafana is hosted in an iframe within SLE, this poses some problems. The issue stems from the fact that grafana itself is hosted under the /dashboardhost route while the grafana Angular app that hosts the iframe is hosted under /dashboards. As a result, we run into the following problem:

  • Links opening within the same tab need to use the /dashboardhost route to avoid navigating the iframe to SLE, which results in nested SLE frames
  • Links opening in a new tab/window (including copy & pasted to a new person or browser) need to use the /dashboard route to avoid navigating to grafana hosted outside of the SLE frame
  • We can't know how a given link will be used, especially given standard link behaviors in browsers such as "Open link in new tab" or "Copy link" in the right-click menu

Because we can't know how a given link that's generated will be opened, the best solution is to allow grafana to generate links as though it were not hosted in an iframe (i.e. using /dashboardhost) but ensure that if grafana is loaded outside of the SLE frame, we automatically redirect the user to SLE. This is accomplished by redirecting from /dashboardhost to /dashboards in the case that grafana is not loaded in an iframe (determined by comparing window.self to window.top). The exception to this is when grafana is running on localhost so that grafana can still be run locally without it being hosted in the Angular app.

@mollykreis mollykreis requested a review from rajsite February 7, 2025 18:02
@mollykreis mollykreis requested a review from rajsite February 10, 2025 17:54
@mollykreis mollykreis marked this pull request as ready for review February 10, 2025 20:29
@mollykreis
Copy link
Author

@pvallone - Do you want to look at these changes, or are you fine with me merging without your review?

@pvallone
Copy link
Collaborator

@pvallone - Do you want to look at these changes, or are you fine with me merging without your review?

@mollykreis Please feel free to merge without my review. Sorry, I miss GitHub PRs sometimes. It probably makes sense for me to remove myself from code owners given the ownership changes, I'll put up a PR for that.

@mollykreis mollykreis merged commit ca8100c into main Feb 12, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants