<commit_before>import * as React from "react";
import {InputGroup, Tag, Classes, Tooltip, Position} from "@blueprintjs/core";
import {ProcessConfigurations, ConfigurationItem} from "../state";

interface IConfigProps {
    configName: string;
    configuration: ConfigurationItem;
    onBlur: (event: any) => void;
}

export class ConfigurationSingleEntry extends React.Component<IConfigProps,any> {
    constructor(props: IConfigProps) {
        super(props);
        this.state = {
            localValue: this.props.configuration.value ? this.props.configuration.value.toString() : ""
        };
    }

    componentWillReceiveProps(nextProps: IConfigProps) {
        const value = nextProps.configuration.value ? nextProps.configuration.value.toString() : "";
        this.setState({
            localValue: value
        })
    }

    public render() {
        const unitTag = (
            <Tag className={Classes.MINIMAL}>{this.props.configuration.units}</Tag>
        );

        const handleOnChange = (event: any) => {
            const value = event.currentTarget.value;
            this.setState({
                localValue: value
            });
        };

        return (
            <tr>
                <td>
                    <Tooltip content={this.props.configuration.description} position={Position.LEFT}>
                        <label className="pt-label pt-inline">
                            {this.props.configName}
                        </label>
                    </Tooltip>
                </td>
                <td>
                    <InputGroup className="config-textbox"
                                name={this.props.configName}
                                value={this.state.localValue}
                        {...this.props.configuration.units ? {rightElement: unitTag} : {}}
                                onChange={handleOnChange}
                                onBlur={this.props.onBlur}
                    />
                </td>
            </tr>
        )
    }
}

export class ConfigurationFlagSingleEntry extends React.Component<IConfigProps, any> {

    constructor(props: IConfigProps) {
        super(props);
        this.state = {
            checked: !!this.props.configuration.value
        }
    }

    componentWillReceiveProps(nextProps) {
        this.setState({
            checked: !!nextProps.configuration.value
        })
    }

    public render() {
        const handleFlagChange = () => {
            this.setState({
                checked: !this.state.checked
            })
        };

        return (
            <Tooltip content={this.props.configuration.description} position={Position.LEFT}>
                <label className="pt-control pt-checkbox">
                    <input type="checkbox"
                           name={this.props.configName}
                           checked={this.state.checked}
                           onChange={handleFlagChange}
                           onBlur={this.props.onBlur}
                    />
                    <span className="pt-control-indicator"/>
                    {this.props.configName}
                </label>
            </Tooltip>
        )
    }
}

interface IConfigEditorProps {
    configurations: ProcessConfigurations;
    handleInputChange: (event: React.FormEvent<HTMLSelectElement>) => void;
}

export class ConfigurationEditor extends React.Component<IConfigEditorProps, any> {
    public render() {
        let configurationElements = [];
        const configurations = this.props.configurations;
        for (let i in configurations) {<commit_msg>do not display __metainf__ in configuration editor<commit_after>import * as React from "react";
import {InputGroup, Tag, Classes, Tooltip, Position} from "@blueprintjs/core";
import {ProcessConfigurations, ConfigurationItem} from "../state";

interface IConfigProps {
    configName: string;
    configuration: ConfigurationItem;
    onBlur: (event: any) => void;
}

export class ConfigurationSingleEntry extends React.Component<IConfigProps,any> {
    constructor(props: IConfigProps) {
        super(props);
        this.state = {
            localValue: this.props.configuration.value ? this.props.configuration.value.toString() : ""
        };
    }

    componentWillReceiveProps(nextProps: IConfigProps) {
        const value = nextProps.configuration.value ? nextProps.configuration.value.toString() : "";
        this.setState({
            localValue: value
        })
    }

    public render() {
        const unitTag = (
            <Tag className={Classes.MINIMAL}>{this.props.configuration.units}</Tag>
        );

        const handleOnChange = (event: any) => {
            const value = event.currentTarget.value;
            this.setState({
                localValue: value
            });
        };

        return (
            <tr>
                <td>
                    <Tooltip content={this.props.configuration.description} position={Position.LEFT}>
                        <label className="pt-label pt-inline">
                            {this.props.configName}
                        </label>
                    </Tooltip>
                </td>
                <td>
                    <InputGroup className="config-textbox"
                                name={this.props.configName}
                                value={this.state.localValue}
                        {...this.props.configuration.units ? {rightElement: unitTag} : {}}
                                onChange={handleOnChange}
                                onBlur={this.props.onBlur}
                    />
                </td>
            </tr>
        )
    }
}

export class ConfigurationFlagSingleEntry extends React.Component<IConfigProps, any> {

    constructor(props: IConfigProps) {
        super(props);
        this.state = {
            checked: !!this.props.configuration.value
        }
    }

    componentWillReceiveProps(nextProps) {
        this.setState({
            checked: !!nextProps.configuration.value
        })
    }

    public render() {
        const handleFlagChange = () => {
            this.setState({
                checked: !this.state.checked
            })
        };

        return (
            <Tooltip content={this.props.configuration.description} position={Position.LEFT}>
                <label className="pt-control pt-checkbox">
                    <input type="checkbox"
                           name={this.props.configName}
                           checked={this.state.checked}
                           onChange={handleFlagChange}
                           onBlur={this.props.onBlur}
                    />
                    <span className="pt-control-indicator"/>
                    {this.props.configName}
                </label>
            </Tooltip>
        )
    }
}

interface IConfigEditorProps {
    configurations: ProcessConfigurations;
    handleInputChange: (event: React.FormEvent<HTMLSelectElement>) => void;
}

export class ConfigurationEditor extends React.Component<IConfigEditorProps, any> {
    public render() {
        let configurationElements = [];
        const configurations = this.props.configurations;
        for (let i in configurations) {
            if (i == "__metainf__") {
                continue;
            }
{'fraction_non_alphanumeric': 0.10501160726478219, 'fraction_numerical': 0.0, 'mean_word_length': 1.5990063875088716, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 57, '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': '5655620', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1747, 'n_words': 324}