Make connection mode a displayname (#20068)

* dropdown not supporting dynamic enablement

* paused for weekend

* Make connection mode display with capitalization but value lowercase

* Undo changes in modelviewutils

Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
Candice Ye
2022-07-18 17:02:31 -07:00
committed by GitHub
parent fae9ccb531
commit 77e7a90c20
7 changed files with 51 additions and 35 deletions

View File

@@ -158,7 +158,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"is_indirect = arc_data_controller_connectivity_mode == 'Indirect'\n", "is_indirect = arc_data_controller_connectivity_mode == 'indirect'\n",
"\n", "\n",
"if not is_indirect:\n", "if not is_indirect:\n",
"\trun_command('az login')" "\trun_command('az login')"

View File

@@ -177,10 +177,16 @@
"variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"options": { "options": {
"values": [ "values": [
"Indirect", {
"Direct" "name": "indirect",
"displayName": "%arc.data.controller.indirect.display.name%"
},
{
"name": "direct",
"displayName": "%arc.data.controller.direct.display.name%"
}
], ],
"defaultValue": "Indirect", "defaultValue": "indirect",
"optionsType": "radio" "optionsType": "radio"
} }
}, },
@@ -193,7 +199,7 @@
"configFileVariableName": "AZDATA_NB_VAR_ARC_CONFIG_FILE", "configFileVariableName": "AZDATA_NB_VAR_ARC_CONFIG_FILE",
"enabled": { "enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Indirect" "value": "indirect"
} }
}, },
{ {
@@ -210,6 +216,10 @@
}, },
"defaultValue": "azure-arc-aks-default-storage", "defaultValue": "azure-arc-aks-default-storage",
"optionsType": "dropdown" "optionsType": "dropdown"
},
"enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "indirect"
} }
} }
] ]
@@ -252,7 +262,11 @@
"uksouth", "uksouth",
"westeurope", "westeurope",
"westus2" "westus2"
] ],
"enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "indirect"
}
} }
] ]
} }
@@ -269,25 +283,6 @@
"label": "%arc.data.controller.details.description%", "label": "%arc.data.controller.details.description%",
"labelWidth": "600px" "labelWidth": "600px"
}, },
{
"type": "text",
"label": "%arc.data.controller.namespace%",
"validations": [
{
"type": "regex_match",
"regex": "^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$",
"description": "%arc.data.controller.namespace.validation.description%"
}
],
"defaultValue": "",
"required": true,
"variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE",
"enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Indirect"
},
"description": "%arc.data.controller.namespace.description%"
},
{ {
"type": "text", "type": "text",
"label": "%arc.data.controller.name%", "label": "%arc.data.controller.name%",
@@ -332,9 +327,28 @@
"variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CLUSTER_NAME", "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CLUSTER_NAME",
"enabled": { "enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Direct" "value": "direct"
} }
}, },
{
"type": "text",
"label": "%arc.data.controller.namespace%",
"validations": [
{
"type": "regex_match",
"regex": "^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$",
"description": "%arc.data.controller.namespace.validation.description%"
}
],
"defaultValue": "",
"required": true,
"variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE",
"enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "indirect"
},
"description": "%arc.data.controller.namespace.description%"
},
{ {
"type": "text", "type": "text",
"label": "%arc.data.controller.custom.location%", "label": "%arc.data.controller.custom.location%",
@@ -343,7 +357,7 @@
"variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CUSTOM_LOCATION", "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CUSTOM_LOCATION",
"enabled": { "enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Direct" "value": "direct"
} }
}, },
{ {
@@ -354,7 +368,7 @@
"defaultValue": false, "defaultValue": false,
"enabled": { "enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Direct" "value": "direct"
} }
}, },
{ {
@@ -365,7 +379,7 @@
"defaultValue": false, "defaultValue": false,
"enabled": { "enabled": {
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
"value": "Direct" "value": "direct"
} }
}, },
{ {

View File

@@ -29,6 +29,8 @@
"arc.data.controller.project.details.description": "Select the subscription to manage deployed resources and costs. Use resource groups like folders to organize and manage all your resources.", "arc.data.controller.project.details.description": "Select the subscription to manage deployed resources and costs. Use resource groups like folders to organize and manage all your resources.",
"arc.data.controller.details.title": "Data controller details", "arc.data.controller.details.title": "Data controller details",
"arc.data.controller.details.description": "For indirect mode, provide a namespace, name and storage class for your Azure Arc data controller. This name will be used to identify your Arc instance for remote management and monitoring. For direct mode you do not need to provide a namespace, but please provide the custom location name.", "arc.data.controller.details.description": "For indirect mode, provide a namespace, name and storage class for your Azure Arc data controller. This name will be used to identify your Arc instance for remote management and monitoring. For direct mode you do not need to provide a namespace, but please provide the custom location name.",
"arc.data.controller.indirect.display.name": "Indirect",
"arc.data.controller.direct.display.name": "Direct",
"arc.data.controller.connectivity.mode": "Connectivity mode", "arc.data.controller.connectivity.mode": "Connectivity mode",
"arc.data.controller.namespace": "Data controller namespace", "arc.data.controller.namespace": "Data controller namespace",
"arc.data.controller.namespace.description": "Data controller namespace. Indirect mode only.", "arc.data.controller.namespace.description": "Data controller namespace. Indirect mode only.",

View File

@@ -70,7 +70,7 @@ export class ControllerModel {
public async refresh(showErrors: boolean = true, namespace: string): Promise<void> { public async refresh(showErrors: boolean = true, namespace: string): Promise<void> {
await this.refreshController(showErrors, namespace); await this.refreshController(showErrors, namespace);
if (this._controllerConfig?.spec.settings.azure.connectionMode === ConnectionMode.direct) { if (this._controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
await this.refreshDirectMode(this._controllerConfig?.spec.settings.azure.resourceGroup, namespace); await this.refreshDirectMode(this._controllerConfig?.spec.settings.azure.resourceGroup, namespace);
} else { } else {
await this.refreshIndirectMode(namespace); await this.refreshIndirectMode(namespace);

View File

@@ -7,7 +7,7 @@ import { ResourceType } from 'arc';
import * as azdata from 'azdata'; import * as azdata from 'azdata';
import * as azurecore from 'azurecore'; import * as azurecore from 'azurecore';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { getConnectionModeDisplayText, getResourceTypeIcon, resourceTypeToDisplayName } from '../../../common/utils'; import { getResourceTypeIcon, resourceTypeToDisplayName } from '../../../common/utils';
import { cssStyles, IconPathHelper, controllerTroubleshootDocsUrl, iconSize } from '../../../constants'; import { cssStyles, IconPathHelper, controllerTroubleshootDocsUrl, iconSize } from '../../../constants';
import * as loc from '../../../localizedConstants'; import * as loc from '../../../localizedConstants';
import { ControllerModel } from '../../../models/controllerModel'; import { ControllerModel } from '../../../models/controllerModel';
@@ -218,7 +218,7 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
this.controllerProperties.resourceGroupName = config?.spec.settings.azure.resourceGroup || this.controllerProperties.resourceGroupName; this.controllerProperties.resourceGroupName = config?.spec.settings.azure.resourceGroup || this.controllerProperties.resourceGroupName;
this.controllerProperties.location = this._azurecoreApi.getRegionDisplayName(config?.spec.settings.azure.location) || this.controllerProperties.location; this.controllerProperties.location = this._azurecoreApi.getRegionDisplayName(config?.spec.settings.azure.location) || this.controllerProperties.location;
this.controllerProperties.subscriptionId = config?.spec.settings.azure.subscription || this.controllerProperties.subscriptionId; this.controllerProperties.subscriptionId = config?.spec.settings.azure.subscription || this.controllerProperties.subscriptionId;
this.controllerProperties.connectionMode = getConnectionModeDisplayText(config?.spec.settings.azure.connectionMode) || this.controllerProperties.connectionMode; this.controllerProperties.connectionMode = config?.spec.settings.azure.connectionMode.toLowerCase() || this.controllerProperties.connectionMode.toLowerCase();
this.controllerProperties.instanceNamespace = config?.metadata.namespace || this.controllerProperties.instanceNamespace; this.controllerProperties.instanceNamespace = config?.metadata.namespace || this.controllerProperties.instanceNamespace;
this.controllerProperties.status = config?.status.state || this.controllerProperties.status; this.controllerProperties.status = config?.status.state || this.controllerProperties.status;
this.refreshDisplayedProperties(); this.refreshDisplayedProperties();

View File

@@ -160,7 +160,7 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
private async getMiaaVersion(): Promise<string | undefined> { private async getMiaaVersion(): Promise<string | undefined> {
try { try {
let miaaShowResult; let miaaShowResult;
if (this._controllerModel.info.connectionMode === ConnectionMode.direct || this._controllerModel.controllerConfig?.spec.settings.azure.connectionMode === ConnectionMode.direct) { if (this._controllerModel.info.connectionMode === ConnectionMode.direct || this._controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
miaaShowResult = await this._azApi.az.sql.miarc.show( miaaShowResult = await this._azApi.az.sql.miarc.show(
this._miaaModel.info.name, this._miaaModel.info.name,
{ {

View File

@@ -201,10 +201,10 @@ export class ConnectToControllerDialog extends ControllerDialogBase {
// default info.name to the name of the controller instance if the user did not specify their own and to a pre-canned default if for some weird reason controller endpoint returned instanceName is also not a valid value // default info.name to the name of the controller instance if the user did not specify their own and to a pre-canned default if for some weird reason controller endpoint returned instanceName is also not a valid value
controllerModel.info.name = controllerModel.info.name || controllerModel.controllerConfig?.metadata.name || loc.defaultControllerName; controllerModel.info.name = controllerModel.info.name || controllerModel.controllerConfig?.metadata.name || loc.defaultControllerName;
controllerModel.info.resourceGroup = <string>controllerModel.controllerConfig?.spec.settings.azure.resourceGroup; controllerModel.info.resourceGroup = <string>controllerModel.controllerConfig?.spec.settings.azure.resourceGroup;
controllerModel.info.connectionMode = <string>controllerModel.controllerConfig?.spec.settings.azure.connectionMode; controllerModel.info.connectionMode = <string>controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase();
controllerModel.info.location = <string>controllerModel.controllerConfig?.spec.settings.azure.location; controllerModel.info.location = <string>controllerModel.controllerConfig?.spec.settings.azure.location;
if (controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct.toLowerCase()) { if (controllerModel.info.connectionMode === ConnectionMode.direct) {
const rawCustomLocation = <string>controllerModel.controllerConfig?.metadata.annotations['management.azure.com/customLocation']; const rawCustomLocation = <string>controllerModel.controllerConfig?.metadata.annotations['management.azure.com/customLocation'];
const exp = /custom[lL]ocations\/([\S]*)/; const exp = /custom[lL]ocations\/([\S]*)/;
controllerModel.info.customLocation = <string>exp.exec(rawCustomLocation)?.pop(); controllerModel.info.customLocation = <string>exp.exec(rawCustomLocation)?.pop();