<commit_before>// @flow

import React from 'react';
import { compose, pure, lifecycle, withHandlers, withState } from 'recompose';
import { connect } from 'react-redux';

import { dismissNotification } from '@ncigdc/dux/bannerNotification';
import nciGdcLogo from '@ncigdc/theme/images/NHI_GDC_DataPortal-logo.svg';
import HomeLink from '@ncigdc/components/Links/HomeLink';
import AnalysisLink from '@ncigdc/components/Links/AnalysisLink';
import RepositoryLink from '@ncigdc/components/Links/RepositoryLink';
import CartLink from '@ncigdc/components/Links/CartLink';
import ExploreLink from '@ncigdc/components/Links/ExploreLink';
import ProjectsLink from '@ncigdc/components/Links/ProjectsLink';
import GDCAppsDropdown from '@ncigdc/components/GDCApps/GDCAppsDropdown';
import QuickSearch from '@ncigdc/components/QuickSearch/QuickSearch';
import LoginButton from '@ncigdc/components/LoginButton';
import UserDropdown from '@ncigdc/components/UserDropdown';
import Hidden from '@ncigdc/components/Hidden';
import { setModal } from '@ncigdc/dux/modal';
import { forceLogout } from '@ncigdc/dux/auth';
import SessionExpiredModal from '@ncigdc/components/Modals/SessionExpiredModal';
import withRouter from '@ncigdc/utils/withRouter';
import Banner from '@ncigdc/uikit/Banner';
import { withTheme } from '@ncigdc/theme';
import { ExternalLink } from '@ncigdc/uikit/Links';
import { AnalysisIcon } from '@ncigdc/theme/icons';
import DatabaseIcon from '@ncigdc/theme/icons/Database';
import ManageSetsLink from '@ncigdc/components/Links/ManageSetsLink';

const styles = {
  iconPadding: {
    paddingRight: '4px',
  },
  activeNavLink: theme => ({
    backgroundColor: theme.greyScale2,
    color: theme.white,
  }),
};

const Header = compose(
  withState('isCollapsed', 'setIsCollapsed', true),
  withRouter,
  connect(state => ({
    notifications: state.bannerNotification,
    user: state.auth.user,
    error: state.error,
  })),
  withHandlers({
    handleApiError: ({ dispatch }) => ({ status, user }) => {
      if (user && status === 401) {
        dispatch(setModal(<SessionExpiredModal />));
        dispatch(forceLogout());
      }
    },
  }),
  lifecycle({
    componentDidMount(): void {
      if (this.props.error) {
        this.props.handleApiError({
          ...this.props.error,
          user: this.props.user,
        });
      }
    },
    componentWillReceiveProps(nextProps: Object): void {
      if (nextProps.error !== this.props.error) {
        this.props.handleApiError({ ...nextProps.error, user: nextProps.user });
      }
    },
  }),
  withTheme,
  pure,
)(({ user, notifications, dispatch, theme, isCollapsed, setIsCollapsed }) =>
  <header
    id="header"
    className="navbar navbar-default navbar-static-top"
    role="banner"
  >
    {notifications.map(n =>
      <Banner
        {...n}
        key={n.id}
        handleOnDismiss={() => dispatch(dismissNotification(n.id))}
      />,
    )}
    <div className="container-fluid">
      <div className="navbar-header">
        <button
          type="button"
          className="navbar-toggle"
          onClick={() => setIsCollapsed(!isCollapsed)}
        >
          <span className="sr-only test-toggle-navigation">
            Toggle navigation
          </span>
          <span className="icon-bar" />
          <span className="icon-bar" />
          <span className="icon-bar" />
        </button>
        <HomeLink className="navbar-brand" tabIndex="0" style={{ padding: 0 }}>
          <img src={nciGdcLogo} alt="gdc-logo" /><Hidden>Home</Hidden>
        </HomeLink>
      </div>
      <nav
        style={{ outline: 'none' }}
        className={`navbar-collapse navbar-responsive-collapse ${isCollapsed
          ? 'collapse'
          : ''}`}
        data-uib-collapse="hc.isCollapsed"
        tabIndex="-1"
        aria-label="Site Navigation"
        onClick={() => setIsCollapsed(true)}
      >
        <ul className="nav navbar-nav">
          <li>
            <HomeLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="fa fa-home" style={styles.iconPadding} />
              <span className="hidden-sm">Home</span>
            </HomeLink>
          </li>
          <li>
            <ProjectsLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="icon-gdc-projects" style={styles.iconPadding} />
              <span className="hidden-sm">Projects</span>
            </ProjectsLink>
          </li>
          <li>
            <ExploreLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="icon-gdc-data" style={styles.iconPadding} />
              <span className="hidden-sm">Exploration</span>
            </ExploreLink>
          </li>
          <li>
            <RepositoryLink exact activeStyle={styles.activeNavLink(theme)}>
              <DatabaseIcon style={styles.iconPadding} />
              <span className="hidden-sm">Repository</span>
            </RepositoryLink>
          </li>
          {!!process.env.SHOW_ANALYSIS_MENU &&
            <li>
              <ExternalLink
                href="https://gdc.cancer.gov/access-data/analytical-tools"
                tabIndex="0"
                hasExternalIcon={false}
              >
                <i className="fa fa-bar-chart" style={styles.iconPadding} />
                <span className="hidden-sm">Analysis</span>
              </ExternalLink>

            </li>}

          <li>
            <AnalysisLink exact activeStyle={styles.activeNavLink(theme)}>
              <AnalysisIcon style={styles.iconPadding} />
              <span className="hidden-sm">Analysis</span>
            </AnalysisLink>
          </li>
        </ul>
        <ul className="nav navbar-nav navbar-right">
          <li><QuickSearch tabIndex="0" /></li>
          <li>
            <ManageSetsLink activeStyle={styles.activeNavLink(theme)} />
          </li><commit_msg>💄 [PRTL-1625] analysis menu before repo (#2083)<commit_after>// @flow

import React from 'react';
import { compose, pure, lifecycle, withHandlers, withState } from 'recompose';
import { connect } from 'react-redux';

import { dismissNotification } from '@ncigdc/dux/bannerNotification';
import nciGdcLogo from '@ncigdc/theme/images/NHI_GDC_DataPortal-logo.svg';
import HomeLink from '@ncigdc/components/Links/HomeLink';
import AnalysisLink from '@ncigdc/components/Links/AnalysisLink';
import RepositoryLink from '@ncigdc/components/Links/RepositoryLink';
import CartLink from '@ncigdc/components/Links/CartLink';
import ExploreLink from '@ncigdc/components/Links/ExploreLink';
import ProjectsLink from '@ncigdc/components/Links/ProjectsLink';
import GDCAppsDropdown from '@ncigdc/components/GDCApps/GDCAppsDropdown';
import QuickSearch from '@ncigdc/components/QuickSearch/QuickSearch';
import LoginButton from '@ncigdc/components/LoginButton';
import UserDropdown from '@ncigdc/components/UserDropdown';
import Hidden from '@ncigdc/components/Hidden';
import { setModal } from '@ncigdc/dux/modal';
import { forceLogout } from '@ncigdc/dux/auth';
import SessionExpiredModal from '@ncigdc/components/Modals/SessionExpiredModal';
import withRouter from '@ncigdc/utils/withRouter';
import Banner from '@ncigdc/uikit/Banner';
import { withTheme } from '@ncigdc/theme';
import { AnalysisIcon } from '@ncigdc/theme/icons';
import DatabaseIcon from '@ncigdc/theme/icons/Database';
import ManageSetsLink from '@ncigdc/components/Links/ManageSetsLink';

const styles = {
  iconPadding: {
    paddingRight: '4px',
  },
  activeNavLink: theme => ({
    backgroundColor: theme.greyScale2,
    color: theme.white,
  }),
};

const Header = compose(
  withState('isCollapsed', 'setIsCollapsed', true),
  withRouter,
  connect(state => ({
    notifications: state.bannerNotification,
    user: state.auth.user,
    error: state.error,
  })),
  withHandlers({
    handleApiError: ({ dispatch }) => ({ status, user }) => {
      if (user && status === 401) {
        dispatch(setModal(<SessionExpiredModal />));
        dispatch(forceLogout());
      }
    },
  }),
  lifecycle({
    componentDidMount(): void {
      if (this.props.error) {
        this.props.handleApiError({
          ...this.props.error,
          user: this.props.user,
        });
      }
    },
    componentWillReceiveProps(nextProps: Object): void {
      if (nextProps.error !== this.props.error) {
        this.props.handleApiError({ ...nextProps.error, user: nextProps.user });
      }
    },
  }),
  withTheme,
  pure,
)(({ user, notifications, dispatch, theme, isCollapsed, setIsCollapsed }) =>
  <header
    id="header"
    className="navbar navbar-default navbar-static-top"
    role="banner"
  >
    {notifications.map(n =>
      <Banner
        {...n}
        key={n.id}
        handleOnDismiss={() => dispatch(dismissNotification(n.id))}
      />,
    )}
    <div className="container-fluid">
      <div className="navbar-header">
        <button
          type="button"
          className="navbar-toggle"
          onClick={() => setIsCollapsed(!isCollapsed)}
        >
          <span className="sr-only test-toggle-navigation">
            Toggle navigation
          </span>
          <span className="icon-bar" />
          <span className="icon-bar" />
          <span className="icon-bar" />
        </button>
        <HomeLink className="navbar-brand" tabIndex="0" style={{ padding: 0 }}>
          <img src={nciGdcLogo} alt="gdc-logo" /><Hidden>Home</Hidden>
        </HomeLink>
      </div>
      <nav
        style={{ outline: 'none' }}
        className={`navbar-collapse navbar-responsive-collapse ${isCollapsed
          ? 'collapse'
          : ''}`}
        data-uib-collapse="hc.isCollapsed"
        tabIndex="-1"
        aria-label="Site Navigation"
        onClick={() => setIsCollapsed(true)}
      >
        <ul className="nav navbar-nav">
          <li>
            <HomeLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="fa fa-home" style={styles.iconPadding} />
              <span className="hidden-sm">Home</span>
            </HomeLink>
          </li>
          <li>
            <ProjectsLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="icon-gdc-projects" style={styles.iconPadding} />
              <span className="hidden-sm">Projects</span>
            </ProjectsLink>
          </li>
          <li>
            <ExploreLink exact activeStyle={styles.activeNavLink(theme)}>
              <i className="icon-gdc-data" style={styles.iconPadding} />
              <span className="hidden-sm">Exploration</span>
            </ExploreLink>
          </li>
          <li>
            <AnalysisLink exact activeStyle={styles.activeNavLink(theme)}>
              <AnalysisIcon style={styles.iconPadding} />
              <span className="hidden-sm">Analysis</span>
            </AnalysisLink>
          </li>
          <li>
            <RepositoryLink exact activeStyle={styles.activeNavLink(theme)}>
              <DatabaseIcon style={styles.iconPadding} />
              <span className="hidden-sm">Repository</span>
            </RepositoryLink>
          </li>
        </ul>
        <ul className="nav navbar-nav navbar-right">
          <li><QuickSearch tabIndex="0" /></li>
          <li>
            <ManageSetsLink activeStyle={styles.activeNavLink(theme)} />
          </li>
{'fraction_non_alphanumeric': 0.14270594461104252, 'fraction_numerical': 0.0023813723760804373, 'mean_word_length': 2.6471534255387583, 'pattern_counts': {'":': 0, '<': 136, '<?xml version=': 0, '>': 154, 'https://': 1, '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': '6528596', 'n_tokens_mistral': 3369, 'n_tokens_neox': 3307, 'n_words': 619}