mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 01:25:38 -05:00
Alanren/tool check (#5810)
* tool check * tools table update * buttons * update tools table * remove tool status check * updates * PR comments
This commit is contained in:
@@ -51,28 +51,9 @@ export enum ToolType {
|
||||
MSSQLCtl
|
||||
}
|
||||
|
||||
export interface ToolStatusInfo {
|
||||
type: ToolType;
|
||||
name: string;
|
||||
description: string;
|
||||
version: string;
|
||||
status: ToolInstallationStatus;
|
||||
}
|
||||
|
||||
export interface ITool {
|
||||
readonly name: string;
|
||||
readonly displayName: string;
|
||||
readonly description: string;
|
||||
readonly type: ToolType;
|
||||
readonly supportAutoInstall: boolean;
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus>;
|
||||
install(version: string): Thenable<void>;
|
||||
}
|
||||
|
||||
export enum ToolInstallationStatus {
|
||||
NotInstalled,
|
||||
Installed,
|
||||
Installing,
|
||||
FailedToInstall
|
||||
}
|
||||
@@ -28,14 +28,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
validationFailures.forEach(message => console.error(message));
|
||||
return;
|
||||
}
|
||||
|
||||
const openDialog = (resourceTypeName: string) => {
|
||||
const filtered = resourceTypes.filter(resourceType => resourceType.name === resourceTypeName);
|
||||
if (filtered.length !== 1) {
|
||||
vscode.window.showErrorMessage(localize('resourceDeployment.UnknownResourceType', 'The resource type: {0} is not defined', resourceTypeName));
|
||||
}
|
||||
else {
|
||||
let dialog = new ResourceDeploymentDialog(context, notebookService, toolsService, resourceTypeService, filtered[0]);
|
||||
} else {
|
||||
const dialog = new ResourceDeploymentDialog(context, notebookService, toolsService, resourceTypeService, filtered[0]);
|
||||
dialog.open();
|
||||
}
|
||||
};
|
||||
@@ -46,6 +44,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('azdata.resource.sql-bdc.deploy', () => {
|
||||
openDialog('sql-bdc');
|
||||
});
|
||||
vscode.commands.registerCommand('azdata.resource.deploy', () => {
|
||||
openDialog('sql-image');
|
||||
});
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolType, ITool, ToolInstallationStatus } from '../../interfaces';
|
||||
import { ToolType, ITool } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -23,21 +23,4 @@ export class AzCliTool implements ITool {
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.AzCLIDisplayName', 'Azure CLI');
|
||||
}
|
||||
|
||||
get supportAutoInstall(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
install(version: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus> {
|
||||
let promise = new Promise<ToolInstallationStatus>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(ToolInstallationStatus.Installed);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolType, ITool, ToolInstallationStatus } from '../../interfaces';
|
||||
import { ToolType, ITool } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
export class DockerTool implements ITool {
|
||||
get name(): string {
|
||||
return 'docker';
|
||||
@@ -24,21 +23,4 @@ export class DockerTool implements ITool {
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.DockerDisplayName', 'Docker');
|
||||
}
|
||||
|
||||
get supportAutoInstall(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
install(version: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus> {
|
||||
let promise = new Promise<ToolInstallationStatus>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(ToolInstallationStatus.Installed);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolType, ITool, ToolInstallationStatus } from '../../interfaces';
|
||||
import { ToolType, ITool } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -13,7 +13,7 @@ export class KubeCtlTool implements ITool {
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
return localize('resourceDeployment.KUBECTLDescription', 'Tool used for managing the Kubernetes cluster');
|
||||
return localize('resourceDeployment.KubeCtlDescription', 'Tool used for managing the Kubernetes cluster');
|
||||
}
|
||||
|
||||
get type(): ToolType {
|
||||
@@ -21,23 +21,6 @@ export class KubeCtlTool implements ITool {
|
||||
}
|
||||
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.KUBECTLDisplayName', 'kubectl');
|
||||
}
|
||||
|
||||
get supportAutoInstall(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
install(version: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus> {
|
||||
let promise = new Promise<ToolInstallationStatus>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(ToolInstallationStatus.Installed);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
return localize('resourceDeployment.KubeCtlDisplayName', 'kubectl');
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolType, ITool, ToolInstallationStatus } from '../../interfaces';
|
||||
import { ToolType, ITool } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -13,7 +13,7 @@ export class MSSQLCtlTool implements ITool {
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
return localize('resourceDeployment.MSSQLCTLDescription', 'Command-line tool for installing and managing the SQL Server big data cluster');
|
||||
return localize('resourceDeployment.MssqlCtlDescription', 'Command-line tool for installing and managing the SQL Server big data cluster');
|
||||
}
|
||||
|
||||
get type(): ToolType {
|
||||
@@ -21,32 +21,6 @@ export class MSSQLCtlTool implements ITool {
|
||||
}
|
||||
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.MSSQLCTLDisplayName', 'mssqlctl');
|
||||
}
|
||||
|
||||
isInstalled(versionExpression: string): Thenable<boolean> {
|
||||
let promise = new Promise<boolean>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
get supportAutoInstall(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
install(version: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus> {
|
||||
let promise = new Promise<ToolInstallationStatus>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(ToolInstallationStatus.Installed);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
return localize('resourceDeployment.MssqlCtlDisplayName', 'mssqlctl');
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolType, ITool, ToolInstallationStatus } from '../../interfaces';
|
||||
import { ToolType, ITool } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
export class PythonTool implements ITool {
|
||||
get name(): string {
|
||||
return 'python';
|
||||
@@ -24,21 +23,4 @@ export class PythonTool implements ITool {
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.PythonDisplayName', 'Python');
|
||||
}
|
||||
|
||||
get supportAutoInstall(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
install(version: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getInstallationStatus(versionExpression: string): Thenable<ToolInstallationStatus> {
|
||||
let promise = new Promise<ToolInstallationStatus>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(ToolInstallationStatus.Installed);
|
||||
}, 500);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { ToolRequirementInfo, ToolStatusInfo, ITool } from '../interfaces';
|
||||
import { ITool } from '../interfaces';
|
||||
import { PythonTool } from './tools/pythonTool';
|
||||
import { DockerTool } from './tools/dockerTool';
|
||||
import { AzCliTool } from './tools/azCliTool';
|
||||
@@ -11,42 +11,17 @@ import { MSSQLCtlTool } from './tools/mssqlCtlTool';
|
||||
import { KubeCtlTool } from './tools/kubeCtlTool';
|
||||
|
||||
export interface IToolsService {
|
||||
getToolStatus(toolRequirements: ToolRequirementInfo[]): Thenable<ToolStatusInfo[]>;
|
||||
getToolByName(toolName: string): ITool | undefined;
|
||||
}
|
||||
|
||||
export class ToolsService implements IToolsService {
|
||||
private static readonly SupportedTools: ITool[] = [new PythonTool(), new DockerTool(), new AzCliTool(), new MSSQLCtlTool(), new KubeCtlTool()];
|
||||
|
||||
getToolStatus(toolRequirements: ToolRequirementInfo[]): Thenable<ToolStatusInfo[]> {
|
||||
const toolStatusList: ToolStatusInfo[] = [];
|
||||
let promises = [];
|
||||
for (let i = 0; i < toolRequirements.length; i++) {
|
||||
const toolRequirement = toolRequirements[i];
|
||||
const tool = this.getToolByName(toolRequirement.name);
|
||||
if (tool !== undefined) {
|
||||
promises.push(tool.getInstallationStatus(toolRequirement.version).then(installStatus => {
|
||||
toolStatusList.push(<ToolStatusInfo>{
|
||||
name: tool.displayName,
|
||||
description: tool.description,
|
||||
status: installStatus,
|
||||
version: toolRequirement.version
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
return Promise.all(promises).then(() => { return toolStatusList; });
|
||||
constructor() {
|
||||
this.SupportedTools = [new PythonTool(), new DockerTool(), new AzCliTool(), new MSSQLCtlTool(), new KubeCtlTool()];
|
||||
}
|
||||
|
||||
private SupportedTools: ITool[];
|
||||
|
||||
getToolByName(toolName: string): ITool | undefined {
|
||||
if (toolName) {
|
||||
for (let i = 0; i < ToolsService.SupportedTools.length; i++) {
|
||||
if (toolName === ToolsService.SupportedTools[i].name) {
|
||||
return ToolsService.SupportedTools[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return this.SupportedTools.find(t => t.name === toolName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import * as azdata from 'azdata';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { IResourceTypeService } from '../services/resourceTypeService';
|
||||
import * as vscode from 'vscode';
|
||||
import { ResourceType, DeploymentProvider, ToolInstallationStatus } from '../interfaces';
|
||||
import { ResourceType, DeploymentProvider } from '../interfaces';
|
||||
import { IToolsService } from '../services/toolsService';
|
||||
import { INotebookService } from '../services/notebookService';
|
||||
|
||||
@@ -41,6 +41,7 @@ export class ResourceDeploymentDialog {
|
||||
private initializeDialog() {
|
||||
let tab = azdata.window.createTab('');
|
||||
tab.registerContent((view: azdata.ModelView) => {
|
||||
const tableWidth = 1126;
|
||||
this._view = view;
|
||||
this.resourceTypeService.getResourceTypes().forEach(resourceType => this.addCard(resourceType));
|
||||
const cardsContainer = view.modelBuilder.flexContainer().withItems(this._resourceTypeCards, { flex: '0 0 auto', CSSStyles: { 'margin-bottom': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'left' }).component();
|
||||
@@ -49,28 +50,22 @@ export class ResourceDeploymentDialog {
|
||||
|
||||
const toolColumn: azdata.TableColumn = {
|
||||
value: localize('deploymentDialog.toolNameColumnHeader', 'Tool'),
|
||||
width: 100
|
||||
width: 150
|
||||
};
|
||||
const descriptionColumn: azdata.TableColumn = {
|
||||
value: localize('deploymentDialog.toolDescriptionColumnHeader', 'Description'),
|
||||
width: 500
|
||||
};
|
||||
const versionColumn: azdata.TableColumn = {
|
||||
value: localize('deploymentDialog.toolVersionColumnHeader', 'Version'),
|
||||
width: 200
|
||||
};
|
||||
const statusColumn: azdata.TableColumn = {
|
||||
value: localize('deploymentDialog.toolStatusColumnHeader', 'Status'),
|
||||
width: 200
|
||||
width: 850
|
||||
};
|
||||
|
||||
this._toolsTable = view.modelBuilder.table().withProperties<azdata.TableComponentProperties>({
|
||||
height: 150,
|
||||
data: [],
|
||||
columns: [toolColumn, descriptionColumn, versionColumn, statusColumn],
|
||||
width: 1000
|
||||
columns: [toolColumn, descriptionColumn],
|
||||
width: tableWidth
|
||||
}).component();
|
||||
|
||||
const toolsTableWrapper = view.modelBuilder.divContainer().withLayout({ width: tableWidth }).component();
|
||||
toolsTableWrapper.addItem(this._toolsTable, { CSSStyles: { 'border-left': '1px solid silver', 'border-top': '1px solid silver' } });
|
||||
|
||||
const formBuilder = view.modelBuilder.formContainer().withFormItems(
|
||||
[
|
||||
{
|
||||
@@ -83,7 +78,7 @@ export class ResourceDeploymentDialog {
|
||||
component: this._optionsContainer,
|
||||
title: localize('deploymentDialog.OptionsTitle', 'Options')
|
||||
}, {
|
||||
component: this._toolsTable,
|
||||
component: toolsTableWrapper,
|
||||
title: localize('deploymentDialog.RequiredToolsTitle', 'Required tools')
|
||||
}
|
||||
],
|
||||
@@ -165,27 +160,18 @@ export class ResourceDeploymentDialog {
|
||||
}
|
||||
|
||||
private updateTools(): void {
|
||||
this.toolsService.getToolStatus(this.getCurrentProvider().requiredTools).then(toolStatus => {
|
||||
let tableData = toolStatus.map(tool => {
|
||||
return [tool.name, tool.description, tool.version, this.getToolStatusText(tool.status)];
|
||||
// do a 10 ms delay to workaround the issue of first time load:
|
||||
// during initialization this update to table will be processed prior to the table initialization update
|
||||
// as a result the data will be overwritten, introduce a short delay so that the order of updates can be maintained.
|
||||
setTimeout(() => {
|
||||
const tools = this.getCurrentProvider().requiredTools;
|
||||
const headerRowHeight = 28;
|
||||
this._toolsTable.height = 25 * tools.length + headerRowHeight;
|
||||
this._toolsTable.data = tools.map(toolRef => {
|
||||
const tool = this.toolsService.getToolByName(toolRef.name)!;
|
||||
return [tool.displayName, tool.description];
|
||||
});
|
||||
this._toolsTable.data = tableData;
|
||||
});
|
||||
}
|
||||
|
||||
private getToolStatusText(status: ToolInstallationStatus): string {
|
||||
switch (status) {
|
||||
case ToolInstallationStatus.Installed:
|
||||
return '✔️ ' + localize('deploymentDialog.InstalledText', 'Installed');
|
||||
case ToolInstallationStatus.NotInstalled:
|
||||
return '❌ ' + localize('deploymentDialog.NotInstalledText', 'Not Installed');
|
||||
case ToolInstallationStatus.Installing:
|
||||
return '⌛ ' + localize('deploymentDialog.InstallingText', 'Installing…');
|
||||
case ToolInstallationStatus.FailedToInstall:
|
||||
return '❌ ' + localize('deploymentDialog.FailedToInstallText', 'Install Failed');
|
||||
default:
|
||||
return 'unknown status';
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
private getCurrentProvider(): DeploymentProvider {
|
||||
|
||||
Reference in New Issue
Block a user