fix: 12456, 12420, 12422 on reconnect modal issues (#12569)

* fixed-12456 gsheet auth issue

* fixed - 12420 save button functionality failed

* fixed - 12422 datasource selection issue

* fixed issue of gsheet authentication

* fixed comments point

* fixed 12511: typo issue

* fixed cypress test import and export
This commit is contained in:
haojin111 2022-04-12 01:30:29 +08:00 committed by GitHub
parent 5bc414082a
commit c32ca69a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 19 deletions

View File

@ -476,7 +476,7 @@ export const IMPORT_FROM_GIT_REPOSITORY_MESSAGE = () =>
export const RECONNECT_MISSING_DATASOURCE_CREDENTIALS = () => export const RECONNECT_MISSING_DATASOURCE_CREDENTIALS = () =>
"Reconnect missing datasource credentials"; "Reconnect missing datasource credentials";
export const RECONNECT_MISSING_DATASOURCE_CREDENTIALS_DESCRIPTION = () => 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 = () => export const RECONNECT_DATASOURCE_SUCCESS_MESSAGE1 = () =>
"These datasources were imported successfully!"; "These datasources were imported successfully!";
export const RECONNECT_DATASOURCE_SUCCESS_MESSAGE2 = () => export const RECONNECT_DATASOURCE_SUCCESS_MESSAGE2 = () =>

View File

@ -330,7 +330,7 @@ function DatasourceCard(props: DatasourceCardProps) {
category={Category.tertiary} category={Category.tertiary}
className="t--reconnect-btn" className="t--reconnect-btn"
onClick={editDatasource} onClick={editDatasource}
text="RECONNECT APPLICATION" text="RECONNECT"
/> />
<MenuWrapper <MenuWrapper

View File

@ -32,6 +32,7 @@ import {
} from "@appsmith/constants/messages"; } from "@appsmith/constants/messages";
import Button, { Category, Size } from "components/ads/Button"; import Button, { Category, Size } from "components/ads/Button";
import { import {
getDatasourceLoading,
getIsDatasourceTesting, getIsDatasourceTesting,
getIsListing, getIsListing,
getIsReconnectingDatasourcesModalOpen, getIsReconnectingDatasourcesModalOpen,
@ -273,6 +274,7 @@ function ReconnectDatasourceModal() {
const pluginNames = useSelector(getPluginNames); const pluginNames = useSelector(getPluginNames);
const isLoading = useSelector(getIsListing); const isLoading = useSelector(getIsListing);
const isDatasourceTesting = useSelector(getIsDatasourceTesting); const isDatasourceTesting = useSelector(getIsDatasourceTesting);
const isDatasourceUpdating = useSelector(getDatasourceLoading);
// getting query from redirection url // getting query from redirection url
const userOrgs = useSelector(getUserApplicationsOrgsList); const userOrgs = useSelector(getUserApplicationsOrgsList);
@ -288,7 +290,7 @@ function ReconnectDatasourceModal() {
const [pageId, setPageId] = useState<string | null>(queryPageId); const [pageId, setPageId] = useState<string | null>(queryPageId);
const [appId, setAppId] = useState<string | null>(queryAppId); const [appId, setAppId] = useState<string | null>(queryAppId);
const [appURL, setAppURL] = useState(""); const [appURL, setAppURL] = useState("");
const [datasouce, setDatasource] = useState<Datasource | null>(null); const [datasource, setDatasource] = useState<Datasource | null>(null);
const [isImport, setIsImport] = useState(queryIsImport); const [isImport, setIsImport] = useState(queryIsImport);
const [isTesting, setIsTesting] = useState(false); const [isTesting, setIsTesting] = useState(false);
@ -359,10 +361,17 @@ function ReconnectDatasourceModal() {
}, [organizationId, isModalOpen]); }, [organizationId, isModalOpen]);
useEffect(() => { useEffect(() => {
if (isModalOpen && isDatasourceTesting) { 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); setIsTesting(true);
} }
}, [isModalOpen, isDatasourceTesting]); }
}, [isModalOpen, isDatasourceTesting, isDatasourceUpdating]);
const handleClose = useCallback(() => { const handleClose = useCallback(() => {
dispatch(setIsReconnectingDatasourcesModalOpen({ isOpen: false })); dispatch(setIsReconnectingDatasourcesModalOpen({ isOpen: false }));
@ -433,24 +442,28 @@ function ReconnectDatasourceModal() {
// checking of full configured // checking of full configured
useEffect(() => { useEffect(() => {
if (isModalOpen && !isTesting) { if (isModalOpen && !isTesting) {
// if there is only one gsheet datasource, it shouldn't be redirected to app immediately // if selected datasource is gsheet datasource, it shouldn't be redirected to app immediately
if ( if (!queryIsImport && datasources.length) {
!queryIsImport && const selectedDS = datasources.find(
datasources.length === 1 && (ds: Datasource) => ds.id === selectedDatasourceId,
datasources[0].isConfigured );
) { if (selectedDS) {
const authType = const authType =
datasources[0].datasourceConfiguration?.authentication selectedDS.datasourceConfiguration?.authentication
?.authenticationType; ?.authenticationType;
if (authType === AuthType.OAUTH2) return; if (authType === AuthType.OAUTH2) return;
} }
}
const id = selectedDatasourceId; const id = selectedDatasourceId;
const pending = datasources.filter((ds: Datasource) => !ds.isConfigured); const pending = datasources.filter((ds: Datasource) => !ds.isConfigured);
if (pending.length > 0) { if (pending.length > 0) {
let next: Datasource | undefined = undefined; let next: Datasource | undefined = undefined;
if (id) { if (id) {
const index = datasources.findIndex((ds: Datasource) => ds.id === id); const index = datasources.findIndex((ds: Datasource) => ds.id === id);
if (index > -1 && !datasources[index].isConfigured) {
return;
}
next = datasources next = datasources
.slice(index + 1) .slice(index + 1)
.find((ds: Datasource) => !ds.isConfigured); .find((ds: Datasource) => !ds.isConfigured);
@ -482,8 +495,7 @@ function ReconnectDatasourceModal() {
}); });
const shouldShowDBForm = const shouldShowDBForm =
isConfigFetched && !isLoading && !datasouce?.isConfigured; isConfigFetched && !isLoading && !datasource?.isConfigured;
const shouldShowSuccessMessages = datasouce && datasouce.isConfigured;
return ( return (
<> <>
@ -527,7 +539,7 @@ function ReconnectDatasourceModal() {
/> />
</DBFormWrapper> </DBFormWrapper>
)} )}
{shouldShowSuccessMessages && SuccessMessages()} {datasource?.isConfigured && SuccessMessages()}
</ContentWrapper> </ContentWrapper>
</BodyContainer> </BodyContainer>
<SkipToAppButtonWrapper> <SkipToAppButtonWrapper>

View File

@ -667,6 +667,10 @@ export const getIsListing = (state: AppState) => {
return state.entities.datasources.isListing; return state.entities.datasources.isListing;
}; };
export const getDatasourceLoading = (state: AppState) => {
return state.entities.datasources.loading;
};
export const selectFilesForExplorer = createSelector( export const selectFilesForExplorer = createSelector(
getActionsForCurrentPage, getActionsForCurrentPage,
getJSCollectionsForCurrentPage, getJSCollectionsForCurrentPage,