<commit_before>'use babel';
/** @jsx etch.dom */

import etch from 'etch';
import SelectListView from 'atom-select-list';

export default class ConfirmingEdit {
  /**
    Expected props
    --------------
    className:
      CSS class name(s) to give to the most prominent part of the control
    
    id:
      HTML id attribute for the active part of the control
    
    value:
      Value to place in the field when editing
    
    displayValue:
      Value to show in the field when not editing
    
    onChange:
      Handler function receiving the confirmed String value
  */
  
  constructor(props) {
    this.props = props;
    etch.initialize(this);
  }
  
  render() {
    const selectList = [];
    if (this.editing) {
      selectList.push(this.renderSelectList());
    }
    return (
      <span className="confirming-editor btn-group" style={{position: 'relative'}}>
        {selectList}
        <button
          className={"btn " + this.props.className}
          attributes={{id: this.props.id}}
          on={{click: this.handleEditButtonClick}}
          >
          {this.props.displayValue}
          <span className="icon icon-pencil"></span>
        </button>
      </span>
    );
  }
  
  renderSelectList() {
    return (
      <div className="select-list popover-list" style={{position: 'absolute', 'z-index': 100}}>
        <SelectListView
          ref="editor"
          items={this.props.suggestions || []}
          elementForItem={generateItemElement}
          didChangeQuery={newQuery => this.handleQueryChanged(newQuery)}
          didConfirmSelection={value => this.handleAccepted(value)}
          didConfirmEmptySelection={() => this.handleConfirmEmpty()}
          didCancelSelection={() => this.handleEditCancelled()}
          />
      </div>
    );
  }
  
  handleEditButtonClick() {
    this.setEditing(true).then(() => this.refs.editor.focus());
  }
  
  handleQueryChanged(newQuery) {
    const view = this.refs.editor;
    view.update({<commit_msg>Pre-set the new casefile name query to the current...<commit_after>'use babel';
/** @jsx etch.dom */

import etch from 'etch';
import SelectListView from 'atom-select-list';

export default class ConfirmingEdit {
  /**
    Expected props
    --------------
    className:
      CSS class name(s) to give to the most prominent part of the control
    
    id:
      HTML id attribute for the active part of the control
    
    value:
      Value to place in the field when editing
    
    displayValue:
      Value to show in the field when not editing
    
    onChange:
      Handler function receiving the confirmed String value
  */
  
  constructor(props) {
    this.props = props;
    etch.initialize(this);
  }
  
  render() {
    const selectList = [];
    if (this.editing) {
      selectList.push(this.renderSelectList());
    }
    return (
      <span className="confirming-editor btn-group" style={{position: 'relative'}}>
        {selectList}
        <button
          className={"btn " + this.props.className}
          attributes={{id: this.props.id}}
          on={{click: this.handleEditButtonClick}}
          >
          {this.props.displayValue}
          <span className="icon icon-pencil"></span>
        </button>
      </span>
    );
  }
  
  renderSelectList() {
    return (
      <div className="select-list popover-list" style={{position: 'absolute', 'z-index': 100}}>
        <SelectListView
          ref="editor"
          items={this.props.suggestions || []}
          elementForItem={generateItemElement}
          didChangeQuery={newQuery => this.handleQueryChanged(newQuery)}
          didConfirmSelection={value => this.handleAccepted(value)}
          didConfirmEmptySelection={() => this.handleConfirmEmpty()}
          didCancelSelection={() => this.handleEditCancelled()}
          />
      </div>
    );
  }
  
  handleEditButtonClick() {
    this.setEditing(true).then(() => 
      this.refs.editor.update({
        query: this.props.value,
        selectQuery: true
      })
    ).then(() =>
      this.refs.editor.focus()
    );
  }
  
  handleQueryChanged(newQuery) {
    const view = this.refs.editor;
    view.update({
{'fraction_non_alphanumeric': 0.1289315726290516, 'fraction_numerical': 0.0014405762304921968, 'mean_word_length': 2.3301358912869703, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 32, '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': '801033', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1182, 'n_words': 273}