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

Remove templateSrv from datasource constructor #9

Merged
merged 2 commits into from
Dec 21, 2020

Conversation

ahlaw
Copy link
Collaborator

@ahlaw ahlaw commented Dec 17, 2020

Because the datasource class has two arguments in the constructor, so there is angular injection at this line:
https://github.com/ryantxu/grafana/blob/6c2375e495a2987c674fa5a11ac44d99d527f275/public/app/features/plugins/datasource_srv.ts#L79

The plugin currently fails at this step, either @ngInject annotation needs to be added to datasource constructor or we remove templateSrv from the constructor to skip angular injection. I think the latter is better since TemplateSrv is no longer an Angular injected dependency and this is more consistent with how the other services are handled for React components. This PR removes templateSrv from the datasource constructor, replaces templateSrv property references with the getTemplateSrv() call, and updates the affected tests by mocking getTemplateSrv() instead.

Copy link
Contributor

@alexanderzobnin alexanderzobnin left a comment

Choose a reason for hiding this comment

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

Good catch!

@alexanderzobnin alexanderzobnin merged commit 605a7e1 into master Dec 21, 2020
@Elfo404 Elfo404 deleted the refactor-templatesrv branch April 14, 2021 08:57
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.

None yet

2 participants