fixed issue of redirecting with one oauth authentication

This commit is contained in:
haojin111 2022-03-30 14:37:34 +08:00
parent b265ac2fd5
commit 8ded371162

View File

@ -47,7 +47,7 @@ import {
setIsReconnectingDatasourcesModalOpen,
setOrgIdForImport,
} from "actions/applicationActions";
import { Datasource } from "entities/Datasource";
import { AuthType, Datasource } from "entities/Datasource";
import { DATASOURCE_DB_FORM } from "constants/forms";
import { initialize } from "redux-form";
import TooltipComponent from "components/ads/Tooltip";
@ -452,6 +452,18 @@ function ReconnectDatasourceModal() {
// checking of full configured
useEffect(() => {
if (isModalOpen && !isTesting) {
// if there is only one gsheet datasource, it shouldn't be redirected to app immediately
if (
!queryIsImport &&
datasources.length === 1 &&
datasources[0].isConfigured
) {
const authType =
datasources[0].datasourceConfiguration?.authentication
?.authenticationType;
if (authType === AuthType.OAUTH2) return;
}
const id = selectedDatasourceId;
const pending = datasources.filter((ds: Datasource) => !ds.isConfigured);
if (pending.length > 0) {
@ -469,7 +481,7 @@ function ReconnectDatasourceModal() {
window.open(appURL, "_self");
}
}
}, [datasources, appURL, isModalOpen, isTesting]);
}, [datasources, appURL, isModalOpen, isTesting, queryIsImport]);
const mappedDataSources = datasources.map((ds: Datasource) => {
return (