mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
support multiple flavor of notebooks (#12159)
* support multiple flavor of notebooks * update resource * comments
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user