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
Datasource: Fix - apply default query also to queries in new panels #59625
Conversation
@@ -9,6 +9,27 @@ export const getNextRefIdChar = (queries: DataQuery[]): string => { | |||
} | |||
}; | |||
|
|||
export function queryIsEmpty(query: DataQuery): boolean { |
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.
This check does not feel future proof as it doesn't take new props into consideration. Any ideas of how to make this more robust?
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.
is this not the same as just doing Object.keys(query).length === 0 ?
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.
Currently this function is checking if the query has prop that is not defined in the DataQuery
interface. So basically if it the data source has called onChange
for the given query.
}; | ||
|
||
for (const key in query) { | ||
if (key === 'label') { |
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.
Also seems like the query runner adds this label
prop to the query. I have no idea where this is coming from.
464c70f
to
01e8613
Compare
Hello @sunker!
Please, if the current pull request addresses a bug fix, label it with the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-59625-to-v9.3.x origin/v9.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 32309a8373fbcf276b24e319010e5ba57818bd9e
# Push it to GitHub
git push --set-upstream origin backport-59625-to-v9.3.x
git switch main
# Remove the local backport branch
git branch -D backport-59625-to-v9.3.x Then, create a pull request where the |
… panels (grafana#59833) Datasource: Fix - apply default query also to queries in new panels (grafana#59625) * apply default query also to new panels * add comment * add tests (cherry picked from commit 32309a8)
What is this feature?
This PR attempts to fix a problem @mmandrus found in this PR, where the default query is only applied when new query rows are added but not when new panels are created.
Will add tests if this turns out to be the right approach.
Why do we need this feature?
This feature is useful because it allows datasources to define a default query without having to call
onChange
the first time the editor is rendered.Who is this feature for?
Plugin developers.
Fixes #59689
Related to #49581
cc @idastambuk