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

Adaptive Cards #471

Merged
merged 53 commits into from
Jun 20, 2017
Merged

Adaptive Cards #471

merged 53 commits into from
Jun 20, 2017

Conversation

danmarshall
Copy link
Contributor

@danmarshall danmarshall commented May 19, 2017

** Please do not merge this PR - this is for review only, until the checklist has been completed **

Must haves:

  • The Adaptive Card tool ac-scss2json needs to be published
  • adaptivecard-hostconfig.js Documentation
  • Add AdaptiveCards HostConfig into CSS content so that it is not another external file
  • Try / catch when Adaptive Card fails, what to display?
  • Remove Action.HTTP buttons
  • Show friendly error card
  • Style injection sample
  • Fix webpack warnings

Stretch goals (if not checked these should become issues after the PR):

  • Use more variables in adaptive-card-config.scss
  • Add a watcher on SCSS to call ac-scss2json
  • Use Adaptive Cards for rendering existing cards
    • Hero Card
    • Thumbnail card
    • Animation card
    • Audio card
    • Video card
    • Receipt Card
    • Signin Card
  • Pagination of buttons when there is more than 5
  • scroll to bottom/call onImageLoad on showPopupCard event / when card is resized
  • Localize error card

@nwhitmont
Copy link

@danmarshall What is the current timeline for Adaptive Cards full support in Web Chat?

@danmarshall
Copy link
Contributor Author

A few more days of core development to get code complete, another few days to get documentation and tests in place.

Copy link
Member

@GeekTrainer GeekTrainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my first pass. I reserve the right to make more passes. :-)

}

AdaptiveCards.AdaptiveCard.onExecuteAction = (action: AdaptiveCards.ExternalAction) => {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup the extra carriage returns through all of the files

}

} else if (action instanceof AdaptiveCards.HttpAction) {
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not going to support HTTP Actions to start we should simply ignore the buttons, UI, etc.

return content.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

public configFromJsonInCss() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove this now as per our last conversation.

@@ -170,34 +169,44 @@ export const AttachmentView = (props: {
case "application/vnd.microsoft.card.hero":
if (!attachment.content)
return null;

const heroCardBuilder = new CardBuilder.AdaptiveCardBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create helper methods to create the various card types for readability.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, maybe create derived classes from AdatpiveCardBuilder for the types? I'm not sure which would look better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had this in a past revision. Made it less maintainable because we have this big switch statement here which consolidates all the types, and didn't want to have a structure like that in 2 places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that I'm convinced. :-) But I'm not going to make this a showstopper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider that this file used to have HTML for all cards.

danmarshall and others added 11 commits June 12, 2017 17:05
* edits from feedback

* moved Action.Http
Enable adaptive cards tests
* receipt card test

Adding support for receipt card

* Recept Card in version 0.5

Recept Card in version 0.5

* load adaptivecards hostconfig from json file, webpacked into bundle (#495)

* remove Action.Http from cards

* corrected alpha channel colors

* add AdaptiveCards.md

* rename to Bot Builder SDK

* change SDK to Bot Builder SDK

* fix typos

* elsewhere

* lowercase titles

* added 'it'

* separates to separate

* handle undefined

* imBack for string

* Small language tweaks (#503)

* Adaptivecards (#505)

* edits from feedback

* moved Action.Http
* Adaptive receipt (#2)

* receipt card test

Adding support for receipt card

* Recept Card in version 0.5

Recept Card in version 0.5

* load adaptivecards hostconfig from json file, webpacked into bundle (#495)

* remove Action.Http from cards

* corrected alpha channel colors

* add AdaptiveCards.md

* rename to Bot Builder SDK

* change SDK to Bot Builder SDK

* fix typos

* elsewhere

* lowercase titles

* added 'it'

* separates to separate

* handle undefined

* imBack for string

* Small language tweaks (#503)

* Adaptivecards (#505)

* edits from feedback

* moved Action.Http

* readme.md (#491)

updated version of readme.md

* edited test/README.md (#510)

* edited test/README.md

* Update README.md

* error handling

Adding SVG to represent the error occures in the JSON parsing or
adaptive card missing properties.

* Revert "error handling"

This reverts commit 92a4d27.

* error handling for ac

1. using this.forceUPdate()
2. svg error message

* minior fixes

* use state for error rendering

* change forceUpdate() to setState()

change forceUpdate() to setState()

* merge

* fix minor bug in ac tests

* add style to error

* latest AdaptiveCards lib

* remove 'lighter' text

* reformatted

* explicit if statement

* catch hyperlink clicks
Copy link
Member

@GeekTrainer GeekTrainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core of the code looks just fine to me. There is some cleanup that needs to be done, though.

AdaptiveCards.md Outdated
@@ -0,0 +1,91 @@
# Adaptive Cards in Microsoft Bot Framework WebChat

WebChat now supports [Adaptive Cards](http://adaptivecards.io/), which you can use to achieve a greater level of rich display and interactivity in your bot's UX. Adaptive Cards are a general-purpose technology, which may be used in a wide variety of applications, but you should be aware of some constraints when using them within the WebChat environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flesh this out a touch more to address the fact that all channels will have limitations WRT Adaptive Cards, and not something that's unique to WebChat.

AdaptiveCards.md Outdated

## Style customization


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One too many carriage returns.


function cardWithoutHttpActions(card: AdaptiveCardSchema.ICard) {
if (!card.actions) return card;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please cleanup the extra carriage returns in this file.

if (!this.props.onClick) return;

//do not allow form elements to trigger a parent click event
switch ((e.target as HTMLElement).tagName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it always be capital letters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

adaptiveCard.parse(cardWithoutHttpActions(this.props.card));
const errors = adaptiveCard.validate();

if (errors.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can errors be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will always return an array

});

attachment.content.items && attachment.content.items.map((item, i) => {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carriage return cleanup for this file, please

@@ -170,34 +169,44 @@ export const AttachmentView = (props: {
case "application/vnd.microsoft.card.hero":
if (!attachment.content)
return null;

const heroCardBuilder = new CardBuilder.AdaptiveCardBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that I'm convinced. :-) But I'm not going to make this a showstopper.

margin-bottom: 20px;
text-align: inherit;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

White space cleanup

})
if (queue) {
if (queue.length > 0) {
let msg = queue.shift();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be constants?

@@ -34,7 +35,16 @@ module.exports = {
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please cleanup the formatting here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@danmarshall danmarshall merged commit c92422b into master Jun 20, 2017
@fbessez
Copy link

fbessez commented Jun 22, 2017

It seems as if this was merged, but I am still getting this issue microsoft/AdaptiveCards#432 -- is there something that I should do?

@compulim compulim deleted the adaptivecards branch June 18, 2018 21:43
compulim pushed a commit to compulim/BotFramework-WebChat that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants