-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Exploratory view] Only show metric loading for relevant series #118299
Conversation
💛 Build succeeded, but was flaky
Test Failures
Metrics [docs]Async chunks
To update your PR or re-run it, just comment with: cc @shahzad31 |
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.
Thank you for the PR @shahzad31!
I've tested it as I've done before, and it looks good to me. As you can see in the GIF below, as I load new metrics the old ones don't show as loading too.
I've only left non-blocking comments. I'll leave it up to you if you think they're worth addressing.
@@ -127,7 +127,7 @@ export function ReportMetricOptions({ seriesId, series, seriesConfig }: Props) { | |||
</EuiPopover> | |||
)} | |||
{series.selectedMetricField && | |||
(indexPattern && !loading ? ( | |||
(indexPattern ? ( |
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 understand this will work because if we get here and decide not to display the EuiLoadingSpinner
that's because we've already done the loading for this particular pattern.
As I was reading code, however, I had to mentally attempt quite a few combinations of state to try to think of edge cases.
As a note for a further improvement (which we don't have to incorporate in this PR unless you want/have time to), I can make the following suggestion:
- Pass
series.dataType
to the hook invocation onL38
- Change the value of
loading
that's passed toIndexPatternContext.Provider
so that it embeds the whole map informing which metrics are loading not only if we're loading any metrics - In the component itself, access the
loading
state for a particularseries.dataType
.
Such a change would allow us to determine whether a particular metric is loading, not only whether any metrics are loading at all.
IMO I think it would also be clearer to the reader that we display the loading because a particular metric is loading, not because of a combination of previous states (and early returns).
}); | ||
|
||
it('should display loading if index pattern is not available and is loading', async function () { | ||
mockAppIndexPattern({ loading: true, indexPatterns: undefined }); |
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 to make the test a bit more robust, it may be worth adding other indexPatterns
to the dictionary object here so that your test could prove that the component checks for that index pattern in particular:
i.e.
mockAppIndexPattern({ loading: true, indexPatterns: { "other-index-pattern": true } });
This is also minor and non-blocking.
The following labels were identified as gaps in your version labels and will be added automatically:
If any of these should not be on your pull request, please manually remove them. |
) (#118459) Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
) (#118460) Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
Summary
Fixes: #117275
Will only show loading for relevant series when index pattern is loading
If index pattenr is already loaded, it won't show the loading
Added relevant unit tests to reflect the change.