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

Runtime: Add provider and access hook for location service #90759

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

aocenas
Copy link
Member

@aocenas aocenas commented Jul 22, 2024

This is part of the effort to make the LocationService non singleton as part of the Sidecar project, see #88797.

This right now just adds a provider for the LocationService and adds it into the React tree that renders app plugins. This way app plugins can get the location service from the context instead of relying on the singleton. This means we can later inject different location providers for 2 separate apps and they won't clash on the URL. You can see the plan here https://github.com/grafana/grafana/pull/88797/files#diff-b1d459ae81cb312ba78da28cfe277013ba08a6787c0f5dcc42ac142f06dadd6cR181 with locationService with MemoryHistory being injected to the second app rendering tree.

Currently the injected locationService is the same as global singleton so nothing should change for grafana itself or any app.

This is also required for this Scenes PR that makes it's URL handling not reliant on the locationService singleton.

@aocenas aocenas requested review from grafanabot and a team as code owners July 22, 2024 16:09
@aocenas aocenas requested review from gabor, joshhunt, ashharrison90 and jackw and removed request for a team July 22, 2024 16:09
@github-actions github-actions bot added this to the 11.2.x milestone Jul 22, 2024
Copy link
Contributor

@leventebalogh leventebalogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left one comment about the tests. 👍

children,
}) => {
return <LocationServiceContext.Provider value={service}>{children}</LocationServiceContext.Provider>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add a basic test case for the hook and the provider in LocationService.test.ts(x).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup added a test there

@aocenas aocenas merged commit 04d8f0f into main Aug 1, 2024
19 checks passed
@aocenas aocenas deleted the aocenas/runtime/provider-location-service branch August 1, 2024 13:59
@aocenas aocenas changed the title Runtime: Add provider for location service Runtime: Add provider and access hook for location service Aug 1, 2024
giorgioatmerqury pushed a commit to cybermerqury/grafana that referenced this pull request Aug 21, 2024
@aangelisc aangelisc modified the milestones: 11.2.x, 11.2.0 Aug 21, 2024
@aocenas aocenas mentioned this pull request Oct 25, 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.

3 participants