From 10be48ecb2444caa5a03af767018f8cd4abcb364 Mon Sep 17 00:00:00 2001 From: Megan Mott <59709511+motm32@users.noreply.github.com> Date: Tue, 19 Sep 2023 10:50:24 -0700 Subject: [PATCH] serviceconnector: Change `nonNullValue` to `nonNullProp` (#1582) * Change to nonNullProp * Change to nonNullPropAndValue --- .../src/createLinker/LinkerCreateStep.ts | 12 ++++++------ serviceconnector/src/createLinker/LinkerNameStep.ts | 4 ++-- .../src/deleteLinker/DeleteLinkerStep.ts | 6 +++--- serviceconnector/src/deleteLinker/LinkerListStep.ts | 6 +++--- .../src/tree/ServiceConnectorGroupItem.ts | 6 +++--- .../src/tree/ServiceConnectorGroupTreeItem.ts | 4 ++-- serviceconnector/src/tree/ServiceConnectorItem.ts | 6 +++--- .../src/tree/ServiceConnectorTreeItem.ts | 4 ++-- .../src/validateLinker/ValidateLinkerStep.ts | 10 +++++----- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/serviceconnector/src/createLinker/LinkerCreateStep.ts b/serviceconnector/src/createLinker/LinkerCreateStep.ts index d2919bd4b1..b3b977e2ca 100644 --- a/serviceconnector/src/createLinker/LinkerCreateStep.ts +++ b/serviceconnector/src/createLinker/LinkerCreateStep.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, nonNullValue, randomUtils } from "@microsoft/vscode-azext-utils"; +import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, nonNullValueAndProp, randomUtils } from "@microsoft/vscode-azext-utils"; import * as vscode from 'vscode'; import { TargetServiceTypeName } from "../../constants"; import { createLinkerClient } from "../linkerClient"; @@ -25,8 +25,8 @@ export class LinkerCreateStep extends AzureWizardExecuteStep{ public async prompt(context: ICreateLinkerContext): Promise { context.linkerName = await context.ui.showInputBox({ prompt: vscode.l10n.t('Enter a name for the connection'), - value: nonNullValue(context.targetServiceType?.name) + '_' + randomUtils.getRandomHexString(5), + value: nonNullValueAndProp(context.targetServiceType, 'name') + '_' + randomUtils.getRandomHexString(5), validateInput: this.validateInput }); } diff --git a/serviceconnector/src/deleteLinker/DeleteLinkerStep.ts b/serviceconnector/src/deleteLinker/DeleteLinkerStep.ts index 43dc19b65e..426ee3f2b6 100644 --- a/serviceconnector/src/deleteLinker/DeleteLinkerStep.ts +++ b/serviceconnector/src/deleteLinker/DeleteLinkerStep.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, nonNullValue, randomUtils } from "@microsoft/vscode-azext-utils"; +import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, randomUtils } from "@microsoft/vscode-azext-utils"; import { createLinkerClient } from "../linkerClient"; import { IPickLinkerContext } from "./IPickLinkerContext"; @@ -12,7 +12,7 @@ export class DeleteLinkerStep extends AzureWizardExecuteStep public async execute(context: IPickLinkerContext): Promise { const client = await createLinkerClient(context); - const config = await client.linker.listConfigurations(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName)); + const config = await client.linker.listConfigurations(nonNullProp(context, 'sourceResourceUri'), nonNullProp(context, 'linkerName')); context.activityChildren = []; for (const item of nonNullProp(config, 'configurations')) { @@ -23,7 +23,7 @@ export class DeleteLinkerStep extends AzureWizardExecuteStep })); } - await client.linker.beginDeleteAndWait(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName)); + await client.linker.beginDeleteAndWait(nonNullProp(context, 'sourceResourceUri'), nonNullProp(context, 'linkerName')); } public shouldExecute(): boolean { diff --git a/serviceconnector/src/deleteLinker/LinkerListStep.ts b/serviceconnector/src/deleteLinker/LinkerListStep.ts index 80c5bdab66..aa66a3a9ad 100644 --- a/serviceconnector/src/deleteLinker/LinkerListStep.ts +++ b/serviceconnector/src/deleteLinker/LinkerListStep.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { uiUtils } from "@microsoft/vscode-azext-azureutils"; -import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp } from "@microsoft/vscode-azext-utils"; import * as vscode from 'vscode'; import { createLinkerClient } from "../linkerClient"; import { IPickLinkerContext } from "./IPickLinkerContext"; @@ -20,9 +20,9 @@ export class LinkerListStep extends AzureWizardPromptStep{ private async getPicks(context: IPickLinkerContext): Promise[]> { const client = await createLinkerClient(context); - const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullValue(context.sourceResourceUri)))); + const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullProp(context, 'sourceResourceUri')))); return linkers.map(l => { - return { label: nonNullValue(l.name), data: nonNullValue(l.name) } + return { label: nonNullProp(l, 'name'), data: nonNullProp(l, 'name') } }); } } diff --git a/serviceconnector/src/tree/ServiceConnectorGroupItem.ts b/serviceconnector/src/tree/ServiceConnectorGroupItem.ts index 17189df91c..ca4debe1ed 100644 --- a/serviceconnector/src/tree/ServiceConnectorGroupItem.ts +++ b/serviceconnector/src/tree/ServiceConnectorGroupItem.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { uiUtils } from "@microsoft/vscode-azext-azureutils"; -import { ISubscriptionContext, TreeElementBase, callWithTelemetryAndErrorHandling, createSubscriptionContext, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { ISubscriptionContext, TreeElementBase, callWithTelemetryAndErrorHandling, createSubscriptionContext, nonNullProp, nonNullValue } from "@microsoft/vscode-azext-utils"; import * as vscode from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from "vscode"; import { LinkerItem } from "../createLinker/createLinker"; @@ -22,11 +22,11 @@ export class ServiceConnectorGroupItem implements TreeElementBase { async getChildren(): Promise { const result = await callWithTelemetryAndErrorHandling('getChildren', async () => { const client = new (await import('@azure/arm-servicelinker')).ServiceLinkerManagementClient(this.subscription.credentials); - const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullValue(this.item.id)))); + const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullProp(this.item, 'id')))); return linkers.map(linker => createServiceConnectorItem(this.subscription, this.item, linker)); }); - return nonNullValue(result); + return nonNullValue(result, 'getChildren'); } getTreeItem(): TreeItem { diff --git a/serviceconnector/src/tree/ServiceConnectorGroupTreeItem.ts b/serviceconnector/src/tree/ServiceConnectorGroupTreeItem.ts index e8c9385bec..31c2a4eb2f 100644 --- a/serviceconnector/src/tree/ServiceConnectorGroupTreeItem.ts +++ b/serviceconnector/src/tree/ServiceConnectorGroupTreeItem.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { uiUtils } from "@microsoft/vscode-azext-azureutils"; -import { AzExtParentTreeItem, AzExtTreeItem, TreeItemIconPath, createContextValue, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { AzExtParentTreeItem, AzExtTreeItem, TreeItemIconPath, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils"; import * as vscode from 'vscode'; import { getIconPath } from "./IconPath"; import { ServiceConnectorTreeItem } from "./ServiceConnectorTreeItem"; @@ -16,7 +16,7 @@ export class ServiceConnectorGroupTreeItem extends AzExtParentTreeItem { public async loadMoreChildrenImpl(): Promise { const client = new (await import('@azure/arm-servicelinker')).ServiceLinkerManagementClient(this.subscription.credentials); - const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullValue(this.resourceId)))); + const linkers = (await uiUtils.listAllIterator(client.linker.list(nonNullProp(this, 'resourceId')))); const children = await this.createTreeItemsWithErrorHandling( linkers, diff --git a/serviceconnector/src/tree/ServiceConnectorItem.ts b/serviceconnector/src/tree/ServiceConnectorItem.ts index db61db2b39..fd08f411e1 100644 --- a/serviceconnector/src/tree/ServiceConnectorItem.ts +++ b/serviceconnector/src/tree/ServiceConnectorItem.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { AzureResource, LinkerResource, TargetServiceBaseUnion } from "@azure/arm-servicelinker"; -import { ISubscriptionContext, TreeElementBase, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { ISubscriptionContext, TreeElementBase, nonNullProp } from "@microsoft/vscode-azext-utils"; import { ThemeIcon, TreeItem } from "vscode"; import { LinkerItem } from "../createLinker/createLinker"; import { getIconPath } from "./IconPath"; @@ -36,9 +36,9 @@ export function createServiceConnectorItem(subscription: ISubscriptionContext, i export function connectionIconPath(linker: LinkerResource): string { - const targetResource = nonNullValue(linker.targetService) + const targetResource = nonNullProp(linker, 'targetService') if (isAzureResource(targetResource)) { - const id: string = nonNullValue(targetResource.id) + const id: string = nonNullProp(targetResource, 'id') if (id.includes('Microsoft.Storage')) { return 'AzureStorageAccount'; } else if (id.includes('Microsoft.DBforPostgreSQL')) { diff --git a/serviceconnector/src/tree/ServiceConnectorTreeItem.ts b/serviceconnector/src/tree/ServiceConnectorTreeItem.ts index d9c786f365..02369dd376 100644 --- a/serviceconnector/src/tree/ServiceConnectorTreeItem.ts +++ b/serviceconnector/src/tree/ServiceConnectorTreeItem.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { LinkerResource } from "@azure/arm-servicelinker"; -import { AzExtParentTreeItem, AzExtTreeItem, TreeItemIconPath, createContextValue, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { AzExtParentTreeItem, AzExtTreeItem, TreeItemIconPath, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils"; import { ThemeIcon } from "vscode"; import { getIconPath } from "./IconPath"; import { connectionIconPath } from "./ServiceConnectorItem"; @@ -25,7 +25,7 @@ export class ServiceConnectorTreeItem extends AzExtTreeItem { } public get label(): string { - return nonNullValue(this.linker.name); + return nonNullProp(this.linker, 'name'); } public get contextValue(): string { diff --git a/serviceconnector/src/validateLinker/ValidateLinkerStep.ts b/serviceconnector/src/validateLinker/ValidateLinkerStep.ts index a7c2b36e6f..762163885b 100644 --- a/serviceconnector/src/validateLinker/ValidateLinkerStep.ts +++ b/serviceconnector/src/validateLinker/ValidateLinkerStep.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { AzureWizardExecuteStep, GenericTreeItem, nonNullValue, randomUtils } from "@microsoft/vscode-azext-utils"; +import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, randomUtils } from "@microsoft/vscode-azext-utils"; import { ThemeColor, ThemeIcon } from "vscode"; import { IPickLinkerContext } from "../deleteLinker/IPickLinkerContext"; import { createLinkerClient } from "../linkerClient"; @@ -13,22 +13,22 @@ export class ValidateLinkerStep extends AzureWizardExecuteStep { const client = await createLinkerClient(context); - const response = await client.linker.beginValidateAndWait(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName)); + const response = await client.linker.beginValidateAndWait(nonNullProp(context, 'sourceResourceUri'), nonNullProp(context, 'linkerName')); context.activityChildren = []; - for (const detail of nonNullValue(response.validationDetail)) { + for (const detail of nonNullProp(response, 'validationDetail')) { if (detail.result === "failure") { context.activityChildren.push(new GenericTreeItem(undefined, { contextValue: `validateResult-${detail.name}-` + randomUtils.getRandomHexString(3), - label: nonNullValue(detail.name), + label: nonNullProp(detail, 'name'), iconPath: new ThemeIcon('error', new ThemeColor('testing.iconFailed')) })); throw new Error(detail.description); } else { context.activityChildren.push(new GenericTreeItem(undefined, { contextValue: `validateResult-${detail.name}` + randomUtils.getRandomHexString(3), - label: nonNullValue(detail.name), + label: nonNullProp(detail, 'name'), iconPath: new ThemeIcon('pass', new ThemeColor('testing.iconPassed')) })); }