<commit_before>import React, {Component, PropTypes} from "react";
import Localization from "localization";
import Module from "./Module";
import Checkbox from "dnn-checkbox";
import "./PageLanguage.less";

import { EyeIcon, ModuleIcon, LinkIcon } from "dnn-svg-icons";

class PageLanguage extends Component {

    constructor() {
        super();
        this.state = {
            allModulesLinked: false,
            allModulesSelected: false
        };
    }

    updateAllModules(key, value) {
        const {modules} = this.props;
        const CultureCode = this.props.local.CultureCode;
        modules.forEach((module, index) => {
            this.props.onUpdateModules(CultureCode, index, value, key);
        });
    }

    selectAllModules(e) {
        const allModulesSelected = e;
        this.setState({ allModulesSelected }, ()=> {
            this.updateAllModules("IsTranslated", e);
        });
    }

    linkAllModules() {
        const allModulesLinked = !this.state.allModulesLinked;
        this.setState({ allModulesLinked }, () => {
            this.updateAllModules("IsLocalized", allModulesLinked);
        });
    } 

    onUpdatePages(key, e) {
        const value = e.target ? e.target.value: e;
        const CultureCode = this.props.local.CultureCode;
        this.props.onUpdatePages(CultureCode, key, value);
    }

    /* eslint-disable react/no-danger */
    render() {
        const iconSrc = this.props.local && this.props.local.Icon ? this.props.local.Icon : "";
        const cultureCode = this.props.local && this.props.local.CultureCode ? this.props.local.CultureCode : "";
        const page = this.props.page || {};
        const modules = this.props.modules || [];
        const moduleComponents = modules.map((module, index) => {
            return <Module
                isDefault={this.props.isDefault}
                module={module}
                onUpdateModules={this.props.onUpdateModules}
                onDeleteModule={this.props.onDeleteModule}
                onRestoreModule={this.props.onRestoreModule}
                index={index}
                cultureCode={cultureCode}
                />;
        });
        return (
            <div className="page-language">
                <div className="page-language-row">
                    <img src={iconSrc} alt={cultureCode} />
                    <span>{cultureCode}</span>
                    <a className="icon" href={page.PageUrl} dangerouslySetInnerHTML={{ __html: EyeIcon }} aria-label="View"></a>
                </div>
                <div className="page-language-row">
                    <input type="text" value={page.TabName} onChange={this.onUpdatePages.bind(this, "TabName") } aria-label="Name" />
                    <input type="text" value={page.Title} onChange={this.onUpdatePages.bind(this, "Title") } aria-label="Title" />
                    <textarea value={page.Description} onChange={this.onUpdatePages.bind(this, "Description") } aria-label="Description"/>
                </div>
                <div className="page-language-row">
                    <div className="page-language-row-header">
                        <span className="icon" dangerouslySetInnerHTML={{ __html: ModuleIcon }} />
                        <span>{Localization.get("ModulesOnThisPage") }</span><commit_msg>DNN-10145: open the page in parent window.<commit_after>import React, {Component, PropTypes} from "react";
import Localization from "localization";
import Module from "./Module";
import Checkbox from "dnn-checkbox";
import "./PageLanguage.less";
import utils from "../../utils";

import { EyeIcon, ModuleIcon, LinkIcon } from "dnn-svg-icons";

class PageLanguage extends Component {

    constructor() {
        super();
        this.state = {
            allModulesLinked: false,
            allModulesSelected: false
        };
    }

    updateAllModules(key, value) {
        const {modules} = this.props;
        const CultureCode = this.props.local.CultureCode;
        modules.forEach((module, index) => {
            this.props.onUpdateModules(CultureCode, index, value, key);
        });
    }

    selectAllModules(e) {
        const allModulesSelected = e;
        this.setState({ allModulesSelected }, ()=> {
            this.updateAllModules("IsTranslated", e);
        });
    }

    linkAllModules() {
        const allModulesLinked = !this.state.allModulesLinked;
        this.setState({ allModulesLinked }, () => {
            this.updateAllModules("IsLocalized", allModulesLinked);
        });
    } 

    onUpdatePages(key, e) {
        const value = e.target ? e.target.value: e;
        const CultureCode = this.props.local.CultureCode;
        this.props.onUpdatePages(CultureCode, key, value);
    }

    onViewPage(url, e){
        utils.getUtilities().closePersonaBar(function () {
            window.parent.location = url;
        });

        e.preventDefault();
        e.stopPropagation();
    }

    /* eslint-disable react/no-danger */
    render() {
        const iconSrc = this.props.local && this.props.local.Icon ? this.props.local.Icon : "";
        const cultureCode = this.props.local && this.props.local.CultureCode ? this.props.local.CultureCode : "";
        const page = this.props.page || {};
        const modules = this.props.modules || [];
        const moduleComponents = modules.map((module, index) => {
            return <Module
                isDefault={this.props.isDefault}
                module={module}
                onUpdateModules={this.props.onUpdateModules}
                onDeleteModule={this.props.onDeleteModule}
                onRestoreModule={this.props.onRestoreModule}
                index={index}
                cultureCode={cultureCode}
                />;
        });
        return (
            <div className="page-language">
                <div className="page-language-row">
                    <img src={iconSrc} alt={cultureCode} />
                    <span>{cultureCode}</span>
                    <a className="icon" href={page.PageUrl} onClick={this.onViewPage.bind(this, page.PageUrl)} dangerouslySetInnerHTML={{ __html: EyeIcon }} aria-label="View"></a>
                </div>
                <div className="page-language-row">
                    <input type="text" value={page.TabName} onChange={this.onUpdatePages.bind(this, "TabName") } aria-label="Name" />
                    <input type="text" value={page.Title} onChange={this.onUpdatePages.bind(this, "Title") } aria-label="Title" />
                    <textarea value={page.Description} onChange={this.onUpdatePages.bind(this, "Description") } aria-label="Description"/>
                </div>
                <div className="page-language-row">
                    <div className="page-language-row-header">
                        <span className="icon" dangerouslySetInnerHTML={{ __html: ModuleIcon }} />
                        <span>{Localization.get("ModulesOnThisPage") }</span>
{'fraction_non_alphanumeric': 0.1340324665996265, 'fraction_numerical': 0.0007182876023559833, 'mean_word_length': 2.1731996353691887, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 49, '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': '4632791', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1858, 'n_words': 338}