<commit_before>import React, { Component, PropTypes } from 'react';
import FlatButton from 'material-ui/lib/flat-button';
import TeamHeader from './team/TeamHeader';
import ProjectHeader from './project/ProjectHeader';
import Breadcrumb from './layout/Breadcrumb';
import MediaHeader from './media/MediaHeader';
import HeaderActions from './HeaderActions';

class Header extends Component {
  isSubdomain(hostname) { // TODO: replace with helpers.js::teamSubdomain or similar
    return (hostname !== 'checkmedia.org' && hostname !== 'qa.checkmedia.org');
  }

  render() {
    const { state } = this.props;
    const path = this.props.location ? this.props.location.pathname : null;

    if (!state.app.token) {
      return null;
    }

    const defaultHeader = (
      <header className='header header--default'>
        <div className='header__container'>
          <Breadcrumb url='/' title={null} />
          <HeaderActions {...this.props} />
        </div>
      </header>
    );

    if (!path) {
      return defaultHeader;
    }

    if (path.match(/media\/[0-9]+/)) {
      const projectUrl = path.match(/(.*)\/media\/[0-9]+/)[1];
      return (
        <header className='header header--media'>
          <div className='header__container'>
            <Breadcrumb url={projectUrl} title='« Back to Project' />
            <MediaHeader {...this.props} />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    if (path.match(/project\/[0-9]+/)) {
      return (
        <header className='header header--project'>
          <div className='header__container'>
            <div className='header__team'><TeamHeader {...this.props} /></div>
            <ProjectHeader {...this.props} />
            {/* TODO: <HeaderActions {...this.props} /> */}
          </div>
        </header>
      );
    }

    if (this.isSubdomain(window.location.hostname) && path.match(/^\/(join|members)/)) {
      return (
        <header className='header header--team-subpage'>
          <div className='header__container'>
            <Breadcrumb url='/' title='« Back to Team' />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    if (this.isSubdomain(window.location.hostname) && path.match(/^\/(teams\/new)?$/)) {
      return (
        <header className='header header--team'>
          <div className='header__container'>
            <Breadcrumb url='/teams' title='« Your Teams' />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    return defaultHeader;
  }
}

export default Header;<commit_msg>Query for team in header on most routes (hacky)<commit_after>import React, { Component, PropTypes } from 'react';
import FlatButton from 'material-ui/lib/flat-button';
import TeamHeader from './team/TeamHeader';
import ProjectHeader from './project/ProjectHeader';
import Breadcrumb from './layout/Breadcrumb';
import MediaHeader from './media/MediaHeader';
import HeaderActions from './HeaderActions';

class Header extends Component {
  isSubdomain(hostname) { // TODO: replace with helpers.js::teamSubdomain or similar
    return (hostname !== 'checkmedia.org' && hostname !== 'qa.checkmedia.org');
  }

  render() {
    const { state } = this.props;
    const path = this.props.location ? this.props.location.pathname : null;

    if (!state.app.token) {
      return null;
    }

    const defaultHeader = (
      <header className='header header--default'>
        <div className='header__container'>
          <Breadcrumb url='/' title={null} />
          <HeaderActions {...this.props} />
        </div>
      </header>
    );

    if (!path) {
      return defaultHeader;
    }

    if (path.match(/media\/[0-9]+/)) {
      const projectUrl = path.match(/(.*)\/media\/[0-9]+/)[1];
      return (
        <header className='header header--media'>
          <div className='header__container'>
            <span style={{display: 'none'}}><TeamHeader {...this.props} /></span>
            <Breadcrumb url={projectUrl} title='« Back to Project' />
            <MediaHeader {...this.props} />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    if (path.match(/project\/[0-9]+/)) {
      return (
        <header className='header header--project'>
          <div className='header__container'>
            <div className='header__team'><TeamHeader {...this.props} /></div>
            <ProjectHeader {...this.props} />
            {/* TODO: <HeaderActions {...this.props} /> */}
          </div>
        </header>
      );
    }

    if (this.isSubdomain(window.location.hostname) && path.match(/^\/(join|members)/)) {
      return (
        <header className='header header--team-subpage'>
          <div className='header__container'>
            <span style={{display: 'none'}}><TeamHeader {...this.props} /></span>
            <Breadcrumb url='/' title='« Back to Team' />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    if (this.isSubdomain(window.location.hostname) && path.match(/^\/(teams\/new)?$/)) {
      return (
        <header className='header header--team'>
          <div className='header__container'>
            <span style={{display: 'none'}}><TeamHeader {...this.props} /></span>
            <Breadcrumb url='/teams' title='« Your Teams' />
            <HeaderActions {...this.props} />
          </div>
        </header>
      );
    }

    return defaultHeader;
  }
}

export default Header;
{'fraction_non_alphanumeric': 0.17181883537023723, 'fraction_numerical': 0.0025161754133716753, 'mean_word_length': 2.209342560553633, 'pattern_counts': {'":': 0, '<': 80, '<?xml version=': 0, '>': 80, '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': '4200478', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1603, 'n_words': 350}