Skip to content

Commit

Permalink
wrap configuration method (#15274)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh authored Jun 19, 2021
1 parent b9ffd41 commit 1f45607
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,28 +356,27 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
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) {
Expand Down

0 comments on commit 1f45607

Please sign in to comment.