Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db-connection-ui): Additional Query Parameters render #15150

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,19 @@ function dbReducer(
[action.payload.name]: action.payload.value,
};
case ActionType.fetched:
let query = '';
if (action.payload?.parameters?.query) {
// convert query into URI params string
query = new URLSearchParams(action.payload.parameters.query).toString();
}
return {
engine: trimmedState.engine,
configuration_method: trimmedState.configuration_method,
...action.payload,
parameters: {
...action.payload.parameters,
query,
},
};
case ActionType.dbSelected:
return {
Expand Down Expand Up @@ -266,6 +275,18 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...update } = db || {};
if (db?.id) {
if (update?.parameters?.query) {
// convert query params into dictionary
update.parameters.query = JSON.parse(
`{"${decodeURI(db.parameters?.query || '')
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')}"}`,
);
} else {
update.parameters.query = {};
}

const result = await updateResource(
db.id as number,
update as DatabaseObject,
Expand Down