-
Notifications
You must be signed in to change notification settings - Fork 484
Migrate from DatasourceAPI to DatasourceWithBackend #2123
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
base: main
Are you sure you want to change the base?
Conversation
|
Levitate is-compatible report: 🔍 Resolving @grafana/data@latest... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... 🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]... ✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/schema,@grafana/e2e-selectors,@grafana/experimental |
| const [interpolatedQuery, setInterpolatedQuery] = useState<ZabbixMetricsQuery>(query); | ||
| useEffect(() => { | ||
| const replacedQuery = datasource.interpolateVariablesInQueries([query], {})[0]; | ||
| setInterpolatedQuery(replacedQuery); | ||
| }, [query]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know why we need to interpolate the query in here just yet, but I see this in some other places too. As this is being repeated I think it's good idea to create a custom hook to handle this. What do you think?
This PR migrates the use of
DatasourceApitoDatasourceWithBackend, with this a couple additional improvements were made:interpolateVariablesInQueryeverywhere instead of the customreplaceTemplateVariableswe were usingdatasource.tsand into the existingutils.tsSelectand usesComboBoxinstead.Now we can see the

querycalls being made to the backend:Tested:
ComboBoxwas working as expectedNext:
Once this is merged, we will next be able to slowly move away from using the
ZabbixConnectorto make backend datasource calls.Fixes: #131