From 8bfb1a9d3926a97231f96ec5492aaff196e1cb89 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Tue, 26 Feb 2019 12:48:35 -0800 Subject: [PATCH] add restore default values button for ports and container settings (#4195) * add restore default values button for ports and container settings * change some resource strings --- extensions/big-data-cluster/src/interfaces.ts | 24 ++++++---- extensions/big-data-cluster/src/main.ts | 1 - .../create-cluster/createClusterModel.ts | 29 ++++++----- .../pages/selectTargetClusterTypePage.ts | 19 ++++++-- .../create-cluster/pages/settingsPage.ts | 48 ++++++++++++++----- 5 files changed, 82 insertions(+), 39 deletions(-) diff --git a/extensions/big-data-cluster/src/interfaces.ts b/extensions/big-data-cluster/src/interfaces.ts index 6471c1ef03..250a2f5de6 100644 --- a/extensions/big-data-cluster/src/interfaces.ts +++ b/extensions/big-data-cluster/src/interfaces.ts @@ -16,23 +16,23 @@ export enum TargetClusterType { } export interface Succeeded { - readonly succeeded: true; - readonly result: T; + readonly succeeded: true; + readonly result: T; } export interface Failed { - readonly succeeded: false; - readonly error: string[]; + readonly succeeded: false; + readonly error: string[]; } export type Errorable = Succeeded | Failed; export function succeeded(e: Errorable): e is Succeeded { - return e.succeeded; + return e.succeeded; } export function failed(e: Errorable): e is Failed { - return !e.succeeded; + return !e.succeeded; } export interface ClusterPorts { sql: string; @@ -59,7 +59,13 @@ export interface TargetClusterTypeInfo { } export interface ToolInfo { - name: string, - description: string, - isInstalled: boolean + name: string; + description: string; + status: ToolInstallationStatus; +} + +export enum ToolInstallationStatus { + Installed, + NotInstalled, + Installing } diff --git a/extensions/big-data-cluster/src/main.ts b/extensions/big-data-cluster/src/main.ts index 4f5c74a77c..6eeb297f72 100644 --- a/extensions/big-data-cluster/src/main.ts +++ b/extensions/big-data-cluster/src/main.ts @@ -20,7 +20,6 @@ const kubectl = kubectlCreate(host, fs, shell, installDependencies); export let controller: MainController; export function activate(context: vscode.ExtensionContext) { - kubectl.checkPresent(CheckPresentMessageMode.Activation); controller = new MainController(context, kubectl); controller.activate(); } diff --git a/extensions/big-data-cluster/src/wizards/create-cluster/createClusterModel.ts b/extensions/big-data-cluster/src/wizards/create-cluster/createClusterModel.ts index c4e67303d8..c42d5ea843 100644 --- a/extensions/big-data-cluster/src/wizards/create-cluster/createClusterModel.ts +++ b/extensions/big-data-cluster/src/wizards/create-cluster/createClusterModel.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { IKubeConfigParser } from '../../data/kubeConfigParser'; -import { ClusterInfo, TargetClusterType, ClusterPorts, ContainerRegistryInfo, TargetClusterTypeInfo, ToolInfo } from '../../interfaces'; -import { getContexts, KubectlContext } from '../../kubectl/kubectlUtils'; +import { TargetClusterType, ClusterPorts, ContainerRegistryInfo, TargetClusterTypeInfo, ToolInfo, ToolInstallationStatus } from '../../interfaces'; +import { getContexts, KubectlContext } from '../../kubectl/kubectlUtils'; import { Kubectl } from '../../kubectl/kubectl'; import * as nls from 'vscode-nls'; @@ -16,7 +15,7 @@ export class CreateClusterModel { private _tmp_tools_installed: boolean = false; - constructor(private _kubectl : Kubectl) { + constructor(private _kubectl: Kubectl) { } public async loadClusters(): Promise { @@ -40,8 +39,8 @@ export class CreateClusterModel { public getDefaultContainerRegistryInfo(): Thenable { let promise = new Promise(resolve => { resolve({ - registry: 'http://repo.corp.microsoft.com/', - repository: 'aris-p-master-dsmain-standard', + registry: 'private-repo.microsoft.com', + repository: 'mssql-private-preview', imageTag: 'latest' }); }); @@ -74,19 +73,19 @@ export class CreateClusterModel { public getRequiredToolStatus(): Thenable { let kubeCtl = { - name: 'KUBECTL', - description: 'KUBECTL', - isInstalled: true + name: 'kubectl', + description: 'Tool used for managing the Kubernetes cluster', + status: ToolInstallationStatus.Installed }; let mssqlCtl = { - name: 'MSSQLCTL', - description: 'MSSQLCTL', - isInstalled: true + name: 'mssqlctl', + description: 'Command-line tool for installing and managing the SQL Server big data cluster', + status: ToolInstallationStatus.Installed }; let azureCli = { - name: 'AzureCLI', - description: 'AzureCLI', - isInstalled: this._tmp_tools_installed + name: 'Azure CLI', + description: 'Tool used for managing Azure services', + status: this._tmp_tools_installed ? ToolInstallationStatus.Installed : ToolInstallationStatus.NotInstalled }; let promise = new Promise(resolve => { setTimeout(() => { diff --git a/extensions/big-data-cluster/src/wizards/create-cluster/pages/selectTargetClusterTypePage.ts b/extensions/big-data-cluster/src/wizards/create-cluster/pages/selectTargetClusterTypePage.ts index 7d2c7bc9ba..7c564c7075 100644 --- a/extensions/big-data-cluster/src/wizards/create-cluster/pages/selectTargetClusterTypePage.ts +++ b/extensions/big-data-cluster/src/wizards/create-cluster/pages/selectTargetClusterTypePage.ts @@ -6,7 +6,7 @@ import * as sqlops from 'sqlops'; import { WizardPageBase } from '../../wizardPageBase'; -import { TargetClusterTypeInfo } from '../../../interfaces'; +import { TargetClusterTypeInfo, ToolInstallationStatus } from '../../../interfaces'; import * as nls from 'vscode-nls'; import { CreateClusterWizard } from '../createClusterWizard'; @@ -184,13 +184,26 @@ export class SelectTargetClusterTypePage extends WizardPageBase !tool.isInstalled).length !== 0; + this.installToolsButton.enabled = tools.filter(tool => tool.status !== ToolInstallationStatus.Installed).length !== 0; this.isValid = !this.installToolsButton.enabled; this.wizard.wizardObject.message = null; let tableData = tools.map(tool => { - return [tool.name, tool.description, tool.isInstalled ? localize('bdc-create.InstalledText', 'Installed') : localize('bdc-create.NotInstalledText', 'Not Installed')]; + return [tool.name, tool.description, this.getStatusText(tool.status)]; }); this.toolsTable.data = tableData; }); } + + private getStatusText(status: ToolInstallationStatus): string { + switch (status) { + case ToolInstallationStatus.Installed: + return localize('bdc-create.InstalledText', 'Installed'); + case ToolInstallationStatus.NotInstalled: + return localize('bdc-create.NotInstalledText', 'Not Installed'); + case ToolInstallationStatus.Installing: + return localize('bdc-create.InstallingText', 'Installing'); + default: + return 'unknown status'; + } + } } diff --git a/extensions/big-data-cluster/src/wizards/create-cluster/pages/settingsPage.ts b/extensions/big-data-cluster/src/wizards/create-cluster/pages/settingsPage.ts index 3cc35d5ce6..1d42653c4f 100644 --- a/extensions/big-data-cluster/src/wizards/create-cluster/pages/settingsPage.ts +++ b/extensions/big-data-cluster/src/wizards/create-cluster/pages/settingsPage.ts @@ -13,6 +13,7 @@ import { CreateClusterWizard } from '../createClusterWizard'; const localize = nls.loadMessageBundle(); const UserNameInputWidth = '300px'; const PortInputWidth = '100px'; +const RestoreDefaultValuesText = localize('bdc-create.RestoreDefaultValuesText', 'Restore Default Values'); export class SettingsPage extends WizardPageBase { constructor(wizard: CreateClusterWizard) { @@ -44,24 +45,36 @@ export class SettingsPage extends WizardPageBase { }, 'password'); // Port settings - let sqlPortInput = this.createInputWithLabel(view, localize('bdc-create.SQLPortText', 'SQL Master port'), true, PortInputWidth, clusterPorts.sql, (inputBox: sqlops.InputBoxComponent) => { + let sqlPortInput = this.createInputWithLabel(view, localize('bdc-create.SQLPortText', 'SQL Server master'), true, PortInputWidth, clusterPorts.sql, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.sqlPort = inputBox.value; }); - let knoxPortInput = this.createInputWithLabel(view, localize('bdc-create.KnoxPortText', 'Knox port'), true, PortInputWidth, clusterPorts.knox, (inputBox: sqlops.InputBoxComponent) => { + let knoxPortInput = this.createInputWithLabel(view, localize('bdc-create.KnoxPortText', 'Knox'), true, PortInputWidth, clusterPorts.knox, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.knoxPort = inputBox.value; }); - let controllerPortInput = this.createInputWithLabel(view, localize('bdc-create.ControllerPortText', 'Controller port'), true, PortInputWidth, clusterPorts.controller, (inputBox: sqlops.InputBoxComponent) => { + let controllerPortInput = this.createInputWithLabel(view, localize('bdc-create.ControllerPortText', 'Controller'), true, PortInputWidth, clusterPorts.controller, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.controllerPort = inputBox.value; }); - let proxyPortInput = this.createInputWithLabel(view, localize('bdc-create.ProxyPortText', 'Proxy port'), true, PortInputWidth, clusterPorts.proxy, (inputBox: sqlops.InputBoxComponent) => { + let proxyPortInput = this.createInputWithLabel(view, localize('bdc-create.ProxyPortText', 'Proxy'), true, PortInputWidth, clusterPorts.proxy, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.proxyPort = inputBox.value; }); - let grafanaPortInput = this.createInputWithLabel(view, localize('bdc-create.GrafanaPortText', 'Grafana port'), true, PortInputWidth, clusterPorts.grafana, (inputBox: sqlops.InputBoxComponent) => { + let grafanaPortInput = this.createInputWithLabel(view, localize('bdc-create.GrafanaPortText', 'Grafana dashboard'), true, PortInputWidth, clusterPorts.grafana, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.grafanaPort = inputBox.value; }); - let kibanaPortInput = this.createInputWithLabel(view, localize('bdc-create.KibanaPortText', 'Kibana port'), true, PortInputWidth, clusterPorts.kibana, (inputBox: sqlops.InputBoxComponent) => { + let kibanaPortInput = this.createInputWithLabel(view, localize('bdc-create.KibanaPortText', 'Kibana dashboard'), true, PortInputWidth, clusterPorts.kibana, (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.kibanaPort = inputBox.value; }); + let restorePortSettingsButton = view.modelBuilder.button().withProperties({ + label: RestoreDefaultValuesText, + width: 200 + }).component(); + restorePortSettingsButton.onDidClick(() => { + sqlPortInput.input.value = clusterPorts.sql; + knoxPortInput.input.value = clusterPorts.knox; + controllerPortInput.input.value = clusterPorts.controller; + proxyPortInput.input.value = clusterPorts.proxy; + grafanaPortInput.input.value = clusterPorts.grafana; + kibanaPortInput.input.value = clusterPorts.kibana; + }); // Container Registry Settings let registryInput = this.createInputWithLabel(view, localize('bdc-create.RegistryText', 'Registry'), true, UserNameInputWidth, containerRegistryInfo.registry, (inputBox: sqlops.InputBoxComponent) => { @@ -83,10 +96,19 @@ export class SettingsPage extends WizardPageBase { let registryPasswordInput = this.createInputWithLabel(view, localize('bdc-create.RegistryPasswordText', 'Password'), false, UserNameInputWidth, '', (inputBox: sqlops.InputBoxComponent) => { this.wizard.model.containerRegistryPassword = inputBox.value; }); + let restoreContainerSettingsButton = view.modelBuilder.button().withProperties({ + label: RestoreDefaultValuesText, + width: 200 + }).component(); + restoreContainerSettingsButton.onDidClick(() => { + registryInput.input.value = containerRegistryInfo.registry; + repositoryInput.input.value = containerRegistryInfo.repository; + imageTagInput.input.value = containerRegistryInfo.imageTag; + }); - let basicSettingsGroup = view.modelBuilder.groupContainer().withItems([adminUserNameInput, adminPasswordInput]).withLayout({ header: localize('bdc-create.BasicSettingsText', 'Basic Settings'), collapsible: true }).component(); - let containerSettingsGroup = view.modelBuilder.groupContainer().withItems([registryInput, repositoryInput, imageTagInput, registryUserNameInput, registryPasswordInput]).withLayout({ header: localize('bdc-create.ContainerRegistrySettings', 'Container Registry Settings'), collapsible: true }).component(); - let portSettingsGroup = view.modelBuilder.groupContainer().withItems([sqlPortInput, knoxPortInput, controllerPortInput, proxyPortInput, grafanaPortInput, kibanaPortInput]).withLayout({ header: localize('bdc-create.PortSettings', 'Port Settings (Optional)'), collapsible: true, collapsed: true }).component(); + let basicSettingsGroup = view.modelBuilder.groupContainer().withItems([adminUserNameInput.row, adminPasswordInput.row]).withLayout({ header: localize('bdc-create.BasicSettingsText', 'Basic Settings'), collapsible: true }).component(); + let containerSettingsGroup = view.modelBuilder.groupContainer().withItems([registryInput.row, repositoryInput.row, imageTagInput.row, registryUserNameInput.row, registryPasswordInput.row, restoreContainerSettingsButton]).withLayout({ header: localize('bdc-create.ContainerRegistrySettings', 'Container Registry Settings'), collapsible: true }).component(); + let portSettingsGroup = view.modelBuilder.groupContainer().withItems([sqlPortInput.row, knoxPortInput.row, controllerPortInput.row, proxyPortInput.row, grafanaPortInput.row, kibanaPortInput.row, restorePortSettingsButton]).withLayout({ header: localize('bdc-create.PortSettings', 'Port Settings (Optional)'), collapsible: true, collapsed: true }).component(); let acceptEulaCheckbox = view.modelBuilder.checkBox().component(); acceptEulaCheckbox.checked = false; @@ -129,7 +151,7 @@ export class SettingsPage extends WizardPageBase { }); } - private createInputWithLabel(view: sqlops.ModelView, label: string, isRequiredField: boolean, inputWidth: string, initialValue: string, textChangedHandler: (inputBox: sqlops.InputBoxComponent) => void, inputType: string = 'text'): sqlops.FlexContainer { + private createInputWithLabel(view: sqlops.ModelView, label: string, isRequiredField: boolean, inputWidth: string, initialValue: string, textChangedHandler: (inputBox: sqlops.InputBoxComponent) => void, inputType: string = 'text'): { row: sqlops.FlexContainer, input: sqlops.InputBoxComponent } { let input = view.modelBuilder.inputBox().withProperties({ required: isRequiredField, inputType: inputType @@ -141,7 +163,11 @@ export class SettingsPage extends WizardPageBase { textChangedHandler(input); }); input.value = initialValue; - return this.createRow(view, [text, input]); + let row = this.createRow(view, [text, input]); + return { + input: input, + row: row + }; } private createRow(view: sqlops.ModelView, items: sqlops.Component[]): sqlops.FlexContainer {