Skip to content

Commit

Permalink
feat: auto select schema (#22160)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Nov 18, 2022
1 parent 9cebc1f commit 17c2bd8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ export default function DatabaseSelector({
);
}, [db]);

function changeSchema(schema: SchemaValue) {
setCurrentSchema(schema);
if (onSchemaChange) {
onSchemaChange(schema.value);
}
}

useEffect(() => {
if (currentDb) {
setLoadingSchemas(true);
Expand All @@ -240,6 +247,7 @@ export default function DatabaseSelector({
}
setSchemaOptions(options);
setLoadingSchemas(false);
if (options.length === 1) changeSchema(options[0]);
if (refresh > 0) addSuccessToast('List refreshed');
})
.catch(err => {
Expand Down Expand Up @@ -270,13 +278,6 @@ export default function DatabaseSelector({
}
}

function changeSchema(schema: SchemaValue) {
setCurrentSchema(schema);
if (onSchemaChange) {
onSchemaChange(schema.value);
}
}

function renderSelectRow(select: ReactNode, refreshBtn: ReactNode) {
return (
<div className="section">
Expand Down

0 comments on commit 17c2bd8

Please sign in to comment.