support multiple flavor of notebooks (#12159)

* support multiple flavor of notebooks

* update resource

* comments
This commit is contained in:
Alan Ren
2020-09-08 16:07:55 -07:00
committed by GitHub
parent f6c63f2dcb
commit e2b5e9bd66
5 changed files with 49 additions and 20 deletions

View File

@@ -7,7 +7,7 @@ import * as azdata from 'azdata';
import { EOL } from 'os';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { DialogInfo, instanceOfNotebookBasedDialogInfo, NotebookBasedDialogInfo } from '../interfaces';
import { DialogInfo, instanceOfNotebookBasedDialogInfo, NotebookBasedDialogInfo, FieldType, NotebookPathInfo } from '../interfaces';
import { INotebookService } from '../services/notebookService';
import { IPlatformService } from '../services/platformService';
import { DialogBase } from './dialogBase';
@@ -17,6 +17,8 @@ import { IToolsService } from '../services/toolsService';
const localize = nls.loadMessageBundle();
const NotebookTypeVariableName: string = 'SYS_NotebookType';
export class DeploymentInputDialog extends DialogBase {
private inputComponents: InputComponents = {};
@@ -41,6 +43,25 @@ export class DeploymentInputDialog extends DialogBase {
protected initialize() {
const self = this;
const validators: Validator[] = [];
if (this.dialogInfo.tabs.length > 0
&& instanceOfNotebookBasedDialogInfo(this.dialogInfo)
&& Array.isArray(this.dialogInfo.notebook)) {
// Add the notebook type field to the dialog
this.dialogInfo.tabs[0].sections.push(
{
fields: [
{
type: FieldType.Options,
label: localize('notebookType', 'Notebook type'),
options: this.dialogInfo.notebook.map(nb => nb.type),
variableName: NotebookTypeVariableName
}
]
}
);
}
initializeDialog({
dialogInfo: this.dialogInfo,
container: this._dialogObject,
@@ -81,7 +102,10 @@ export class DeploymentInputDialog extends DialogBase {
if (this.dialogInfo.runNotebook) {
this.executeNotebook(this.dialogInfo);
} else {
this.notebookService.launchNotebook(this.dialogInfo.notebook).then(() => { }, (error) => {
const notebook = Array.isArray(this.dialogInfo.notebook) ?
this.dialogInfo.notebook.find(nb => nb.type === model.getStringValue(NotebookTypeVariableName))?.path :
this.dialogInfo.notebook;
this.notebookService.launchNotebook(notebook!).catch(error => {
vscode.window.showErrorMessage(error);
});
}
@@ -91,6 +115,6 @@ export class DeploymentInputDialog extends DialogBase {
}
private executeNotebook(notebookDialogInfo: NotebookBasedDialogInfo): void {
this.notebookService.backgroundExecuteNotebook(notebookDialogInfo.taskName, notebookDialogInfo.notebook, 'deploy', this.platformService);
this.notebookService.backgroundExecuteNotebook(notebookDialogInfo.taskName, notebookDialogInfo.notebook as string | NotebookPathInfo, 'deploy', this.platformService);
}
}