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.
fix: clean LG/LU resources when deleting a Trigger (microsoft#2844)
* pass shellApi as a params into hook * clean trigger resources by using useTriggerApi
- Loading branch information
Showing
11 changed files
with
67 additions
and
30 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
8 changes: 3 additions & 5 deletions
8
Composer/packages/extensions/extension/src/hooks/useDialogApi.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
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
31 changes: 31 additions & 0 deletions
31
Composer/packages/extensions/extension/src/hooks/useTriggerApi.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,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { ShellApi, SDKKinds } from '@bfc/shared'; | ||
import get from 'lodash/get'; | ||
|
||
import { useActionApi } from './useActionApi'; | ||
import { useLuApi } from './useLuApi'; | ||
|
||
export const useTriggerApi = (shellAPi: ShellApi) => { | ||
const { deleteActions } = useActionApi(shellAPi); | ||
const { deleteLuIntent } = useLuApi(shellAPi); | ||
|
||
const deleteTrigger = (dialogId: string, trigger) => { | ||
// Clean the lu resource on intent trigger | ||
if (trigger.$kind === SDKKinds.OnIntent) { | ||
const triggerIntent = get(trigger, 'intent', ''); | ||
deleteLuIntent(dialogId, triggerIntent); | ||
} | ||
|
||
// Clean action resources | ||
const actions = get(trigger, 'actions'); | ||
if (!actions || !Array.isArray(actions)) return; | ||
|
||
deleteActions(dialogId, actions); | ||
}; | ||
|
||
return { | ||
deleteTrigger, | ||
}; | ||
}; |
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