diff --git a/Composer/cypress/support/commands.js b/Composer/cypress/support/commands.js index 8550d6d2e2..0318a076c6 100644 --- a/Composer/cypress/support/commands.js +++ b/Composer/cypress/support/commands.js @@ -77,6 +77,5 @@ Cypress.Commands.add('addEventHandler', handler => { cy.get(`[data-testid="eventTypeDropDown"]`).click(); cy.getByText('consultDialog').click(); } - cy.get('input[data-testid="triggerName"]').type(`__TestTrigger`); cy.get(`[data-testid="triggerFormSubmit"]`).click(); }); diff --git a/Composer/packages/client/src/components/ProjectTree/TriggerCreationModal.tsx b/Composer/packages/client/src/components/ProjectTree/TriggerCreationModal.tsx index 62f596ddc4..da5342f120 100644 --- a/Composer/packages/client/src/components/ProjectTree/TriggerCreationModal.tsx +++ b/Composer/packages/client/src/components/ProjectTree/TriggerCreationModal.tsx @@ -16,7 +16,7 @@ import { import { StoreContext } from '../../store'; import { DialogInfo } from '../../store/types'; -import { styles, dropdownStyles, name, dialogWindow, constraint } from './styles'; +import { styles, dropdownStyles, intent, dialogWindow } from './styles'; const isValidName = name => { const nameRegex = /^[a-zA-Z0-9-_.]+$/; @@ -24,10 +24,7 @@ const isValidName = name => { }; const validateForm = (data: TriggerFormData): TriggerFormDataErrors => { const errors: TriggerFormDataErrors = {}; - const { name, $type, eventType } = data; - if (!name || !isValidName(name)) { - errors.name = formatMessage('Spaces and special characters are not allowed. Use letters, numbers, -, or _.'); - } + const { $type, eventType } = data; if ($type === eventTypeKey && !eventType) { errors.eventType = formatMessage('please select a event type'); @@ -49,8 +46,7 @@ interface TriggerCreationModalProps { const initialFormData: TriggerFormData = { errors: {}, $type: intentTypeKey, - name: '', - constraint: '', + intent: '', eventType: '', }; @@ -60,8 +56,8 @@ export const TriggerCreationModal: React.FC = props = const { isOpen, onDismiss, onSubmit, dialogId } = props; const [formData, setFormData] = useState(initialFormData); const { state } = useContext(StoreContext); - const { dialogs, schemas } = state; - + const { dialogs, schemas, luFiles } = state; + const luFile = luFiles.find(lu => lu.id === dialogId); const onClickSubmitButton = e => { e.preventDefault(); const errors = validateForm(formData); @@ -87,6 +83,10 @@ export const TriggerCreationModal: React.FC = props = setFormData({ ...formData, eventType: option.key }); }; + const onSelectIntent = (e, option) => { + setFormData({ ...formData, intent: option.key }); + }; + const updateForm = field => (e, newValue) => { setFormData({ ...formData, @@ -98,7 +98,14 @@ export const TriggerCreationModal: React.FC = props = return { key: t, text: t }; } ); + + const intents = get(luFile, 'parsedContent.LUISJsonStructure.intents', []); + + const intentOptions = intents.map(t => { + return { key: t.name, text: t.name }; + }); const showEventDropDown = formData.$type === eventTypeKey; + const showIntentDropDown = formData.$type === intentTypeKey; return (