<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import isEqual from 'lodash/isEqual';

import Logo from '../../img/treeherder-logo.png';
import Login from '../../shared/auth/Login';
import LogoMenu from '../../shared/LogoMenu';

import NotificationsMenu from './NotificationsMenu';
import InfraMenu from './InfraMenu';
import ReposMenu from './ReposMenu';
import TiersMenu from './TiersMenu';
import FiltersMenu from './FiltersMenu';
import HelpMenu from './HelpMenu';
import SecondaryNavBar from './SecondaryNavBar';

export default class PrimaryNavBar extends React.Component {
  shouldComponentUpdate(prevProps) {
    const { filterModel, repos, user } = this.props;

    return (
      prevProps.filterModel !== filterModel ||
      !isEqual(prevProps.user, user) ||
      !isEqual(prevProps.repos, repos)
    );
  }

  render() {
    const {
      user,
      setUser,
      repos,
      updateButtonClick,
      serverChanged,
      filterModel,
      setCurrentRepoTreeStatus,
      duplicateJobsVisible,
      groupCountsExpanded,
      toggleFieldFilterVisible,
    } = this.props;

    return (
      <div id="global-navbar-container">
        <div id="th-global-top-nav-panel">
          <nav id="th-global-navbar" className="navbar navbar-dark">
            <div id="th-global-navbar-top">
              <LogoMenu menuText="Treeherder" menuImage={Logo} />
              <span className="navbar-right">
                <NotificationsMenu />
                <InfraMenu />
                <ReposMenu repos={repos} />
                <TiersMenu filterModel={filterModel} />
                <FiltersMenu filterModel={filterModel} user={user} />
                <HelpMenu />
                <Login user={user} setUser={setUser} />
              </span>
            </div>
            <SecondaryNavBar
              updateButtonClick={updateButtonClick}
              serverChanged={serverChanged}
              filterModel={filterModel}
              repos={repos}
              setCurrentRepoTreeStatus={setCurrentRepoTreeStatus}
              duplicateJobsVisible={duplicateJobsVisible}
              groupCountsExpanded={groupCountsExpanded}
              toggleFieldFilterVisible={toggleFieldFilterVisible}
            />
          </nav>
        </div>
      </div>
    );
  }
}

PrimaryNavBar.propTypes = {
  filterModel: PropTypes.object.isRequired,
  repos: PropTypes.array.isRequired,
  updateButtonClick: PropTypes.func.isRequired,
  serverChanged: PropTypes.bool.isRequired,
  setUser: PropTypes.func.isRequired,
  user: PropTypes.object.isRequired,
  setCurrentRepoTreeStatus: PropTypes.func.isRequired,
  duplicateJobsVisible: PropTypes.bool.isRequired,
  groupCountsExpanded: PropTypes.bool.isRequired,
  toggleFieldFilterVisible: PropTypes.func.isRequired,
};<commit_msg>Bug 1520979 - Fix expand/collapse job group counts (#4491)<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import isEqual from 'lodash/isEqual';

import Logo from '../../img/treeherder-logo.png';
import Login from '../../shared/auth/Login';
import LogoMenu from '../../shared/LogoMenu';

import NotificationsMenu from './NotificationsMenu';
import InfraMenu from './InfraMenu';
import ReposMenu from './ReposMenu';
import TiersMenu from './TiersMenu';
import FiltersMenu from './FiltersMenu';
import HelpMenu from './HelpMenu';
import SecondaryNavBar from './SecondaryNavBar';

export default class PrimaryNavBar extends React.Component {
  shouldComponentUpdate(prevProps) {
    const {
      filterModel,
      repos,
      user,
      serverChanged,
      groupCountsExpanded,
      duplicateJobsVisible,
    } = this.props;

    return (
      prevProps.filterModel !== filterModel ||
      !isEqual(prevProps.user, user) ||
      !isEqual(prevProps.repos, repos) ||
      prevProps.serverChanged !== serverChanged ||
      prevProps.groupCountsExpanded !== groupCountsExpanded ||
      prevProps.duplicateJobsVisible !== duplicateJobsVisible
    );
  }

  render() {
    const {
      user,
      setUser,
      repos,
      updateButtonClick,
      serverChanged,
      filterModel,
      setCurrentRepoTreeStatus,
      duplicateJobsVisible,
      groupCountsExpanded,
      toggleFieldFilterVisible,
    } = this.props;

    return (
      <div id="global-navbar-container">
        <div id="th-global-top-nav-panel">
          <nav id="th-global-navbar" className="navbar navbar-dark">
            <div id="th-global-navbar-top">
              <LogoMenu menuText="Treeherder" menuImage={Logo} />
              <span className="navbar-right">
                <NotificationsMenu />
                <InfraMenu />
                <ReposMenu repos={repos} />
                <TiersMenu filterModel={filterModel} />
                <FiltersMenu filterModel={filterModel} user={user} />
                <HelpMenu />
                <Login user={user} setUser={setUser} />
              </span>
            </div>
            <SecondaryNavBar
              updateButtonClick={updateButtonClick}
              serverChanged={serverChanged}
              filterModel={filterModel}
              repos={repos}
              setCurrentRepoTreeStatus={setCurrentRepoTreeStatus}
              duplicateJobsVisible={duplicateJobsVisible}
              groupCountsExpanded={groupCountsExpanded}
              toggleFieldFilterVisible={toggleFieldFilterVisible}
            />
          </nav>
        </div>
      </div>
    );
  }
}

PrimaryNavBar.propTypes = {
  updateButtonClick: PropTypes.func.isRequired,
  setUser: PropTypes.func.isRequired,
  setCurrentRepoTreeStatus: PropTypes.func.isRequired,
  toggleFieldFilterVisible: PropTypes.func.isRequired,
  filterModel: PropTypes.object.isRequired,
  repos: PropTypes.array.isRequired,
  serverChanged: PropTypes.bool.isRequired,
  user: PropTypes.object.isRequired,
  duplicateJobsVisible: PropTypes.bool.isRequired,
  groupCountsExpanded: PropTypes.bool.isRequired,
};
{'fraction_non_alphanumeric': 0.11010558069381599, 'fraction_numerical': 0.0018434724317077259, 'mean_word_length': 2.645693341478314, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7307767', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1630, 'n_words': 312}