From f5dad9db7d7a3fa1bb70b6877ecb240a770268a4 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:07:36 +0200 Subject: [PATCH] Fix VariableValueType typing to match API type And adapt formUtil functions to handle undefined values --- client/src/api/configTemplates.ts | 2 +- client/src/components/ConfigTemplates/formUtil.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/api/configTemplates.ts b/client/src/api/configTemplates.ts index 51b21382c505..16c4369c4589 100644 --- a/client/src/api/configTemplates.ts +++ b/client/src/api/configTemplates.ts @@ -10,7 +10,7 @@ export type TemplateVariable = | components["schemas"]["TemplateVariablePathComponent"] | components["schemas"]["TemplateVariableBoolean"]; export type TemplateSecret = components["schemas"]["TemplateSecret"]; -export type VariableValueType = (string | boolean | number) | undefined; +export type VariableValueType = string | boolean | number; export type VariableData = { [key: string]: VariableValueType }; export type SecretData = { [key: string]: string }; diff --git a/client/src/components/ConfigTemplates/formUtil.ts b/client/src/components/ConfigTemplates/formUtil.ts index e211cb301729..2fa06a8abb2a 100644 --- a/client/src/components/ConfigTemplates/formUtil.ts +++ b/client/src/components/ConfigTemplates/formUtil.ts @@ -39,7 +39,7 @@ export function metadataFormEntryDescription(what: string): FormEntry { }; } -export function templateVariableFormEntry(variable: TemplateVariable, variableValue: VariableValueType): FormEntry { +export function templateVariableFormEntry(variable: TemplateVariable, variableValue?: VariableValueType): FormEntry { const common_fields = { name: variable.name, label: variable.label ?? variable.name, @@ -166,7 +166,7 @@ export function createFormDataToPayload(template: TemplateSummary, formData: any return payload; } -export function formDataTypedGet(variableDefinition: TemplateVariable, formData: any): VariableValueType { +export function formDataTypedGet(variableDefinition: TemplateVariable, formData: any): VariableValueType | undefined { // galaxy form library doesn't type values traditionally, so add a typed // access to the data if coming back as string. Though it does seem to be // typed properly - this might not be needed anymore?