-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: support lg templates cross-file copy during Visual Editor c…
…opy / paste (#2236) * dump real lg content before paste them * implement lg resources walker * update lg walker api * split insertNodes from pasteNodes * fix tslint * change copyUtils ExtarnelAPI interface * migrate to new api format * create real lg template when pasting
- Loading branch information
Showing
14 changed files
with
167 additions
and
62 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
export { walkLgResourcesInAction, walkLgResourcesInActionList } from './walkLgResources'; |
42 changes: 42 additions & 0 deletions
42
Composer/packages/lib/shared/src/walkerUtils/walkLgResources.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,42 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { walkAdaptiveAction } from '../deleteUtils/walkAdaptiveAction'; | ||
import { SDKTypes } from '../types'; | ||
import { walkAdaptiveActionList } from '../deleteUtils/walkAdaptiveActionList'; | ||
|
||
type LgFieldHandler = (action, lgFieldName: string, lgString: string) => any; | ||
|
||
const findLgFields = (action: any, handleLgField: LgFieldHandler) => { | ||
if (typeof action === 'string') return; | ||
if (!action || !action.$type) return; | ||
|
||
const onFound = (fieldName: string) => { | ||
action[fieldName] && handleLgField(action, fieldName, action[fieldName]); | ||
}; | ||
|
||
switch (action.$type) { | ||
case SDKTypes.SendActivity: | ||
onFound('activity'); | ||
break; | ||
case SDKTypes.AttachmentInput: | ||
case SDKTypes.ChoiceInput: | ||
case SDKTypes.ConfirmInput: | ||
case SDKTypes.DateTimeInput: | ||
case SDKTypes.NumberInput: | ||
case SDKTypes.TextInput: | ||
onFound('prompt'); | ||
onFound('unrecognizedPrompt'); | ||
onFound('invalidPrompt'); | ||
onFound('defaultValueResponse'); | ||
break; | ||
} | ||
}; | ||
|
||
export const walkLgResourcesInAction = (action, handleLgResource: LgFieldHandler) => { | ||
walkAdaptiveAction(action, action => findLgFields(action, handleLgResource)); | ||
}; | ||
|
||
export const walkLgResourcesInActionList = (actioList: any[], handleLgResource: LgFieldHandler) => { | ||
walkAdaptiveActionList(actioList, action => findLgFields(action, handleLgResource)); | ||
}; |