Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix initialization callouts to properly show when first loading anomaly results page #300

Merged

Conversation

ohltyler
Copy link
Contributor

@ohltyler ohltyler commented Sep 3, 2020

Issue #, if available: #299

Description of changes:

This PR fixes the issue of the anomaly results page not properly showing the callouts relating to init progress (if applicable) when first loading the page after detector creation. Specifically, this fix will re-get the detector details when first rendering the page, to update the redux store with the detector details if they haven't been updated already.

The issue (before): user creates detector -> redux store gets updated with detector info returned by create detector api (which doesn't include any info related to init progress) -> user clicks on anomaly results page -> page uses existing detector info -> assumes no init progress -> renders old callout. Note that this issue only comes up if the store hasn't already been updated by rendering some other page, like detector list or dashboard for example, where getDetectors() is called, which would update the redux store with up-to-date detector details.

Confirmed all UT/IT pass.

Will cherry-pick to opendistro-1.10 branch and push new tag.

Screenshots:

Before:
Screen Shot 2020-09-03 at 9 14 22 AM

After:
Screen Shot 2020-09-03 at 9 16 44 AM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ohltyler ohltyler added the bug Something isn't working label Sep 3, 2020
Comment on lines -94 to +95
await dispatch(getDetector(detectorId));
dispatch(getDetector(detectorId));
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering why removing await here?

Copy link
Contributor Author

@ohltyler ohltyler Sep 3, 2020

Choose a reason for hiding this comment

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

Unnecessary, since dispatch() is just used to trigger a separate async action to make the api call and update the redux store, and the fn itself is already async. Also, nothing is done after the action is done within this function (like catch errors, do something with the response, etc) if we were to await. VS code also complains about it being unnecessary / has no effect.

Once the action is done, the page will render with the updated detector since the redux store will be updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

VS code also complains about it being unnecessary / has no effect.

Hmm, why I didn't see that in my VS code. is it because of any good plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, don't have extensions specific to javascript/typescript/react. Just looks like this. Have also noticed it in many other places, just fixed here though.

Screen Shot 2020-09-03 at 11 35 02 AM

Copy link
Contributor

@yizheliu-amazon yizheliu-amazon left a comment

Choose a reason for hiding this comment

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

thanks for the fix

@ohltyler ohltyler merged commit 635c363 into opendistro-for-elasticsearch:master Sep 3, 2020
ohltyler added a commit that referenced this pull request Sep 3, 2020
ohltyler added a commit that referenced this pull request Sep 3, 2020
@ohltyler ohltyler deleted the fixInitCallout branch September 3, 2020 21:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialization callout is sometimes out of date when first loading
3 participants