eschutho commented on code in PR #28376: URL: https://github.com/apache/superset/pull/28376#discussion_r1594576985
########## superset-frontend/src/components/DatabaseSelector/index.tsx: ########## @@ -244,17 +263,55 @@ export default function DatabaseSelector({ onError: () => handleError(t('There was an error loading the schemas')), }); - const schemaOptions = data || EMPTY_SCHEMA_OPTIONS; + const schemaOptions = schemaData || EMPTY_SCHEMA_OPTIONS; + + function changeCatalog(catalog: CatalogOption | undefined) { + setCurrentCatalog(catalog); + setCurrentSchema(undefined); + if (onCatalogChange && catalog?.value !== catalogRef.current) { + onCatalogChange(catalog?.value); + } + } + + const { + data: catalogData, + isFetching: loadingCatalogs, + refetch: refetchCatalogs, + } = useCatalogs({ + dbId: currentDb?.value, + onSuccess: (catalogs, isFetched) => { + if (catalogs.length === 1) { + changeCatalog(catalogs[0]); + } else if ( + !catalogs.find( + catalogOption => catalogRef.current === catalogOption.value, + ) + ) { + changeCatalog(undefined); + } + + if (isFetched) { + addSuccessToast('List refreshed'); Review Comment: translate? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org