diff --git a/app/client/src/ce/constants/messages.ts b/app/client/src/ce/constants/messages.ts index e90a08af18..bfcf95dc2f 100644 --- a/app/client/src/ce/constants/messages.ts +++ b/app/client/src/ce/constants/messages.ts @@ -476,7 +476,7 @@ export const IMPORT_FROM_GIT_REPOSITORY_MESSAGE = () => export const RECONNECT_MISSING_DATASOURCE_CREDENTIALS = () => "Reconnect missing datasource credentials"; export const RECONNECT_MISSING_DATASOURCE_CREDENTIALS_DESCRIPTION = () => - "Fill these with utmost care as the application will not behave normally otherwsie"; + "Fill these with utmost care as the application will not behave normally otherwise"; export const RECONNECT_DATASOURCE_SUCCESS_MESSAGE1 = () => "These datasources were imported successfully!"; export const RECONNECT_DATASOURCE_SUCCESS_MESSAGE2 = () => diff --git a/app/client/src/pages/Editor/IntegrationEditor/DatasourceCard.tsx b/app/client/src/pages/Editor/IntegrationEditor/DatasourceCard.tsx index c8d5d9df4b..6d7be0e0f9 100644 --- a/app/client/src/pages/Editor/IntegrationEditor/DatasourceCard.tsx +++ b/app/client/src/pages/Editor/IntegrationEditor/DatasourceCard.tsx @@ -330,7 +330,7 @@ function DatasourceCard(props: DatasourceCardProps) { category={Category.tertiary} className="t--reconnect-btn" onClick={editDatasource} - text="RECONNECT APPLICATION" + text="RECONNECT" /> (queryPageId); const [appId, setAppId] = useState(queryAppId); const [appURL, setAppURL] = useState(""); - const [datasouce, setDatasource] = useState(null); + const [datasource, setDatasource] = useState(null); const [isImport, setIsImport] = useState(queryIsImport); const [isTesting, setIsTesting] = useState(false); @@ -359,10 +361,17 @@ function ReconnectDatasourceModal() { }, [organizationId, isModalOpen]); useEffect(() => { - if (isModalOpen && isDatasourceTesting) { - setIsTesting(true); + if (isModalOpen) { + // while updating datasource, testing flag should be false + if (isDatasourceUpdating) { + setIsTesting(false); + } + // while testing datasource, testing flag should be true + if (isDatasourceTesting) { + setIsTesting(true); + } } - }, [isModalOpen, isDatasourceTesting]); + }, [isModalOpen, isDatasourceTesting, isDatasourceUpdating]); const handleClose = useCallback(() => { dispatch(setIsReconnectingDatasourcesModalOpen({ isOpen: false })); @@ -433,17 +442,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 selected datasource is gsheet datasource, it shouldn't be redirected to app immediately + if (!queryIsImport && datasources.length) { + const selectedDS = datasources.find( + (ds: Datasource) => ds.id === selectedDatasourceId, + ); + if (selectedDS) { + const authType = + selectedDS.datasourceConfiguration?.authentication + ?.authenticationType; - if (authType === AuthType.OAUTH2) return; + if (authType === AuthType.OAUTH2) return; + } } const id = selectedDatasourceId; const pending = datasources.filter((ds: Datasource) => !ds.isConfigured); @@ -451,6 +461,9 @@ function ReconnectDatasourceModal() { let next: Datasource | undefined = undefined; if (id) { const index = datasources.findIndex((ds: Datasource) => ds.id === id); + if (index > -1 && !datasources[index].isConfigured) { + return; + } next = datasources .slice(index + 1) .find((ds: Datasource) => !ds.isConfigured); @@ -482,8 +495,7 @@ function ReconnectDatasourceModal() { }); const shouldShowDBForm = - isConfigFetched && !isLoading && !datasouce?.isConfigured; - const shouldShowSuccessMessages = datasouce && datasouce.isConfigured; + isConfigFetched && !isLoading && !datasource?.isConfigured; return ( <> @@ -527,7 +539,7 @@ function ReconnectDatasourceModal() { /> )} - {shouldShowSuccessMessages && SuccessMessages()} + {datasource?.isConfigured && SuccessMessages()} diff --git a/app/client/src/selectors/entitiesSelector.ts b/app/client/src/selectors/entitiesSelector.ts index f44287c8e9..7c56b9288b 100644 --- a/app/client/src/selectors/entitiesSelector.ts +++ b/app/client/src/selectors/entitiesSelector.ts @@ -667,6 +667,10 @@ export const getIsListing = (state: AppState) => { return state.entities.datasources.isListing; }; +export const getDatasourceLoading = (state: AppState) => { + return state.entities.datasources.loading; +}; + export const selectFilesForExplorer = createSelector( getActionsForCurrentPage, getJSCollectionsForCurrentPage,