<commit_before>import React from 'react';

import { Modal, Button, Input } from 'react-bootstrap';

export default class NodeModal extends React.Component {
  render() {
    let onKeydownProp = (e) => {
      if (e.keyCode == 13) {
        this.props.onSavePropsNode();
      }
    };

    let def = this.props.nodedefs.defs[this.props.node.type];
    let properties = def.properties || {};
    let modalFields = Object.keys(properties).map(
      (key) => {
        let p = properties[key];
        let name = p.nativeName || key;
        let type = 'text';
        let inputChildren = null;
        if (Array.isArray(p.type)) {
          type = 'select';
          inputChildren = Object.keys(p.type).map(
            (key) => {
              let opt = p.type[key];
              return <option value={opt.value || opt} key={key}>{opt.name || opt}</option>
            });
        }
        else if (typeof p.type == 'object') {
          type = 'select';
          inputChildren = Object.keys(p.type).map(
            (key) => {
              let opt = p.type[key];
              return <option value={key} key={key}>{p.type[key]}</option>
            });
        }
        return (<div className="form-horizontal" key={key}>
          <Input type={type}
                 name={key}
                 ref={"input_box_"+key}
                 label={name+": "}
                 labelClassName="col-xs-3" wrapperClassName="col-xs-9"
                 onChange={this.props.onChangeNodeProp}
                 onKeyDown={onKeydownProp}
                 value={this.props.node.properties[key]}>
            {inputChildren}
          </Input>
        </div>);
      });
    return (
      <Modal show={true} onHide={this.props.closeNodeModal} bsSize="large">
        <Modal.Header closeButton>
          <Modal.Title>{this.props.node.type} Node: {this.props.currentNodeName}</Modal.Title>
        </Modal.Header>
        <Modal.Body>
          <h4>Node:</h4>
          <div className="form-horizontal">
            <Input type="text"
                   name="nodeName"
                   label="Name: "
                   labelClassName="col-xs-3" wrapperClassName="col-xs-9"
                   onChange={this.props.onChangeNodeName}
                   onKeyDown={onKeydownProp}
                   value={this.props.currentNodeName}>
            </Input>
          </div>
          <h4>Properties:</h4>
          {modalFields}
        </Modal.Body>
        <Modal.Footer>
          <Button onClick={this.props.onDeleteNode} bsStyle="danger" style={{float:"left"}}>Delete Node</Button>
          <Button onClick={this.props.closeNodeModal}>Close</Button>
          <Button onClick={this.props.onSavePropsNode} bsStyle="primary" disabled={this.props.saveDisabled}>Save Changes</Button>
        </Modal.Footer>
      </Modal>
    );
  }
}
<commit_msg>Added animation error in validation node name unique<commit_after>import React from 'react';

import { Modal, Button, Input } from 'react-bootstrap';

export default class NodeModal extends React.Component {
  render() {
    // Key listener
    let onKeydownProp = (e) => {
      if (e.keyCode == 13) {
        this.props.onSavePropsNode();
      }
    };

    // Props fields
    let def = this.props.nodedefs.defs[this.props.node.type];
    let properties = def.properties || {};
    let modalFields = Object.keys(properties).map(
      (key) => {
        let p = properties[key];
        let name = p.nativeName || key;
        let type = 'text';
        let inputChildren = null;
        if (Array.isArray(p.type)) {
          type = 'select';
          inputChildren = Object.keys(p.type).map(
            (key) => {
              let opt = p.type[key];
              return <option value={opt.value || opt} key={key}>{opt.name || opt}</option>
            });
        }
        else if (typeof p.type == 'object') {
          type = 'select';
          inputChildren = Object.keys(p.type).map(
            (key) => {
              let opt = p.type[key];
              return <option value={key} key={key}>{p.type[key]}</option>
            });
        }
        return (<div className="form-horizontal" key={key}>
          <Input type={type}
                 name={key}
                 ref={"input_box_"+key}
                 label={name+": "}
                 labelClassName="col-xs-3" wrapperClassName="col-xs-9"
                 onChange={this.props.onChangeNodeProp}
                 onKeyDown={onKeydownProp}
                 value={this.props.node.properties[key]}>
            {inputChildren}
          </Input>
        </div>);
      });
    return (
      <Modal show={true} onHide={this.props.closeNodeModal} bsSize="large">
        <Modal.Header closeButton>
          <Modal.Title>{this.props.node.type} Node: {this.props.currentNodeName}</Modal.Title>
        </Modal.Header>
        <Modal.Body>
          <h4>Node:</h4>
          <div className={this.props.saveDisabled ? 'form-horizontal has-error' : 'form-horizontal'}>
            <Input type="text"
                   name="nodeName"
                   label="Name: "
                   labelClassName="col-xs-3" wrapperClassName="col-xs-9"
                   onChange={this.props.onChangeNodeName}
                   onKeyDown={onKeydownProp}
                   value={this.props.currentNodeName}>
            </Input>
          </div>
          <h4>Properties:</h4>
          {modalFields}
        </Modal.Body>
        <Modal.Footer>
          <Button onClick={this.props.onDeleteNode} bsStyle="danger" style={{float:"left"}}>Delete Node</Button>
          <Button onClick={this.props.closeNodeModal}>Close</Button>
          <Button onClick={this.props.onSavePropsNode} bsStyle="primary" disabled={this.props.saveDisabled}>Save Changes</Button>
        </Modal.Footer>
      </Modal>
    );
  }
}

{'fraction_non_alphanumeric': 0.14710431345592026, 'fraction_numerical': 0.003437016669530847, 'mean_word_length': 1.8404099560761347, 'pattern_counts': {'":': 2, '<': 67, '<?xml version=': 0, '>': 75, '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': '6185444', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1658, 'n_words': 296}