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: ensure validation for db modal for googlesheets #19018

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Changes from all commits
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
13 changes: 6 additions & 7 deletions superset-frontend/src/views/CRUD/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ export function useDatabaseValidation() {
null,
);
const getValidation = useCallback(
(database: Partial<DatabaseObject> | null, onCreate = false) => {
(database: Partial<DatabaseObject> | null, onCreate = false) =>
SupersetClient.post({
endpoint: '/api/v1/database/validate_parameters',
body: JSON.stringify(database),
Expand All @@ -658,9 +658,10 @@ export function useDatabaseValidation() {
.then(() => {
setValidationErrors(null);
})
// eslint-disable-next-line consistent-return
.catch(e => {
if (typeof e.json === 'function') {
e.json().then(({ errors = [] }: JsonObject) => {
return e.json().then(({ errors = [] }: JsonObject) => {
const parsedErrors = errors
.filter((error: { error_type: string }) => {
const skipValidationError = ![
Expand Down Expand Up @@ -748,12 +749,10 @@ export function useDatabaseValidation() {
);
setValidationErrors(parsedErrors);
});
} else {
// eslint-disable-next-line no-console
console.error(e);
}
});
},
// eslint-disable-next-line no-console
console.error(e);
}),
[setValidationErrors],
);

Expand Down