mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
Save And Close Functionality (#17000)
* save and close * wip * working save and close * cleanup * pr changes * pr changes * fix capitalization * fix build * pr fix
This commit is contained in:
@@ -6,15 +6,20 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { WizardController } from './wizard/wizardController';
|
||||
import * as mssql from '../../mssql';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as loc from './constants/strings';
|
||||
import { MigrationNotebookInfo, NotebookPathHelper } from './constants/notebookPathHelper';
|
||||
import { IconPathHelper } from './constants/iconPathHelper';
|
||||
import { DashboardWidget } from './dashboard/sqlServerDashboard';
|
||||
import { MigrationLocalStorage } from './models/migrationLocalStorage';
|
||||
import { MigrationStateModel, SavedInfo } from './models/stateMachine';
|
||||
import { SavedAssessmentDialog } from './dialog/assessmentResults/savedAssessmentDialog';
|
||||
|
||||
class SQLMigration {
|
||||
|
||||
public stateModel!: MigrationStateModel;
|
||||
|
||||
constructor(private readonly context: vscode.ExtensionContext) {
|
||||
NotebookPathHelper.setExtensionContext(context);
|
||||
IconPathHelper.setExtensionContext(context);
|
||||
@@ -76,16 +81,47 @@ class SQLMigration {
|
||||
async launchMigrationWizard(): Promise<void> {
|
||||
let activeConnection = await azdata.connection.getCurrentConnection();
|
||||
let connectionId: string = '';
|
||||
let serverName: string = '';
|
||||
if (!activeConnection) {
|
||||
const connection = await azdata.connection.openConnectionDialog();
|
||||
if (connection) {
|
||||
connectionId = connection.connectionId;
|
||||
serverName = connection.options.server;
|
||||
}
|
||||
} else {
|
||||
connectionId = activeConnection.connectionId;
|
||||
serverName = activeConnection.serverName;
|
||||
}
|
||||
if (serverName) {
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
this.stateModel = new MigrationStateModel(this.context, connectionId, api.sqlMigration);
|
||||
this.context.subscriptions.push(this.stateModel);
|
||||
let savedInfo = this.checkSavedInfo(serverName);
|
||||
if (savedInfo) {
|
||||
this.stateModel.savedInfo = savedInfo;
|
||||
this.stateModel.serverName = serverName;
|
||||
let savedAssessmentDialog = new SavedAssessmentDialog(this.context, this.stateModel);
|
||||
await savedAssessmentDialog.openDialog();
|
||||
} else {
|
||||
const wizardController = new WizardController(this.context, this.stateModel);
|
||||
await wizardController.openWizard(connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private checkSavedInfo(serverName: string): SavedInfo | undefined {
|
||||
let savedInfo: SavedInfo | undefined = this.context.globalState.get(`${this.stateModel.mementoString}.${serverName}`);
|
||||
if (savedInfo) {
|
||||
return savedInfo;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
const wizardController = new WizardController(this.context);
|
||||
await wizardController.openWizard(connectionId);
|
||||
}
|
||||
|
||||
async launchNewSupportRequest(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user