fix(sqllab): Allow router navigation to explore (#25941)

This commit is contained in:
JUST.in DO IT 2023-11-14 10:27:44 -08:00 committed by GitHub
parent f6ba75a185
commit f18fb24b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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,
});
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.'));
}