From ae510760c3f26906134b3451db7cf8e3a5d103ac Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 17 Dec 2021 18:21:36 +0000 Subject: [PATCH] Some minor UI tweaks. --- packages/builder/src/helpers/data/utils.js | 14 +++++++++++--- .../_components/DynamicVariableModal.svelte | 6 +++++- packages/server/src/threads/query.js | 10 +++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/helpers/data/utils.js b/packages/builder/src/helpers/data/utils.js index c8eb7a4d3b..6d7843e0e5 100644 --- a/packages/builder/src/helpers/data/utils.js +++ b/packages/builder/src/helpers/data/utils.js @@ -137,9 +137,9 @@ export function getDynamicVariables(datasource, queryId) { // convert dynamic variables object back to a list, enrich with query id export function rebuildVariables(datasource, queryId, variables) { - let finalVars = [] + let newVariables = [] if (variables) { - finalVars = Object.entries(variables).map(entry => { + newVariables = Object.entries(variables).map(entry => { return { name: entry[0], value: entry[1], @@ -147,7 +147,15 @@ export function rebuildVariables(datasource, queryId, variables) { } }) } - return [...(datasource?.config?.dynamicVariables || []), ...finalVars] + let existing = datasource?.config?.dynamicVariables || [] + // filter out any by same name + existing = existing.filter( + variable => + !newVariables.find( + newVar => newVar.name.toLowerCase() === variable.name.toLowerCase() + ) + ) + return [...existing, ...newVariables] } export function shouldShowVariables(dynamicVariables, variablesReadOnly) { diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte index 2941826427..61d0a1993c 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte @@ -1,5 +1,5 @@