diff --git a/Composer/packages/extensions/obiformeditor/__tests__/Form/ArrayFieldTemplate/IDialogArray.test.tsx b/Composer/packages/extensions/obiformeditor/__tests__/Form/ArrayFieldTemplate/IDialogArray.test.tsx index 5e4c4d5800..960b95bc8b 100644 --- a/Composer/packages/extensions/obiformeditor/__tests__/Form/ArrayFieldTemplate/IDialogArray.test.tsx +++ b/Composer/packages/extensions/obiformeditor/__tests__/Form/ArrayFieldTemplate/IDialogArray.test.tsx @@ -62,27 +62,25 @@ describe('', () => { fireEvent.click(addBtn); - const responseMenu = await findByText(document.body, 'Send Messages'); + const responseMenu = await findByText(document.body, 'Send a response'); fireEvent.click(responseMenu); - const sendActivity = await findByText(document.body, 'Send an Activity'); - fireEvent.click(sendActivity); - expect(onAddClick.mock.calls[0][1]).toEqual({ $type: 'Microsoft.SendActivity', $designer: { id: expect.any(String), - name: 'Send an Activity', + name: 'Send a response', }, data: { $type: 'Microsoft.SendActivity', $designer: { id: expect.any(String), - name: 'Send an Activity', + name: 'Send a response', }, }, key: 'Microsoft.SendActivity', - name: 'Send an Activity', + name: 'Send a response', + onClick: expect.any(Function), }); }); }); diff --git a/Composer/packages/lib/shared/src/labelMap.ts b/Composer/packages/lib/shared/src/labelMap.ts index 61050cb278..63dfe34d4c 100644 --- a/Composer/packages/lib/shared/src/labelMap.ts +++ b/Composer/packages/lib/shared/src/labelMap.ts @@ -28,25 +28,25 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('AdaptiveDialog'), }, [SDKTypes.AttachmentInput]: { - title: formatMessage('Prompt for Attachment'), + title: formatMessage('File or attachment'), }, [SDKTypes.BeginDialog]: { - title: formatMessage('Begin a Dialog'), + title: formatMessage('Begin a new dialog'), }, [SDKTypes.CancelAllDialogs]: { - title: formatMessage('Cancel All Dialogs'), + title: formatMessage('Cancel all dialogs'), }, [SDKTypes.ChoiceInput]: { - title: formatMessage('Prompt with multi-choice'), + title: formatMessage('Multiple choice'), }, [SDKTypes.ConditionalSelector]: { title: formatMessage('ConditionalSelector'), }, [SDKTypes.ConfirmInput]: { - title: formatMessage('Prompt for confirmation'), + title: formatMessage('Confirmation'), }, [SDKTypes.DateTimeInput]: { - title: formatMessage('Prompt for a date'), + title: formatMessage('Date or time'), }, [SDKTypes.DebugBreak]: { title: formatMessage('Debug Break'), @@ -55,7 +55,7 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('Delete a Property'), }, [SDKTypes.EditActions]: { - title: formatMessage('Modify active dialog'), + title: formatMessage('Modify this dialog'), }, [SDKTypes.EditArray]: { title: formatMessage('Edit an Array Property'), @@ -64,22 +64,22 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('Emit a custom event'), }, [SDKTypes.EndDialog]: { - title: formatMessage('End Dialog'), + title: formatMessage('End this dialog'), }, [SDKTypes.EndTurn]: { - title: formatMessage('End Turn'), + title: formatMessage('End dialog turn'), }, [SDKTypes.FirstSelector]: { title: formatMessage('FirstSelector'), }, [SDKTypes.Foreach]: { - title: formatMessage('Loop: For Each'), + title: formatMessage('Loop: for each item'), }, [SDKTypes.ForeachPage]: { - title: formatMessage('Loop: For Each Page'), + title: formatMessage('Loop: for each page (multiple items)'), }, [SDKTypes.HttpRequest]: { - title: formatMessage('HTTP Request'), + title: formatMessage('Send an HTTP request'), }, [SDKTypes.IfCondition]: { title: formatMessage('Branch: If/Else'), @@ -109,7 +109,7 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('Language Understanding'), }, [SDKTypes.NumberInput]: { - title: formatMessage('Prompt for a number'), + title: formatMessage('Number input'), }, [SDKTypes.OAuthInput]: { title: formatMessage('OAuth Login'), @@ -177,7 +177,7 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('Handle Unknown Intent'), }, [SDKTypes.QnAMakerDialog]: { - title: formatMessage('QnAMakerDialog'), + title: formatMessage('Connect to QnA Knowledgebase'), }, [SDKTypes.RandomSelector]: { title: formatMessage('RandomSelector'), @@ -193,16 +193,16 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { title: formatMessage('Replace this Dialog'), }, [SDKTypes.SendActivity]: { - title: formatMessage('Send an Activity'), + title: formatMessage('Send a response'), }, [SDKTypes.SetProperty]: { title: formatMessage('Set a Property'), }, [SDKTypes.SwitchCondition]: { - title: formatMessage('Branch: Switch'), + title: formatMessage('Branch: Switch (multiple options)'), }, [SDKTypes.TextInput]: { - title: formatMessage('Prompt for text'), + title: formatMessage('Text input'), }, [SDKTypes.TraceActivity]: { title: formatMessage('Emit a trace event'), diff --git a/Composer/packages/lib/shared/src/viewUtils.ts b/Composer/packages/lib/shared/src/viewUtils.ts index 98879e5680..1fec5c957f 100644 --- a/Composer/packages/lib/shared/src/viewUtils.ts +++ b/Composer/packages/lib/shared/src/viewUtils.ts @@ -52,15 +52,15 @@ export const dialogGroups: DialogGroupsMap = { ], }, [DialogGroup.BRANCHING]: { - label: 'Flow', + label: 'Create a condition', types: [SDKTypes.IfCondition, SDKTypes.SwitchCondition, SDKTypes.Foreach, SDKTypes.ForeachPage], }, [DialogGroup.MEMORY]: { - label: 'Memory manipulation', + label: 'Manage properties', types: [SDKTypes.SetProperty, SDKTypes.InitProperty, SDKTypes.DeleteProperty, SDKTypes.EditArray], }, [DialogGroup.STEP]: { - label: 'Dialogs', + label: 'Dialog management', types: [ SDKTypes.BeginDialog, SDKTypes.EndDialog, @@ -71,7 +71,7 @@ export const dialogGroups: DialogGroupsMap = { ], }, [DialogGroup.CODE]: { - label: 'Integrations', + label: 'Access external resources', types: [ SDKTypes.HttpRequest, SDKTypes.EmitEvent, @@ -81,7 +81,7 @@ export const dialogGroups: DialogGroupsMap = { ], }, [DialogGroup.LOG]: { - label: 'Debugging', + label: 'Debugging options', types: [/* SDKTypes.DebugBreak, */ SDKTypes.LogAction, SDKTypes.TraceActivity], }, [DialogGroup.EVENTS]: { @@ -133,15 +133,56 @@ export const dialogGroups: DialogGroupsMap = { }, }; +const menuItemHandler = ( + handleType: ( + e: React.MouseEvent | React.KeyboardEvent | undefined, + item: IContextualMenuItem + ) => void +) => ( + e: React.MouseEvent | React.KeyboardEvent | undefined, + item: IContextualMenuItem | undefined +) => { + if (item) { + item = { + ...item, + $type: item.$type, + ...seedNewDialog(item.$type, { + name: + ConceptLabels[item.$type] && ConceptLabels[item.$type].title ? ConceptLabels[item.$type].title : item.$type, + }), + data: { + $type: item.$type, // used by the steps field to create the item + ...seedNewDialog(item.$type, { + name: + ConceptLabels[item.$type] && ConceptLabels[item.$type].title ? ConceptLabels[item.$type].title : item.$type, + }), + }, + }; + return handleType(e, item); + } +}; + export const createStepMenu = ( stepLabels: DialogGroup[], subMenu = true, - handleType: (e: any, item: IContextualMenuItem) => void, + handleType: ( + e: React.MouseEvent | React.KeyboardEvent | undefined, + item: IContextualMenuItem + ) => void, filter?: (x: SDKTypes) => boolean ): IContextualMenuItem[] => { if (subMenu) { const stepMenuItems = stepLabels.map(x => { const item = dialogGroups[x]; + if (item.types.length === 1) { + const conceptLabel = ConceptLabels[item.types[0]]; + return { + key: item.types[0], + name: conceptLabel && conceptLabel.title ? conceptLabel.title : item.types[0], + $type: item.types[0], + onClick: menuItemHandler(handleType), + }; + } const subMenu: IContextualMenuProps = { items: item.types.filter(filter || (() => true)).map($type => { const conceptLabel = ConceptLabels[$type]; @@ -152,30 +193,7 @@ export const createStepMenu = ( $type: $type, }; }), - onItemClick: (e, item: IContextualMenuItem | undefined) => { - if (item) { - item = { - ...item, - $type: item.$type, - ...seedNewDialog(item.$type, { - name: - ConceptLabels[item.$type] && ConceptLabels[item.$type].title - ? ConceptLabels[item.$type].title - : item.$type, - }), - data: { - $type: item.$type, // used by the steps field to create the item - ...seedNewDialog(item.$type, { - name: - ConceptLabels[item.$type] && ConceptLabels[item.$type].title - ? ConceptLabels[item.$type].title - : item.$type, - }), - }, - }; - return handleType(e, item); - } - }, + onItemClick: menuItemHandler(handleType), }; const menuItem: IContextualMenuItem = {