<commit_before>import React, {Component, PropTypes } from "react";
import { connect } from "react-redux";
import "./style.less";
import "react-widgets/lib/less/react-widgets.less";
import DropDown from "dnn-dropdown";
import "./style.less";
import resx from "../../../resources";
import IconButton from "../../common/IconButton";
import SearchBox from "dnn-search-box";
import GridCell from "dnn-grid-cell";
import RoleGroupEditor from "../RoleEditor/RoleGroupEditor";
import util from "../../../utils";
import {
    roles as RolesActions
} from "../../../actions";

class FiltersBar extends Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedGroup: {
                label: resx.get("GlobalRolesGroup"),
                value: -1
            },
            showPopup: false
        };
    }
    componentWillMount() {
    }
    componentDidMount() {
    }
    componentWillUnmount() {
    }
    componentWillReceiveProps() {
    }
    onDeleteGroup() {
        const {props} = this;
        this.closeDropDown();
        util.utilities.confirm(resx.get("DeleteRoleGroup.Confirm"), resx.get("Delete"), resx.get("Cancel"), () => {
            props.dispatch(RolesActions.deleteRoleGroup(this.getCurrentGroup(), () => {
                util.utilities.notify(resx.get("DeleteRoleGroup.Message"));
                let {selectedGroup} = this.state;
                selectedGroup.value = -1;
                selectedGroup.label = resx.get("GlobalRolesGroup");
                this.setState({
                    selectedGroup
                });
                this.props.onRoleGroupChanged(selectedGroup);
            }));
        }, () => {
        });
    }

    onSave(group) {
        this.updateSelectedGroup({ label: group.name, value: group.id });
        let {showPopup} = this.state;
        showPopup = !showPopup;
        this.setState({
            showPopup
        });
    }
    closeDropDown() {
        /*This is done in order to keep the dropdown closed on click on edit/delete*/
        let {state} = this.refs["groupsDropdown"];
        state.dropDownOpen = true;
        this.refs["groupsDropdown"].setState({
            state
        });
    }
    onSelect(option) {
        this.updateSelectedGroup(option);
        this.props.onRoleGroupChanged(option);
    }
    toggleEditGroup() {
        this.closeDropDown();
        let {showPopup} = this.state;
        showPopup = !showPopup;
        this.setState({
            showPopup
        });
    }
    updateSelectedGroup(option) {
        let { label} = option;
        let { value} = option;
        let {selectedGroup} = this.state;
        selectedGroup.label = label;
        selectedGroup.value = value;
        this.setState({
            selectedGroup
        });
    }<commit_msg>PAE-30: Fixed edit role group issue<commit_after>import React, {Component, PropTypes } from "react";
import { connect } from "react-redux";
import "./style.less";
import "react-widgets/lib/less/react-widgets.less";
import DropDown from "dnn-dropdown";
import "./style.less";
import resx from "../../../resources";
import IconButton from "../../common/IconButton";
import SearchBox from "dnn-search-box";
import GridCell from "dnn-grid-cell";
import RoleGroupEditor from "../RoleEditor/RoleGroupEditor";
import util from "../../../utils";
import {
    roles as RolesActions
} from "../../../actions";

class FiltersBar extends Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedGroup: {
                label: resx.get("GlobalRolesGroup"),
                value: -1
            },
            showPopup: false
        };
    }
    componentWillMount() {
    }
    componentDidMount() {
    }
    componentWillUnmount() {
    }
    componentWillReceiveProps() {
    }
    onDeleteGroup() {
        const {props} = this;
        this.closeDropDown();
        util.utilities.confirm(resx.get("DeleteRoleGroup.Confirm"), resx.get("Delete"), resx.get("Cancel"), () => {
            props.dispatch(RolesActions.deleteRoleGroup(this.getCurrentGroup(), () => {
                util.utilities.notify(resx.get("DeleteRoleGroup.Message"));
                let {selectedGroup} = this.state;
                selectedGroup.value = -1;
                selectedGroup.label = resx.get("GlobalRolesGroup");
                this.setState({
                    selectedGroup
                });
                this.props.onRoleGroupChanged(selectedGroup);
            }));
        }, () => {
        });
    }

    onSave(group) {
        this.updateSelectedGroup({ label: group.name, value: group.id });
        let {showPopup} = this.state;
        showPopup = !showPopup;
        this.setState({
            showPopup
        });
    }
    closeDropDown() {
        /*This is done in order to keep the dropdown closed on click on edit/delete*/
        let {state} = this.refs["groupsDropdown"];
        state.dropDownOpen = false;
        this.refs["groupsDropdown"].setState({
            state
        });
    }
    onSelect(option) {
        this.updateSelectedGroup(option);
        this.props.onRoleGroupChanged(option);
    }
    toggleEditGroup() {
        let {showPopup} = this.state;
        showPopup = !showPopup;
        this.setState({
            showPopup
        }, () => {
            this.closeDropDown();
        });
    }
    updateSelectedGroup(option) {
        let { label} = option;
        let { value} = option;
        let {selectedGroup} = this.state;
        selectedGroup.label = label;
        selectedGroup.value = value;
        this.setState({
            selectedGroup
        });
    }
{'fraction_non_alphanumeric': 0.13536886692552064, 'fraction_numerical': 0.0010589481115425344, 'mean_word_length': 1.968569931901519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1570649', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1562, 'n_words': 307}