<commit_before>import {FormGroup, TextFormGroup, TextAreaFormGroup} from "bootstrap-react-components";
import React from "react";
import {connect} from "react-redux";

class EdgeEditor extends React.Component {

	cancel() {

	}

	componentWillMount() {
		this.propsToState(this.props);
	}

	componentWillReceiveProps(nextProps) {
		this.propsToState(nextProps);
	}

	constructor(props) {
		super(props);
		this.state = {
			nameError: "",
			descriptionError: ""
		};
	}

	descriptionChange(e) {
		this.setState({
			description: e.target.value
		})
	}

	edgeTypeChange(e) {
		let edgeType = this.props.edgeTypes.find((et) => et._id === e.target.value);
		this.setState({
			edgeType
		})

	}

	propsToState(props) {
		let {_id, name, description, edgeType} = props;
		this.setState({
			_id, name, description, edgeType
		});
	}

	nameChange(e) {
		this.setState({
			name: e.target.value
		})
	}

	render() {
		let {_id, name, description, edgeType, nameError, descriptionError} = this.state;
		return (
				<div id="EdgeEditorForm">
					<TextFormGroup
							error={nameError}
							label="Edge Name"
							id={"name" + _id}
							onChange={this.nameChange.bind(this)}
							value={name}
							required={true}/>
					<FormGroup label="Edge Type" id="edgeType" error={""} required={true}>
						<select class="form-control" id="edgeTypeSelect" onChange={this.edgeTypeChange.bind(this)}
						        value={edgeType._id}>
							{this.props.edgeTypes.map((et) => <option key={et._id} value={et._id}>{et.name}</option>)}
						</select>
					</FormGroup>
					<TextAreaFormGroup
							error={descriptionError}
							label="Description"
							id={"description" + _id}
							onChange={this.descriptionChange.bind(this)}
							value={description}
					/>
					<button type="button" class="btn btn-primary"
					        onClick={this.save.bind(this)}>Save
					</button>
					<button type="button" class="btn btn-default" onClick={this.cancel.bind(this)}>Cancel</button>
				</div>
		);
	}

	save(event) {
		event.preventDefault();
		let {_id, name, description, edgeType} = this.state;
		this.props.save({
			_id, name, description, edgeType
		});

	}
}

const mapStateToProps = (state) => {
	return {
		edgeTypes: state.PlotPoint.plotPoint.edgeTypes,
		edges: state.PlotPoint.plotPoint.edges
	};
};

const mapDispatchToProps = (dispatch) => {
	return {};
};

export default connect(mapStateToProps, mapDispatchToProps)(EdgeEditor);<commit_msg>Edges work<commit_after>import {FormGroup, TextFormGroup, TextAreaFormGroup} from "bootstrap-react-components";
import React from "react";
import {connect} from "react-redux";

class EdgeEditor extends React.Component {

	cancel() {

	}

	componentWillMount() {
		this.propsToState(this.props);
	}

	componentWillReceiveProps(nextProps) {
		this.propsToState(nextProps);
	}

	constructor(props) {
		super(props);
		this.state = {
			nameError: "",
			descriptionError: ""
		};
	}

	descriptionChange(e) {
		this.setState({
			description: e.target.value
		})
	}

	edgeTypeChange(e) {
		let edgeType = this.props.edgeTypes.find((et) => et._id === e.target.value);
		this.setState({
			edgeType
		})

	}

	propsToState(props) {
		let {_id, name, description, edgeType} = props;
		this.setState({
			_id, name, description, edgeType
		});
	}

	nameChange(e) {
		this.setState({
			name: e.target.value
		})
	}

	render() {
		let {_id, name, description, edgeType} = this.state;
		return (
				<div id="EdgeEditorForm">
					<TextFormGroup
							label="Edge Name"
							onChange={this.nameChange.bind(this)}
							value={name}
							required={true}/>
					<FormGroup label="Edge Type" id="edgeType" required={true}>
						<select class="form-control" id="edgeTypeSelect" onChange={this.edgeTypeChange.bind(this)}
						        value={edgeType && edgeType._id ? edgeType._id : ""}>
							{this.props.edgeTypes.map((et) => <option key={et._id} value={et._id}>{et.name}</option>)}
						</select>
					</FormGroup>
					<TextAreaFormGroup
							label="Description"
							onChange={this.descriptionChange.bind(this)}
							value={description}
					/>
					<button type="button" class="btn btn-primary"
					        onClick={this.save.bind(this)}>Save
					</button>
					<button type="button" class="btn btn-default" onClick={this.cancel.bind(this)}>Cancel</button>
				</div>
		);
	}

	save(event) {
		event.preventDefault();
		let {_id, name, description, edgeType = this.props.edgeTypes[0]} = this.state;
		this.props.save({
			_id, name, description, edgeType
		});

	}
}

const mapStateToProps = (state) => {
	return {
		edgeTypes: state.PlotPoint.plotPoint.edgeTypes,
		edges: state.PlotPoint.plotPoint.edges
	};
};

const mapDispatchToProps = (dispatch) => {
	return {};
};

export default connect(mapStateToProps, mapDispatchToProps)(EdgeEditor);
{'fraction_non_alphanumeric': 0.1562304971915956, 'fraction_numerical': 0.00020802995631370917, 'mean_word_length': 3.5877862595419847, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 39, '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': '4882355', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1588, 'n_words': 278}