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

DUOS-810 [risk=no] Swapped out ResponsiveMenu for conditional rendering of navbar #885

Merged
merged 21 commits into from Feb 22, 2021

Conversation

JVThomas
Copy link
Contributor

@JVThomas JVThomas commented Feb 16, 2021

Addresses DUOS-810 since the navbar's dependence on react-responsive menu is holding back the upgrade to React 17.

PR aims to replace the ResponsiveMenu with conditional rendering in line with Material-UI style components. This ultimately results in the conditional rendering of a desktop navbar and a mobile/condensed navbar depending on the client's screen width. The PR sets the breakpoint for the switch at the upper range for "medium" sized widths (as described by material-ui docs), though that can be adjusted based on feedback. PR also poses a question for displaying navbar links: Should dropdowns be implemented or should they be displayed as separate links? (also to be adjusted based on feedback).

NOTE: Work can be done to avoid the dual navbar implementation, but that falls outside of the scope of this PR. The focus right now is to pave the way for a React 17 upgrade while providing a functional navbar for smaller devices. Creating a singular, flexible navbar would be close to a rewrite since the current navbar is heavily styled by element (not class) specific css.

Have you read Terra's Contributing Guide lately? If not, do that first.

I, the developer opening this PR, do solemnly pinky swear that:

  • PR is labeled with a Jira ticket number and includes a link to the ticket
  • PR is labeled with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes

In all cases:

  • Get a minimum of one thumbs worth of review, preferably 2 if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Squash and merge; you can delete your branch after this
  • Test this change deployed correctly and works on dev environment after deployment

@JVThomas JVThomas requested a review from a team as a code owner February 16, 2021 18:33
const dropdownLinks = {
statistics: {
'Votes Statistics': {
isRendered: !(isDataOwner || isResearcher) || isAdmin,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to have explicit roles defined in the affirmative here instead of the negative. For example, if we add a new role, say, "isSigningOfficial" and we don't explicitly negate that role here, then that role will gain access to this link. Same feedback for reviewed cases.

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 was the pre-existing condition on the navbar, but it's not obvious who's limited to seeing it (why Admin but not DataOwner or Researcher? Can a Researcher be a DAC member? What happens then?, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I need to remove the conditional on Votes Statistics, there's no conditional on that link right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Statistics are admin only right now, which is why we should clean this up. At some point, DAC Chairs will have a version of this page to look at, but we don't have it yet.

h(DropdownComponent, {isRendered: isAdmin, label: 'Statistics', goToLink: this.goToLink, onMouseEnter: applyPointer, dropdownLinks: dropdownLinks.statistics, classes}),
h(BasicListItem, {isRendered: isLogged, applyPointer, targetLink: '/dataset_catalog', label: 'Dataset Catalog', goToLink: this.goToLink}),
h(BasicListItem, {isRendered: !isLogged, applyPointer, targetLink: '/home_about', label: 'About', goToLink: this.goToLink}),
h(BasicListItem, {isRendered: !isLogged, applyPointer, targetLink: '/FAQs', label: 'FAQs', goToLink: this.goToLink}),
Copy link
Contributor

Choose a reason for hiding this comment

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

We show FAQs now in both logged in and non-logged in state. We should keep that visible in both versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ul({ isRendered: !isLogged, className: 'navbar-public' }, [
    li({}, [
      h(Link, { id: 'link_about', className: 'navbar-duos-link', to: '/home_about' }, [
        div({ className: 'navbar-duos-icon-about', style: navbarDuosIcon }),
        span({ style: navbarDuosText }, ['About'])
      ])
    ]),
    li({}, [
      h(Link, { id: 'link_help', className: 'navbar-duos-link', to: '/FAQs' }, [
        div({ className: 'navbar-duos-icon-help', style: navbarDuosIcon }),
        span({ style: navbarDuosText }, ['FAQs'])
      ])
    ]),
    contactUsButton, supportrequestModal
  ])
])

This is still present, which means it's a conditional duplicate, so I might as well remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, didn't realize the current navbar maintains ul tags for logged in/logged out states

JVThomas and others added 2 commits February 17, 2021 07:27
Co-authored-by: Greg Rushton <rushtong@users.noreply.github.com>
@DataBiosphere DataBiosphere deleted a comment from JVThomas Feb 17, 2021
@DataBiosphere DataBiosphere deleted a comment from JVThomas Feb 17, 2021
@DataBiosphere DataBiosphere deleted a comment from JVThomas Feb 17, 2021
Copy link
Contributor

@rushtong rushtong left a comment

Choose a reason for hiding this comment

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

Really nice! One minor suggestion inline, then 👍🏽

@@ -14,7 +116,8 @@ class DuosHeader extends Component {
this.state = {
showSupportRequestModal: false,
hover: false,
dacChairPath: '/chair_console'
dacChairPath: '/chair_console',
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but https://broadworkbench.atlassian.net/browse/DUOS-1045 should address the bug that we aren't dynamically checking for the correct console path here.

Comment on lines +359 to +363
img({
style: duosLogoImage, src: '/images/duos_logo.svg',
alt: 'DUOS Logo',
onClick: (e) => this.goToLink('/home')
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing we lost here is the cursor hover style over the icon. In expanded mode, it works, but here, it's a normal arrow icon. I think that has to do with the css class name in the expanded version.

@rushtong
Copy link
Contributor

The failing npm audit check is a false positive: facebook/create-react-app#10578
We can ignore that for this PR.

@JVThomas JVThomas merged commit b06a57b into develop Feb 22, 2021
@JVThomas JVThomas deleted the DUOS-810 branch February 22, 2021 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants