Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,25 @@ describe('<IDialogArray />', () => {

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),
});
});
});
34 changes: 17 additions & 17 deletions Composer/packages/lib/shared/src/labelMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand All @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down
78 changes: 48 additions & 30 deletions Composer/packages/lib/shared/src/viewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -71,7 +71,7 @@ export const dialogGroups: DialogGroupsMap = {
],
},
[DialogGroup.CODE]: {
label: 'Integrations',
label: 'Access external resources',
types: [
SDKTypes.HttpRequest,
SDKTypes.EmitEvent,
Expand All @@ -81,7 +81,7 @@ export const dialogGroups: DialogGroupsMap = {
],
},
[DialogGroup.LOG]: {
label: 'Debugging',
label: 'Debugging options',
types: [/* SDKTypes.DebugBreak, */ SDKTypes.LogAction, SDKTypes.TraceActivity],
},
[DialogGroup.EVENTS]: {
Expand Down Expand Up @@ -133,15 +133,56 @@ export const dialogGroups: DialogGroupsMap = {
},
};

const menuItemHandler = (
handleType: (
e: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement> | undefined,
item: IContextualMenuItem
) => void
) => (
e: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement> | 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<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement> | 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];
Expand All @@ -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 = {
Expand Down