<commit_before>var builder = require('focus').component.builder;
var type = require('focus').component.types;
var React = require('react');

//var type = require('../../core/validation/types');
var find = require('lodash/collection/find');
var uuid = require('uuid');
var scopeMixin = {
  /**
   * Component tag name.
   * @type {String}
   */
  displayName: "Scope",
  /**
   * Component default properties.
   */
  getDefaultProps: function getScopeDefaultProperties() {
    return {
      list: [],
      value: undefined,
      isDeployed: false
    };
  },
  /**
   * Scope property validation.
   * @type {Object}
   */
   propTypes:{
      list: type('array'),
      isDeployed: type('bool'),
      value: type(['string', 'number'])
    },
  /**
   * Get the initial state from the data.
   */
  getInitialState: function getScopeInitialState() {
    return {
      isDeployed: this.props.isDeployed,
      value: this.props.value
    };
  },
  /**
   * Get the value of the scope.
   */
  getValue: function() {
    return this.state.value;
  },
  /**
   * Define the scope label.
   */
  scopeLabel: function scopeLabel() {
    return;
    if (!this.state.value) {
      return "Choose your scope";
    }
    return this.state.value;
  },
  /**
   * Internal function which handles the click on the scope line element and call the real handleOnclick if it is defined.
   * @param {object} event - Event trigger by the search.
   */
  _handleOnClick: function(event) {
    var val = event.target.hasAttribute("value") ? event.target.value :
      undefined;
    this.setState({
      value: val,
      isDeployed: false
    }, this.props.handleOnClick);
  },
  /**
   * Handle the click on the scope element.
   */
  handleDeployClick: function() {
    this.setState({
      isDeployed: !this.state.isDeployed
    });
  },
  /**
   * Get the current active scope.
   */
  getActiveScope: function getActiveScope() {
    return find(this.props.list, (scope) => {
      return scope.code === this.state.value;
    });
  },
  /**
   * Return the css class for the scope.
   */
  scopeStyle: function scopeStyle() {
    var activeScope = activeScope;
    return activeScope.style || `qs-scope-${activeScope.value}`;
  },
  renderScopeList: function renderScopeList() {
    if (!this.state.isDeployed) {
      return;
    }
    var scopes = this.props.list.map((scope) => {
      var selectedValue = this.state.value === scope.code ? "active" : "";
      return ( <li key={scope.code || uuid.v4()}
        value={scope.code}
        className={`${selectedValue} ${scope.style}`}
        onClick = {this._handleOnClick}>
        {scope.label}
        </li>
      );
    });
    return ( <ul className="qs-scope-list"> {
          scopes
        } </ul>);
      },
      /**
       * Render the complete scope element.
       * @return {object} - The jsx element.
       */
      render: function renderScopeComponent() {
        var cssClass = `qs-icon qs-scope-deploy-${this.state.isDeployed ? "up": "down"}`;
        return ( <div className = {
            this.props.className + " qs-scope"
          }><commit_msg>[quick-search] Fix Scope style undefined.<commit_after>var builder = require('focus').component.builder;
var type = require('focus').component.types;
var React = require('react');

//var type = require('../../core/validation/types');
var find = require('lodash/collection/find');
var uuid = require('uuid');
var scopeMixin = {
  /**
   * Component tag name.
   * @type {String}
   */
  displayName: "Scope",
  /**
   * Component default properties.
   */
  getDefaultProps: function getScopeDefaultProperties() {
    return {
      list: [],
      value: undefined,
      isDeployed: false
    };
  },
  /**
   * Scope property validation.
   * @type {Object}
   */
   propTypes:{
      list: type('array'),
      isDeployed: type('bool'),
      value: type(['string', 'number'])
    },
  /**
   * Get the initial state from the data.
   */
  getInitialState: function getScopeInitialState() {
    return {
      isDeployed: this.props.isDeployed,
      value: this.props.value
    };
  },
  /**
   * Get the value of the scope.
   */
  getValue: function() {
    return this.state.value;
  },
  /**
   * Define the scope label.
   */
  scopeLabel: function scopeLabel() {
    return;
    if (!this.state.value) {
      return "Choose your scope";
    }
    return this.state.value;
  },
  /**
   * Internal function which handles the click on the scope line element and call the real handleOnclick if it is defined.
   * @param {object} event - Event trigger by the search.
   */
  _handleOnClick: function(event) {
    var val = event.target.hasAttribute("value") ? event.target.value :
      undefined;
    this.setState({
      value: val,
      isDeployed: false
    }, this.props.handleOnClick);
  },
  /**
   * Handle the click on the scope element.
   */
  handleDeployClick: function() {
    this.setState({
      isDeployed: !this.state.isDeployed
    });
  },
  /**
   * Get the current active scope.
   */
  getActiveScope: function getActiveScope() {
    return find(this.props.list, (scope) => {
      return scope.code === this.state.value;
    });
  },
  /**
   * Return the css class for the scope.
   */
  scopeStyle: function scopeStyle() {
    var activeScope = this.getActiveScope();
		if(!activeScope){
			return "qs-scope-none";
		}
    return activeScope.style || `qs-scope-${activeScope.value}`;
  },
  renderScopeList: function renderScopeList() {
    if (!this.state.isDeployed) {
      return;
    }
    var scopes = this.props.list.map((scope) => {
      var selectedValue = this.state.value === scope.code ? "active" : "";
      return ( <li key={scope.code || uuid.v4()}
        value={scope.code}
        className={`${selectedValue} ${scope.style}`}
        onClick = {this._handleOnClick}>
        {scope.label}
        </li>
      );
    });
    return ( <ul className="qs-scope-list"> {
          scopes
        } </ul>);
      },
      /**
       * Render the complete scope element.
       * @return {object} - The jsx element.
       */
      render: function renderScopeComponent() {
        var cssClass = `qs-icon qs-scope-deploy-${this.state.isDeployed ? "up": "down"}`;
        return ( <div className = {
            this.props.className + " qs-scope"
          }>
{'fraction_non_alphanumeric': 0.15026070469268446, 'fraction_numerical': 0.00031600568810238584, 'mean_word_length': 2.4123989218328843, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 17, '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': '4012232', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1955, 'n_words': 467}