-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
QueryHistory: Improve handling of mixed datasource entries #62214
Conversation
For the cases where a datasource was removed, I would recommend graying out the query in the UI, and greying out the button if all queries in the history are greyed out. I think we should still keep the text in the db as usual and display it in case the user has a query or something they want to copy/paste out of there. |
Backend code coverage report for PR #62214 |
Frontend code coverage report for PR #62214
|
{ query: 'query3', refId: 'C' }, | ||
], | ||
}, | ||
}); | ||
const datasourceName = await screen.findByLabelText('Data source name'); | ||
expect(datasourceName).toHaveTextContent('Data source does not exist anymore'); |
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.
Would we want to test the button is disabled here too?
setQueries(exploreId, queriesToRun); | ||
} else { | ||
setQueries(exploreId, queriesToRun); | ||
await changeDatasource(exploreId, query.datasourceUid); |
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.
👏 importing queries doesn't make any sense here - thank you!
@@ -161,42 +152,68 @@ export function RichHistoryCard(props: Props) { | |||
} = props; | |||
const [activeUpdateComment, setActiveUpdateComment] = useState(false); | |||
const [comment, setComment] = useState<string | undefined>(query.comment); | |||
const [queryDsInstance, setQueryDsInstance] = useState<DataSourceApi | undefined>(undefined); | |||
const { value, loading } = useAsync(async () => { |
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 is the nittyest of nits, but what do you think about something besides value
for this variable name? I know it's literally the value of the rich history card so your variable name makes sense, but we have areas reading queries
values from props and some from this, it might be helpful to either define this variable name or leave a comment. Maybe like dsPopulatedData
dsEnhancedRecord
for possible variable names?
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.
tbh i think with a few rafactorings that happened variable names in this component went all bonkers (like queryDsInstance
, dsInstance
, query
(which is instead historyEntry
) ), i actually settled for value
because it felt the lcearer to me :D
i wanted to rename ~all the things but didn't want to pollute the PR with a bunch of renaming that would have made reviewing harder. if it's ok tho i'll just push an extra commit to do all the renaming. wdyt?
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.
Nah, I understand where you're coming from. Feel free to leave it, it's easy enough to understand what's going on
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'll create another issue when merging this and a follow up pr to address all the ambiguous names in this file
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.
Just a couple small nits but overall this looks great! Glad to see this problem solved :D
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.
What is this feature?
Improves QueryHistory display and handling of mixed datasource queries in Explore.
A mixed entry where all datasources implement
![Screenshot 2023-01-26 at 13 48 42](https://user-images.githubusercontent.com/1170767/214852645-71b6b7ee-2d03-429f-8858-01f263ae54e1.png)
![Screenshot 2023-01-26 at 13 54 10](https://user-images.githubusercontent.com/1170767/214853326-02f04802-5822-4f95-b508-ccd7785e3afa.png)
getQueryDisplayText
:note that explore's root datasource was set to Mixed. when an entry datasource does not match explore's root datasource, this would be shown instead:
A regular entry wit no mixed queries:
![Screenshot 2023-01-26 at 13 52 55](https://user-images.githubusercontent.com/1170767/214853011-359bb497-2753-4739-bd7a-1175b51e0178.png)
A mixed entry with one of the datasources that does not implement
![Screenshot 2023-01-26 at 13 48 16](https://user-images.githubusercontent.com/1170767/214853551-1ef25628-e089-43be-b667-c294bd806151.png)
getQueryDisplayText
:open points:
A mixed entry that has queries from an unavailable datasources still shows an active run queries button. upon clicking it Explore will show an error i the query row stating that the datasource was not found (for each query that has a missing datasource).
Not sure what the best approach is here: removing the queries without a datasource seem sensible when a mixed entry also contains queries for which the datasource is still available. and in case no query has a datasource available maybe the card should behave like a regular entry; disabling the run query button (or probably removing it in the first place)
opinions?
Why do we need this feature?
We are gradually introducing support for Mixed datasource queries in Explore. Query History was not initially meant to handle Mixed datasource entries.
Which issue(s) does this PR fix?:
Fixes #61089
Special notes for your reviewer: