<commit_before>/*jshint esversion: 6 */

import React, {PropTypes} from 'react';
import {
  ListGroupItem,
  Grid,
  Row,
  Col,
  Button,
  ButtonGroup,
  Glyphicon
} from 'react-bootstrap';
var LinkContainer = require('react-router-bootstrap').LinkContainer;
import Actions from '../../../actions';
import {calculateMapName} from './map-name-calculator';
import $ from 'jquery';

export default class MapListElement extends React.Component {

  constructor(props) {
    super(props);

    this.componentDidMount = this.componentDidMount.bind(this);
    this.computeSubmapReferencesMessage = this.computeSubmapReferencesMessage.bind(this);
  }

  archive(workspace, id) {
    Actions.archiveMap(workspace, id);
  }
  componentDidMount() {
    var mapID = this.props.id;
    $.ajax({
      type: 'GET',
      url: '/api/submap/' + mapID + '/usage',
      success: function(referencingMaps) {
        this.setState({referencingMaps:referencingMaps})
      }.bind(this)
    });
  }

  computeSubmapReferencesMessage(){
    if(!this.state || !this.state.referencingMaps){
      return null;
    }
    var mapsList = [];
    for(var i = 0; i < this.state.referencingMaps.length; i++){
      var href = '/map/' + this.state.referencingMaps[i]._id;
      var name = calculateMapName('Unknown',this.state.referencingMaps[i].user, this.state.referencingMaps[i].purpose,this.state.referencingMaps[i].name );
      var punctuation = ', ';
      if(i === this.state.referencingMaps.length - 1){
        punctuation = null;
      }
      if(i === this.state.referencingMaps.length - 2){
        punctuation = ' and ';
      }
      mapsList.push(<span>&#39;<a href={href}>{name}</a>&#39;{punctuation}</span>);
    }
    return (<div>Maps {mapsList} use this submap.</div>);
  }
  render() {
    var mapid = this.props.id;
    var workspaceID = this.props.workspaceID;
    var href = '/map/' + mapid;
    var mapName = calculateMapName("I like being lost.", this.props.user, this.props.purpose, this.props.name);

    var deleteButton = (<Button bsStyle="default" href="#" onClick={this.archive.bind(this, workspaceID, mapid)}>
      <Glyphicon glyph="remove"></Glyphicon> Delete
    </Button>);<commit_msg>Highlight submaps without dependencies<commit_after>/*jshint esversion: 6 */

import React, {PropTypes} from 'react';
import {
  ListGroupItem,
  Grid,
  Row,
  Col,
  Button,
  ButtonGroup,
  Glyphicon
} from 'react-bootstrap';
var LinkContainer = require('react-router-bootstrap').LinkContainer;
import Actions from '../../../actions';
import {calculateMapName} from './map-name-calculator';
import $ from 'jquery';

export default class MapListElement extends React.Component {

  constructor(props) {
    super(props);

    this.componentDidMount = this.componentDidMount.bind(this);
    this.computeSubmapReferencesMessage = this.computeSubmapReferencesMessage.bind(this);
  }

  archive(workspace, id) {
    Actions.archiveMap(workspace, id);
  }
  componentDidMount() {
    var mapID = this.props.id;
    $.ajax({
      type: 'GET',
      url: '/api/submap/' + mapID + '/usage',
      success: function(referencingMaps) {
        this.setState({referencingMaps:referencingMaps})
      }.bind(this)
    });
  }

  computeSubmapReferencesMessage(){
    if(!this.state || !this.state.referencingMaps){
      return null;
    }
    if(this.state.referencingMaps.length === 0){
      return <div>No other map uses this submap. It&#39;s undesired.</div>;
    }
    var mapsList = [];
    for(var i = 0; i < this.state.referencingMaps.length; i++){
      var href = '/map/' + this.state.referencingMaps[i]._id;
      var name = calculateMapName('Unknown',this.state.referencingMaps[i].user, this.state.referencingMaps[i].purpose,this.state.referencingMaps[i].name );
      var punctuation = ', ';
      if(i === this.state.referencingMaps.length - 1){
        punctuation = null;
      }
      if(i === this.state.referencingMaps.length - 2){
        punctuation = ' and ';
      }
      mapsList.push(<span>&#39;<a href={href}>{name}</a>&#39;{punctuation}</span>);
    }
    return (<div>Maps {mapsList} use this submap.</div>);
  }
  render() {
    var mapid = this.props.id;
    var workspaceID = this.props.workspaceID;
    var href = '/map/' + mapid;
    var mapName = calculateMapName("I like being lost.", this.props.user, this.props.purpose, this.props.name);

    var deleteButton = (<Button bsStyle="default" href="#" onClick={this.archive.bind(this, workspaceID, mapid)}>
      <Glyphicon glyph="remove"></Glyphicon> Delete
    </Button>);
{'fraction_non_alphanumeric': 0.15647007042253522, 'fraction_numerical': 0.004181338028169014, 'mean_word_length': 3.4255111976630963, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, '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': '251640', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1456, 'n_words': 285}