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

sceneUtils: expose setWindowGrafanaSceneContext #999

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gtk-grafana
Copy link
Contributor

@gtk-grafana gtk-grafana commented Dec 12, 2024

So scene apps can set global timeSrv to enable copying time range
Potential usage:

 public onActivate() {
      const unsetGlobalScene = setWindowGrafanaSceneContext(this);
      return () => {
        unsetGlobalScene();
      };
}

@gtk-grafana
Copy link
Contributor Author

I'm interested in finding solutions to automatically add keybindings for all scene apps: ideally every scene app would support copy/paste of time range automatically, or maybe by setting a new prop on SceneTimeRangeState in case apps have several time ranges.

@gtk-grafana gtk-grafana added release Create a release when this pr is merged minor Increment the minor version when merged labels Dec 12, 2024
@torkelo
Copy link
Member

torkelo commented Dec 16, 2024

setWindowGrafanaSceneContext is best called on-scene activation (already called automatically by EmbeddedScene) rather than in a command handler

@torkelo
Copy link
Member

torkelo commented Dec 16, 2024

I'm interested in finding solutions to automatically add keybindings for all scene apps: ideally every scene app would support copy/paste of time range automatically, or maybe by setting a new prop on SceneTimeRangeState in case apps have several time ranges.

yes, I agree. there are other keybindings to zoom out, move left / right as well

question is how best to opt-in or opt-out of them (and how to handle cases when there are multiple time ranges)

@gtk-grafana
Copy link
Contributor Author

Thanks @torkelo, I had missed that this was already called in the EmbeddedScene, but it appears that doesn't always work when the time range is set on a child scene of the Embedded Scene. While we might be able to move our $timeRange up and get this working as expected, is this still something we'd want exposed to scene apps for cases where the time range that should get copied is not set when the Embedded scene is activated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants