Skip to content

Commit

Permalink
fix type script issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Jun 14, 2021
1 parent 4fac58f commit 7c918e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function dbReducer(
const trimmedState = {
...(state || {}),
};
let query = '';

switch (action.type) {
case ActionType.inputChange:
Expand Down Expand Up @@ -169,10 +170,11 @@ 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();
query = new URLSearchParams(
action.payload.parameters.query as string,
).toString();
}
return {
engine: trimmedState.engine,
Expand Down Expand Up @@ -278,12 +280,12 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
if (update?.parameters?.query) {
// convert query params into dictionary
update.parameters.query = JSON.parse(
`{"${decodeURI(update?.parameters?.query || '')
`{"${decodeURI((update?.parameters?.query as string) || '')
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')}"}`,
);
} else {
} else if (update.parameters) {
update.parameters.query = {};
}

Expand All @@ -309,7 +311,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
if (update?.parameters?.query) {
// convert query params into dictionary
update.parameters.query = JSON.parse(
`{"${decodeURI(db.parameters?.query || '')
`{"${decodeURI((db.parameters?.query as string) || '')
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')}"}`,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/data/database/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type DatabaseObject = {
username?: string;
password?: string;
encryption?: boolean;
query?: string;
query?: string | object;
};
configuration_method: CONFIGURATION_METHOD;
engine?: string;
Expand Down

0 comments on commit 7c918e8

Please sign in to comment.