Skip to content

Commit

Permalink
Move Adaptive Cards to bundle (#1936)
Browse files Browse the repository at this point in the history
* Move Adaptive Cards to bundle

* Update CHANGELOG.md
  • Loading branch information
Corina authored May 6, 2019
1 parent 2c5b7aa commit 2948e96
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 96 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix [#1945](https://github.com/Microsoft/BotFramework-WebChat/issues/1945). QA fixes for 4.4, by [@corinagum](https://github.com/johndoe) in PR [#1950](https://github.com/Microsoft/BotFramework-WebChat/pull/1950)
- Fix [#1947](https://github.com/Microsoft/BotFramework-WebChat/issues/1947). Fix scrollbar in suggested action should be hidden in Firefox, remove gaps, and use style set for customizing `react-film`, by [@compulim](https://github.com/compulim) in PR [#1953](https://github.com/Microsoft/BotFramework-WebChat/pull/1953)
- Fix [#1948](https://github.com/Microsoft/BotFramework-WebChat/issues/1948). Fixed sample 17.chat-send-history to work with Firefox and Edge, by [@tdurnford](https://github.com/tdurnford) in PR [#1956](https://github.com/Microsoft/BotFramework-WebChat/pull/1956)
- Fix [#1304](https://github.com/Microsoft/BotFramework-WebChat/issues/1304). Move Adaptive Cards from component to bundle, by [@compulim](https://github.com/compulim) and [@corinagum](https://github.com/corinagum) in PR [#1936](https://github.com/Microsoft/BotFramework-WebChat/pull/1936)

### Changed
- Deployment: Bumps to [`[email protected]`](https://github.com/azure/blobxfer/), by [@compulim](https://github.com/compulim), in PR [#1897](https://github.com/Microsoft/BotFramework-WebChat/pull/1897)
Expand Down
1 change: 1 addition & 0 deletions __tests__/cardActionMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ test('card action "signin"', async () => {
await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('oauth', { waitForSend: true });

await driver.wait(minNumActivitiesShown(2), timeouts.directLine);
const openUrlButton = await driver.findElement(By.css('[role="log"] ul > li button'));

await openUrlButton.click();
Expand Down
1 change: 1 addition & 0 deletions packages/bundle/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}
},
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime",
"babel-plugin-version-transform"
Expand Down
46 changes: 46 additions & 0 deletions packages/bundle/package-lock.json

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

1 change: 1 addition & 0 deletions packages/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.3",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/bundle/src/FullReactWebChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import * as adaptiveCards from 'adaptivecards';
import memoize from 'memoize-one';
import React from 'react';

import BasicWebChat, { createAdaptiveCardsAttachmentMiddleware, concatMiddleware } from 'botframework-webchat-component';
import BasicWebChat, { concatMiddleware } from 'botframework-webchat-component';

import createAdaptiveCardsAttachmentMiddleware from './adaptiveCards/createAdaptiveCardMiddleware';

import renderMarkdown from './renderMarkdown';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function addCardAction(cardAction: CardAction, includesOAuthButtons?: boolean) {
}
}

export class AdaptiveCardBuilder {
export default class AdaptiveCardBuilder {
card: AdaptiveCard;
container: Container;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { HostConfig } from 'adaptivecards';
import React from 'react';

import { localize } from '../Localization/Localize';
import connectToWebChat from '../connectToWebChat';
import ErrorBox from '../ErrorBox';
import getTabIndex from '../Utils/TypeFocusSink/getTabIndex';
import { Components, connectToWebChat, getTabIndex, localize } from 'botframework-webchat-component';

const { ErrorBox } = Components;

function isPlainObject(obj) {
return obj.__proto__ === Object.prototype;
}

class AdaptiveCardRenderer extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -97,9 +101,12 @@ class AdaptiveCardRenderer extends React.PureComponent {
}
};

adaptiveCard.hostConfig = adaptiveCardHostConfig;
adaptiveCard.onExecuteAction = this.handleExecuteAction;

if (adaptiveCardHostConfig) {
adaptiveCard.hostConfig = isPlainObject(adaptiveCardHostConfig) ? new HostConfig(adaptiveCardHostConfig) : adaptiveCardHostConfig;
}

const errors = adaptiveCard.validate();

if (errors.length) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import { Components, connectToWebChat } from 'botframework-webchat-component';
import { AdaptiveCardBuilder } from './AdaptiveCardBuilder';
import CommonCard from './CommonCard';
import connectToWebChat from '../connectToWebChat';
import ImageContent from './ImageContent';
import VideoContent from './VideoContent';

const { ImageContent, VideoContent } = Components;

class AnimationCardAttachment extends React.Component {
constructor(props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import AudioContent from './AudioContent';
import { Components, connectToWebChat } from 'botframework-webchat-component';
import CommonCard from './CommonCard';
import connectToWebChat from '../connectToWebChat';

const { AudioContent } = Components;

export default connectToWebChat(
({ styleSet }) => ({ styleSet })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import AdaptiveCardBuilder from './AdaptiveCardBuilder';
import AdaptiveCardRenderer from './AdaptiveCardRenderer';

export default class extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import AdaptiveCardBuilder from './AdaptiveCardBuilder';
import AdaptiveCardRenderer from './AdaptiveCardRenderer';

export default class extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import AdaptiveCardBuilder from './AdaptiveCardBuilder';
import AdaptiveCardRenderer from './AdaptiveCardRenderer';

export default class extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import { localize } from '../Localization/Localize';
import { connectToWebChat, localize } from 'botframework-webchat-component';
import AdaptiveCardBuilder from './AdaptiveCardBuilder';
import AdaptiveCardRenderer from './AdaptiveCardRenderer';
import connectToWebChat from '../connectToWebChat';

function nullOrUndefined(obj) {
return obj === null || typeof obj === 'undefined';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import CommonCard from './CommonCard';
import connectToWebChat from '../connectToWebChat';
import { connectToWebChat } from 'botframework-webchat-component';

export default connectToWebChat(
({ styleSet }) => ({ styleSet })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import memoize from 'memoize-one';
import React from 'react';

import { AdaptiveCardBuilder } from '../Utils/AdaptiveCardBuilder';
import AdaptiveCardBuilder from './AdaptiveCardBuilder';
import AdaptiveCardRenderer from './AdaptiveCardRenderer';

export default class extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import { Components, connectToWebChat } from 'botframework-webchat-component';
import CommonCard from './CommonCard';
import connectToWebChat from '../connectToWebChat';
import VideoContent from './VideoContent';

const { VideoContent } = Components;

export default connectToWebChat(
({ styleSet }) => ({ styleSet })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';

import AdaptiveCardAttachment from '../../Attachment/AdaptiveCardAttachment';
import AnimationCardAttachment from '../../Attachment/AnimationCardAttachment';
import AudioCardAttachment from '../../Attachment/AudioCardAttachment';
import HeroCardAttachment from '../../Attachment/HeroCardAttachment';
import OAuthCardAttachment from '../../Attachment/OAuthCardAttachment';
import ReceiptCardAttachment from '../../Attachment/ReceiptCardAttachment';
import SignInCardAttachment from '../../Attachment/SignInCardAttachment';
import ThumbnailCardAttachment from '../../Attachment/ThumbnailCardAttachment';
import VideoCardAttachment from '../../Attachment/VideoCardAttachment';
import AdaptiveCardAttachment from './Attachment/AdaptiveCardAttachment';
import AnimationCardAttachment from './Attachment/AnimationCardAttachment';
import AudioCardAttachment from './Attachment/AudioCardAttachment';
import HeroCardAttachment from './Attachment/HeroCardAttachment';
import OAuthCardAttachment from './Attachment/OAuthCardAttachment';
import ReceiptCardAttachment from './Attachment/ReceiptCardAttachment';
import SignInCardAttachment from './Attachment/SignInCardAttachment';
import ThumbnailCardAttachment from './Attachment/ThumbnailCardAttachment';
import VideoCardAttachment from './Attachment/VideoCardAttachment';

// TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
export default function (props) {
Expand Down
1 change: 0 additions & 1 deletion packages/component/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
}
},
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"babel-plugin-version-transform"
],
Expand Down
57 changes: 0 additions & 57 deletions packages/component/package-lock.json

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

2 changes: 0 additions & 2 deletions packages/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/preset-env": "^7.4.3",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
Expand All @@ -43,7 +42,6 @@
"typescript": "^3.1.6"
},
"dependencies": {
"adaptivecards": "~1.1.3",
"botframework-webchat-core": "^0.0.0-0",
"bytes": "^3.0.0",
"classnames": "^2.2.6",
Expand Down
1 change: 1 addition & 0 deletions packages/component/src/Composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class Composer extends React.Component {
// If we let it thru, the code below become simplified and the user can plug in whatever they want for context, via Composer.props
{
activityRenderer,
// TODO: [P3] We should move adaptiveCardHostConfig to bundle
adaptiveCardHostConfig: adaptiveCardHostConfig || defaultAdaptiveCardHostConfig(this.props.styleOptions),
attachmentRenderer,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// TODO: [P4] We are moving attachments related to Adaptive Cards out of "component"
// Later, we will rewrite these attachments without Adaptive Cards
// We are leaving the CSS here as-is for now

export default function () {
return {
display: 'flex',
Expand Down
4 changes: 4 additions & 0 deletions packages/component/src/Styles/StyleSet/AudioCardAttachment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// TODO: [P4] We are moving attachments related to Adaptive Cards out of "component"
// Later, we will rewrite these attachments without Adaptive Cards
// We are leaving the CSS here as-is for now

export default function ({
paddingRegular
}) {
Expand Down
Loading

0 comments on commit 2948e96

Please sign in to comment.