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

[Bug fix] Update nav link when it belongs to the same plugin #58008

Merged
merged 9 commits into from
Feb 24, 2020

Conversation

maryia-lapata
Copy link
Contributor

@maryia-lapata maryia-lapata commented Feb 19, 2020

Fixes #57573

When a user navigates to dashboard, there is a verification if a default index pattern exists; if it doesn't, the app is redirected to management. But dashboard's KbnUrlTracker has been already created and the dashboard app has been mounted, which means that dashboard has subscribed on history url changes. Meanwhile the app is going to management -> the url is changed and dashboard's history listener is invoked with management url, which is led to the original issue. And only after that the app scope is destroyed and the dashboard unsubscribes to history changes.

To fix the issue I added a condition, whether a url belongs to the current app, to the history listener. This condition can be customized by shouldTrackUrlUpdate custom implementation.

@maryia-lapata maryia-lapata added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Feb 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@maryia-lapata maryia-lapata added the WIP Work in progress label Feb 20, 2020
@maryia-lapata maryia-lapata changed the title Update nav link when it belongs to the same plugin [WIP] Update nav link when it belongs to the same plugin Feb 20, 2020
@maryia-lapata maryia-lapata changed the title [WIP] Update nav link when it belongs to the same plugin Update nav link when it belongs to the same plugin Feb 20, 2020
@maryia-lapata maryia-lapata removed the WIP Work in progress label Feb 20, 2020
@maryia-lapata maryia-lapata changed the title Update nav link when it belongs to the same plugin [Bug fix] Update nav link when it belongs to the same plugin Feb 20, 2020
@maryia-lapata maryia-lapata marked this pull request as ready for review February 20, 2020 18:23
@maryia-lapata maryia-lapata requested a review from a team February 20, 2020 18:23
@maryia-lapata maryia-lapata requested a review from a team as a code owner February 20, 2020 18:23
@@ -58,6 +58,12 @@ export function createKbnUrlTracker({
toastNotifications,
history,
storage,
shouldTrackUrlUpdate = pathname => {
const currentAppName = defaultSubUrl.slice(2); // cut hash and slash symbols
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes me realize that kbn_url_tracker works only for current Kibana's url format and hash router. Will need to revisit when / if someone wants to use it in np app with browser router

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, I didn't want to introduce too many degrees on freedom on this helper just yet to keep the complexity low. Let's generalize once there are use cases for this

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

code lgtm

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested and works, code LGTM

@lizozom
Copy link
Contributor

lizozom commented Feb 22, 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

@maryia-lapata maryia-lapata merged commit db0a9cc into elastic:master Feb 24, 2020
@maryia-lapata maryia-lapata deleted the fix-last-url branch February 24, 2020 11:03
maryia-lapata added a commit to maryia-lapata/kibana that referenced this pull request Feb 24, 2020
…#58008)

* Update nav link when it belongs to the same plugin

* Move the plugin name check to history listener

* Add isUrlBelongsToApp function

* Code review comments

* Update unit tests

Co-authored-by: Elastic Machine <[email protected]>
maryia-lapata added a commit that referenced this pull request Feb 24, 2020
…#58326)

* Update nav link when it belongs to the same plugin

* Move the plugin name check to history listener

* Add isUrlBelongsToApp function

* Code review comments

* Update unit tests

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User cannot navigate to dashboard after installing sample data
7 participants