mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 01:25:37 -05:00
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:
38
extensions/sql-migration/src/contants.ts
Normal file
38
extensions/sql-migration/src/contants.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 './models/strings';
|
||||
|
||||
export class NotebookPathHelper {
|
||||
private static context: vscode.ExtensionContext;
|
||||
|
||||
public static inlineMigrationNotebook: MigrationNotebookInfo;
|
||||
public static sqlAssessmentNotebook: MigrationNotebookInfo;
|
||||
|
||||
public static setExtensionContext(context: vscode.ExtensionContext) {
|
||||
NotebookPathHelper.context = context;
|
||||
NotebookPathHelper.inlineMigrationNotebook = {
|
||||
label: loc.NOTEBOOK_INLINE_MIGRATION_TITLE,
|
||||
notebookPath: NotebookPathHelper.context.asAbsolutePath('notebooks/Inline_Migration_Notebook.ipynb')
|
||||
};
|
||||
NotebookPathHelper.sqlAssessmentNotebook = {
|
||||
label: loc.NOTEBOOK_SQL_MIGRATION_ASSESSMENT_TITLE,
|
||||
notebookPath: NotebookPathHelper.context.asAbsolutePath('notebooks/SQL_Assessment_Notebook.ipynb')
|
||||
};
|
||||
}
|
||||
|
||||
public static getAllMigrationNotebooks(): MigrationNotebookInfo[] {
|
||||
return [
|
||||
NotebookPathHelper.inlineMigrationNotebook,
|
||||
NotebookPathHelper.sqlAssessmentNotebook
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export interface MigrationNotebookInfo {
|
||||
label: string;
|
||||
notebookPath: string
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
];
|
||||
|
||||
|
||||
@@ -143,3 +143,10 @@ export const REFRESH = localize('sql.migration.refresh', "Refresh");
|
||||
export const SUBMIT = localize('sql.migration.submit', "Submit");
|
||||
export const CREATE = localize('sql.migration.create', "Create");
|
||||
export const CANCEL = localize('sql.migration.cancel', "Cancel");
|
||||
|
||||
|
||||
// Open notebook quick pick string
|
||||
export const NOTEBOOK_QUICK_PICK_PLACEHOLDER = localize('sql.migration.quick.pick.placeholder', "Select the operation you'd like to perform");
|
||||
export const NOTEBOOK_INLINE_MIGRATION_TITLE = localize('sql.migration.inline.migration.notebook.title', "Inline migration");
|
||||
export const NOTEBOOK_SQL_MIGRATION_ASSESSMENT_TITLE = localize('sql.migration.sql.assessment.notebook.title', "SQL migration assessment");
|
||||
export const NOTEBOOK_OPEN_ERROR = localize('sql.migration.notebook.open.error', "Error opening migration notebook");
|
||||
|
||||
Reference in New Issue
Block a user