<commit_before>import React from "react";
import { ShallowComponent } from "robe-react-commons";
import Col from "react-bootstrap/lib/Col";
import Pager from "react-bootstrap/lib/Pager";
import PageItem from "react-bootstrap/lib/PageItem";
import NotificationManager from "react-notifications/lib/NotificationManager";
import Button from "react-bootstrap/lib/Button";
import FaIcon from "../faicon/FaIcon";
import "./Wizard.css";


export default class Wizard extends ShallowComponent {
     /**
     * PropTypes of the component.
     *
     * @static
     */
    static propTypes = {
        /**
         * Current page index to render.
         */
        currentStep: React.PropTypes.number,
        /**
         * Text for the next button.
         */
        nextButtonText: React.PropTypes.string,
        /**
         * Text for the previous button.
         */
        preButtonText: React.PropTypes.string,
        /**
         * Text for the complete button.
         */
        completeButtonText: React.PropTypes.string
    };

    static defaultProps = {
        currentStep: 0,
        nextButtonText: "Next",
        preButtonText: "Previous",
        completeButtonText: "Finish"
    };
    __stepValidInfo = [];
    __content = undefined;


    constructor(props: Object) {
        super(props);
        this.state = {
            currentStep: this.props.currentStep,
            valid: true
        };
    }

    render(): Object {
        return (
            <div>
                <Col className="wizard">
                    <Col className="wizard-row setup-panel">
                        {this.__renderSteps()}
                    </Col>
                </Col>
                {this.__renderContent()}
                {this.__renderPager()}
            </div>
        );
    }

    __renderSteps = (): Array => {
        let steps = [];
        for (let i = 0; i < this.props.steps.length; i++) {
            let item = this.props.steps[i];
            let styleClass = (this.state.currentStep === i) ? "btn-primary" : "btn-default";
            let step = (
                <Col key={i} className="wizard-step">
                    <a
                        onClick={() => { this.__onClickStepButton(i); }}
                        className={`btn btn-circle ${styleClass}`}>
                        {i + 1}
                    </a>
                    <p>{item.title}</p>
                </Col>);
            steps.push(step);
        }
        return steps;
    };

    __onClickStepButton = (index: number) => {
        if (this.state.currentStep === index) {
            return;
        }
        this.__stepValidInfo[this.state.currentStep] = this.isValid();

        let state = {};
        if (this.state.currentStep < index) {
            if (this.__areStepsValid(this.state.currentStep, index)) {
                state.currentStep = index;
                this.setState(state);
            }
        } else if (this.state.currentStep > index) {
            state.currentStep = index;
            this.setState(state);
        }
    };
    __areStepsValid = (start: number, end: number): boolean => {
        for (start; start < end; start++) {
            if (!this.__stepValidInfo[start]) {
                return false;
            }
        }
        return true;
    };

    __renderContent = (): Object => {
        this.__content = this.props.steps[this.state.currentStep].component;
        return this.__content;
    };

    __handleNextButtonClick = () => {
        this.__onClickStepButton(this.state.currentStep + 1);
    };

    __handlePreviousButtonClick = () => {
        this.__onClickStepButton(this.state.currentStep - 1);
    };

    __renderPager = (): Object => {
        let nextButton = undefined;
        if (this.state.currentStep === this.props.steps.length - 1) {
            nextButton = (
                <Col className="pull-right">
                    <Button
                        bsStyle="primary"
                        onClick={this.props.onCompleteClick}
                    >
                    <FaIcon
                        code="fa-check-circle"
                    />
                    {this.props.completeButtonText}
                    </Button>
                </Col>
            );
        } else {
            nextButton = (
                <PageItem
                    next
                    disabled={!this.state.valid}
                    onClick={this.__handleNextButtonClick}
                >
                    {this.props.nextButtonText} &rarr;
                </PageItem>
            );
        }
        return (
            <Pager>
                <PageItem
                    previous
                    disabled={this.state.currentStep === 0}
                    onClick={this.state.currentStep === 0 ? null : this.__handlePreviousButtonClick}
                >
                    &larr;{this.props.preButtonText}
                </PageItem>
                {nextButton}
            </Pager>
        );
    };
    
    isValid = (): boolean => {
        if (this.__content === undefined) {
            return false;
        }
        let result = this.__content._owner._instance.refs.step.isValid();
        if (!result) {
            NotificationManager.error(result.message);
            return false;
        }
        return true;
    };
}<commit_msg>- removed Arrow functions from wizard.<commit_after>import React from "react";
import { ShallowComponent } from "robe-react-commons";
import Col from "react-bootstrap/lib/Col";
import Pager from "react-bootstrap/lib/Pager";
import PageItem from "react-bootstrap/lib/PageItem";
import NotificationManager from "react-notifications/lib/NotificationManager";
import Button from "react-bootstrap/lib/Button";
import FaIcon from "../faicon/FaIcon";
import "./Wizard.css";


export default class Wizard extends ShallowComponent {
     /**
     * PropTypes of the component.
     *
     * @static
     */
    static propTypes = {
        /**
         * Current page index to render.
         */
        currentStep: React.PropTypes.number,
        /**
         * Text for the next button.
         */
        nextButtonText: React.PropTypes.string,
        /**
         * Text for the previous button.
         */
        preButtonText: React.PropTypes.string,
        /**
         * Text for the complete button.
         */
        completeButtonText: React.PropTypes.string
    };

    static defaultProps = {
        currentStep: 0,
        nextButtonText: "Next",
        preButtonText: "Previous",
        completeButtonText: "Finish"
    };
    __stepValidInfo = [];
    __content = undefined;


    constructor(props: Object) {
        super(props);
        this.state = {
            currentStep: this.props.currentStep,
            valid: true
        };
        this.__renderSteps = this.__renderSteps.bind(this);
        this.__onClickStepButton = this.__onClickStepButton.bind(this);
        this.__areStepsValid = this.__areStepsValid.bind(this);
        this.__renderContent = this.__renderContent.bind(this);
        this.__handleNextButtonClick = this.__handleNextButtonClick.bind(this);
        this.__handlePreviousButtonClick = this.__handlePreviousButtonClick.bind(this);
        this.__renderPager = this.__renderPager.bind(this);
    }

    render(): Object {
        return (
            <div>
                <Col className="wizard">
                    <Col className="wizard-row setup-panel">
                        {this.__renderSteps()}
                    </Col>
                </Col>
                {this.__renderContent()}
                {this.__renderPager()}
            </div>
        );
    }

    __renderSteps(): Array {
        let steps = [];
        for (let i = 0; i < this.props.steps.length; i++) {
            let item = this.props.steps[i];
            let styleClass = (this.state.currentStep === i) ? "btn-primary" : "btn-default";
            let step = (
                <Col key={i} className="wizard-step">
                    <a
                        onClick={() => { this.__onClickStepButton(i); }}
                        className={`btn btn-circle ${styleClass}`}>
                        {i + 1}
                    </a>
                    <p>{item.title}</p>
                </Col>);
            steps.push(step);
        }
        return steps;
    }

    __onClickStepButton(index: number) {
        if (this.state.currentStep === index) {
            return;
        }
        this.__stepValidInfo[this.state.currentStep] = this.isValid();

        let state = {};
        if (this.state.currentStep < index) {
            if (this.__areStepsValid(this.state.currentStep, index)) {
                state.currentStep = index;
                this.setState(state);
            }
        } else if (this.state.currentStep > index) {
            state.currentStep = index;
            this.setState(state);
        }
    }

    __areStepsValid(start: number, end: number): boolean {
        for (start; start < end; start++) {
            if (!this.__stepValidInfo[start]) {
                return false;
            }
        }
        return true;
    }

    __renderContent(): Object {
        this.__content = this.props.steps[this.state.currentStep].component;
        return this.__content;
    }

    __handleNextButtonClick () {
        this.__onClickStepButton(this.state.currentStep + 1);
    }

    __handlePreviousButtonClick () {
        this.__onClickStepButton(this.state.currentStep - 1);
    }

    __renderPager(): Object {
        let nextButton = undefined;
        if (this.state.currentStep === this.props.steps.length - 1) {
            nextButton = (
                <Col className="pull-right">
                    <Button
                        bsStyle="primary"
                        onClick={this.props.onCompleteClick}
                    >
                    <FaIcon
                        code="fa-check-circle"
                    />
                    {this.props.completeButtonText}
                    </Button>
                </Col>
            );
        } else {
            nextButton = (
                <PageItem
                    next
                    disabled={!this.state.valid}
                    onClick={this.__handleNextButtonClick}
                >
                    {this.props.nextButtonText} <FaIcon code="fa-arrow-right" size={"10px"} />
                </PageItem>
            );
        }
        return (
            <Pager>
                <PageItem
                    previous
                    disabled={this.state.currentStep === 0}
                    onClick={this.state.currentStep === 0 ? null : this.__handlePreviousButtonClick}
                >
                    <FaIcon code="fa-arrow-left" size={"10px"} />{this.props.preButtonText}
                </PageItem>
                {nextButton}
            </Pager>
        );
    }

    isValid(): boolean {
        if (this.__content === undefined) {
            return false;
        }
        let result = this.__content._owner._instance.refs.step.isValid();
        if (!result) {
            NotificationManager.error(result.message);
            return false;
        }
        return true;
    };
}
{'fraction_non_alphanumeric': 0.11598579040852576, 'fraction_numerical': 0.0017761989342806395, 'mean_word_length': 1.4222413422241342, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 63, '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': '7422744', 'n_tokens_mistral': 3000, 'n_tokens_neox': 2873, 'n_words': 554}