From c79389ce09d7cea8f90ae53ffc1443265adf9d27 Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Mon, 1 Mar 2021 18:58:35 -0800 Subject: [PATCH 1/2] Add back button to add param files on linked deployments --- src/documents/templates/ChildTemplateCodeLens.ts | 10 +++++----- .../templates/deploymentTemplateCodeLenses.ts | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/documents/templates/ChildTemplateCodeLens.ts b/src/documents/templates/ChildTemplateCodeLens.ts index 06015b69c..b4ed8eff4 100644 --- a/src/documents/templates/ChildTemplateCodeLens.ts +++ b/src/documents/templates/ChildTemplateCodeLens.ts @@ -16,13 +16,14 @@ import { assertNever } from '../../util/assertNever'; import { parseUri, stringifyUri } from "../../util/uri"; import { ResolvableCodeLens } from '../DeploymentDocument'; import { IParameterValuesSourceProvider } from '../parameters/IParameterValuesSourceProvider'; +import { SelectParameterFileCodeLens } from "./deploymentTemplateCodeLenses"; import { ILinkedTemplateReference } from "./linkedTemplates/ILinkedTemplateReference"; import { LinkedFileLoadState } from "./linkedTemplates/LinkedFileLoadState"; import { IFullValidationStatus } from "./linkedTemplates/linkedTemplates"; import { TemplateScope, TemplateScopeKind } from './scopes/TemplateScope'; import { LinkedTemplateScope } from './scopes/templateScopes'; -const fullValidationOffMsg = "($(warning)full validation off)"; +//const fullValidationOffMsg = "($(warning)full validation off)"; abstract class ChildTemplateCodeLens extends ResolvableCodeLens { } @@ -138,7 +139,7 @@ export class LinkedTemplateCodeLens extends ChildTemplateCodeLens { } if (!fullValidationStatus.fullValidationEnabled) { - title += ` ${fullValidationOffMsg}`; + // title += ` ${fullValidationOffMsg}`; } else if (!firstLinkedTemplateRef) { title += " " + "(cannot validate - make sure all other validation errors have been fixed)"; } @@ -264,7 +265,6 @@ function addSelectParamFileLensIfNeeded( scope: TemplateScope, span: Span ): void { - /* if (!fullValidationStatus.fullValidationEnabled) { lenses.push( new SelectParameterFileCodeLens( @@ -272,9 +272,9 @@ function addSelectParamFileLensIfNeeded( span, topLevelParameterValuesProvider?.parameterFileUri, { - isForLinkedTemplate: true, + isForLinkedOrNestedTemplate: true, fullValidationStatus }) ); - */ + } } diff --git a/src/documents/templates/deploymentTemplateCodeLenses.ts b/src/documents/templates/deploymentTemplateCodeLenses.ts index 446cf958b..910e739ec 100644 --- a/src/documents/templates/deploymentTemplateCodeLenses.ts +++ b/src/documents/templates/deploymentTemplateCodeLenses.ts @@ -58,6 +58,7 @@ export class SelectParameterFileCodeLens extends ResolvableCodeLens { span: Span, private parameterFileUri: Uri | undefined, private _options: { + isForLinkedOrNestedTemplate?: true; fullValidationStatus: IFullValidationStatus | undefined; } ) { @@ -72,7 +73,9 @@ export class SelectParameterFileCodeLens extends ResolvableCodeLens { title = this._options.fullValidationStatus?.allParametersHaveDefaults ? "Select or create a parameter file..." : - "Select or create a parameter file to enable full validation..."; + this._options?.isForLinkedOrNestedTemplate ? + `$(warning) Full template validation off. Add parameter file or top-level parameter defaults to enable.` : + "Select or create a parameter file to enable full validation..."; } this.command = { From 5c76e2afc39f5d4bdcd6b272d38eade206f30c05 Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Mon, 1 Mar 2021 19:02:45 -0800 Subject: [PATCH 2/2] fix suites --- test/DeploymentTemplate.CodeLenses.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/DeploymentTemplate.CodeLenses.test.ts b/test/DeploymentTemplate.CodeLenses.test.ts index 2657656d1..b7882ccce 100644 --- a/test/DeploymentTemplate.CodeLenses.test.ts +++ b/test/DeploymentTemplate.CodeLenses.test.ts @@ -365,6 +365,7 @@ suite("DeploymentTemplate code lenses", () => { [ "TopLevel: \"Select or create a parameter file to enable full validation...\" (azurerm-vscode-tools.selectParameterFile) at [1,1-1,1]", "NestedDeploymentWithInnerScope: \"Nested template with inner scope\" () at [22,21-47,10]", + "NestedDeploymentWithInnerScope: \"$(warning) Full template validation off. Add parameter file or top-level parameter defaults to enable.\" (azurerm-vscode-tools.selectParameterFile) at [22,21-47,10]", "NestedDeploymentWithInnerScope: \"Using default value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [26,13-26,17]", "NestedDeploymentWithInnerScope: \"Value: \"p2 value\"\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [30,13-30,17]", "NestedDeploymentWithInnerScope: \"Value: \"[add(1, 2)]\"\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [33,13-33,17]", @@ -421,7 +422,7 @@ suite("DeploymentTemplate code lenses", () => { [ "TopLevel: \"Select or create a parameter file to enable full validation...\" (azurerm-vscode-tools.selectParameterFile) at [1,1-1,1]", "NestedDeploymentWithInnerScope: \"Nested template with inner scope\" () at [14,21-39,10]", - "NestedDeploymentWithInnerScope: \"Using default value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [18,13-18,17]", + "NestedDeploymentWithInnerScope: \"$(warning) Full template validation off. Add parameter file or top-level parameter defaults to enable.\" (azurerm-vscode-tools.selectParameterFile) at [14,21-39,10]", "NestedDeploymentWithInnerScope: \"Using default value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [18,13-18,17]", "NestedDeploymentWithInnerScope: \"$(warning) No value found - click here to enter a value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [22,13-22,17]", "NestedDeploymentWithInnerScope: \"$(warning) No value found - click here to enter a value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [25,13-25,17]", "NestedDeploymentWithInnerScope: \"$(warning) No value found - click here to enter a value\" (azurerm-vscode-tools.codeLens.gotoParameterValue) at [28,13-28,17]",