<commit_before>var React = require('react');
var ReactPropTypes = React.PropTypes;
var SDMXDimensionActions = require('../actions/SDMXDimensionActions');
var SDMXDimensionStore = require('../stores/SDMXDimensionStore');
var QBerModal = require('./QBerModal.react');
var SDMXDimensionForm = require('./SDMXDimensionForm.react');
var CodesTable = require('./CodesTable.react');



/**
 * Retrieve the current visibility from the SDMXDimensionStore
 */
function getSDMXDimensionPanelState() {
  return {
    'dimensions': SDMXDimensionStore.getDimensions(),
    'variable': SDMXDimensionStore.getVariable(),
    'dimension': SDMXDimensionStore.getDimension(),
    'modal_visible': SDMXDimensionStore.getModalVisible(),
  };
}


var SDMXDimensionPanel = React.createClass({

  // This React class only works if a list of 'codes' and the name of the dataset is passed through its properties.
  propTypes: {
    values: ReactPropTypes.object.isRequired,
    datasetName: ReactPropTypes.string.isRequired
  },

  getInitialState: function() {
    return getSDMXDimensionPanelState();
  },

  componentDidMount: function() {
    SDMXDimensionStore.addChangeListener(this._onChange);
  },

  componentWillUnmount: function() {
    SDMXDimensionStore.removeChangeListener(this._onChange);
  },

  /**
   * @return {object}
   */
  render: function() {
    // This section should be visible by default
    // and shown when there is a dataset and variable.
    // if (Object.keys(this.props.dimensions).length < 1 || this.props.dimensions === undefined) {
    //   return null;
    // }


    return (
      <section id="sdmx_dimension_panel">
        <SDMXDimensionForm variable={this.state.variable}
                           dimension={this.state.dimension}
                           doUpdate={this._handleUpdate}
                           doSelectDimension={this._handleShowDimensions}
                           doBuildDimension={this._handleBuildDimension}/>
        <QBerModal  visible={this.state.modal_visible}
                    title="Select an external SDMX dimension definition"
                    options={this.state.dimensions}
                    doSelect={this._handleSelected}
                    doClose={this._handleHideDimensions} />
        <CodesTable values={this.props.values}
                    dimension={this.state.dimension}
                    doMapping={this._handleMapping} />
      </section>
    );
  },


  /**
   * Event handler for the button that generates a Dimension definition
   */
  _handleBuildDimension: function(){
    SDMXDimensionActions.buildDimension(this.props.values, this.props.datasetName);
  },

  /**
   * Event handler for the button that shows the Dimensions modal
   */
  _handleShowDimensions: function(){
    SDMXDimensionActions.showDimensions();
  },

  /**
   * Event handler for the button that hides the Dimensions modal
   */
  _handleHideDimensions: function(){
    SDMXDimensionActions.hideDimensions();
  },

  /**
   * Event handler for a selection in the Dimension modal
   */
  _handleSelected: function(value) {
    SDMXDimensionActions.chooseDimension(value);
  },

  _handleUpdate: function(dimension) {
    SDMXDimensionActions.updateDimension(dimension);
  },

  _handleMapping: function(value, code) {
    SDMXDimensionActions.addMapping(value, code);
  },

  /**
   * Event handler for 'change' events coming from the DatasetStore
   */
  _onChange: function() {
    console.log('Something changed for SDMXDimensionPanel');
    this.setState(getSDMXDimensionPanelState());
  }

});

module.exports = SDMXDimensionPanel;
<commit_msg>Typos fixed<commit_after>var React = require('react');
var ReactPropTypes = React.PropTypes;
var SDMXDimensionActions = require('../actions/SDMXDimensionActions');
var SDMXDimensionStore = require('../stores/SDMXDimensionStore');
var QBerModal = require('./QBerModal.react');
var SDMXDimensionForm = require('./SDMXDimensionForm.react');
var CodesTable = require('./CodesTable.react');



/**
 * Retrieve the current visibility from the SDMXDimensionStore
 */
function getSDMXDimensionPanelState() {
  return {
    'dimensions': SDMXDimensionStore.getDimensions(),
    'variable': SDMXDimensionStore.getVariable(),
    'dimension': SDMXDimensionStore.getDimension(),
    'modal_visible': SDMXDimensionStore.getModalVisible(),
  };
}


var SDMXDimensionPanel = React.createClass({

  // This React class only works if a list of 'codes' and the name of the dataset is passed through its properties.
  propTypes: {
    values: ReactPropTypes.object.isRequired,
    datasetName: ReactPropTypes.string.isRequired
  },

  getInitialState: function() {
    return getSDMXDimensionPanelState();
  },

  componentDidMount: function() {
    SDMXDimensionStore.addChangeListener(this._onChange);
  },

  componentWillUnmount: function() {
    SDMXDimensionStore.removeChangeListener(this._onChange);
  },

  /**
   * @return {object}
   */
  render: function() {
    // This section should be visible by default
    // and shown when there is a dataset and variable.
    // if (Object.keys(this.props.dimensions).length < 1 || this.props.dimensions === undefined) {
    //   return null;
    // }


    return (
      <section id="sdmx_dimension_panel">
        <SDMXDimensionForm variable={this.state.variable}
                           dimension={this.state.dimension}
                           doUpdate={this._handleUpdate}
                           doSelectDimension={this._handleShowDimensions}
                           doBuildDimension={this._handleBuildDimension}/>
        <QBerModal  visible={this.state.modal_visible}
                    title="Select an external SDMX dimension definition"
                    options={this.state.dimensions}
                    doSelect={this._handleSelected}
                    doClose={this._handleHideDimensions} />
        <CodesTable codes={this.props.values}
                    dimension={this.state.dimension}
                    doMapping={this._handleMapping} />
      </section>
    );
  },


  /**
   * Event handler for the button that generates a Dimension definition
   */
  _handleBuildDimension: function(){
    SDMXDimensionActions.buildDimension(this.props.values, this.props.datasetName);
  },

  /**
   * Event handler for the button that shows the Dimensions modal
   */
  _handleShowDimensions: function(){
    SDMXDimensionActions.showDimensions();
  },

  /**
   * Event handler for the button that hides the Dimensions modal
   */
  _handleHideDimensions: function(){
    SDMXDimensionActions.hideDimensions();
  },

  /**
   * Event handler for a selection in the Dimension modal
   */
  _handleSelected: function(value) {
    SDMXDimensionActions.chooseDimension(value);
  },

  _handleUpdate: function(dimension) {
    SDMXDimensionActions.updateDimension(dimension);
  },

  _handleMapping: function(value, code) {
    SDMXDimensionActions.addMapping(value, code);
  },

  /**
   * Event handler for 'change' events coming from the DatasetStore
   */
  _onChange: function() {
    console.log('Something changed for SDMXDimensionPanel');
    this.setState(getSDMXDimensionPanelState());
  }

});

module.exports = SDMXDimensionPanel;

{'fraction_non_alphanumeric': 0.10955484676189156, 'fraction_numerical': 0.0002773540424351685, 'mean_word_length': 3.149597238204833, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '4226750', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1970, 'n_words': 417}