<commit_before>import React, {Component, PropTypes} from "react";
import GridCell from "dnn-grid-cell";
import { EditIcon, TrashIcon } from "dnn-svg-icons";
import styles from "./style.less";
import Localization from "../../../localization";
import EditUrl from "./EditUrl";
import utils from "../../../utils";

class UrlRow extends Component {
    onDelete(url) {
        const {onDelete} = this.props;
        utils.confirm(
            Localization.get("Pages_Seo_DeleteWarningMessage"),
            Localization.get("Delete"),
            Localization.get("Cancel"),
            function onConfirmDeletion() {
                onDelete(url);
            }
        );
    }
    
    render() {
        const {url, siteAliases, primaryAliasId, editedUrl, saving, onChange, pageHasParent, onOpenEditForm, 
            onSave, onCancel} = this.props;
        let generatedBy = Localization.get("Pages_Seo_GeneratedByAutomatic");
        
        if (!url.autoGenerated) {
            generatedBy = "generatedBy";
        }
        const opened = editedUrl && editedUrl.id === url.id;
        
        return (
            /* eslint-disable react/no-danger */
            <div className={styles.urlRow} >
                <GridCell columnSize={50} >
                    {url.path}
                </GridCell>
                <GridCell  columnSize={20} >
                    {url.statusCode.Value}
                </GridCell>
                <GridCell  columnSize={20} >
                    {generatedBy}
                </GridCell>
                {!url.autoGenerated &&
                    <GridCell  columnSize={10}>
                        <div className="extension-action" 
                            onClick={this.onDelete.bind(this, url)} dangerouslySetInnerHTML={{ __html: TrashIcon }}></div>
                        <div className="extension-action" 
                            onClick={onOpenEditForm.bind(this, url)} dangerouslySetInnerHTML={{ __html: EditIcon }}></div>
                    </GridCell>
                }
                {opened &&
                <EditUrl url={editedUrl} 
                    saving={saving}
                    pageHasParent={pageHasParent}
                    accordion={true} isOpened={opened} keepCollapsedContent={true}
                    onChange={onChange}
                    onSave={onSave} 
                    onCancel={onCancel} 
                    siteAliases={siteAliases}
                    primaryAliasId={primaryAliasId}<commit_msg>PAE-52 - when clicking on edit button twice cancels the edition<commit_after>import React, {Component, PropTypes} from "react";
import GridCell from "dnn-grid-cell";
import { EditIcon, TrashIcon } from "dnn-svg-icons";
import styles from "./style.less";
import Localization from "../../../localization";
import EditUrl from "./EditUrl";
import utils from "../../../utils";

class UrlRow extends Component {
    onDelete(url) {
        const {onDelete} = this.props;
        utils.confirm(
            Localization.get("Pages_Seo_DeleteWarningMessage"),
            Localization.get("Delete"),
            Localization.get("Cancel"),
            function onConfirmDeletion() {
                onDelete(url);
            }
        );
    }
    
    onOpenEditForm(url) {
        const {editedUrl, onOpenEditForm, onCancel} = this.props;
        const opened = editedUrl && editedUrl.id === url.id;
        if (opened) {
            onCancel();
        } else {
            onOpenEditForm(url);
        }
    }
    
    render() {
        const {url, siteAliases, primaryAliasId, editedUrl, saving, onChange, pageHasParent, 
            onSave, onCancel} = this.props;
        let generatedBy = Localization.get("Pages_Seo_GeneratedByAutomatic");
        
        if (!url.autoGenerated) {
            generatedBy = "generatedBy";
        }
        const opened = editedUrl && editedUrl.id === url.id;
        
        return (
            /* eslint-disable react/no-danger */
            <div className={styles.urlRow} >
                <GridCell columnSize={50} >
                    {url.path}
                </GridCell>
                <GridCell  columnSize={20} >
                    {url.statusCode.Value}
                </GridCell>
                <GridCell  columnSize={20} >
                    {generatedBy}
                </GridCell>
                {!url.autoGenerated &&
                    <GridCell  columnSize={10}>
                        <div className="extension-action" 
                            onClick={this.onDelete.bind(this, url)} dangerouslySetInnerHTML={{ __html: TrashIcon }}></div>
                        <div className="extension-action" 
                            onClick={this.onOpenEditForm.bind(this, url)} dangerouslySetInnerHTML={{ __html: EditIcon }}></div>
                    </GridCell>
                }
                {opened &&
                <EditUrl url={editedUrl} 
                    saving={saving}
                    pageHasParent={pageHasParent}
                    accordion={true} isOpened={opened} keepCollapsedContent={true}
                    onChange={onChange}
                    onSave={onSave} 
                    onCancel={onCancel} 
                    siteAliases={siteAliases}
                    primaryAliasId={primaryAliasId}
{'fraction_non_alphanumeric': 0.11322891111530478, 'fraction_numerical': 0.003396867333459143, 'mean_word_length': 1.5715672003881611, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, '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': '1468749', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1325, 'n_words': 265}