<commit_before>import React, { PropTypes } from 'react';

import APINotLoaded from 'es6!display/not_loaded';

import * as api from 'es6!server/api';

/*
 * Shows artifacts for a jobstep
 */
export var JobstepDetails = React.createClass({
  propTypes: {
    jobstepID: PropTypes.string,
  },

  getInitialState: function() {
    return {};
  },

  componentDidMount: function() {
    api.fetch(this, {
      details: `/api/0/jobsteps/${this.props.jobstepID}/artifacts/`
    });
  },

  render: function() {
    var { jobstepID, className, ...props} = this.props;

    if (!api.isLoaded(this.state.details)) {
      return <APINotLoaded calls={this.state.details} />;
    }
    var details = this.state.details.getReturnedData();

    className = (className || "") + " jobstepDetails";

    return <div {...props} className={className}>
      {this.renderArtifacts(details.artifacts)}
    </div>;
  },

  renderArtifacts(artifacts) {
    var markup = [];
    if (artifacts.length > 0) {
      markup.push(<div className="lb marginTopM">Artifacts</div>);
      _.each(artifacts, a => {
        markup.push(
          <div> <a className="external" target="_blank" href={a.url}>
            {a.name}
          </a> </div>
        );
      });
    }

    return markup;
  }
});
<commit_msg>Don't add a link for artifacts that we didn't save<commit_after>import React, { PropTypes } from 'react';

import APINotLoaded from 'es6!display/not_loaded';

import * as api from 'es6!server/api';

/*
 * Shows artifacts for a jobstep
 */
export var JobstepDetails = React.createClass({
  propTypes: {
    jobstepID: PropTypes.string,
  },

  getInitialState: function() {
    return {};
  },

  componentDidMount: function() {
    api.fetch(this, {
      details: `/api/0/jobsteps/${this.props.jobstepID}/artifacts/`
    });
  },

  render: function() {
    var { jobstepID, className, ...props} = this.props;

    if (!api.isLoaded(this.state.details)) {
      return <APINotLoaded calls={this.state.details} />;
    }
    var details = this.state.details.getReturnedData();

    className = (className || "") + " jobstepDetails";

    return <div {...props} className={className}>
      {this.renderArtifacts(details.artifacts)}
    </div>;
  },

  renderArtifacts(artifacts) {
    var markup = [];
    if (artifacts.length > 0) {
      markup.push(<div className="lb marginTopM">Artifacts</div>);
      _.each(artifacts, a => {
        if (a.url) {
          markup.push(
              <div><a className="external" target="_blank" href={a.url}>
                {a.name}
              </a></div>
          );
        } else {
          // if there's no URL don't add a link
          markup.push(<div>{a.name}</div>);
        }
      });
    }

    return markup;
  }
});

{'fraction_non_alphanumeric': 0.1620152229068503, 'fraction_numerical': 0.002899601304820587, 'mean_word_length': 2.570504527813713, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '3301234', 'n_tokens_mistral': 911, 'n_tokens_neox': 883, 'n_words': 179}