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

Reset chrome fields while switching an app #73064

Merged
merged 11 commits into from
Aug 26, 2020

Conversation

sulemanof
Copy link
Contributor

@sulemanof sulemanof commented Jul 23, 2020

Summary

Fixes #72896
Fixes #72671

Initial issue description:
Help menu not resetting on navigating to Kibana home for some apps

Actually, the problem is also related to switching the apps, which don't have its own chrome fields (e.x. help menu extension, badge, breadcrumbs, etc), so there is a previous one always appear. (e.x. go from Visualize to Dev Tools, or from Dashboard to Stack Management).

So I put the subscription on application.currentAppId$ to erase the previous chrome fields

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@sulemanof sulemanof marked this pull request as ready for review July 24, 2020 09:53
@sulemanof sulemanof requested a review from a team as a code owner July 24, 2020 09:53
@sulemanof sulemanof added release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0 labels Jul 24, 2020
@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -157,6 +157,11 @@ export class ChromeService {
const recentlyAccessed = await this.recentlyAccessed.start({ http });
const docTitle = this.docTitle.start({ document: window.document });

// erase the help menu extension from previous app while switching to a next app
application.currentAppId$.subscribe(() => {
helpExtension$.next(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Shouldn't we reset all the Chrome fields then? Badge, Breadcrumbs, etc.
  2. It implicitly enforces calling order for navigation and setHelpExtension. @joshdover should we make this logic explicit? For example, we can move some Chrome params into the Application interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Shouldn't we reset all the Chrome fields then? Badge, Breadcrumbs, etc.
  2. It implicitly enforces calling order for navigation and setHelpExtension. @joshdover should we make this logic explicit? For example, we can move some Chrome params into the Application interface?

  1. Good point, I would also do this on switching an app.
    Especially since I still see couple of places when a page title is not changed after navigating to any app, or such a PR's like Add doc titles to ES UI apps #71045 , where chrome.docTitle.reset() is manually called on application destroy.
    So doing it once after switching to any app would close other issues.
  2. I was also under assumption to set default chrome params explicitly in navigateToApp, but discovered that chrome service depends on application one.
    So, the other implementation way would cause significant code changes.

I'm excited to receive @joshdover opinion! 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Yes, let's go ahead and do those for the chrome items that make sense.
  2. I agree this would be much better. I think it would be best to split that change into two phases where we first introduce the new API, separately migrate each usage of the existing imperative APIs, and then remove the imperative APIs. This could be done as a different issue / PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshdover Should I expand this PR with other chrome items reset, or close it in favor of new API ?

Copy link
Contributor

@mshustov mshustov Jul 30, 2020

Choose a reason for hiding this comment

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

Should I expand this PR with other chrome items reset, or close it in favor of new API ?

We can fix it here quickly and refactor chrome service after. Another complain: #72671

but let's wait for @joshdover opinion

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I agree, let's go ahead and do the quick fix now in this PR and refactor later.

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

@sulemanof sulemanof changed the title Reset chrome help extension while switching an app Reset chrome fields while switching an app Aug 21, 2020
@sulemanof sulemanof requested a review from mshustov August 21, 2020 14:07
@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

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.

Can we add a test about that behavior in src/core/public/chrome/chrome_service.test.ts ?

Apart from that, LGTM

@sulemanof
Copy link
Contributor Author

Can we add a test about that behavior in src/core/public/chrome/chrome_service.test.ts ?

Apart from that, LGTM

Sure! Done!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
savedObjectsManagement 169.2KB +244.0B 168.9KB

page load bundle size

id value diff baseline
core 1.2MB +144.0B 1.2MB

History

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

@sulemanof sulemanof merged commit 4efaba3 into elastic:master Aug 26, 2020
@sulemanof sulemanof deleted the fix/erase_help_extension branch August 26, 2020 08:48
sulemanof added a commit that referenced this pull request Aug 27, 2020
* Reset chrome help extension while switching an app

* Reset other chrome fields

* Set docTitle in saved objects app

* Add unit tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0
Projects
None yet
6 participants