Add persistence and connect dialog to Arc view (#11014)

* Add controller persistence and info prompting

* more stuff

* clean up

* Add arc tests to scripts
This commit is contained in:
Charles Gagnon
2020-06-19 14:35:11 -07:00
committed by GitHub
parent c879d77b62
commit f278e2a7a2
17 changed files with 576 additions and 176 deletions

View File

@@ -5,17 +5,11 @@
import * as vscode from 'vscode';
import * as loc from './localizedConstants';
import { IconPathHelper } from './constants';
import { BasicAuth } from './controller/auth';
import { PostgresDashboard } from './ui/dashboards/postgres/postgresDashboard';
import { ControllerModel } from './models/controllerModel';
import { PostgresModel } from './models/postgresModel';
import { ControllerDashboard } from './ui/dashboards/controller/controllerDashboard';
import { MiaaDashboard } from './ui/dashboards/miaa/miaaDashboard';
import { MiaaModel } from './models/miaaModel';
import { AzureArcTreeDataProvider } from './ui/tree/controllerTreeDataProvider';
import { IconPathHelper, refreshActionId } from './constants';
import { AzureArcTreeDataProvider } from './ui/tree/azureArcTreeDataProvider';
import { ControllerTreeNode } from './ui/tree/controllerTreeNode';
import { TreeNode } from './ui/tree/treeNode';
import { ConnectToControllerDialog } from './ui/dialogs/connectControllerDialog';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
IconPathHelper.setExtensionContext(context);
@@ -23,85 +17,30 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const treeDataProvider = new AzureArcTreeDataProvider(context);
vscode.window.registerTreeDataProvider('azureArc', treeDataProvider);
vscode.commands.registerCommand('arc.addController', () => {
// Controller information
const controllerUrl = '';
const auth = new BasicAuth('', '');
const controllerModel = new ControllerModel(controllerUrl, auth);
treeDataProvider.addController(controllerModel);
vscode.commands.registerCommand('arc.createController', async () => {
await vscode.commands.executeCommand('azdata.resource.deploy');
});
vscode.commands.registerCommand('arc.removeController', (controllerNode: ControllerTreeNode) => {
treeDataProvider.removeController(controllerNode);
vscode.commands.registerCommand('arc.connectToController', async () => {
const dialog = new ConnectToControllerDialog(treeDataProvider);
dialog.showDialog();
const model = await dialog.waitForClose();
if (model) {
await treeDataProvider.addOrUpdateController(model.controllerModel, model.password);
}
});
vscode.commands.registerCommand('arc.removeController', async (controllerNode: ControllerTreeNode) => {
await treeDataProvider.removeController(controllerNode);
});
vscode.commands.registerCommand(refreshActionId, async (treeNode: TreeNode) => {
treeDataProvider.refreshNode(treeNode);
});
vscode.commands.registerCommand('arc.openDashboard', async (treeNode: TreeNode) => {
await treeNode.openDashboard().catch(err => vscode.window.showErrorMessage(loc.openDashboardFailed(err)));
});
vscode.commands.registerCommand('arc.manageArcController', async () => {
// Controller information
const controllerUrl = '';
const auth = new BasicAuth('', '');
try {
const controllerModel = new ControllerModel(controllerUrl, auth);
const controllerDashboard = new ControllerDashboard(controllerModel);
await Promise.all([
controllerDashboard.showDashboard(),
controllerModel.refresh()
]);
} catch (error) {
// vscode.window.showErrorMessage(loc.failedToManagePostgres(`${dbNamespace}.${dbName}`, error));
}
});
vscode.commands.registerCommand('arc.manageMiaa', async () => {
// Controller information
const controllerUrl = '';
const auth = new BasicAuth('', '');
const instanceNamespace = '';
const instanceName = '';
try {
const controllerModel = new ControllerModel(controllerUrl, auth);
const miaaModel = new MiaaModel(controllerUrl, auth, instanceNamespace, instanceName);
const miaaDashboard = new MiaaDashboard(controllerModel, miaaModel);
await Promise.all([
miaaDashboard.showDashboard(),
controllerModel.refresh()
]);
} catch (error) {
// vscode.window.showErrorMessage(loc.failedToManagePostgres(`${dbNamespace}.${dbName}`, error));
}
});
vscode.commands.registerCommand('arc.managePostgres', async () => {
// Controller information
const controllerUrl = '';
const auth = new BasicAuth('', '');
// Postgres information
const dbNamespace = '';
const dbName = '';
try {
const controllerModel = new ControllerModel(controllerUrl, auth);
const postgresModel = new PostgresModel(controllerUrl, auth, dbNamespace, dbName);
const postgresDashboard = new PostgresDashboard(context, controllerModel, postgresModel);
await Promise.all([
postgresDashboard.showDashboard(),
controllerModel.refresh(),
postgresModel.refresh()
]);
} catch (error) {
vscode.window.showErrorMessage(loc.failedToManagePostgres(`${dbNamespace}.${dbName}`, error));
}
});
}
export function deactivate(): void {