alexandrusoare commented on code in PR #42241:
URL: https://github.com/apache/superset/pull/42241#discussion_r3629677880
##########
superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx:
##########
@@ -84,26 +84,30 @@ const PopEditorTab: React.FC<{ children?: React.ReactNode
}> = ({
setIsLoading(true);
const targetUrl = `${URI(SQL_LAB_URL).query(pick(requestedQuery,
Object.keys(restUrlParams)))}`;
setUpdatedUrl(targetUrl);
- if (permalink) {
- dispatch(popPermalink(permalink));
- } else if (id) {
- dispatch(popStoredQuery(id));
- } else if (savedQueryId) {
- dispatch(popSavedQuery(savedQueryId));
- } else if (queryId) {
- dispatch(popQuery(queryId));
- } else if (datasourceKey) {
- dispatch(popDatasourceQuery(datasourceKey, sql));
- } else if (sql) {
- const newQueryEditor = {
- name,
- dbId: Number(dbid),
- catalog,
- schema,
- autorun,
- sql,
- };
- dispatch(addQueryEditor(newQueryEditor));
+ try {
+ if (permalink) {
+ await dispatch(popPermalink(permalink));
+ } else if (id) {
+ await dispatch(popStoredQuery(id));
+ } else if (savedQueryId) {
+ await dispatch(popSavedQuery(savedQueryId));
+ } else if (queryId) {
+ await dispatch(popQuery(queryId));
+ } else if (datasourceKey) {
+ await dispatch(popDatasourceQuery(datasourceKey, sql));
+ } else if (sql) {
+ const newQueryEditor = {
+ name,
+ dbId: Number(dbid),
+ catalog,
+ schema,
+ autorun,
+ sql,
+ };
+ dispatch(addQueryEditor(newQueryEditor));
+ }
+ } finally {
+ setIsLoading(false);
Review Comment:
Added a regression test. Regardin the `catch`, not needed — the pop* thunks
already have internal .catch() handlers, so the promise always resolves. The
try/finally here just ensures setIsLoading(false) runs regardless.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]