Skip to content

Commit

Permalink
use luIntents to populate intent dropdown when creating a trigger (#1921
Browse files Browse the repository at this point in the history
)

closes #1919
  • Loading branch information
a-b-r-o-w-n authored Jan 30, 2020
1 parent 12d77a0 commit db239d0
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
getEventTypes,
getActivityTypes,
getMessageTypes,
regexRecognizerKey,
} from '../../utils/dialogUtil';
import { StoreContext } from '../../store';

Expand Down Expand Up @@ -69,8 +68,7 @@ export const TriggerCreationModal: React.FC<TriggerCreationModalProps> = props =
const { isOpen, onDismiss, onSubmit, dialogId } = props;
const [formData, setFormData] = useState(initialFormData);
const { state } = useContext(StoreContext);
const { dialogs, luFiles } = state;
const luFile = luFiles.find(lu => lu.id === dialogId);
const { dialogs } = state;
const dialogFile = dialogs.find(dialog => dialog.id === dialogId);
const onClickSubmitButton = e => {
e.preventDefault();
Expand Down Expand Up @@ -104,14 +102,8 @@ export const TriggerCreationModal: React.FC<TriggerCreationModalProps> = props =
const activityTypes: IDropdownOption[] = getActivityTypes();
const messageTypes: IDropdownOption[] = getMessageTypes();

const isRegEx = get(dialogFile, 'content.recognizer.$type', '') === regexRecognizerKey;

const regexIntents = get(dialogFile, 'content.recognizer.intents', []);
const luisIntents = get(luFile, 'intents', []);
const intents = isRegEx ? regexIntents : luisIntents;

const intentOptions = intents.map(t => {
return { key: t.name || t.intent, text: t.name || t.intent };
const intentOptions = get(dialogFile, 'luIntents', [] as string[]).map(intent => {
return { key: intent, text: intent };
});

const showIntentDropDown = formData.$type === intentTypeKey;
Expand Down

0 comments on commit db239d0

Please sign in to comment.