From ec913b45d6f61d6856088eb2e8eef4d617d92f33 Mon Sep 17 00:00:00 2001 From: matias-portainer <104775949+matias-portainer@users.noreply.github.com> Date: Mon, 4 Mar 2024 10:35:19 -0300 Subject: [PATCH] fix(edge/templates): get correct default value for selectType env vars EE-6796 (#11293) --- .../CreateView/TemplateFieldset/EnvVarsFieldset.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/react/edge/edge-stacks/CreateView/TemplateFieldset/EnvVarsFieldset.tsx b/app/react/edge/edge-stacks/CreateView/TemplateFieldset/EnvVarsFieldset.tsx index 715e49320..dd570614f 100644 --- a/app/react/edge/edge-stacks/CreateView/TemplateFieldset/EnvVarsFieldset.tsx +++ b/app/react/edge/edge-stacks/CreateView/TemplateFieldset/EnvVarsFieldset.tsx @@ -81,7 +81,15 @@ function Item({ } export function getDefaultValues(definitions: Array): Value { - return Object.fromEntries(definitions.map((v) => [v.name, v.default || ''])); + return Object.fromEntries( + definitions.map((v) => { + if (v.select) { + return [v.name, v.select.find((v) => v.default)?.value || '']; + } + + return [v.name, v.default || '']; + }) + ); } export function envVarsFieldsetValidation(): SchemaOf {