Skip to content

Commit

Permalink
fix: Loading indicator of table and schema selectors (apache#17040)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Oct 8, 2021
1 parent 2c8e06e commit 7c1c89c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 8 additions & 6 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ export default function DatabaseSelector({
const queryParams = rison.encode({ force: refresh > 0 });
const endpoint = `/api/v1/database/${currentDb.value}/schemas/?q=${queryParams}`;

try {
// TODO: Would be nice to add pagination in a follow-up. Needs endpoint changes.
SupersetClient.get({ endpoint }).then(({ json }) => {
// TODO: Would be nice to add pagination in a follow-up. Needs endpoint changes.
SupersetClient.get({ endpoint })
.then(({ json }) => {
const options = json.result
.map((s: string) => ({
value: s,
Expand All @@ -210,10 +210,12 @@ export default function DatabaseSelector({
onSchemasLoad(options);
}
setSchemaOptions(options);
setLoadingSchemas(false);
})
.catch(e => {
setLoadingSchemas(false);
handleError(t('There was an error loading the schemas'));
});
} finally {
setLoadingSchemas(false);
}
}
}, [currentDb, onSchemasLoad, refresh]);

Expand Down
12 changes: 7 additions & 5 deletions superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
setPreviousRefresh(refresh);
}

try {
SupersetClient.get({ endpoint }).then(({ json }) => {
SupersetClient.get({ endpoint })
.then(({ json }) => {
const options: TableOption[] = [];
let currentTable;
json.options.forEach((table: Table) => {
Expand All @@ -213,10 +213,12 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
),
);
setCurrentTable(currentTable);
setLoadingTables(false);
})
.catch(e => {
setLoadingTables(false);
handleError(t('There was an error loading the tables'));
});
} finally {
setLoadingTables(false);
}
}
// We are using the refresh state to re-trigger the query
// previousRefresh should be out of dependencies array
Expand Down

0 comments on commit 7c1c89c

Please sign in to comment.