From 91823a7ddb1d486014d498f4a10e91341cc89851 Mon Sep 17 00:00:00 2001 From: tyaginidhi Date: Thu, 28 Sep 2023 10:04:59 +0530 Subject: [PATCH] Do not show welcome banner in non-us orgs (#725) --- src/common/copilot/PowerPagesCopilot.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index 0a66a666..8e5c1147 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -140,9 +140,9 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { const pacOutput = await this._pacWrapper?.activeOrg(); if (pacOutput && pacOutput.Status === PAC_SUCCESS) { - this.handleOrgChangeSuccess(pacOutput.Results); + await this.handleOrgChangeSuccess(pacOutput.Results); } else if (!IS_DESKTOP && orgID && activeOrgUrl) { - this.handleOrgChangeSuccess({ OrgId: orgID, UserId: userID, OrgUrl: activeOrgUrl } as ActiveOrgOutput); + await this.handleOrgChangeSuccess({ OrgId: orgID, UserId: userID, OrgUrl: activeOrgUrl } as ActiveOrgOutput); } webviewView.webview.html = this._getHtmlForWebview(webviewView.webview); @@ -150,6 +150,11 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { webviewView.webview.onDidReceiveMessage(async (data) => { switch (data.type) { case "webViewLoaded": { + if (this.aibEndpoint === COPILOT_UNAVAILABLE) { + this.sendMessageToWebview({ type: 'Unavailable' }); + return; + } + sendTelemetryEvent(this.telemetry, { eventName: CopilotLoadedEvent, copilotSessionId: sessionID, orgId: orgID }); this.sendMessageToWebview({ type: 'env' }); //TODO Use IS_DESKTOP await this.checkAuthentication(); @@ -327,7 +332,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { this.aibEndpoint = await getIntelligenceEndpoint(orgID, this.telemetry, sessionID); if (this.aibEndpoint === COPILOT_UNAVAILABLE) { - sendTelemetryEvent(this.telemetry, {eventName: CopilotNotAvailable, copilotSessionId: sessionID, orgId: orgID}); + sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailable, copilotSessionId: sessionID, orgId: orgID }); this.sendMessageToWebview({ type: 'Unavailable' }); } else { this.sendMessageToWebview({ type: 'Available' });