Skip to content

Commit

Permalink
Cherrypick OAuthPrompt InputHint changes to master (#1047)
Browse files Browse the repository at this point in the history
* Merge pull request #1043 from microsoft/stgum/oauth-inputHint

Change OAuthPrompt to default to AcceptingInput instead of ExpectingInput

* fix minor typo in TurnContext
  • Loading branch information
stevengum authored Jul 11, 2019
1 parent 8ac0d83 commit 9e285ac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 39 deletions.
33 changes: 0 additions & 33 deletions libraries/botbuilder-azure/package.json.lerna_backup

This file was deleted.

6 changes: 4 additions & 2 deletions libraries/botbuilder-core/src/turnContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ export class TurnContext {

/**
* Rewrites the activity text without any at mention.
* Use with caution because this function is altering the text on the Activity.
*
* @remarks
* Some channels, for example Microsoft Teams, add at mention details into the text on a message activity.
* This can interfer with later procsesing. This is a helper function to remove the at mention.
* This can interfere with later processing. This is a helper function to remove the at mention.
*
* ```JavaScript
* const updatedText = TurnContext.removeRecipientMention(context.request);
Expand All @@ -97,10 +98,11 @@ export class TurnContext {

/**
* Rewrites the activity text without any at mention. Specifying a particular recipient id.
* Use with caution because this function is altering the text on the Activity.
*
* @remarks
* Some channels, for example Microsoft Teams, add at mention details into the text on a message activity.
* This can interfer with later procsesing. This is a helper function to remove the at mention.
* This can interfere with later processing. This is a helper function to remove the at mention.
*
* ```JavaScript
* const updatedText = TurnContext.removeRecipientMention(context.request);
Expand Down
6 changes: 3 additions & 3 deletions libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export class OAuthPrompt extends Dialog {
// Ensure prompts have input hint set
const o: Partial<PromptOptions> = {...options};
if (o.prompt && typeof o.prompt === 'object' && typeof o.prompt.inputHint !== 'string') {
o.prompt.inputHint = InputHints.ExpectingInput;
o.prompt.inputHint = InputHints.AcceptingInput;
}
if (o.retryPrompt && typeof o.retryPrompt === 'object' && typeof o.retryPrompt.inputHint !== 'string') {
o.retryPrompt.inputHint = InputHints.ExpectingInput;
o.retryPrompt.inputHint = InputHints.AcceptingInput;
}

// Initialize prompt state
Expand Down Expand Up @@ -242,7 +242,7 @@ export class OAuthPrompt extends Dialog {

// Initialize outgoing message
const msg: Partial<Activity> =
typeof prompt === 'object' ? {...prompt} : MessageFactory.text(prompt, undefined, InputHints.ExpectingInput);
typeof prompt === 'object' ? {...prompt} : MessageFactory.text(prompt, undefined, InputHints.AcceptingInput);
if (!Array.isArray(msg.attachments)) { msg.attachments = []; }

// Add login card as needed
Expand Down
3 changes: 2 additions & 1 deletion libraries/botbuilder-dialogs/tests/oauthPrompt.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActivityTypes, ConversationState, MemoryStorage, TestAdapter, CardFactory } = require('botbuilder-core');
const { ActivityTypes, CardFactory, ConversationState, InputHints, MemoryStorage, TestAdapter } = require('botbuilder-core');
const { OAuthPrompt, OAuthPromptSettings, DialogSet, DialogTurnStatus, ListStyle } = require('../');
const assert = require('assert');

Expand Down Expand Up @@ -47,6 +47,7 @@ describe('OAuthPrompt', function () {
.assertReply(activity => {
assert(activity.attachments.length === 1);
assert(activity.attachments[0].contentType === CardFactory.contentTypes.oauthCard);
assert(activity.inputHint === InputHints.AcceptingInput);

// send a mock EventActivity back to the bot with the token
adapter.addUserToken(connectionName, activity.channelId, activity.recipient.id, token);
Expand Down

0 comments on commit 9e285ac

Please sign in to comment.