mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
deployment extensibility (#7394)
* rename button and update dialog button width * make deployment resource type contributable * conflicts * fix card width hight issue * comments
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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, instanceOfNotebookBasedDialogInfo } from '../interfaces';
|
||||
import { Validator, initializeDialog, InputComponents, setModelValues } from './modelViewUtils';
|
||||
import { Model } from './model';
|
||||
import { EOL } from 'os';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class DeploymentInputDialog 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);
|
||||
if (instanceOfNotebookBasedDialogInfo(this.dialogInfo)) {
|
||||
model.setEnvironmentVariables();
|
||||
this.notebookService.launchNotebook(this.dialogInfo.notebook).then(() => { }, (error) => {
|
||||
vscode.window.showErrorMessage(error);
|
||||
});
|
||||
} else {
|
||||
vscode.commands.executeCommand(this.dialogInfo.command, model);
|
||||
}
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user