From d451528b36d3882b5421cd804c181ef5713e2787 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 27 Nov 2019 14:42:28 -0800 Subject: [PATCH] Fix loading component not disappearing (#8495) --- .../dialog/bdcDashboardModel.ts | 25 +++++++++++-------- .../dialog/bdcDashboardOverviewPage.ts | 7 ++++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts index 30cb2bad1b..e4052cdc0e 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts @@ -20,10 +20,10 @@ export type BdcErrorEvent = { error: Error, errorType: BdcErrorType }; export class BdcDashboardModel { private _clusterController: ClusterController; - private _bdcStatus: BdcStatusModel; - private _endpoints: EndpointModel[] = []; - private _bdcStatusLastUpdated: Date; - private _endpointsLastUpdated: Date; + private _bdcStatus: BdcStatusModel | undefined; + private _endpoints: EndpointModel[] | undefined; + private _bdcStatusLastUpdated: Date | undefined; + private _endpointsLastUpdated: Date | undefined; private readonly _onDidUpdateEndpoints = new vscode.EventEmitter(); private readonly _onDidUpdateBdcStatus = new vscode.EventEmitter(); private readonly _onBdcError = new vscode.EventEmitter(); @@ -49,15 +49,15 @@ export class BdcDashboardModel { return this._bdcStatus; } - public get serviceEndpoints(): EndpointModel[] { - return this._endpoints || []; + public get serviceEndpoints(): EndpointModel[] | undefined { + return this._endpoints; } - public get bdcStatusLastUpdated(): Date { + public get bdcStatusLastUpdated(): Date | undefined { return this._bdcStatusLastUpdated; } - public get endpointsLastUpdated(): Date { + public get endpointsLastUpdated(): Date | undefined { return this._endpointsLastUpdated; } @@ -75,7 +75,7 @@ export class BdcDashboardModel { this._onDidUpdateBdcStatus.fire(this.bdcStatus); }).catch(error => this._onBdcError.fire({ error: error, errorType: 'bdcStatus' })), this._clusterController.getEndPoints(true).then(response => { - this._endpoints = response.endPoints || []; + this._endpoints = response.endPoints; fixEndpoints(this._endpoints); this._endpointsLastUpdated = new Date(); this._onDidUpdateEndpoints.fire(this.serviceEndpoints); @@ -92,7 +92,7 @@ export class BdcDashboardModel { * @returns The IConnectionProfile - or undefined if the endpoints haven't been loaded yet */ public getSqlServerMasterConnectionProfile(): azdata.IConnectionProfile | undefined { - const sqlServerMasterEndpoint = this.serviceEndpoints.find(e => e.name === Endpoint.sqlServerMaster); + const sqlServerMasterEndpoint = this.serviceEndpoints && this.serviceEndpoints.find(e => e.name === Endpoint.sqlServerMaster); if (!sqlServerMasterEndpoint) { return undefined; } @@ -166,7 +166,10 @@ export function getTroubleshootNotebookUrl(service?: string): string { * Applies fixes to the endpoints received so they are displayed correctly * @param endpoints The endpoints received to modify */ -function fixEndpoints(endpoints: EndpointModel[]) { +function fixEndpoints(endpoints?: EndpointModel[]): void { + if (!endpoints) { + return; + } endpoints.forEach(e => { if (e.name === Endpoint.metricsui && e.endpoint && e.endpoint.indexOf('/d/wZx3OUdmz') === -1) { // Update to have correct URL diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts index 224c72204c..6df4747f42 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts @@ -384,7 +384,10 @@ export class BdcDashboardOverviewPage extends BdcDashboardPage { } } - private handleEndpointsUpdate(endpoints: EndpointModel[]): void { + private handleEndpointsUpdate(endpoints?: EndpointModel[]): void { + if (!endpoints) { + return; + } // Sort the endpoints. The sort method is that SQL Server Master is first - followed by all // others in alphabetical order by endpoint const sqlServerMasterEndpoints = endpoints.filter(e => e.name === Endpoint.sqlServerMaster); @@ -406,7 +409,7 @@ export class BdcDashboardOverviewPage extends BdcDashboardPage { copyValueCell.iconHeight = '14px'; copyValueCell.iconWidth = '14px'; return [getEndpointDisplayText(e.name, e.description), - createEndpointComponent(this.modelBuilder, e, this.model, hyperlinkedEndpoints.some(he => he === e.name)), //e.endpoint, + createEndpointComponent(this.modelBuilder, e, this.model, hyperlinkedEndpoints.some(he => he === e.name)), copyValueCell]; });