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

Explore: Fix Browser title not updated on Navigation to Explore #34651

Merged
merged 4 commits into from May 26, 2021

Conversation

axelavargas
Copy link
Member

@axelavargas axelavargas commented May 25, 2021

What this PR does / why we need it:
When navigating to Explore page the document.title was not being updated, this was caused because Explore page is not using Page component that takes care of this functionality.

##Notes about the Approach
I decided to add the functionality on Explore page by duplicating the same logic we applied on Page component. That component is being used on other pages (Configuration, Alerting, etc...) but for the explore page will cause some unwanted styling issues and refactoring.

ExploreDocumentTitle

Which issue(s) this PR fixes:

Fixes #32898

Special notes for your reviewer:

- Update document.title on Explore page
- Add unit test and snapshot for Wrapper component
@axelavargas axelavargas added this to the 8.0.0-beta3 milestone May 25, 2021
@axelavargas axelavargas self-assigned this May 25, 2021
@axelavargas axelavargas requested a review from a team as a code owner May 25, 2021 12:48
@axelavargas axelavargas added this to In Review (max. internal 8, external 3) in Frontend Platform Backlog via automation May 25, 2021
@axelavargas axelavargas requested review from Elfo404, hugohaggmark and grafanabot and removed request for a team and Elfo404 May 25, 2021 12:48
@axelavargas axelavargas added the old backport v8.0.x Mark PR for automatic backport to v8.0.x label May 25, 2021
@hugohaggmark hugohaggmark requested review from dprokop, aocenas and ivanahuckova and removed request for grafanabot May 25, 2021 13:46
Copy link
Contributor

@hugohaggmark hugohaggmark left a comment

Choose a reason for hiding this comment

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

Code looks great, but I'm not sure about the title part. I think Explore - Grafana should be enough. Explore: Explore - Grafana looks weird to me.

public/app/features/explore/Wrapper.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Wrapper.tsx Outdated Show resolved Hide resolved
@torkelo torkelo moved this from In Review (max. internal 8, external 3) to In progress (max. internal 6) in Frontend Platform Backlog May 26, 2021
@torkelo torkelo removed this from In progress (max. internal 6) in Frontend Platform Backlog May 26, 2021
…approach

- Remove unnecesary comments
- Wrapper component is now inferring connected props
- Update snapshot
@axelavargas
Copy link
Member Author

axelavargas commented May 26, 2021

Code looks great, but I'm not sure about the title part. I think Explore - Grafana should be enough. Explore: Explore - Grafana looks weird to me.

Thanks, @hugohaggmark for the review, indeed it looks weird, I did the changes here 0e69909#diff-06aad0593d46c656f9c92b1a6e517f30e9758c1f1eff827194d81389ee5c74f6R35, I had to use directly the value from ${navModel.main.text}, my old approach was using getTitleFromNavModel(navModel); but unfortunately this doesn't work in Explore page because the main.text and the node.text are the same text, and this is something generated in the backend.

ps. I updated the gif in this PR with the new title

@hugohaggmark
Copy link
Contributor

Code looks great, but I'm not sure about the title part. I think Explore - Grafana should be enough. Explore: Explore - Grafana looks weird to me.

Thanks, @hugohaggmark for the review, indeed it looks weird, I did the changes here 0e69909#diff-06aad0593d46c656f9c92b1a6e517f30e9758c1f1eff827194d81389ee5c74f6R35, I had to use directly the value from ${navModel.main.text}, my old approach was using getTitleFromNavModel(navModel); but unfortunately this doesn't work in Explore page because the main.text and the node.text are the same text, and this is something generated in the backend.

ps. I updated the gif in this PR with the new title

Outstanding, will do another pass now.

Copy link
Contributor

@hugohaggmark hugohaggmark left a comment

Choose a reason for hiding this comment

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

Looks outstanding! 🎉

The change from Component to PureComponent should be fine AFAIK but there might be some edge case that I'm unaware of.

@@ -1,18 +1,43 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import React, { PureComponent } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

The change from Component to PureComponent should be fine AFAIK but maybe @ivanahuckova or @aocenas can confirm this too?

Copy link
Member

Choose a reason for hiding this comment

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

As far as I know, the change should be okay. 🙂

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it should break anything but I have a feeling:

navModel: getNavModel(state.navIndex, 'explore'),

will break any benefit as it seems to create a new object every time.

Copy link
Member Author

Choose a reason for hiding this comment

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

great 🙌🏾, thank you @ivanahuckova for taking a look, I will proceed to merge :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it should break anything but I have a feeling:

navModel: getNavModel(state.navIndex, 'explore'),

will break any benefit as it seems to create a new object every time.

Hey, @aocenas thanks for checking out this PR 😄 , I was looking into getNavModel function, even though it generates a new object every time, the values are always the same if the parameters don't change, and because PureComponent only does a shallow comparison on the ComponentShouldUpdate I think will keep the benefits. I also verified the children's Wrapper component to confirm they are also PureComponents (to be sure these changers are not breaking anything).

let me know if I am mistaken(I still lacking context in the project 😅 ) , I will merge the PR but ofc, if we find later on this change don't add any benefits, we can put it back as before :)

Copy link
Member

@ivanahuckova ivanahuckova left a comment

Choose a reason for hiding this comment

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

Thank you for working on this @axelavargas! 🧡 It has been in the backlog for quite some time and I am very happy that Explore has finally title.✨ LGTM!

@axelavargas axelavargas merged commit cebe67a into main May 26, 2021
@axelavargas axelavargas deleted the axelav/explore-title-not-updated branch May 26, 2021 16:44
grafanabot pushed a commit that referenced this pull request May 26, 2021
- Update document.title on Explore page
- Add unit test and snapshot for Wrapper component

(cherry picked from commit cebe67a)
dprokop pushed a commit that referenced this pull request May 27, 2021
…ore (#34764)

* Explore: Fix Browser title not updated on Navigation to Explore (#34651)

- Update document.title on Explore page
- Add unit test and snapshot for Wrapper component

(cherry picked from commit cebe67a)

* fix: remove snapshot for wrapper test

Co-authored-by: Maria Alexandra <239999+axelavargas@users.noreply.github.com>
Co-authored-by: Alexandra Vargas <alexa1866@gmail.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.

Explore: browser title not updated on navigation to Explore
5 participants