Skip to content
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

[ML] avoid full page reload for links following CSV import #79539

Merged
merged 4 commits into from
Oct 6, 2020

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Oct 5, 2020

The current implementation of linking to Discover, Index management, and Index pattern management after a CSV import causes a full page reload. Clicking the buttons below should not cause a full page reload.

Screen Shot 2020-10-05 at 12 46 06 PM

This PR updates the implementation to used navigateToApp and navigateToUrl to avoid the full page reload.

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)


let discoverUrlGenerator;
try {
discoverUrlGenerator = getUrlGenerator(DISCOVER_APP_URL_GENERATOR);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getUrlGenerator throws when the id is not found. Adding code to avoid unhandled errors

if (!discoverUrlGenerator) {
return;
}
const discoverUrl = await discoverUrlGenerator.createUrl(state);
if (!unmounted) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to check for unmounted after await, not before

@@ -142,9 +148,26 @@ export const ResultsLinks: FC<Props> = ({
}
}

function openInDiscover(e: React.MouseEvent<HTMLButtonElement>) {
e.preventDefault();
getApplication().navigateToUrl(discoverLink);
Copy link
Member

Choose a reason for hiding this comment

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

Should this fallback to something else instead of '' if getUrlGenerator(DISCOVER_APP_URL_GENERATOR) throws an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Button is not visible if discoverLink is not provided so onClick could not be called.

@nreese nreese requested review from jgowdyelastic and qn895 October 6, 2020 13:58
@nreese
Copy link
Contributor Author

nreese commented Oct 6, 2020

@elasticmachine merge upstream

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
ml 10.6MB 10.6MB +870.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@nreese nreese merged commit d9ca4c5 into elastic:master Oct 6, 2020
nreese added a commit to nreese/kibana that referenced this pull request Oct 6, 2020
…9539)

* [ML] avoid full page reload for links following CSV import

* cleanup

* review feedback

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
nreese added a commit that referenced this pull request Oct 6, 2020
…79698)

* [ML] avoid full page reload for links following CSV import

* cleanup

* review feedback

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants