-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename steps to actions, rename rules to conditions (#1382)
* Adaptive: rename rules to conditions * Adaptive: rename steps to actions * revert changes for componentDialog.ts, dialogContext.ts
- Loading branch information
Qi Kang
authored
Nov 1, 2019
1 parent
a92ab74
commit c876437
Showing
98 changed files
with
567 additions
and
567 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
89 changes: 89 additions & 0 deletions
89
libraries/botbuilder-dialogs-adaptive/src/actions/editActions.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,89 @@ | ||
/** | ||
* @module botbuilder-planning | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { DialogCommand, DialogTurnResult, Dialog, DialogConfiguration } from 'botbuilder-dialogs'; | ||
import { ActionChangeType, SequenceContext, ActionChangeList, ActionState } from '../sequenceContext'; | ||
|
||
export interface EditActionsConfiguration extends DialogConfiguration { | ||
/** | ||
* The type of change to make to the dialogs list of actions. | ||
*/ | ||
changeType?: ActionChangeType; | ||
|
||
/** | ||
* The actions to update the dialog with. | ||
*/ | ||
actions?: Dialog[]; | ||
|
||
/** | ||
* Tags to insert actions before when [changeType](#changetype) is `ActionChangeType.insertActionsBeforeTags`. | ||
*/ | ||
tags?: string[]; | ||
} | ||
|
||
export class EditActions extends DialogCommand { | ||
/** | ||
* The type of change to make to the dialogs list of actions. | ||
*/ | ||
public changeType: ActionChangeType; | ||
|
||
/** | ||
* The actions to update the dialog with. | ||
*/ | ||
public actions: Dialog[]; | ||
|
||
/** | ||
* Tags to insert actions before when [changeType](#changetype) is `PlanChangeType.doActionsBeforeTags`. | ||
*/ | ||
public tags: string[]; | ||
|
||
/** | ||
* Creates a new `EditActions` instance. | ||
* @param changeType The type of change to make to the dialogs list of actions. | ||
* @param actions The actions to update the dialog with. | ||
*/ | ||
constructor(); | ||
constructor(changeType: ActionChangeType, actions: Dialog[], tags?: string[]); | ||
constructor(changeType?: ActionChangeType, actions?: Dialog[], tags?: string[]) { | ||
super(); | ||
if (changeType !== undefined) { this.changeType = changeType } | ||
if (Array.isArray(actions)) { this.actions = actions } | ||
if (Array.isArray(tags)) { this.tags = tags } | ||
} | ||
|
||
protected onComputeID(): string { | ||
return `editActions[${this.hashedLabel(this.changeType)}]`; | ||
} | ||
|
||
public configure(config: EditActionsConfiguration): this { | ||
return super.configure(config); | ||
} | ||
|
||
public getDependencies(): Dialog[] { | ||
return this.actions; | ||
} | ||
|
||
protected async onRunCommand(sequence: SequenceContext, options: object): Promise<DialogTurnResult> { | ||
// Ensure planning context and condition | ||
if (!(sequence instanceof SequenceContext)) { throw new Error(`${this.id}: should only be used within a planning or sequence dialog.`) } | ||
if (this.changeType == undefined) { throw new Error(`${this.id}: no 'changeType' specified.`) } | ||
|
||
// Queue changes | ||
const changes: ActionChangeList = { | ||
changeType: this.changeType, | ||
actions: this.actions.map((action) => { | ||
return { dialogId: action.id, dialogStack: [] } as ActionState | ||
}) | ||
}; | ||
if (this.changeType == ActionChangeType.insertActionsBeforeTags) { | ||
changes.tags = this.tags; | ||
} | ||
sequence.queueChanges(changes); | ||
|
||
return await sequence.endDialog(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.