Skip to content

Conversation

@Dosant
Copy link
Contributor

@Dosant Dosant commented Mar 25, 2020

Summary

Part of #61230
Addresses one of the issues when navigating within different dashboards.

The fix is as simple as removing url.parse when extracting hash from the url, but I moved the logic into separate function to be able to add a unit test for an edge case I wanted to fix.

This is the unit test which is fixed by this pr:
https://github.com/elastic/kibana/pull/61245/files#diff-58b12ddd89613d7380892977f494f217R47

I bumped into it in #60087 when trying to navigate from 1 dashboard to another using core's navigateToApp using:

navigateToApp('kibana', {
   path: '#/dashboard/f8bc19f0-6918-11ea-9258-a74c2ded064d?_a=(filters:!(),query:(language:kuery,query:''))&_g=(filters:!(),time:(from:now-120m,to:now))'
 })

Internally core is using url.parse which converts ' -> %27. Performs the navigation. And then angular maps it back causing 2 history records for one navigation.
Change to our existing has encoding workarounds logic makes sure angular does it's update with replace

Testing

I don't know how to test it in current master. The real use case this is needed for will be introduced later in #60087 (comment) and will be covered by functional test

don’t use url.parse to extract hash
@Dosant
Copy link
Contributor Author

Dosant commented Mar 25, 2020

@elasticmachine merge upstream

*/

export function areDecodedHashesEqual(urlA: string, urlB: string): boolean {
const getHash = (url: string) => url.split('#')[1] ?? '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the change in a nutshell. instead of using url.parse(url).hash use this simpler method.
The problem with url.parse that it encodes ' -> %27.
This test would fail with original functionality: https://github.com/elastic/kibana/pull/61245/files#diff-58b12ddd89613d7380892977f494f217R47

@Dosant Dosant added v7.8.0 Feature:Drilldowns Embeddable panel Drilldowns release_note:skip Skip the PR/issue when compiling release notes Team:AppArch labels Mar 25, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@Dosant Dosant added the v8.0.0 label Mar 25, 2020
@Dosant Dosant marked this pull request as ready for review March 25, 2020 18:08
@Dosant Dosant requested review from joshdover and pgayvallet March 25, 2020 18:08
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM with added test

@Dosant
Copy link
Contributor Author

Dosant commented Mar 30, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Mar 31, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@Dosant Dosant merged commit 99a9288 into elastic:master Mar 31, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Mar 31, 2020
* Simpler url parsing in sub url hooks

don’t use url.parse to extract hash

* review improvements

Co-authored-by: Elastic Machine <[email protected]>
# Conflicts:
#	src/legacy/ui/public/chrome/api/sub_url_hooks.js
Dosant added a commit that referenced this pull request Mar 31, 2020
* Simpler url parsing in sub url hooks

don’t use url.parse to extract hash

* review improvements

Co-authored-by: Elastic Machine <[email protected]>
# Conflicts:
#	src/legacy/ui/public/chrome/api/sub_url_hooks.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Drilldowns Embeddable panel Drilldowns release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants