From 1f45607e6bf1138f546b6e836843239f9ae03e42 Mon Sep 17 00:00:00 2001 From: "Hugh A. Miles II" Date: Sat, 19 Jun 2021 18:42:52 -0400 Subject: [PATCH] wrap configuration method (#15274) --- .../data/database/DatabaseModal/index.tsx | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index 210b054fd2518..5ef060947fc86 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -356,28 +356,27 @@ const DatabaseModal: FunctionComponent = ({ const onSave = async () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { id, ...update } = db || {}; - if (update?.parameters?.query) { - // convert query params into dictionary - update.parameters.query = JSON.parse( - `{"${decodeURI((update?.parameters?.query as string) || '') - .replace(/"/g, '\\"') - .replace(/&/g, '","') - .replace(/=/g, '":"')}"}`, - ); - } else if (update?.parameters?.query === '') { - update.parameters.query = {}; - } - const engine = update.backend || update.engine; - if ( - engine === 'bigquery' && - update.configuration_method === CONFIGURATION_METHOD.DYNAMIC_FORM && - update.parameters?.credentials_info - ) { - // wrap encrypted_extra in credentials_info only for BigQuery - update.encrypted_extra = JSON.stringify({ - credentials_info: JSON.parse(update.parameters?.credentials_info), - }); + if (update.configuration_method === CONFIGURATION_METHOD.DYNAMIC_FORM) { + if (update?.parameters?.query) { + // convert query params into dictionary + update.parameters.query = JSON.parse( + `{"${decodeURI((update?.parameters?.query as string) || '') + .replace(/"/g, '\\"') + .replace(/&/g, '","') + .replace(/=/g, '":"')}"}`, + ); + } else if (update?.parameters?.query === '') { + update.parameters.query = {}; + } + + const engine = update.backend || update.engine; + if (engine === 'bigquery' && update.parameters?.credentials_info) { + // wrap encrypted_extra in credentials_info only for BigQuery + update.encrypted_extra = JSON.stringify({ + credentials_info: JSON.parse(update.parameters?.credentials_info), + }); + } } if (db?.id) {