mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Some cleanup and fixes for Arc/BDC dashboards (#11075)
This commit is contained in:
@@ -14,6 +14,8 @@ import { ConnectToControllerDialog } from './ui/dialogs/connectControllerDialog'
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
||||
IconPathHelper.setExtensionContext(context);
|
||||
|
||||
await vscode.commands.executeCommand('setContext', 'arc.loaded', false);
|
||||
|
||||
const treeDataProvider = new AzureArcTreeDataProvider(context);
|
||||
vscode.window.registerTreeDataProvider('azureArc', treeDataProvider);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ export class ControllerModel {
|
||||
}
|
||||
}
|
||||
|
||||
public async refresh(): Promise<void> {
|
||||
public async refresh(showErrors: boolean = true): Promise<void> {
|
||||
// We haven't gotten our password yet, fetch it now
|
||||
if (!this._auth) {
|
||||
let password = '';
|
||||
@@ -93,7 +93,9 @@ export class ControllerModel {
|
||||
// If an error occurs show a message so the user knows something failed but still
|
||||
// fire the event so callers can know to update (e.g. so dashboards don't show the
|
||||
// loading icon forever)
|
||||
vscode.window.showErrorMessage(loc.fetchEndpointsFailed(this.info.url, err));
|
||||
if (showErrors) {
|
||||
vscode.window.showErrorMessage(loc.fetchEndpointsFailed(this.info.url, err));
|
||||
}
|
||||
this._onEndpointsUpdated.fire(this._endpoints);
|
||||
throw err;
|
||||
}),
|
||||
@@ -107,7 +109,9 @@ export class ControllerModel {
|
||||
// If an error occurs show a message so the user knows something failed but still
|
||||
// fire the event so callers can know to update (e.g. so dashboards don't show the
|
||||
// loading icon forever)
|
||||
vscode.window.showErrorMessage(loc.fetchRegistrationsFailed(this.info.url, err));
|
||||
if (showErrors) {
|
||||
vscode.window.showErrorMessage(loc.fetchRegistrationsFailed(this.info.url, err));
|
||||
}
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
throw err;
|
||||
}),
|
||||
|
||||
@@ -184,8 +184,24 @@ export class MiaaModel extends ResourceModel {
|
||||
}
|
||||
|
||||
if (!connection) {
|
||||
// We need the password so prompt the user for it
|
||||
const connectionProfile: azdata.IConnectionProfile = {
|
||||
serverName: (this.registration.externalIp && this.registration.externalPort) ? `${this.registration.externalIp},${this.registration.externalPort}` : '',
|
||||
databaseName: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
providerName: 'MSSQL',
|
||||
connectionName: '',
|
||||
userName: 'sa',
|
||||
password: '',
|
||||
savePassword: true,
|
||||
groupFullName: undefined,
|
||||
saveProfile: true,
|
||||
id: '',
|
||||
groupId: undefined,
|
||||
options: {}
|
||||
};
|
||||
// Weren't able to load the existing connection so prompt user for new one
|
||||
connection = await azdata.connection.openConnectionDialog(['MSSQL']);
|
||||
connection = await azdata.connection.openConnectionDialog(['MSSQL'], connectionProfile);
|
||||
}
|
||||
|
||||
if (connection) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import * as TypeMoq from 'typemoq';
|
||||
import { AzureArcTreeDataProvider } from '../../../ui/tree/azureArcTreeDataProvider';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { ControllerTreeNode } from '../../../ui/tree/controllerTreeNode';
|
||||
import { LoadingControllerNode } from '../../../ui/tree/loadingTreeNode';
|
||||
|
||||
describe('AzureArcTreeDataProvider tests', function (): void {
|
||||
let treeDataProvider: AzureArcTreeDataProvider;
|
||||
@@ -67,11 +66,10 @@ describe('AzureArcTreeDataProvider tests', function (): void {
|
||||
});
|
||||
|
||||
describe('getChildren', function (): void {
|
||||
it('should return a loading node before loading stored controllers is completed', async function (): Promise<void> {
|
||||
it('should return an empty array before loading stored controllers is completed', async function (): Promise<void> {
|
||||
treeDataProvider['_loading'] = true;
|
||||
let children = await treeDataProvider.getChildren();
|
||||
should(children.length).equal(1, 'While loading we should return the loading node');
|
||||
should(children[0] instanceof LoadingControllerNode).be.true('Node returned was not a LoadingControllerNode');
|
||||
should(children.length).equal(0, 'While loading we should return an empty array');
|
||||
});
|
||||
|
||||
it('should return no children after loading', async function (): Promise<void> {
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ControllerDashboard extends Dashboard {
|
||||
public async showDashboard(): Promise<void> {
|
||||
await super.showDashboard();
|
||||
// Kick off the model refresh but don't wait on it since that's all handled with callbacks anyways
|
||||
this._controllerModel.refresh().catch(err => console.log(`Error refreshing Controller dashboard ${err}`));
|
||||
this._controllerModel.refresh(false).catch(err => console.log(`Error refreshing Controller dashboard ${err}`));
|
||||
}
|
||||
|
||||
protected async registerTabs(modelView: azdata.ModelView): Promise<(azdata.DashboardTab | azdata.DashboardTabGroup)[]> {
|
||||
|
||||
@@ -162,7 +162,7 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
try {
|
||||
this._propertiesLoadingComponent!.loading = true;
|
||||
this._arcResourcesLoadingComponent!.loading = true;
|
||||
await this._controllerModel.refresh();
|
||||
await this.refresh();
|
||||
} finally {
|
||||
refreshButton.enabled = true;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,6 @@ export class MiaaConnectionStringsPage extends DashboardPage {
|
||||
}));
|
||||
}
|
||||
|
||||
protected async refresh(): Promise<void> {
|
||||
await this._controllerModel.refresh();
|
||||
}
|
||||
|
||||
protected get title(): string {
|
||||
return loc.connectionStrings;
|
||||
}
|
||||
|
||||
@@ -199,10 +199,7 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
this._grafanaLoading!.loading = true;
|
||||
this._databasesTableLoading!.loading = true;
|
||||
|
||||
await Promise.all([
|
||||
this._miaaModel.refresh(),
|
||||
this._controllerModel.refresh()
|
||||
]);
|
||||
await this.refresh();
|
||||
} finally {
|
||||
refreshButton.enabled = true;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export class ConnectToControllerDialog {
|
||||
const controllerModel = new ControllerModel(this._treeDataProvider, controllerInfo, this.passwordInputBox.value);
|
||||
try {
|
||||
// Validate that we can connect to the controller
|
||||
await controllerModel.refresh();
|
||||
await controllerModel.refresh(false);
|
||||
} catch (err) {
|
||||
vscode.window.showErrorMessage(loc.connectToControllerFailed(this.urlInputBox.value, err));
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { ControllerTreeNode } from './controllerTreeNode';
|
||||
import { TreeNode } from './treeNode';
|
||||
import { LoadingControllerNode as LoadingTreeNode } from './loadingTreeNode';
|
||||
import { ControllerModel, ControllerInfo } from '../../models/controllerModel';
|
||||
|
||||
const mementoToken = 'arcControllers';
|
||||
@@ -23,7 +22,6 @@ export class AzureArcTreeDataProvider implements vscode.TreeDataProvider<TreeNod
|
||||
readonly onDidChangeTreeData: vscode.Event<TreeNode | undefined> = this._onDidChangeTreeData.event;
|
||||
|
||||
private _loading: boolean = true;
|
||||
private _loadingNode = new LoadingTreeNode();
|
||||
|
||||
private _controllerNodes: ControllerTreeNode[] = [];
|
||||
|
||||
@@ -33,9 +31,14 @@ export class AzureArcTreeDataProvider implements vscode.TreeDataProvider<TreeNod
|
||||
|
||||
public async getChildren(element?: TreeNode): Promise<TreeNode[]> {
|
||||
if (this._loading) {
|
||||
return [this._loadingNode];
|
||||
return [];
|
||||
}
|
||||
|
||||
// We set the context here since VS Code takes a bit of time to process the _onDidChangeTreeData
|
||||
// and so if we set it as soon as we finished loading the controllers it would briefly flash
|
||||
// the "connect to controller" welcome view
|
||||
await vscode.commands.executeCommand('setContext', 'arc.loaded', true);
|
||||
|
||||
if (element) {
|
||||
return element.getChildren();
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ export class ControllerTreeNode extends TreeNode {
|
||||
// First reset our deferred promise so we're sure we'll get the refreshed children
|
||||
this._childrenRefreshPromise = new Deferred();
|
||||
try {
|
||||
await this.model.refresh();
|
||||
await this.model.refresh(false);
|
||||
await this._childrenRefreshPromise.promise;
|
||||
} catch (err) {
|
||||
// Couldn't get the children and TreeView doesn't have a way to collapse a node
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as loc from '../../localizedConstants';
|
||||
import { TreeNode } from './treeNode';
|
||||
|
||||
/**
|
||||
* A placeholder TreeNode to display while we're loading the initial set of stored nodes
|
||||
*/
|
||||
export class LoadingControllerNode extends TreeNode {
|
||||
|
||||
constructor() {
|
||||
super(loc.loading, vscode.TreeItemCollapsibleState.None, 'loading');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user