Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint Node using-cards #1422

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/javascript_nodejs/06.using-cards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ A key to good bot design is to send interactive media, such as Rich Cards. There
When [designing the user experience][27] developers should consider adding visual elements such as Rich Cards.

## Deploy the bot to Azure

To learn more about deploying a bot to Azure, see [Deploy your bot to Azure][40] for a complete list of deployment instructions.

## Further reading
Expand Down
6 changes: 3 additions & 3 deletions samples/javascript_nodejs/06.using-cards/bots/richCardsBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class RichCardsBot extends DialogBot {
const membersAdded = context.activity.membersAdded;
for (let cnt = 0; cnt < membersAdded.length; cnt++) {
if (membersAdded[cnt].id !== context.activity.recipient.id) {
const reply = MessageFactory.text('Welcome to CardBot.'
+ ' This bot will show you different types of Rich Cards.'
+ ' Please type anything to get started.');
const reply = MessageFactory.text('Welcome to CardBot. ' +
'This bot will show you different types of Rich Cards. ' +
'Please type anything to get started.');
await context.sendActivity(reply);
}
}
Expand Down
96 changes: 48 additions & 48 deletions samples/javascript_nodejs/06.using-cards/dialogs/mainDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

const { AttachmentLayoutTypes, CardFactory } = require('botbuilder');
const { ChoicePrompt, ComponentDialog, DialogSet, DialogTurnStatus, ListStyle, WaterfallDialog, WaterfallStepContext } = require('botbuilder-dialogs');
const { ChoicePrompt, ComponentDialog, DialogSet, DialogTurnStatus, WaterfallDialog, WaterfallStepContext } = require('botbuilder-dialogs');
const AdaptiveCard = require('../resources/adaptiveCard.json');

const MAIN_WATERFALL_DIALOG = 'mainWaterfallDialog';
Expand All @@ -21,9 +21,9 @@ class MainDialog extends ComponentDialog {
// Define the main dialog and its related components.
this.addDialog(new ChoicePrompt('cardPrompt'));
this.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [
this.choiceCardStep.bind(this),
this.showCardStep.bind(this)
]));
this.choiceCardStep.bind(this),
this.showCardStep.bind(this)
]));

// The initial child Dialog to run.
this.initialDialogId = MAIN_WATERFALL_DIALOG;
Expand All @@ -50,10 +50,10 @@ class MainDialog extends ComponentDialog {
* 1. Prompts the user if the user is not in the middle of a dialog.
* 2. Re-prompts the user when an invalid input is received.
*
* @param {WaterfallStepContext} stepContext
* @param {WaterfallStepContext} stepContext
*/
async choiceCardStep(stepContext) {
this.logger.log("MainDialog.choiceCardStep");
this.logger.log('MainDialog.choiceCardStep');

// Create the PromptOptions which contain the prompt and re-prompt messages.
// PromptOptions also contains the list of choices available to the user.
Expand All @@ -70,55 +70,55 @@ class MainDialog extends ComponentDialog {
/**
* Send a Rich Card response to the user based on their choice.
* This method is only called when a valid prompt response is parsed from the user's response to the ChoicePrompt.
* @param {WaterfallStepContext} stepContext
* @param {WaterfallStepContext} stepContext
*/
async showCardStep(stepContext) {
this.logger.log("MainDialog.showCardStep");
this.logger.log('MainDialog.showCardStep');

switch (stepContext.result.value) {
case 'Adaptive Card':
await stepContext.context.sendActivity({ attachments: [this.createAdaptiveCard()] });
break;
case 'Animation Card':
await stepContext.context.sendActivity({ attachments: [this.createAnimationCard()] });
break;
case 'Audio Card':
await stepContext.context.sendActivity({ attachments: [this.createAudioCard()] });
break;
case 'Hero Card':
await stepContext.context.sendActivity({ attachments: [this.createHeroCard()] });
break;
case 'Receipt Card':
await stepContext.context.sendActivity({ attachments: [this.createReceiptCard()] });
break;
case 'Signin Card':
await stepContext.context.sendActivity({ attachments: [this.createSignInCard()] });
break;
case 'Thumbnail Card':
await stepContext.context.sendActivity({ attachments: [this.createThumbnailCard()] });
break;
case 'Video Card':
await stepContext.context.sendActivity({ attachments: [this.createVideoCard()] });
break;
default:
await stepContext.context.sendActivity({
attachments: [
this.createAdaptiveCard(),
this.createAnimationCard(),
this.createAudioCard(),
this.createHeroCard(),
this.createReceiptCard(),
this.createSignInCard(),
this.createThumbnailCard(),
this.createVideoCard()
],
attachmentLayout: AttachmentLayoutTypes.Carousel
});
break;
case 'Adaptive Card':
await stepContext.context.sendActivity({ attachments: [this.createAdaptiveCard()] });
break;
case 'Animation Card':
await stepContext.context.sendActivity({ attachments: [this.createAnimationCard()] });
break;
case 'Audio Card':
await stepContext.context.sendActivity({ attachments: [this.createAudioCard()] });
break;
case 'Hero Card':
await stepContext.context.sendActivity({ attachments: [this.createHeroCard()] });
break;
case 'Receipt Card':
await stepContext.context.sendActivity({ attachments: [this.createReceiptCard()] });
break;
case 'Signin Card':
await stepContext.context.sendActivity({ attachments: [this.createSignInCard()] });
break;
case 'Thumbnail Card':
await stepContext.context.sendActivity({ attachments: [this.createThumbnailCard()] });
break;
case 'Video Card':
await stepContext.context.sendActivity({ attachments: [this.createVideoCard()] });
break;
default:
await stepContext.context.sendActivity({
attachments: [
this.createAdaptiveCard(),
this.createAnimationCard(),
this.createAudioCard(),
this.createHeroCard(),
this.createReceiptCard(),
this.createSignInCard(),
this.createThumbnailCard(),
this.createVideoCard()
],
attachmentLayout: AttachmentLayoutTypes.Carousel
});
break;
}

// Give the user instructions about what to do next
await stepContext.context.sendActivity("Type anything to see another card.");
await stepContext.context.sendActivity('Type anything to see another card.');

return await stepContext.endDialog();
}
Expand Down
6 changes: 3 additions & 3 deletions samples/javascript_nodejs/06.using-cards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ adapter.onTurnError = async (context, error) => {
// This check writes out errors to console log
// NOTE: In production environment, you should consider logging this to Azure
// application insights.
console.error(`\n [onTurnError]: ${error}`);
console.error(`\n [onTurnError]: ${ error }`);
// Send a message to the user
await context.sendActivity(`Oops. Something went wrong!`);
// Clear out state
Expand All @@ -55,8 +55,8 @@ const bot = new RichCardsBot(conversationState, userState, dialog, logger);

// Create HTTP server.
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log(`\n${server.name} listening to ${server.url}.`);
server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log(`\n${ server.name } listening to ${ server.url }.`);
console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator.`);
});

Expand Down