<commit_before>var Network = React.createClass({

    mixins: [Reflux.connect(dhcpOptionsStore, 'options')],

    componentDidMount() {
        DhcpOptionActions.list();
    },

    save() {
        var errors = [];

        var net = this.refs.network;
        var dhcp = this.refs.dhcp_options;
        var dhcp6 = this.refs.dhcp_options6;
        var pools = this.refs.pools;

        errors = errors.concat(net.validate());
        errors = errors.concat(dhcp.validate());
        errors = errors.concat(dhcp6.validate());
        errors = errors.concat(pools.validate());

        if (errors.length > 0) {
            FeedbackActions.set('error', 'Form contains invalid data', errors);
        } else {
            var data = net.getValues();
            data['dhcp_options'] = dhcp.getValues().concat(dhcp6.getValues());
            data['pools'] = pools.getValues();
            this.props.save_handler(data);
        }
    },

    getInitialState() {
        return {'network': {
                    'dhcp_options': [],
                    'pools': []},
                'options': []}
    },

    componentWillReceiveProps(p) {
        if (p) {
            this.setState({'network': p.network_data});
        }
    },

    render() {

        var options4 = _.pick(this.state.options, function(val) {
            return val.family == 'inet';
        });
        var options6 = _.pick(this.state.options, function(val) {
              return val.family == 'inet6';
        });

        var values4 = _.filter(this.state.network.dhcp_options, val => {
            return _.has(this.state.options, val.option) &&
                   this.state.options[val.option].family == 'inet';
        });
        var values6 = _.filter(this.state.network.dhcp_options, val => {
             return _.has(this.state.options, val.option) &&
                    this.state.options[val.option].family == 'inet6';
        });

        return (
        <div>
            <AdminNavbar />
            <div className="col-xs-12 container">
                <h1>{this.props.title}</h1>
                <Feedback />
                <div className="row">
                    <div className="col-xs-12 col-md-4">
                        <NetworkForm ref="network"
                                     values={this.state.network}
                                     saveHandler={this.save}/>
                    </div>

                    <div className="col-xs-12 col-md-4">
                        <IPPools ref="pools"
                                 values={this.state.network.pools}
                                 network={this.state.network.uuid} />
                    </div>

                    <div className="col-xs-12 col-md-4">
                        <DhcpOptionValues ref="dhcp_options"
                                          values={values4}
                                          options={options4}
                                          title="DHCP options"/>

                        <DhcpOptionValues ref="dhcp_options6"
                                          values={values6}
                                          options={options6}
                                          title="DHCP options v6"/>

                    </div>
                </div>
            </div>
        </div>
    )
  }
});
<commit_msg>refactored sorting options/values of dhcp in networks<commit_after>var Network = React.createClass({

    mixins: [Reflux.connect(dhcpOptionsStore, 'options')],

    componentDidMount() {
        DhcpOptionActions.list();
    },

    save() {
        var errors = [];

        var net = this.refs.network;
        var dhcp = this.refs.dhcp_options;
        var dhcp6 = this.refs.dhcp_options6;
        var pools = this.refs.pools;

        errors = errors.concat(net.validate());
        errors = errors.concat(dhcp.validate());
        errors = errors.concat(dhcp6.validate());
        errors = errors.concat(pools.validate());

        if (errors.length > 0) {
            FeedbackActions.set('error', 'Form contains invalid data', errors);
        } else {
            var data = net.getValues();
            data['dhcp_options'] = dhcp.getValues().concat(dhcp6.getValues());
            data['pools'] = pools.getValues();
            this.props.save_handler(data);
        }
    },

    getInitialState() {
        return {'network': {
                    'dhcp_options': [],
                    'pools': []},
                'options': []}
    },

    componentWillReceiveProps(p) {
        if (p) {
            this.setState({'network': p.network_data});
        }
    },

    render() {
        var values = sortDhcpValues(this.state.network.dhcp_options,
                                     this.state.options);
        var options = sortDhcpOptions(this.state.options);

        return (
        <div>
            <AdminNavbar />
            <div className="col-xs-12 container">
                <h1>{this.props.title}</h1>
                <Feedback />
                <div className="row">
                    <div className="col-xs-12 col-md-4">
                        <NetworkForm ref="network"
                                     values={this.state.network}
                                     saveHandler={this.save}/>
                    </div>

                    <div className="col-xs-12 col-md-4">
                        <IPPools ref="pools"
                                 values={this.state.network.pools}
                                 network={this.state.network.uuid} />
                    </div>

                    <div className="col-xs-12 col-md-4">
                        <DhcpOptionValues ref="dhcp_options"
                                          values={values.inet}
                                          options={options.inet}
                                          title="DHCP options"/>

                        <DhcpOptionValues ref="dhcp_options6"
                                          values={values.inet6}
                                          options={options.inet6}
                                          title="DHCP options v6"/>

                    </div>
                </div>
            </div>
        </div>
    )
  }
});

{'fraction_non_alphanumeric': 0.12528071863971768, 'fraction_numerical': 0.008341353865896696, 'mean_word_length': 1.1884871884871886, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2485696', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1549, 'n_words': 259}