forked from microsoft/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Trigger UI Schema (microsoft#4079)
* chore: move TriggerCreationModal to folder * chore: move styles into styles.ts * chore: move validators out * Extract dropdown options as constants * remove outdated dropdown option generators * don't re-declare SDKKinds as type key * remove initialError, fix tslint * fix warning icon size * refactor show warning logic * move static func outside TriggerModal * refactor: move trigger widget out of Modal * replay changes in microsoft#4117 'mutiple projects' * fix a wrong import path * refactor: extract TriggerDropdownGroup * define builtinSchema * TriggerOptionTree * remove duplicated $kinds * link leaf ndoe to parent node * migrate to option tree * fix a React grammar * rename builtinSchema * refactor the warning icon logic of trigger modal * remove unreferenced utils * add a todo * fix UT by adding data-testid * declare TriggerUISchema in extension * use trigger uischema from extension context * check trigger option existence * sort trigger dropdown labels * move root text out of tree utils * pass in option compare fn * add UT for triggerOptionTree * align icon size with main * migrate 1.2 PVA logic * use 'Boolean' to filter trigger menus Co-authored-by: Andy Brown <asbrown002@gmail.com> * wrap trigger UI Schema with formatMessage * add 'px' unit to styles * add trigger menu order * 'order' property to manage trigger order * early returning & add comments * avoid duplicated iteration and add comments * fix trigger modal UT * lint * replay Ben's commit * CI fix Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com> Co-authored-by: Andy Brown <asbrown002@gmail.com>
- Loading branch information
1 parent
69d64c2
commit 92e68a5
Showing
25 changed files
with
981 additions
and
638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Composer/packages/client/__tests__/components/TriggerCreationModal/triggerOptionTree.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { TriggerUISchema } from '@bfc/extension-client'; | ||
import { SDKKinds } from '@botframework-composer/types'; | ||
|
||
import { | ||
generateTriggerOptionTree, | ||
TriggerOptionGroupNode, | ||
} from '../../../src/components/TriggerCreationModal/TriggerOptionTree'; | ||
|
||
describe('generateTriggerOptionTree()', () => { | ||
it('can generate one layer tree.', () => { | ||
const simpleTriggerUIOptions: TriggerUISchema = { | ||
[SDKKinds.OnIntent]: { | ||
label: '1.OnIntent', | ||
order: 1, | ||
}, | ||
[SDKKinds.OnInvokeActivity]: { | ||
label: '2.OnInvokeActivity', | ||
order: 2, | ||
}, | ||
}; | ||
const tree = generateTriggerOptionTree(simpleTriggerUIOptions, 'Select a trigger', 'Which trigger?'); | ||
|
||
expect(tree.prompt).toEqual('Select a trigger'); | ||
expect(tree.placeholder).toEqual('Which trigger?'); | ||
|
||
expect(tree.parent).toBeNull(); | ||
expect(tree.children.length).toEqual(2); | ||
|
||
expect(tree.children[0].label).toEqual('1.OnIntent'); | ||
expect(tree.children[0].parent).toEqual(tree); | ||
|
||
expect(tree.children[1].label).toEqual('2.OnInvokeActivity'); | ||
expect(tree.children[1].parent).toEqual(tree); | ||
}); | ||
|
||
it('can generate tree with submenu.', () => { | ||
const advancedTriggerUIOptions: TriggerUISchema = { | ||
[SDKKinds.OnIntent]: { | ||
label: '1.OnIntent', | ||
order: 1, | ||
}, | ||
[SDKKinds.OnTypingActivity]: { | ||
label: '2.1.OnTypingActivity', | ||
order: 2.1, | ||
submenu: { | ||
label: '2.Activities', | ||
prompt: 'Select an activity trigger', | ||
placeholder: 'Which activity?', | ||
}, | ||
}, | ||
[SDKKinds.OnEventActivity]: { | ||
label: '2.2OnEventActivity', | ||
order: 2.2, | ||
submenu: '2.Activities', | ||
}, | ||
[SDKKinds.OnInvokeActivity]: { | ||
label: '2.3OnInvokeActivity', | ||
order: 2.3, | ||
submenu: '2.Activities', | ||
}, | ||
}; | ||
const tree = generateTriggerOptionTree(advancedTriggerUIOptions, 'Select a trigger', 'Which trigger?'); | ||
|
||
expect(tree.children.length).toEqual(2); | ||
|
||
expect(tree.children[0].label).toEqual('1.OnIntent'); | ||
expect(tree.children[0].parent).toEqual(tree); | ||
|
||
const secondChild = tree.children[1] as TriggerOptionGroupNode; | ||
expect(secondChild.label).toEqual('2.Activities'); | ||
expect(secondChild.prompt).toEqual('Select an activity trigger'); | ||
expect(secondChild.children.length).toEqual(3); | ||
|
||
expect(secondChild.children[0].label).toEqual('2.1.OnTypingActivity'); | ||
expect(secondChild.children[0].parent).toEqual(secondChild); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.