mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: Gsheets takes 2 clicks to save (#21740)
This commit is contained in:
parent
0c461497ff
commit
aef6217a80
@ -26,4 +26,5 @@ export default interface Database {
|
|||||||
impersonate_user: boolean;
|
impersonate_user: boolean;
|
||||||
server_cert: string;
|
server_cert: string;
|
||||||
sqlalchemy_uri: string;
|
sqlalchemy_uri: string;
|
||||||
|
catalog: object;
|
||||||
}
|
}
|
||||||
|
@ -668,6 +668,21 @@ export function useAvailableDatabases() {
|
|||||||
return [availableDbs, getAvailable] as const;
|
return [availableDbs, getAvailable] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const transformDB = (db: Partial<DatabaseObject> | null) => {
|
||||||
|
if (db && Array.isArray(db?.catalog)) {
|
||||||
|
return {
|
||||||
|
...db,
|
||||||
|
catalog: Object.assign(
|
||||||
|
{},
|
||||||
|
...db.catalog.map((x: { name: string; value: string }) => ({
|
||||||
|
[x.name]: x.value,
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return db;
|
||||||
|
};
|
||||||
|
|
||||||
export function useDatabaseValidation() {
|
export function useDatabaseValidation() {
|
||||||
const [validationErrors, setValidationErrors] = useState<JsonObject | null>(
|
const [validationErrors, setValidationErrors] = useState<JsonObject | null>(
|
||||||
null,
|
null,
|
||||||
@ -676,7 +691,7 @@ export function useDatabaseValidation() {
|
|||||||
(database: Partial<DatabaseObject> | null, onCreate = false) =>
|
(database: Partial<DatabaseObject> | null, onCreate = false) =>
|
||||||
SupersetClient.post({
|
SupersetClient.post({
|
||||||
endpoint: '/api/v1/database/validate_parameters/',
|
endpoint: '/api/v1/database/validate_parameters/',
|
||||||
body: JSON.stringify(database),
|
body: JSON.stringify(transformDB(database)),
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user