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

Merge production Web Chat #623

Merged
merged 7 commits into from
May 31, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"packages/app/client",
"packages/app/main",
"packages/app/shared",
"packages/custom-botframework-webchat",
"packages/custom-botframework-directlinejs",
"packages/emulator/cli",
"packages/emulator/core",
"packages/sdk/client",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/client/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var gulp = require('gulp');
// TODO: We should expose CSS programmatically in Web Chat
gulp.task('copy:webchat:css', function () {
return gulp
.src(require.resolve('@bfemulator/custom-botframework-webchat/botchat.css'))
.src(require.resolve('botframework-webchat/botchat.css'))
.pipe(gulp.dest('./public/external/css'));
});

Expand Down
2 changes: 1 addition & 1 deletion packages/app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
},
"dependencies": {
"@bfemulator/app-shared": "^1.0.0",
"@bfemulator/custom-botframework-webchat": "^0.11.5-c0",
"@bfemulator/sdk-client": "^1.0.0",
"@bfemulator/sdk-shared": "^1.0.0",
"@bfemulator/ui-react": "^1.0.0",
Expand All @@ -87,6 +86,7 @@
"@uifabric/styling": "^5.20.0",
"@uifabric/utilities": "^5.19.0",
"base64url": "^2.0.0",
"botframework-webchat": "^0.13.1",
"classnames": "^2.2.5",
"glamor": "^2.20.40",
"jsonpath": "^1.0.0",
Expand Down
16 changes: 14 additions & 2 deletions packages/app/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ export function registerCommands() {
store.dispatch(ChatActions.newDocument(
documentId,
'livechat',
{ endpointId: endpoint.id }
{
botId: 'bot',
endpointId: endpoint.id,
userId: 'default-user'
}
));

store.dispatch(EditorActions.open(
Expand All @@ -180,7 +184,15 @@ export function registerCommands() {
CommandRegistry.registerCommand('transcript:open', (filename: string, additionalData?: object) => {
const tabGroup = getTabGroupForDocument(filename);
if (!tabGroup) {
store.dispatch(ChatActions.newDocument(filename, 'transcript', additionalData));
store.dispatch(ChatActions.newDocument(
filename,
'transcript',
{
...additionalData,
botId: 'bot',
userId: 'default-user'
}
));
}
store.dispatch(EditorActions.open(
Constants.CONTENT_TYPE_TRANSCRIPT,
Expand Down
2 changes: 0 additions & 2 deletions packages/app/client/src/data/action/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
//

import { LogEntry } from '@bfemulator/app-shared';
import { createStore as createWebChatStore } from '@bfemulator/custom-botframework-webchat';

export const NEW_CHAT_DOCUMENT = 'CHAT/DOCUMENT/NEW';
export const OPEN_CHAT_DOCUMENT = 'CHAT/DOCUMENT/OPEN';
Expand Down Expand Up @@ -148,7 +147,6 @@ export function newDocument(documentId: string, mode: ChatMode, additionalData?:
mode,
documentId,
conversationId: null,
webChatStore: createWebChatStore(),
directLine: null,
log: {
entries: []
Expand Down
1 change: 0 additions & 1 deletion packages/app/client/src/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@bfemulator/app-shared';
import '@bfemulator/custom-botframework-webchat';
import '@bfemulator/ui-react';
import '@bfemulator/sdk-shared';
import '@bfemulator/sdk-client';
32 changes: 21 additions & 11 deletions packages/app/client/src/ui/editor/emulator/emulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import * as BotChat from '@bfemulator/custom-botframework-webchat';
import * as BotChat from 'botframework-webchat';

import { uniqueId } from '@bfemulator/sdk-shared';
import { Colors, Splitter } from '@bfemulator/ui-react';
Expand Down Expand Up @@ -138,20 +138,20 @@ const PRESENTATION_CSS = css({
export type EmulatorMode = 'transcript' | 'livechat';

interface EmulatorProps {
clearLog?: (documentId: string) => void;
conversationId?: string;
dirty?: boolean;
document?: any;
documentId?: string;
enablePresentationMode?: (enabled: boolean) => void;
endpointId?: string;
endpointService?: IEndpointService;
mode?: EmulatorMode;
newConversation?: (documentId: string, options: any) => void;
pingDocument?: (documentId: string) => void;
pingId?: number;
presentationModeEnabled?: boolean;
pingDocument?: (documentId: string) => void;
enablePresentationMode?: (enabled: boolean) => void;
setInspectorObjects?: (documentId: string, objects: any) => void;
clearLog?: (documentId: string) => void;
newConversation?: (documentId: string, options: any) => void;
updateDocument?: (documentId: string, updatedValues: any) => void;
}

Expand Down Expand Up @@ -234,16 +234,27 @@ class EmulatorComponent extends React.Component<EmulatorProps, {}> {
try {
// transcript was deep linked via protocol,
// and should just be fed its own activities attached to the document
await CommandServiceImpl
.remoteCall('emulator:feed-transcript:deep-link', conversation.conversationId, props.document.activities);
await CommandServiceImpl.remoteCall(
'emulator:feed-transcript:deep-link',
conversation.conversationId,
props.document.botId,
props.document.userId,
props.document.activities
);
} catch (err) {
throw new Error(`Error while feeding deep-linked transcript to conversation: ${err}`);
}
} else {
try {
// the transcript is on disk, so its activities need to be read on the main side and fed in
const fileInfo: { fileName: string, filePath: string } = await CommandServiceImpl
.remoteCall('emulator:feed-transcript:disk', conversation.conversationId, props.document.documentId);
const fileInfo: { fileName: string, filePath: string } = await CommandServiceImpl.remoteCall(
'emulator:feed-transcript:disk',
conversation.conversationId,
props.document.botId,
props.document.userId,
props.document.documentId
);

this.props.updateDocument(this.props.documentId, { fileName: fileInfo.fileName });
} catch (err) {
throw new Error(`Error while feeding transcript on disk to conversation: ${err}`);
Expand All @@ -257,7 +268,6 @@ class EmulatorComponent extends React.Component<EmulatorProps, {}> {
}

initConversation(props: any, options: any, selectedActivity$: any, subscription: any) {
const webChatStore = BotChat.createStore();
const encodedOptions = encode(JSON.stringify(options));

// TODO: We need to use encoded token because we need to pass both endpoint ID and conversation ID
Expand All @@ -270,7 +280,7 @@ class EmulatorComponent extends React.Component<EmulatorProps, {}> {

this.props.newConversation(props.documentId, {
conversationId: options.conversationId,
webChatStore,
// webChatStore,
directLine,
selectedActivity$,
subscription
Expand Down