<commit_before>/** @jsx React.DOM */

"use strict";

var $ = require('atom-space-pen-views').$;

const React = require('react-atom-fork');

const JoinWorkspace = React.createClass({
  getInitialState: function () {
    return {
      path: ""
    };
  },
  onSubmit: function () {
    this.props.on_url(this.state.path, this.refs.url.getDOMNode().value);
  },
  onChange_: function (event) {
    const files = event.target.files;
    if (!files.length) {
      return;
    }
    const path = files[0].path;
    this.setState({path: path});
  },
  componentDidMount: function () {
    this.refs.dir.getDOMNode().setAttribute("webkitdirectory", true);
    
    setTimeout(function () {
      $("#floobits-url").focus();
    }, 0);

    var that = this;
    $("#join-workspace").keyup(function(e) {
      if (e.keyCode !== 27) { 
        return;
      }
      that.destroy();
    });

    const root = atom.project.rootDirectories;
    if (!root.length) {
      return;
    }
    const path = root[0].getPath();
    if (!path) {
      return;
    }
    this.setState({path: path});
  },
  destroy: function () {
    this.getDOMNode().parentNode.destroy(); 
  },
  onTyping: function (event) {
    const path = event.target.value;
    if (path === this.state.path) {
      return;
    }
    this.setState({path: path});
  },
  clickFileInput: function (event) {
    $("#ultra-secret-hidden-file-input").trigger('click');
  },
  render: function () {
    return (
      <div>
        <h2>Join Workspace</h2>
        <div className="well">
          <form id="join-workspace" onSubmit={this.onSubmit} className="native-key-bindings">
            <input id="ultra-secret-hidden-file-input" type="file" ref="dir" style={{display: "none"}} onChange={this.onChange_} />
            
            <div className="row">
              <div className="col-lg-12">
                <div className="input-group">
                  <span className="input-group-addon" id="url-addon">URL</span>
                  <input id="floobits-url" ref="url" className="native-key-bindings form-control" placeholder={this.props.url} aria-describedby="url-addon" />
                </div>
              </div>
            </div>

            <div className="row">
              <div className="col-lg-12">
                <div className="input-group">
                  <span onClick={this.clickFileInput} className="input-group-addon" id="directory-addon" >Select Directory</span>
                  <input onClick={this.clickFileInput} onChange={this.onTyping} type="text" className="native-key-bindings form-control" placeholder="..." 
                    aria-describedby="directory-addon" value={this.state.path} />
                </div>
              </div>
            </div>

            <div className="row">
              <div className="col-lg-12">
                <input onClick={this.onSubmit} type="submit" value="Join" className="floobits-submit" />
              </div>
            </div>
          </form>
        </div>
      </div>
    );
  }
});

module.exports = JoinWorkspace<commit_msg>fix join UI:<commit_after>/** @jsx React.DOM */

"use strict";

var $ = require('atom-space-pen-views').$;

const React = require('react-atom-fork');

const JoinWorkspace = React.createClass({
  getInitialState: function () {
    return {
      path: ""
    };
  },
  onSubmit: function () {
    setTimeout(function () {
      this.props.on_url(this.state.path, this.refs.url.getDOMNode().value);
    }.bind(this), 0);
    this.destroy();
  },
  onChange_: function (event) {
    const files = event.target.files;
    if (!files.length) {
      return;
    }
    const path = files[0].path;
    this.setState({path: path});
  },
  onTab: function (event) {
    event.preventDefault();
    const position = parseInt(event.target.attributes["data-tab_order"].value, 10)
    const c = event.shiftKey ? -1 : 1;
    const next = (position + c) % 3
    const refName = {0: "url", 1: "dir", 2: "submit"}[next];
    const ref = this.refs[refName].getDOMNode();
    ref.focus();
  },
  componentDidUpdate: function () {
    $("#ultra-secret-hidden-file-input").attr("webkitdirectory", true);
  },
  componentDidMount: function () {
    $("#ultra-secret-hidden-file-input").attr("webkitdirectory", true);
    
    setTimeout(function () {
      $("#floobits-url").focus();
    }, 0);

    const that = this;
    $("#join-workspace").keydown(function(e) {
      switch (e.keyCode) {
        case 27:  // escape
          that.destroy();
          return;
        case 13:  // enter
          that.onSubmit();
          return;
        case 9:  // tab
          that.onTab(e);
          return;
        default:
          break;
      }
    });

    const root = atom.project.rootDirectories;
    if (!root.length) {
      return;
    }
    const path = root[0].getPath();
    if (!path) {
      return;
    }
    this.setState({path: path});
    $("#ultra-secret-hidden-file-input").attr("webkitdirectory", true);
  },
  destroy: function () {
    $("#join-workspace").off("keydown");
    this.getDOMNode().parentNode.destroy(); 
  },
  onTyping: function (event) {
    const path = event.target.value;
    if (path === this.state.path) {
      return;
    }
    this.setState({path: path});
  },
  focusFileInput: function (event) {
    $("#ultra-secret-hidden-file-input").trigger('click');
  },
  render: function () {
    return (
      <div>
        <h2>Join Workspace</h2>
        <div className="well">
          <form id="join-workspace" onSubmit={this.onSubmit} className="native-key-bindings">
            <input id="ultra-secret-hidden-file-input" type="file" ref="dir" style={{display: "none"}} onChange={this.onChange_} webkitdirectory />
            
            <div className="row">
              <div className="col-lg-12">
                <div className="input-group">
                  <span className="input-group-addon" id="url-addon">URL</span>
                  <input data-tab_order="0" id="floobits-url" ref="url" className="native-key-bindings form-control" placeholder={this.props.url} aria-describedby="url-addon" />
                </div>
              </div>
            </div>

            <div className="row">
              <div className="col-lg-12">
                <div className="input-group">
                  <span onClick={this.clickFileInput} className="input-group-addon" id="directory-addon" >Select Directory</span>
                  <input data-tab_order="1" onFocus={this.focusFileInput} onChange={this.onTyping} type="text" className="native-key-bindings form-control" placeholder="..." 
                    aria-describedby="directory-addon" value={this.state.path} ref="dir" />
                </div>
              </div>
            </div>

            <div className="row">
              <div className="col-lg-12">
                <input data-tab_order="2" ref="submit" onClick={this.onSubmit} type="submit" value="Join" className="floobits-submit" />
              </div>
            </div>
          </form>
        </div>
      </div>
    );
  }
});

module.exports = JoinWorkspace
{'fraction_non_alphanumeric': 0.17035055610305505, 'fraction_numerical': 0.005772208925805998, 'mean_word_length': 2.2057761732851984, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 67, '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': '7512339', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2174, 'n_words': 386}