Skip to content

Commit

Permalink
fix(sqllab): Allow router navigation to explore (apache#25941)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark authored and sfirke committed Mar 22, 2024
1 parent ebe62ac commit 7186bee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions superset-frontend/src/SqlLab/components/ResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import React, { useCallback, useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router-dom';
import ButtonGroup from 'src/components/ButtonGroup';
import Alert from 'src/components/Alert';
import Button from 'src/components/Button';
Expand Down Expand Up @@ -161,6 +162,7 @@ const ResultSet = ({
const [showSaveDatasetModal, setShowSaveDatasetModal] = useState(false);
const [alertIsOpen, setAlertIsOpen] = useState(false);

const history = useHistory();
const dispatch = useDispatch();

const reRunQueryIfSessionTimeoutErrorOnMount = useCallback(() => {
Expand Down Expand Up @@ -215,9 +217,11 @@ const ResultSet = ({
setSearchText(event.target.value);
};

const createExploreResultsOnClick = async () => {
const createExploreResultsOnClick = async (clickEvent: React.MouseEvent) => {
const { results } = query;

const openInNewWindow = clickEvent.metaKey;

if (results?.query_id) {
const key = await postFormData(results.query_id, 'query', {
...EXPLORE_CHART_DEFAULT,
Expand All @@ -229,7 +233,11 @@ const ResultSet = ({
const url = mountExploreUrl(null, {
[URL_PARAMS.formDataKey.name]: key,
});
window.open(url, '_blank', 'noreferrer');
if (openInNewWindow) {
window.open(url, '_blank', 'noreferrer');
} else {
history.push(url);
}
} else {
addDangerToast(t('Unable to create chart without a query id.'));
}
Expand Down

0 comments on commit 7186bee

Please sign in to comment.