Skip to content

Commit 81edda8

Browse files
authored
Merge pull request #41106 from appsmithorg/release
11/07 Daily Promotion
2 parents 7ffb554 + 7282f64 commit 81edda8

File tree

3 files changed

+82
-45
lines changed

3 files changed

+82
-45
lines changed

app/client/cypress/support/Pages/GitSync.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,38 @@ export class GitSync {
159159
repoName = "Repo",
160160
assertConnect = true,
161161
privateFlag = false,
162+
useNewAPI = false,
162163
) {
163164
this.agHelper.GenerateUUID();
164165
cy.get("@guid").then((uid) => {
165166
repoName += uid;
166167
this.CreateTestGiteaRepo(repoName, privateFlag);
167168

168-
cy.intercept("POST", "/api/v1/applications/ssh-keypair/*").as(
169-
`generateKey-${repoName}`,
170-
);
169+
if (useNewAPI) {
170+
cy.intercept("POST", "/api/v1/git/applications/*/ssh-keypair*").as(
171+
`generateKey-${repoName}`,
172+
);
171173

172-
cy.intercept("GET", "/api/v1/git/branch/app/*/protected").as(
173-
`protected-${repoName}`,
174-
);
174+
cy.intercept("GET", "/api/v1/git/applications/*/protected-branches").as(
175+
`protected-${repoName}`,
176+
);
175177

176-
cy.intercept("GET", "/api/v1/git/branch/app/*").as(
177-
`branches-${repoName}`,
178-
);
178+
cy.intercept("GET", "/api/v1/git/applications/*/refs").as(
179+
`branches-${repoName}`,
180+
);
181+
} else {
182+
cy.intercept("POST", "/api/v1/applications/ssh-keypair/*").as(
183+
`generateKey-${repoName}`,
184+
);
185+
186+
cy.intercept("GET", "/api/v1/git/branch/app/*/protected").as(
187+
`protected-${repoName}`,
188+
);
189+
190+
cy.intercept("GET", "/api/v1/git/branch/app/*").as(
191+
`branches-${repoName}`,
192+
);
193+
}
179194

180195
this.OpenConnectModal();
181196

app/client/src/ce/utils/signupHelpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface RedirectUserAfterSignupProps {
2424
validLicense?: boolean;
2525
dispatch: Dispatch;
2626
isAiAgentInstanceEnabled: boolean;
27+
isMultiOrgEnabled?: boolean;
2728
isOnLoginPage: boolean;
2829
}
2930

app/client/src/pages/setup/SignupSuccess.tsx

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
22
import { requiresAuth } from "pages/UserAuth/requiresAuthHOC";
33
import React from "react";
4-
import { useCallback } from "react";
4+
import { useCallback, useState } from "react";
55
import { useEffect } from "react";
66
import { useDispatch, useSelector } from "react-redux";
77
import { getCurrentUser } from "selectors/usersSelectors";
@@ -16,6 +16,7 @@ import { redirectUserAfterSignup } from "ee/utils/signupHelpers";
1616
import { setUserSignedUpFlag } from "utils/storage";
1717
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
1818
import { getIsAiAgentInstanceEnabled } from "ee/selectors/aiAgentSelectors";
19+
import { useIsCloudBillingEnabled } from "hooks/useIsCloudBillingEnabled";
1920

2021
export function SignupSuccess() {
2122
const dispatch = useDispatch();
@@ -25,50 +26,78 @@ export function SignupSuccess() {
2526
"enableFirstTimeUserExperience",
2627
);
2728
const isAiAgentInstanceEnabled = useSelector(getIsAiAgentInstanceEnabled);
29+
const isMultiOrgEnabled = useIsCloudBillingEnabled();
2830
const validLicense = useSelector(isValidLicense);
2931
const user = useSelector(getCurrentUser);
3032
const isOnLoginPage = !useSelector(isWithinAnOrganization);
3133

34+
const [isRedirecting, setIsRedirecting] = useState(false);
35+
3236
useEffect(() => {
3337
user?.email && setUserSignedUpFlag(user?.email);
3438
}, []);
3539

3640
const isNonInvitedUser = shouldEnableFirstTimeUserOnboarding === "true";
3741

38-
const redirectUsingQueryParam = useCallback(
39-
() =>
40-
redirectUserAfterSignup({
42+
const redirectUsingQueryParam = useCallback(async () => {
43+
if (isRedirecting) return;
44+
45+
setIsRedirecting(true);
46+
47+
try {
48+
await redirectUserAfterSignup({
4149
redirectUrl,
4250
shouldEnableFirstTimeUserOnboarding,
4351
validLicense,
4452
dispatch,
4553
isAiAgentInstanceEnabled,
54+
isMultiOrgEnabled,
4655
isOnLoginPage,
47-
}),
48-
[
49-
dispatch,
50-
isNonInvitedUser,
51-
isOnLoginPage,
52-
redirectUrl,
53-
shouldEnableFirstTimeUserOnboarding,
54-
validLicense,
55-
],
56-
);
56+
});
57+
} catch (err) {
58+
setIsRedirecting(false);
59+
}
60+
}, [
61+
dispatch,
62+
isNonInvitedUser,
63+
isOnLoginPage,
64+
redirectUrl,
65+
shouldEnableFirstTimeUserOnboarding,
66+
validLicense,
67+
isAiAgentInstanceEnabled,
68+
isMultiOrgEnabled,
69+
]);
5770

58-
const onGetStarted = useCallback((proficiency?: string, useCase?: string) => {
59-
dispatch({
60-
type: ReduxActionTypes.UPDATE_USER_DETAILS_INIT,
61-
payload: {
71+
const onGetStarted = useCallback(
72+
async (proficiency?: string, useCase?: string) => {
73+
dispatch({
74+
type: ReduxActionTypes.UPDATE_USER_DETAILS_INIT,
75+
payload: {
76+
proficiency,
77+
useCase,
78+
},
79+
});
80+
AnalyticsUtil.logEvent("GET_STARTED_CLICKED", {
6281
proficiency,
63-
useCase,
64-
},
65-
});
66-
AnalyticsUtil.logEvent("GET_STARTED_CLICKED", {
67-
proficiency,
68-
goal: useCase,
69-
});
70-
redirectUsingQueryParam();
71-
}, []);
82+
goal: useCase,
83+
});
84+
await redirectUsingQueryParam();
85+
},
86+
[redirectUsingQueryParam],
87+
);
88+
89+
const shouldAutoRedirect =
90+
user?.isSuperUser ||
91+
((user?.role || user?.proficiency) && user?.useCase) ||
92+
shouldEnableFirstTimeUserOnboarding !== "true" ||
93+
isAiAgentInstanceEnabled ||
94+
isMultiOrgEnabled;
95+
96+
useEffect(() => {
97+
if (shouldAutoRedirect && !isRedirecting) {
98+
redirectUsingQueryParam();
99+
}
100+
}, [shouldAutoRedirect, redirectUsingQueryParam, isRedirecting]);
72101

73102
/*
74103
* Proceed with redirection,
@@ -78,15 +107,7 @@ export function SignupSuccess() {
78107
* We identify an invited user based on `enableFirstTimeUserExperience` flag in url.
79108
*/
80109
//TODO(Balaji): Factor in case, where user had closed the tab, while filling the form.And logs back in again.
81-
if (
82-
user?.isSuperUser ||
83-
((user?.role || user?.proficiency) && user?.useCase) ||
84-
shouldEnableFirstTimeUserOnboarding !== "true" ||
85-
isAiAgentInstanceEnabled
86-
) {
87-
redirectUsingQueryParam();
88-
89-
// Showing a loader until the redirect
110+
if (shouldAutoRedirect) {
90111
return (
91112
<Center>
92113
<Spinner size="lg" />

0 commit comments

Comments
 (0)