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

Move Adaptive Cards to bundle #1936

Merged
merged 3 commits into from
May 6, 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 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 [`blobxfer@1.7.1`](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
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