From 1a8fe8282133be2d94c406c92403dc963f6ec35a Mon Sep 17 00:00:00 2001 From: LP B Date: Tue, 19 Jul 2022 15:38:00 +0200 Subject: [PATCH] fix(app/mustache): reuse mustache variables in templates [EE-3689] (#7286) --- .../custom-templates/components/utils.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/react/portainer/custom-templates/components/utils.ts b/app/react/portainer/custom-templates/components/utils.ts index 315fd4a92..2c2362264 100644 --- a/app/react/portainer/custom-templates/components/utils.ts +++ b/app/react/portainer/custom-templates/components/utils.ts @@ -38,12 +38,15 @@ export function intersectVariables( ) { const oldVariablesWithLabel = oldVariables.filter((v) => !!v.label); - return [ - ...oldVariablesWithLabel, - ...newVariables.filter( - (v) => !oldVariablesWithLabel.find(({ name }) => name === v.name) - ), - ]; + return _.uniqBy( + [ + ...oldVariablesWithLabel, + ...newVariables.filter( + (v) => !oldVariablesWithLabel.find(({ name }) => name === v.name) + ), + ], + 'name' + ); } export function renderTemplate(