Archived
* wip * wip2 * wip eod 820 * wip 822 * text component improvements and misc changes * aria-label * targetClusterPage wip * target cluster page * target cluster page * wip 827 * wip deployment profile page * profile page * service settings page * wip 0903 * 0909 wip * 0910 * 0911 * sql instance and working directory * notebooks * docker version on windows * EULA env var * 917 updates * address comments * use async file access * fix the summary page display issue for ad auth * add save json file buttons * use promise for private methds * review feedbacks * refactor * pass json to notebooks * fix no tool scenario * bypass tool check if installed * update hint text * update notebooks * workaround azdata first time use * comments * accept eula and some text update * fix the error in package.json * promise instead of thenable * comments * fix typo
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as azdata from 'azdata';
|
|
import * as vscode from 'vscode';
|
|
import * as nls from 'vscode-nls';
|
|
import { DialogBase } from './dialogBase';
|
|
import { INotebookService } from '../services/notebookService';
|
|
import { DialogInfo } from '../interfaces';
|
|
import { Validator, initializeDialog, InputComponents, setModelValues } from './modelViewUtils';
|
|
import { Model } from './model';
|
|
import { EOL } from 'os';
|
|
|
|
const localize = nls.loadMessageBundle();
|
|
|
|
export class NotebookInputDialog extends DialogBase {
|
|
|
|
private inputComponents: InputComponents = {};
|
|
|
|
constructor(private notebookService: INotebookService,
|
|
private dialogInfo: DialogInfo) {
|
|
super(dialogInfo.title, dialogInfo.name, false);
|
|
this._dialogObject.okButton.label = localize('deploymentDialog.OKButtonText', 'Open Notebook');
|
|
this._dialogObject.okButton.onClick(() => this.onComplete());
|
|
}
|
|
|
|
protected initialize() {
|
|
const self = this;
|
|
const validators: Validator[] = [];
|
|
initializeDialog({
|
|
dialogInfo: this.dialogInfo,
|
|
container: this._dialogObject,
|
|
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
|
this._toDispose.push(disposable);
|
|
},
|
|
onNewInputComponentCreated: (name: string, component: azdata.DropDownComponent | azdata.InputBoxComponent | azdata.CheckBoxComponent): void => {
|
|
this.inputComponents[name] = component;
|
|
},
|
|
onNewValidatorCreated: (validator: Validator): void => {
|
|
validators.push(validator);
|
|
}
|
|
});
|
|
this._dialogObject.registerCloseValidator(() => {
|
|
const messages: string[] = [];
|
|
validators.forEach(validator => {
|
|
const result = validator();
|
|
if (!result.valid) {
|
|
messages.push(result.message);
|
|
}
|
|
});
|
|
if (messages.length > 0) {
|
|
self._dialogObject.message = { level: azdata.window.MessageLevel.Error, text: messages.join(EOL) };
|
|
} else {
|
|
self._dialogObject.message = { text: '' };
|
|
}
|
|
return messages.length === 0;
|
|
});
|
|
}
|
|
|
|
private onComplete(): void {
|
|
const model: Model = new Model();
|
|
setModelValues(this.inputComponents, model);
|
|
model.setEnvironmentVariables();
|
|
this.notebookService.launchNotebook(this.dialogInfo.notebook).then(() => { }, (error) => {
|
|
vscode.window.showErrorMessage(error);
|
|
});
|
|
this.dispose();
|
|
}
|
|
}
|