<commit_before>
import * as React from 'react'
import { Route } from 'react-router'
import { ifError } from '../../../Framework/Signum.React/Scripts/Globals';
import { ajaxPost, ajaxGet, ValidationError } from '../../../Framework/Signum.React/Scripts/Services';
import { SearchControl, ValueSearchControlLine } from '../../../Framework/Signum.React/Scripts/Search'
import { EntitySettings, ViewPromise } from '../../../Framework/Signum.React/Scripts/Navigator'
import * as Navigator from '../../../Framework/Signum.React/Scripts/Navigator'
import MessageModal from '../../../Framework/Signum.React/Scripts/Modals/MessageModal'
import { EntityData, EntityKind, symbolNiceName } from '../../../Framework/Signum.React/Scripts/Reflection'
import { EntityOperationSettings } from '../../../Framework/Signum.React/Scripts/Operations'
import * as Operations from '../../../Framework/Signum.React/Scripts/Operations'
import * as EntityOperations from '../../../Framework/Signum.React/Scripts/Operations/EntityOperations'
import { Entity, NormalControlMessage, NormalWindowMessage } from '../../../Framework/Signum.React/Scripts/Signum.Entities'
import * as Constructor from '../../../Framework/Signum.React/Scripts/Constructor'
import * as QuickLink from '../../../Framework/Signum.React/Scripts/QuickLinks'
import { StyleContext } from '../../../Framework/Signum.React/Scripts/TypeContext'


import { ValueLine, EntityLine, EntityCombo, EntityList, EntityDetail, EntityStrip, EntityRepeater } from '../../../Framework/Signum.React/Scripts/Lines'
import { DynamicTypeEntity, DynamicMixinConnectionEntity, DynamicTypeOperation, DynamicSqlMigrationEntity, DynamicRenameEntity, DynamicTypeMessage, DynamicPanelPermission } from './Signum.Entities.Dynamic'
import DynamicTypeComponent from './Type/DynamicType' //typings only
import * as DynamicClient from './DynamicClient'
import * as AuthClient from '../Authorization/AuthClient'
import { Tab } from '../../../Framework/Signum.React/Scripts/Components/Tabs';

export function start(options: { routes: JSX.Element[] }) {

    Navigator.addSettings(new EntitySettings(DynamicTypeEntity, w => import('./Type/DynamicType')));
    Navigator.addSettings(new EntitySettings(DynamicMixinConnectionEntity, w => import('./Type/DynamicMixinConnection')));
    Navigator.addSettings(new EntitySettings(DynamicSqlMigrationEntity, w => import('./Type/DynamicSqlMigration')));

    Operations.addSettings(new EntityOperationSettings(DynamicTypeOperation.Clone, {
        contextual: { icon: "fa fa-clone", iconColor: "black" },
    }));

    Operations.addSettings(new EntityOperationSettings(DynamicTypeOperation.Save, {
        onClick: eoc => {
            (eoc.frame.entityComponent as DynamicTypeComponent).beforeSave();

            Operations.API.executeEntity(eoc.entity, eoc.operationInfo.key)
                .then(pack => { eoc.frame.onReload(pack); EntityOperations.notifySuccess(); })
                .then(() => {
                    if (AuthClient.isPermissionAuthorized(DynamicPanelPermission.ViewDynamicPanel)) {
                        MessageModal.show({
                            title: NormalControlMessage.Save.niceToString(),
                            message: DynamicTypeMessage.DynamicType0SucessfullySavedGoToDynamicPanelNow.niceToString(eoc.entity.typeName),
                            buttons: "yes_no",
                            style: "success",
                            icon: "success"
                        }).then(result => {
                            if (result == "yes")
                                window.open(Navigator.toAbsoluteUrl("~/dynamic/panel"));
                        }).done();
                    }
                })
                .catch(ifError(ValidationError, e => eoc.frame.setError(e.modelState, "request.entity")))
                .done();
        }
    }));

    QuickLink.registerQuickLink(DynamicTypeEntity, ctx => new QuickLink.QuickLinkLink("ViewDynamicPanel",
        symbolNiceName(DynamicPanelPermission.ViewDynamicPanel), "~/dynamic/panel", {
            isVisible: AuthClient.isPermissionAuthorized(DynamicPanelPermission.ViewDynamicPanel)
        }));

    DynamicClient.Options.onGetDynamicLineForPanel.push(ctx => <ValueSearchControlLine ctx={ctx} findOptions={{ queryName: DynamicTypeEntity }} />);
    DynamicClient.Options.onGetDynamicLineForPanel.push(ctx => <ValueSearchControlLine ctx={ctx} findOptions={{ queryName: DynamicMixinConnectionEntity }} />);
    DynamicClient.Options.getDynaicMigrationsStep = () =>
        <Tab eventKey="migrations" title="Migrations" >
            <h3>{DynamicSqlMigrationEntity.nicePluralName()}</h3>
            <SearchControl findOptions={{ queryName: DynamicSqlMigrationEntity }} />
            <h3>{DynamicRenameEntity.nicePluralName()}</h3>
            <SearchControl findOptions={{ queryName: DynamicRenameEntity }} />
        </Tab>;
}

export namespace API {

    export function getPropertyType(property: DynamicProperty): Promise<string> {
        return ajaxPost<string>({ url: `~/api/dynamic/type/propertyType` }, property);
    }

    export function expressionNames(typeName: string): Promise<Array<string>> {<commit_msg>add icon for dynamic panel quick link<commit_after>
import * as React from 'react'
import { Route } from 'react-router'
import { ifError } from '../../../Framework/Signum.React/Scripts/Globals';
import { ajaxPost, ajaxGet, ValidationError } from '../../../Framework/Signum.React/Scripts/Services';
import { SearchControl, ValueSearchControlLine } from '../../../Framework/Signum.React/Scripts/Search'
import { EntitySettings, ViewPromise } from '../../../Framework/Signum.React/Scripts/Navigator'
import * as Navigator from '../../../Framework/Signum.React/Scripts/Navigator'
import MessageModal from '../../../Framework/Signum.React/Scripts/Modals/MessageModal'
import { EntityData, EntityKind, symbolNiceName } from '../../../Framework/Signum.React/Scripts/Reflection'
import { EntityOperationSettings } from '../../../Framework/Signum.React/Scripts/Operations'
import * as Operations from '../../../Framework/Signum.React/Scripts/Operations'
import * as EntityOperations from '../../../Framework/Signum.React/Scripts/Operations/EntityOperations'
import { Entity, NormalControlMessage, NormalWindowMessage } from '../../../Framework/Signum.React/Scripts/Signum.Entities'
import * as Constructor from '../../../Framework/Signum.React/Scripts/Constructor'
import * as QuickLink from '../../../Framework/Signum.React/Scripts/QuickLinks'
import { StyleContext } from '../../../Framework/Signum.React/Scripts/TypeContext'


import { ValueLine, EntityLine, EntityCombo, EntityList, EntityDetail, EntityStrip, EntityRepeater } from '../../../Framework/Signum.React/Scripts/Lines'
import { DynamicTypeEntity, DynamicMixinConnectionEntity, DynamicTypeOperation, DynamicSqlMigrationEntity, DynamicRenameEntity, DynamicTypeMessage, DynamicPanelPermission } from './Signum.Entities.Dynamic'
import DynamicTypeComponent from './Type/DynamicType' //typings only
import * as DynamicClient from './DynamicClient'
import * as AuthClient from '../Authorization/AuthClient'
import { Tab } from '../../../Framework/Signum.React/Scripts/Components/Tabs';

export function start(options: { routes: JSX.Element[] }) {

    Navigator.addSettings(new EntitySettings(DynamicTypeEntity, w => import('./Type/DynamicType')));
    Navigator.addSettings(new EntitySettings(DynamicMixinConnectionEntity, w => import('./Type/DynamicMixinConnection')));
    Navigator.addSettings(new EntitySettings(DynamicSqlMigrationEntity, w => import('./Type/DynamicSqlMigration')));

    Operations.addSettings(new EntityOperationSettings(DynamicTypeOperation.Clone, {
        contextual: { icon: "fa fa-clone", iconColor: "black" },
    }));

    Operations.addSettings(new EntityOperationSettings(DynamicTypeOperation.Save, {
        onClick: eoc => {
            (eoc.frame.entityComponent as DynamicTypeComponent).beforeSave();

            Operations.API.executeEntity(eoc.entity, eoc.operationInfo.key)
                .then(pack => { eoc.frame.onReload(pack); EntityOperations.notifySuccess(); })
                .then(() => {
                    if (AuthClient.isPermissionAuthorized(DynamicPanelPermission.ViewDynamicPanel)) {
                        MessageModal.show({
                            title: NormalControlMessage.Save.niceToString(),
                            message: DynamicTypeMessage.DynamicType0SucessfullySavedGoToDynamicPanelNow.niceToString(eoc.entity.typeName),
                            buttons: "yes_no",
                            style: "success",
                            icon: "success"
                        }).then(result => {
                            if (result == "yes")
                                window.open(Navigator.toAbsoluteUrl("~/dynamic/panel"));
                        }).done();
                    }
                })
                .catch(ifError(ValidationError, e => eoc.frame.setError(e.modelState, "request.entity")))
                .done();
        }
    }));

    QuickLink.registerQuickLink(DynamicTypeEntity, ctx => new QuickLink.QuickLinkLink("ViewDynamicPanel",
        symbolNiceName(DynamicPanelPermission.ViewDynamicPanel), "~/dynamic/panel", {
            isVisible: AuthClient.isPermissionAuthorized(DynamicPanelPermission.ViewDynamicPanel),
            icon: "fa fa-arrows-alt",
            iconColor: "purple",
        }));

    DynamicClient.Options.onGetDynamicLineForPanel.push(ctx => <ValueSearchControlLine ctx={ctx} findOptions={{ queryName: DynamicTypeEntity }} />);
    DynamicClient.Options.onGetDynamicLineForPanel.push(ctx => <ValueSearchControlLine ctx={ctx} findOptions={{ queryName: DynamicMixinConnectionEntity }} />);
    DynamicClient.Options.getDynaicMigrationsStep = () =>
        <Tab eventKey="migrations" title="Migrations" >
            <h3>{DynamicSqlMigrationEntity.nicePluralName()}</h3>
            <SearchControl findOptions={{ queryName: DynamicSqlMigrationEntity }} />
            <h3>{DynamicRenameEntity.nicePluralName()}</h3>
            <SearchControl findOptions={{ queryName: DynamicRenameEntity }} />
        </Tab>;
}

export namespace API {

    export function getPropertyType(property: DynamicProperty): Promise<string> {
        return ajaxPost<string>({ url: `~/api/dynamic/type/propertyType` }, property);
    }

    export function expressionNames(typeName: string): Promise<Array<string>> {
{'fraction_non_alphanumeric': 0.13776971548596526, 'fraction_numerical': 0.0009547450830628223, 'mean_word_length': 3.19, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 55, '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': '3103324', 'n_tokens_mistral': 2705, 'n_tokens_neox': 2729, 'n_words': 479}