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

Bump to Adaptive Cards 1.0.0 #899

Merged
merged 4 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed
- Update dependencies
- [`[email protected]-beta9`](https://www.npmjs.com/package/adaptivecards), in [PR #849](https://github.com/Microsoft/BotFramework-WebChat/pull/849)
- [`[email protected]`](https://www.npmjs.com/package/adaptivecards), in [PR #849](https://github.com/Microsoft/BotFramework-WebChat/pull/849) and [PR #XXX](https://github.com/Microsoft/BotFramework-WebChat/pull/XXX)
- [`[email protected]`](https://www.npmjs.com/package/http-server), in [PR #829](https://github.com/Microsoft/BotFramework-WebChat/pull/829)
- [`[email protected]`](https://www.npmjs.com/package/microsoft-speech-browser-sdk), in [PR #888](https://github.com/Microsoft/BotFramework-WebChat/pull/888)
- [`[email protected]`](https://www.npmjs.com/package/nightmare), in [PR #887](https://github.com/Microsoft/BotFramework-WebChat/pull/887)
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"author": "Microsoft Corp",
"license": "MIT",
"dependencies": {
"adaptivecards": "1.0.0-beta9",
"adaptivecards": "1.0.0",
"botframework-directlinejs": "0.9.13",
"core-js": "2.4.1",
"markdown-it": "8.3.1",
Expand Down
40 changes: 28 additions & 12 deletions src/AdaptiveCardContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { findDOMNode } from 'react-dom';
import { connect } from 'react-redux';
import { Action, AdaptiveCard, HostConfig, IValidationError, OpenUrlAction, SubmitAction } from 'adaptivecards';
import { IActionBase, IActionShowCard, IAdaptiveCard } from 'adaptivecards/lib/schema';
import { IAction, IAdaptiveCard, IOpenUrlAction, IShowCardAction, ISubmitAction } from 'adaptivecards/lib/schema';
import { CardAction } from 'botframework-directlinejs/built/directLine';
import { classList, IDoCardAction } from './Chat';
import { AjaxResponse, AjaxRequest } from 'rxjs/observable/dom/AjaxObservable';
Expand Down Expand Up @@ -31,18 +31,34 @@ export interface BotFrameworkCardAction extends CardAction {
const defaultHostConfig = new HostConfig(adaptivecardsHostConfig);

function cardWithoutHttpActions(card: IAdaptiveCard) {
if (!card.actions) return card;
const actions: IActionBase[] = [];
card.actions.forEach(action => {
//filter out http action buttons
if (action.type === 'Action.Http') return;
if (action.type === 'Action.ShowCard') {
const showCardAction = action as IActionShowCard;
showCardAction.card = cardWithoutHttpActions(showCardAction.card);
if (!card.actions) {
return card;
}

const nextActions: (IOpenUrlAction | IShowCardAction | ISubmitAction)[] = card.actions.reduce((nextActions, action) => {
// Filter out HTTP action buttons
switch (action.type) {
case 'Action.Submit':
break;

case 'Action.ShowCard':
nextActions.push({
...action,
card: cardWithoutHttpActions(action.card)
});

break;

default:
nextActions.push(action);

break;
}
actions.push(action);
});
return { ...card, actions };

return nextActions;
}, []);

return { ...card, nextActions };
}

class AdaptiveCardContainer extends React.Component<Props, State> {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"noImplicitAny": true,
"outDir": "./built/",
"target": "es5",
"skipLibCheck": true,
"sourceMap": true,
"inlineSources": true
},
Expand Down