diff --git a/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponent.tsx b/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponent.tsx index 190bda4e0..a5ca1dcba 100644 --- a/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponent.tsx +++ b/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponent.tsx @@ -4,13 +4,19 @@ import ReactWebChat, { createDirectLine } from "botframework-webchat"; export interface SupportPaneComponentProps { directLineToken: string; + userToken: string; + subId: string; + rg:string; + accName:string; } export class SupportPaneComponent extends React.Component { private readonly userId: string = _.uniqueId(); + constructor(props: SupportPaneComponentProps) { super(props); + } public render(): JSX.Element { @@ -18,7 +24,24 @@ export class SupportPaneComponent extends React.Component; + + const directLine = createDirectLine({ token: this.props.directLineToken }); + const dl = + { + ...directLine, + postActivity: (activity: any) => { + // Add whatever needs to be added. + activity.channelData.token = this.props.userToken; + activity.channelData.subId = this.props.subId; + activity.channelData.rg = this.props.rg; + activity.channelData.accName = this.props.accName; + + //activity.channelData.MyKey = "hello"; + return directLine.postActivity(activity) + } + } + + return ; + } } diff --git a/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponentAdapter.tsx b/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponentAdapter.tsx index 5b5aac94c..3407ba97a 100644 --- a/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponentAdapter.tsx +++ b/src/Explorer/Controls/SupportPaneComponent/SupportPaneComponentAdapter.tsx @@ -3,26 +3,59 @@ import * as React from "react"; import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; import Explorer from "../../Explorer"; import { SupportPaneComponent } from "./SupportPaneComponent"; +import { userContext } from "../../../UserContext"; export interface SupportPaneComponentParams { directLineAccessToken: string; + userToken: string; + subId: string; + rg: string; + accName: string; } export class SupportPaneComponentAdapter implements ReactAdapter { public parameters: ko.Observable; constructor(private container: Explorer) { + this.parameters = ko.observable({ - directLineAccessToken: this.container.conversationToken() + directLineAccessToken: this.container.conversationToken(), + userToken: this.container.userToken(), + subId: this.container.subId(), + rg: this.container.rg(), + accName: this.container.accName() }); this.container.conversationToken.subscribe(accessToken => { this.parameters().directLineAccessToken = accessToken; this.forceRender(); }); + this.container.userToken.subscribe(userToken => { + this.parameters().userToken = userToken; + this.forceRender(); + }); + this.container.subId.subscribe(subId => { + this.parameters().subId = subId; + this.forceRender(); + }); + this.container.rg.subscribe(rg => { + this.parameters().rg = rg; + this.forceRender(); + }); + this.container.accName.subscribe(accName => { + this.parameters().accName = accName; + this.forceRender(); + }); + } public renderComponent(): JSX.Element { - return ; + return ; } public forceRender(): void { diff --git a/src/Explorer/Explorer.ts b/src/Explorer/Explorer.ts index 788000516..dc7a1409b 100644 --- a/src/Explorer/Explorer.ts +++ b/src/Explorer/Explorer.ts @@ -177,6 +177,10 @@ export default class Explorer { public isResourceTokenCollectionNodeSelected: ko.Computed; private resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken; public conversationToken: ko.Observable; + public userToken: ko.Observable; + public subId: ko.Observable; + public rg: ko.Observable; + public accName: ko.Observable; // Tabs public isTabsContentExpanded: ko.Observable; @@ -329,6 +333,10 @@ export default class Explorer { this.hasStorageAnalyticsAfecFeature.subscribe((enabled: boolean) => this.refreshCommandBarButtons()); this.isSynapseLinkUpdating = ko.observable(false); this.conversationToken = ko.observable(); + this.userToken = ko.observable(); + this.subId = ko.observable(); + this.rg = ko.observable(); + this.accName = ko.observable(); this.isAccountReady.subscribe(async (isAccountReady: boolean) => { if (isAccountReady) { this.isAuthWithResourceToken() ? this.refreshDatabaseForResourceToken() : this.refreshAllDatabases(true); @@ -1625,7 +1633,6 @@ export default class Explorer { const tokenResponse: { conversationId: string; token: string; expires_in: number } = await response.json(); this.conversationToken(tokenResponse?.token); - if (tokenResponse?.expires_in) { setTimeout(() => this.generateConversationToken(), (tokenResponse?.expires_in - 1000) * 1000); } @@ -1998,6 +2005,11 @@ export default class Explorer { resourceGroup: inputs.resourceGroup, subscriptionId: inputs.subscriptionId }); + + this.userToken(userContext.authorizationToken); + this.subId(userContext.subscriptionId); + this.rg(userContext.resourceGroup); + this.accName(userContext.databaseAccount.name); TelemetryProcessor.traceSuccess( Action.LoadDatabaseAccount, { diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts index a8d0a7ca0..58550416a 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts @@ -180,7 +180,7 @@ export class CommandBarComponentButtonFactory { } if (window.authType === AuthType.AAD) { - const label = "Support"; + const label = "Chat Assistant"; const supportPaneButton: CommandButtonComponentProps = { iconSrc: FeedbackIcon, iconAlt: label, diff --git a/src/Explorer/Panes/SupportPane.ts b/src/Explorer/Panes/SupportPane.ts index 36dad7b1d..27339884d 100644 --- a/src/Explorer/Panes/SupportPane.ts +++ b/src/Explorer/Panes/SupportPane.ts @@ -7,7 +7,7 @@ export class SupportPane extends ContextualPaneBase { constructor(options: ViewModels.PaneOptions) { super(options); - this.title("Cosmos DB Support"); + this.title("Cosmos DB Chat Assistant"); this.resetData(); this.supportPaneComponentAdapter = new SupportPaneComponentAdapter(this.container); } diff --git a/src/explorer.html b/src/explorer.html index 02e01853f..63345aee9 100644 --- a/src/explorer.html +++ b/src/explorer.html @@ -7,8 +7,10 @@ Azure Cosmos DB + +