Adding notebooks to migration extension (#14189)

* Adding migration notebooks to extension

* Adding toast notification instead of printing error in the console

* removed localization info from the links in the notebook

* Removed localization info from the links 2

* Fixed comments, placeholder and letter cases.
This commit is contained in:
Aasim Khan
2021-02-09 08:07:30 -08:00
committed by GitHub
parent a3cddbc8aa
commit b2eb0e6958
7 changed files with 1104 additions and 2 deletions

View File

@@ -7,10 +7,15 @@ import * as vscode from 'vscode';
import * as azdata from 'azdata';
import { WizardController } from './wizard/wizardController';
import { AssessmentResultsDialog } from './dialog/assessmentResults/assessmentResultsDialog';
import { MigrationNotebookInfo, NotebookPathHelper } from './contants';
import { promises as fs } from 'fs';
import * as loc from './models/strings';
class SQLMigration {
constructor(private readonly context: vscode.ExtensionContext) {
NotebookPathHelper.setExtensionContext(context);
}
async start(): Promise<void> {
@@ -37,6 +42,31 @@ class SQLMigration {
vscode.commands.registerCommand('sqlmigration.testDialog', async () => {
let dialog = new AssessmentResultsDialog('ownerUri', undefined!, 'Assessment Dialog');
await dialog.openDialog();
}),
vscode.commands.registerCommand('sqlmigration.openNotebooks', async () => {
const input = vscode.window.createQuickPick<MigrationNotebookInfo>();
input.placeholder = loc.NOTEBOOK_QUICK_PICK_PLACEHOLDER;
input.items = NotebookPathHelper.getAllMigrationNotebooks();
input.onDidAccept(async (e) => {
const selectedNotebook = input.selectedItems[0];
if (selectedNotebook) {
try {
azdata.nb.showNotebookDocument(vscode.Uri.parse(`untitled: ${selectedNotebook.label}`), {
preview: false,
initialContent: (await fs.readFile(selectedNotebook.notebookPath)).toString(),
initialDirtyState: false
});
} catch (e) {
vscode.window.showErrorMessage(`${loc.NOTEBOOK_OPEN_ERROR} - ${e.toString()}`);
}
input.hide();
}
});
input.show();
})
];