mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix(sqllab): Allow router navigation to explore (#25941)
This commit is contained in:
parent
f6ba75a185
commit
f18fb24b3d
@ -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';
|
||||
@ -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(() => {
|
||||
@ -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,
|
||||
@ -229,7 +233,11 @@ const ResultSet = ({
|
||||
const url = mountExploreUrl(null, {
|
||||
[URL_PARAMS.formDataKey.name]: key,
|
||||
});
|
||||
if (openInNewWindow) {
|
||||
window.open(url, '_blank', 'noreferrer');
|
||||
} else {
|
||||
history.push(url);
|
||||
}
|
||||
} else {
|
||||
addDangerToast(t('Unable to create chart without a query id.'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user