Fix loading component not disappearing (#8495)

This commit is contained in:
Charles Gagnon
2019-11-27 14:42:28 -08:00
committed by GitHub
parent 48b2cbb0bf
commit d451528b36
2 changed files with 19 additions and 13 deletions

View File

@@ -20,10 +20,10 @@ export type BdcErrorEvent = { error: Error, errorType: BdcErrorType };
export class BdcDashboardModel { export class BdcDashboardModel {
private _clusterController: ClusterController; private _clusterController: ClusterController;
private _bdcStatus: BdcStatusModel; private _bdcStatus: BdcStatusModel | undefined;
private _endpoints: EndpointModel[] = []; private _endpoints: EndpointModel[] | undefined;
private _bdcStatusLastUpdated: Date; private _bdcStatusLastUpdated: Date | undefined;
private _endpointsLastUpdated: Date; private _endpointsLastUpdated: Date | undefined;
private readonly _onDidUpdateEndpoints = new vscode.EventEmitter<EndpointModel[]>(); private readonly _onDidUpdateEndpoints = new vscode.EventEmitter<EndpointModel[]>();
private readonly _onDidUpdateBdcStatus = new vscode.EventEmitter<BdcStatusModel>(); private readonly _onDidUpdateBdcStatus = new vscode.EventEmitter<BdcStatusModel>();
private readonly _onBdcError = new vscode.EventEmitter<BdcErrorEvent>(); private readonly _onBdcError = new vscode.EventEmitter<BdcErrorEvent>();
@@ -49,15 +49,15 @@ export class BdcDashboardModel {
return this._bdcStatus; return this._bdcStatus;
} }
public get serviceEndpoints(): EndpointModel[] { public get serviceEndpoints(): EndpointModel[] | undefined {
return this._endpoints || []; return this._endpoints;
} }
public get bdcStatusLastUpdated(): Date { public get bdcStatusLastUpdated(): Date | undefined {
return this._bdcStatusLastUpdated; return this._bdcStatusLastUpdated;
} }
public get endpointsLastUpdated(): Date { public get endpointsLastUpdated(): Date | undefined {
return this._endpointsLastUpdated; return this._endpointsLastUpdated;
} }
@@ -75,7 +75,7 @@ export class BdcDashboardModel {
this._onDidUpdateBdcStatus.fire(this.bdcStatus); this._onDidUpdateBdcStatus.fire(this.bdcStatus);
}).catch(error => this._onBdcError.fire({ error: error, errorType: 'bdcStatus' })), }).catch(error => this._onBdcError.fire({ error: error, errorType: 'bdcStatus' })),
this._clusterController.getEndPoints(true).then(response => { this._clusterController.getEndPoints(true).then(response => {
this._endpoints = response.endPoints || []; this._endpoints = response.endPoints;
fixEndpoints(this._endpoints); fixEndpoints(this._endpoints);
this._endpointsLastUpdated = new Date(); this._endpointsLastUpdated = new Date();
this._onDidUpdateEndpoints.fire(this.serviceEndpoints); 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 * @returns The IConnectionProfile - or undefined if the endpoints haven't been loaded yet
*/ */
public getSqlServerMasterConnectionProfile(): azdata.IConnectionProfile | undefined { 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) { if (!sqlServerMasterEndpoint) {
return undefined; return undefined;
} }
@@ -166,7 +166,10 @@ export function getTroubleshootNotebookUrl(service?: string): string {
* Applies fixes to the endpoints received so they are displayed correctly * Applies fixes to the endpoints received so they are displayed correctly
* @param endpoints The endpoints received to modify * @param endpoints The endpoints received to modify
*/ */
function fixEndpoints(endpoints: EndpointModel[]) { function fixEndpoints(endpoints?: EndpointModel[]): void {
if (!endpoints) {
return;
}
endpoints.forEach(e => { endpoints.forEach(e => {
if (e.name === Endpoint.metricsui && e.endpoint && e.endpoint.indexOf('/d/wZx3OUdmz') === -1) { if (e.name === Endpoint.metricsui && e.endpoint && e.endpoint.indexOf('/d/wZx3OUdmz') === -1) {
// Update to have correct URL // Update to have correct URL

View File

@@ -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 // Sort the endpoints. The sort method is that SQL Server Master is first - followed by all
// others in alphabetical order by endpoint // others in alphabetical order by endpoint
const sqlServerMasterEndpoints = endpoints.filter(e => e.name === Endpoint.sqlServerMaster); const sqlServerMasterEndpoints = endpoints.filter(e => e.name === Endpoint.sqlServerMaster);
@@ -406,7 +409,7 @@ export class BdcDashboardOverviewPage extends BdcDashboardPage {
copyValueCell.iconHeight = '14px'; copyValueCell.iconHeight = '14px';
copyValueCell.iconWidth = '14px'; copyValueCell.iconWidth = '14px';
return [getEndpointDisplayText(e.name, e.description), 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]; copyValueCell];
}); });