<commit_before>import React from 'react';
import navigateAction from '../action/navigate-action';
import TutorialStore from '../stores/tutorial-store';
import {connectToStores} from 'fluxible-addons-react';
import _ from 'lodash';

class Breadcrumbs extends React.Component {
  
  handleClick(params) {
    let action = this.props.customNavigationAction || navigateAction;
    let payload = {};
    if (params.quickstart) payload.quickstartId = params.quickstart.name;
    if (params.platform)   payload.platformId   = params.platform.name;
    if (params.article)    payload.articleId    = params.article.name;
    this.context.executeAction(action, payload);
  }
  
  render() {
    let crumbs = [];
    let {quickstart, platform, article} = this.props;
    
    if (!quickstart) {
      return <div />;
    }
    
    crumbs.push(
      <a key="base" onClick={this.handleClick.bind(this, {})}>
        <span className="text">Documentation</span>
      </a>
    );
    
    crumbs.push(
      <a key="quickstart" onClick={this.handleClick.bind(this, {quickstart})}>
        <i className="icon-budicon-461"></i><span className="text">{quickstart.title}</span>
      </a>
    );

    if (platform) {
      crumbs.push(
        <a key="platform" onClick={this.handleClick.bind(this, {quickstart, platform, article: platform.articles[0]})}>
          <i className="icon-budicon-461"></i><span className="text">{platform.title}</span>
        </a>
      );
    }

    if (article) {
      crumbs.push(
        <a key="article" onClick={this.handleClick.bind(this, {quickstart, platform, article})}>
          <i className="icon-budicon-461"></i><span className="text">{article.title}</span>
        </a>
      );
    }
    
    return <div className="breadcrumbs">{crumbs}</div>;
  }
  
}

Breadcrumbs.propTypes = {
  quickstart: React.PropTypes.object,
  platform: React.PropTypes.object,
  article: React.PropTypes.object,
  customNavigationAction: React.PropTypes.func
}

Breadcrumbs.contextTypes = {<commit_msg>Only display article in breadcrumbs if there are multiple articles for the platform<commit_after>import React from 'react';
import navigateAction from '../action/navigate-action';
import TutorialStore from '../stores/tutorial-store';
import {connectToStores} from 'fluxible-addons-react';
import _ from 'lodash';

class Breadcrumbs extends React.Component {
  
  handleClick(params) {
    let action = this.props.customNavigationAction || navigateAction;
    let payload = {};
    if (params.quickstart) payload.quickstartId = params.quickstart.name;
    if (params.platform)   payload.platformId   = params.platform.name;
    if (params.article)    payload.articleId    = params.article.name;
    this.context.executeAction(action, payload);
  }
  
  render() {
    let crumbs = [];
    let {quickstart, platform, article} = this.props;
    
    if (!quickstart) {
      return <div />;
    }
    
    crumbs.push(
      <a key="base" onClick={this.handleClick.bind(this, {})}>
        <span className="text">Documentation</span>
      </a>
    );
    
    crumbs.push(
      <a key="quickstart" onClick={this.handleClick.bind(this, {quickstart})}>
        <i className="icon-budicon-461"></i><span className="text">{quickstart.title}</span>
      </a>
    );

    if (platform) {
      crumbs.push(
        <a key="platform" onClick={this.handleClick.bind(this, {quickstart, platform, article: platform.articles[0]})}>
          <i className="icon-budicon-461"></i><span className="text">{platform.title}</span>
        </a>
      );
      if (article && platform.articles.length > 1) {
        crumbs.push(
          <a key="article" onClick={this.handleClick.bind(this, {quickstart, platform, article})}>
            <i className="icon-budicon-461"></i><span className="text">{article.title}</span>
          </a>
        );
      }
    }
    
    return <div className="breadcrumbs">{crumbs}</div>;
  }
  
}

Breadcrumbs.propTypes = {
  quickstart: React.PropTypes.object,
  platform: React.PropTypes.object,
  article: React.PropTypes.object,
  customNavigationAction: React.PropTypes.func
}

Breadcrumbs.contextTypes = {
{'fraction_non_alphanumeric': 0.15148586615124426, 'fraction_numerical': 0.005073689296931626, 'mean_word_length': 3.1902834008097165, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 54, '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': '4114596', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1293, 'n_words': 238}