Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Keep Reporting menu in Nav Menu when switching Index Patterns #299

Conversation

davidcui1225
Copy link
Contributor

Issue #, if available:
N/A
Description of changes:

  • Fix in-context menu so it does not disappear when switching index patterns in the Discover page
  • Instead of checking just that the navMenu length is greater than 1 on Report source pages, checks to make sure the length matches based on the report source type
    • Dashboard nav menu length should be 4
    • Visualization nav menu length should be 3
    • Saved search nav menu length should be 5

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #299 (966f51a) into dev (47cbe19) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #299   +/-   ##
=======================================
  Coverage   77.67%   77.67%           
=======================================
  Files          32       32           
  Lines        1805     1805           
  Branches      356      356           
=======================================
  Hits         1402     1402           
  Misses        398      398           
  Partials        5        5           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 47cbe19...966f51a. Read the comment docs.

@@ -234,12 +234,34 @@ $(function () {
locationHashChanged();
});

const isDiscoverNavMenu = (navMenu) => {
return navMenu[0].children.length === 5 &&
Copy link
Member

Choose a reason for hiding this comment

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

why is it always 5, 4, or 3. I feel it's kind of fragile to used == (a fixed number)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It checks how many items are in the nav menu depending on what kind of report source it is- I can extract them to constants too

Copy link
Member

Choose a reason for hiding this comment

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

can we remove this length check, since you have the title check?Or can we just use length >= 0 or length >= 1? What's the downside you see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the old check, which resulted in the issue. Basically it would not add the Reporting menu if the nav menu had length greater than 1, which is why the Reporting menu would not show up. But we need to not only check that the Nav menu is populated, but that it has the correct number of items

Copy link
Contributor

Choose a reason for hiding this comment

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

a better way might be to add an id to reports menu element, loop through navMenu and check for the id to determine whether reports menu is added. probably a todo item

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 - I think that's a good idea but it doesn't sound like a quick fix

const isDiscoverNavMenu = (navMenu) => {
return navMenu[0].children.length === 5 &&
($('[data-test-subj="breadcrumb first"]').prop('title') === 'Discover' ||
$('[data-test-subj="breadcrumb first last"]').prop('title') === 'Discover')
Copy link
Member

Choose a reason for hiding this comment

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

why there are 2 conditions being checked, while the other functions contain one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because on the Discover page the Reporting menu will be present in the menu even if there is no Saved search selected, but the id of the Discover breadcrumb prop is different when there is a Saved search selected vs. when there isn't

Copy link
Member

Choose a reason for hiding this comment

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

got it. So, this only happens with Discover, not the other two?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah- because on the base Dashboard and Visualizations screens it is just a list of the available ones, but you are not on the actual page with the nav menu

Copy link
Member

@zhongnansu zhongnansu Jan 8, 2021

Choose a reason for hiding this comment

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

Did you try the "create visualization/dashboard"? I think it leads to a similar scenario with Discover, with no saved object selected, but with a nav bar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch- I will have to add those checks as well

Copy link
Contributor

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

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

some comments

Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

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

LGTM, be careful when backporting to 7.9.1

@davidcui1225 davidcui1225 merged commit d3c844f into opendistro-for-elasticsearch:dev Jan 9, 2021
@davidcui1225 davidcui1225 deleted the fix-reporting-discover branch January 9, 2021 00:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants