<commit_before>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Drawer from '@material-ui/core/Drawer';
import PermissionFilter from './PermissionsFilter';
import StatusFilter from './StatusFilter';
import DateFilter from './DateFilter';
import FilterHeader from './FilterHeader';
import CustomScrollbar from '../CustomScrollbar';
import ProvidersFilter from './ProvidersFilter';

export class FilterDrawer extends Component {
    constructor(props) {
        super(props);
        this.getDefaultState = this.getDefaultState.bind(this);
        this.handleFilterApply = this.handleFilterApply.bind(this);
        this.handleFilterClear = this.handleFilterClear.bind(this);
        this.handlePermissionsChange = this.handlePermissionsChange.bind(this);
        this.handleProvidersChange = this.handleProvidersChange.bind(this);
        this.handleStatusChange = this.handleStatusChange.bind(this);
        this.handleMinDate = this.handleMinDate.bind(this);
        this.handleMaxDate = this.handleMaxDate.bind(this);
        this.state = this.getDefaultState();
    }

    getDefaultState() {
        return {
            permissions: {
                value: '',
                groups: {},
                members: {},
            },
            minDate: null,
            maxDate: null,
            status: {
                completed: false,
                incomplete: false,
                submitted: false,
            },
            providers: {},
        };
    }

    handleFilterApply() {
        this.props.onFilterApply(this.state);
    }

    handleFilterClear() {
        this.setState(this.getDefaultState());
        this.props.onFilterClear();
    }

    handlePermissionsChange(permissions) {
        this.setState({ permissions: { ...this.state.permissions, ...permissions } });
    }

    handleStatusChange(stateChange) {
        let { status } = this.state;
        status = Object.assign(status, stateChange);
        this.setState({ status });
    }

    handleProvidersChange(slug, isSelected) {
        const { providers } = this.state;
        if (isSelected) {
            providers[slug] = true;
        } else {
            delete providers[slug];
        }

        this.setState({ providers });
    }

    handleMinDate(e) {
        this.setState({ minDate: e.target.value });
    }

    handleMaxDate(e) {
        this.setState({ maxDate: e.target.value });
    }

    render() {
        const styles = {
            containerStyle: {
                backgroundColor: '#fff',
                top: '221px',
                height: window.innerHeight - 221,
                overflowY: 'hidden',
                overflowX: 'hidden',
                width: '250px',
            },
        };

        return (
            <Drawer
                className="qa-FilterDrawer-Drawer"
                variant="persistent"
                anchor="right"
                open={this.props.open}
                PaperProps={{ style: styles.containerStyle }}
            >
                <CustomScrollbar>
                    <FilterHeader
                        onApply={this.handleFilterApply}
                        onClear={this.handleFilterClear}
                    />
                    <PermissionFilter
                        onChange={this.handlePermissionsChange}
                        permissions={this.state.permissions}
                        groups={this.props.groups}<commit_msg>fix drawer hidding bug<commit_after>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Drawer from '@material-ui/core/Drawer';
import PermissionFilter from './PermissionsFilter';
import StatusFilter from './StatusFilter';
import DateFilter from './DateFilter';
import FilterHeader from './FilterHeader';
import CustomScrollbar from '../CustomScrollbar';
import ProvidersFilter from './ProvidersFilter';

export class FilterDrawer extends Component {
    constructor(props) {
        super(props);
        this.getDefaultState = this.getDefaultState.bind(this);
        this.handleFilterApply = this.handleFilterApply.bind(this);
        this.handleFilterClear = this.handleFilterClear.bind(this);
        this.handlePermissionsChange = this.handlePermissionsChange.bind(this);
        this.handleProvidersChange = this.handleProvidersChange.bind(this);
        this.handleStatusChange = this.handleStatusChange.bind(this);
        this.handleMinDate = this.handleMinDate.bind(this);
        this.handleMaxDate = this.handleMaxDate.bind(this);
        this.state = this.getDefaultState();
    }

    getDefaultState() {
        return {
            permissions: {
                value: '',
                groups: {},
                members: {},
            },
            minDate: null,
            maxDate: null,
            status: {
                completed: false,
                incomplete: false,
                submitted: false,
            },
            providers: {},
        };
    }

    handleFilterApply() {
        this.props.onFilterApply(this.state);
    }

    handleFilterClear() {
        this.setState(this.getDefaultState());
        this.props.onFilterClear();
    }

    handlePermissionsChange(permissions) {
        this.setState({ permissions: { ...this.state.permissions, ...permissions } });
    }

    handleStatusChange(stateChange) {
        let { status } = this.state;
        status = Object.assign(status, stateChange);
        this.setState({ status });
    }

    handleProvidersChange(slug, isSelected) {
        const { providers } = this.state;
        if (isSelected) {
            providers[slug] = true;
        } else {
            delete providers[slug];
        }

        this.setState({ providers });
    }

    handleMinDate(e) {
        this.setState({ minDate: e.target.value });
    }

    handleMaxDate(e) {
        this.setState({ maxDate: e.target.value });
    }

    render() {
        const styles = {
            containerStyle: {
                backgroundColor: '#fff',
                top: '221px',
                height: window.innerHeight - 221,
                overflowY: 'hidden',
                overflowX: 'hidden',
                width: '250px',
            },
        };

        return (
            <Drawer
                className="qa-FilterDrawer-Drawer"
                variant="persistent"
                anchor="right"
                open={this.props.open}
                PaperProps={{ style: styles.containerStyle }}
                SlideProps={{
                    unmountOnExit: true,
                }}
            >
                <CustomScrollbar>
                    <FilterHeader
                        onApply={this.handleFilterApply}
                        onClear={this.handleFilterClear}
                    />
                    <PermissionFilter
                        onChange={this.handlePermissionsChange}
                        permissions={this.state.permissions}
                        groups={this.props.groups}
{'fraction_non_alphanumeric': 0.10801195389213035, 'fraction_numerical': 0.00256154831364736, 'mean_word_length': 1.7388932190179267, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '3437708', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1734, 'n_words': 315}