From 3b6567bd287d8416497cbca1fe0d63719fe3dbab Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 26 Aug 2019 13:33:04 -0500 Subject: [PATCH 1/4] feat: remove direct prebuilt types --- .../EntityCreatorContainer.tsx | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx index a7659954..2e2516d6 100644 --- a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx +++ b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as React from 'react' @@ -98,18 +98,6 @@ class Container extends React.Component { text: Util.formatMessageId(intl, FM.ENTITYCREATOREDITOR_ENTITYOPTION_ENUM), itemType: OF.DropdownMenuItemType.Normal, style: 'clDropdown--command' - }, - { - key: 'divider', - text: '-', - itemType: OF.DropdownMenuItemType.Divider, - style: 'clDropdown--normal' - }, - { - key: 'Header', - text: 'Pre-Trained', - itemType: OF.DropdownMenuItemType.Header, - style: 'clDropdown--normal' } ] } @@ -151,8 +139,7 @@ class Container extends React.Component { })) if (nextProps.entity === null) { - const filteredPreBuiltOptions = localePreBuiltOptions.filter(entityOption => !nextProps.entities.some(e => !e.doNotMemorize && e.entityType === entityOption.key)) - this.entityOptions = [...this.staticEntityOptions, ...filteredPreBuiltOptions] + this.entityOptions = this.staticEntityOptions this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] this.setState({ @@ -166,7 +153,7 @@ class Container extends React.Component { enumValues: this.initEnumValues(undefined) }); } else { - this.entityOptions = [...this.staticEntityOptions, ...localePreBuiltOptions] + this.entityOptions = this.staticEntityOptions this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] const entityType = nextProps.entity.entityType const isPrebuilt = CLM.isPrebuilt(nextProps.entity) @@ -381,7 +368,7 @@ class Container extends React.Component { const enumValueObj = enumValuesObjs[index] if (newValue.length > 0) { - // Create new EnumValue if needed + // Create new EnumValue if needed if (!enumValueObj) { enumValuesObjs[index] = { enumValue: newValue } } @@ -545,7 +532,7 @@ class Container extends React.Component { .some(condition => condition.entityId === entity.entityId && condition.valueId === enumValue.enumValueId) - + const usedToSetValue = (a.actionType === CLM.ActionTypes.SET_ENTITY) && a.entityId === entity.entityId && a.enumValueId === enumValue.enumValueId From 702e51dcb36fc45d4cb8e48ea8e04dc64e28ff88 Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 26 Aug 2019 13:44:23 -0500 Subject: [PATCH 2/4] chore: remove staticEntityOptions --- .../EntityCreatorContainer.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx index 2e2516d6..01f16a0b 100644 --- a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx +++ b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx @@ -67,15 +67,18 @@ export const getPrebuiltEntityName = (preBuiltType: string): string => { } class Container extends React.Component { - staticEntityOptions: CLDropdownOption[] staticResolverOptions: CLDropdownOption[] entityOptions: CLDropdownOption[] resolverOptions: CLDropdownOption[] constructor(props: Props) { super(props) - this.state = { ...initState, entityTypeVal: CLM.EntityType.LUIS, entityResolverVal: this.NONE_RESOLVER } - this.staticEntityOptions = this.getStaticEntityOptions(this.props.intl) + this.state = { + ...initState, + entityTypeVal: CLM.EntityType.LUIS, + entityResolverVal: this.NONE_RESOLVER, + } + this.entityOptions = this.getStaticEntityOptions(this.props.intl) this.staticResolverOptions = this.getStaticResolverOptions(this.props.intl) } @@ -138,10 +141,9 @@ class Container extends React.Component { style: 'clDropdown--normal' })) - if (nextProps.entity === null) { - this.entityOptions = this.staticEntityOptions - this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] + this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] + if (nextProps.entity === null) { this.setState({ ...initState, title: nextProps.intl.formatMessage({ @@ -153,8 +155,6 @@ class Container extends React.Component { enumValues: this.initEnumValues(undefined) }); } else { - this.entityOptions = this.staticEntityOptions - this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] const entityType = nextProps.entity.entityType const isPrebuilt = CLM.isPrebuilt(nextProps.entity) const resolverType = nextProps.entity.resolverType === null ? this.NONE_RESOLVER : nextProps.entity.resolverType @@ -534,8 +534,8 @@ class Container extends React.Component { && condition.valueId === enumValue.enumValueId) const usedToSetValue = (a.actionType === CLM.ActionTypes.SET_ENTITY) - && a.entityId === entity.entityId - && a.enumValueId === enumValue.enumValueId + && a.entityId === entity.entityId + && a.enumValueId === enumValue.enumValueId return usedAsCondition || usedToSetValue }) From 94ddfff1dd5dd2e7df26e2ec524740d7e13c7129 Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 26 Aug 2019 16:32:17 -0500 Subject: [PATCH 3/4] chore: restore prebuilts for existing --- .../modals/EntityCreatorEditor/EntityCreatorContainer.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx index 01f16a0b..d2ca4efc 100644 --- a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx +++ b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx @@ -67,6 +67,7 @@ export const getPrebuiltEntityName = (preBuiltType: string): string => { } class Container extends React.Component { + staticEntityOptions: CLDropdownOption[] staticResolverOptions: CLDropdownOption[] entityOptions: CLDropdownOption[] resolverOptions: CLDropdownOption[] @@ -78,8 +79,10 @@ class Container extends React.Component { entityTypeVal: CLM.EntityType.LUIS, entityResolverVal: this.NONE_RESOLVER, } - this.entityOptions = this.getStaticEntityOptions(this.props.intl) + this.staticEntityOptions = this.getStaticEntityOptions(this.props.intl) + this.entityOptions = this.staticEntityOptions this.staticResolverOptions = this.getStaticResolverOptions(this.props.intl) + this.entityOptions = this.staticResolverOptions } getStaticEntityOptions(intl: InjectedIntl): CLDropdownOption[] { @@ -142,8 +145,9 @@ class Container extends React.Component { })) this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] - if (nextProps.entity === null) { + this.entityOptions = [...this.staticEntityOptions] + this.setState({ ...initState, title: nextProps.intl.formatMessage({ From a9bb28c5cf80c3c43fe62fc23c99987f5efa4669 Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 26 Aug 2019 17:00:36 -0500 Subject: [PATCH 4/4] chore: restore entity options on edit --- .../modals/EntityCreatorEditor/EntityCreatorContainer.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx index d2ca4efc..7bdeb541 100644 --- a/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx +++ b/src/components/modals/EntityCreatorEditor/EntityCreatorContainer.tsx @@ -145,6 +145,7 @@ class Container extends React.Component { })) this.resolverOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] + if (nextProps.entity === null) { this.entityOptions = [...this.staticEntityOptions] @@ -159,6 +160,7 @@ class Container extends React.Component { enumValues: this.initEnumValues(undefined) }); } else { + this.entityOptions = [...this.staticResolverOptions, ...localePreBuiltOptions] const entityType = nextProps.entity.entityType const isPrebuilt = CLM.isPrebuilt(nextProps.entity) const resolverType = nextProps.entity.resolverType === null ? this.NONE_RESOLVER : nextProps.entity.resolverType