mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
support multiple flavor of notebooks (#12159)
* support multiple flavor of notebooks * update resource * comments
This commit is contained in:
@@ -125,7 +125,7 @@ export interface NotebookWizardPageInfo extends PageInfoBase {
|
||||
description?: string;
|
||||
}
|
||||
export interface NotebookBasedDialogInfo extends DialogInfoBase {
|
||||
notebook: string | NotebookPathInfo;
|
||||
notebook: string | NotebookPathInfo | NotebookInfo[];
|
||||
runNotebook?: boolean;
|
||||
taskName?: string;
|
||||
}
|
||||
@@ -298,6 +298,14 @@ export interface NotebookPathInfo {
|
||||
linux: string;
|
||||
}
|
||||
|
||||
export interface NotebookInfo {
|
||||
/**
|
||||
* Type of the notebook, for example: powershell, python...
|
||||
*/
|
||||
type: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export enum OsDistribution {
|
||||
win32 = 'win32',
|
||||
darwin = 'darwin',
|
||||
|
||||
@@ -13,7 +13,7 @@ import * as nls from 'vscode-nls';
|
||||
import { INotebookService } from './notebookService';
|
||||
import { IPlatformService } from './platformService';
|
||||
import { IToolsService } from './toolsService';
|
||||
import { ResourceType, ResourceTypeOption, NotebookPathInfo, DeploymentProvider, instanceOfWizardDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfNotebookDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookWizardDeploymentProvider } from '../interfaces';
|
||||
import { ResourceType, ResourceTypeOption, NotebookPathInfo, DeploymentProvider, instanceOfWizardDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfNotebookDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookWizardDeploymentProvider, NotebookInfo } from '../interfaces';
|
||||
import { DeployClusterWizard } from '../ui/deployClusterWizard/deployClusterWizard';
|
||||
import { DeploymentInputDialog } from '../ui/deploymentInputDialog';
|
||||
|
||||
@@ -77,10 +77,14 @@ export class ResourceTypeService implements IResourceTypeService {
|
||||
});
|
||||
}
|
||||
|
||||
private updateNotebookPath(objWithNotebookProperty: { notebook: string | NotebookPathInfo } | undefined, extensionPath: string): void {
|
||||
private updateNotebookPath(objWithNotebookProperty: { notebook: string | NotebookPathInfo | NotebookInfo[] } | undefined, extensionPath: string): void {
|
||||
if (objWithNotebookProperty && objWithNotebookProperty.notebook) {
|
||||
if (typeof objWithNotebookProperty.notebook === 'string') {
|
||||
objWithNotebookProperty.notebook = path.join(extensionPath, objWithNotebookProperty.notebook);
|
||||
} else if (Array.isArray(objWithNotebookProperty.notebook)) {
|
||||
objWithNotebookProperty.notebook.forEach(nb => {
|
||||
nb.path = path.join(extensionPath, nb.path);
|
||||
});
|
||||
} else {
|
||||
if (objWithNotebookProperty.notebook.darwin) {
|
||||
objWithNotebookProperty.notebook.darwin = path.join(extensionPath, objWithNotebookProperty.notebook.darwin);
|
||||
|
||||
@@ -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