<commit_before>﻿import * as React from "react"
import { Router, Route, Redirect } from "react-router"

import { Dic } from '../Globals';
import { Lite, Entity, liteKey, ModifiableEntity } from '../Signum.Entities';
import * as Navigator from '../Navigator';
import { Link  } from 'react-router-dom';

export interface EntityLinkProps extends React.HTMLAttributes<HTMLAnchorElement>, React.Props<EntityLink> {
    lite: Lite<Entity>;
    inSearch?: boolean;
    onNavigated?: (lite: Lite<Entity>) => void;
    getViewPromise?: (e: ModifiableEntity) => undefined | string | Navigator.ViewPromise<ModifiableEntity>;
}


export default class EntityLink extends React.Component<EntityLinkProps>{

    render() {
        const { lite, inSearch, children, onNavigated, getViewPromise, ...htmlAtts } = this.props;

        if (!Navigator.isNavigable(lite.EntityType, undefined, this.props.inSearch || false))
            return <span data-entity={liteKey(lite) }>{this.props.children || lite.toStr}</span>;


        return (
            <Link
                to={Navigator.navigateRoute(lite) }
                title={lite.toStr}
                onClick={this.handleClick}
                data-entity={liteKey(lite)}
                {...(htmlAtts as React.HTMLAttributes<HTMLAnchorElement>) }>
                {children || lite.toStr}                
            </Link>
        );
    }

    handleClick = (event: React.MouseEvent<any>) => {

        const lite = this.props.lite;

        const s = Navigator.getSettings(lite.EntityType)

        const avoidPopup = s != undefined && s.avoidPopup;

        if (avoidPopup || event.ctrlKey || event.button == 1)
            return;

        event.preventDefault();

        Navigator.navigate(lite, { getViewPromise: this.props.getViewPromise }).then(() => {
            this.props.onNavigated && this.props.onNavigated(lite);
        }).done();
    }
}<commit_msg>make EntityLink do window.open to keep session<commit_after>﻿import * as React from "react"
import { Router, Route, Redirect } from "react-router"

import { Dic } from '../Globals';
import { Lite, Entity, liteKey, ModifiableEntity } from '../Signum.Entities';
import * as Navigator from '../Navigator';
import { Link  } from 'react-router-dom';

export interface EntityLinkProps extends React.HTMLAttributes<HTMLAnchorElement>, React.Props<EntityLink> {
    lite: Lite<Entity>;
    inSearch?: boolean;
    onNavigated?: (lite: Lite<Entity>) => void;
    getViewPromise?: (e: ModifiableEntity) => undefined | string | Navigator.ViewPromise<ModifiableEntity>;
}


export default class EntityLink extends React.Component<EntityLinkProps>{

    render() {
        const { lite, inSearch, children, onNavigated, getViewPromise, ...htmlAtts } = this.props;

        if (!Navigator.isNavigable(lite.EntityType, undefined, this.props.inSearch || false))
            return <span data-entity={liteKey(lite) }>{this.props.children || lite.toStr}</span>;


        return (
            <Link
                to={Navigator.navigateRoute(lite) }
                title={lite.toStr}
                onClick={this.handleClick}
                data-entity={liteKey(lite)}
                {...(htmlAtts as React.HTMLAttributes<HTMLAnchorElement>) }>
                {children || lite.toStr}                
            </Link>
        );
    }

    handleClick = (event: React.MouseEvent<any>) => {
       

        const lite = this.props.lite;

        const s = Navigator.getSettings(lite.EntityType)

        const avoidPopup = s != undefined && s.avoidPopup;

        if (event.ctrlKey || event.button == 1) {
            event.preventDefault();
            window.open(Navigator.navigateRoute(lite));
            return;
        }

        if (avoidPopup) {
            return; //just go
        }

        event.preventDefault();
        Navigator.navigate(lite, { getViewPromise: this.props.getViewPromise }).then(() => {
            this.props.onNavigated && this.props.onNavigated(lite);
        }).done();
    }
}
{'fraction_non_alphanumeric': 0.13275217932752179, 'fraction_numerical': 0.00049813200498132, 'mean_word_length': 2.5166374781085814, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 35, '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': '5388833', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1125, 'n_words': 244}