chore streamline signup redirection logic CE (#40063)

CE PR

/ok-to-test tags="@tag.Sanity"

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14240869595>
> Commit: 50725a8e93d6e0e2cedcb06022aec348fe77eb7f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14240869595&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 03 Apr 2025 11:15:59 UTC
<!-- end of auto-generated comment: Cypress test results  -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced navigation in the Widgets Editor with improved redirection
behavior for agent-related flows.
- Integrated AI agent flow status into the signup process to optimize
user redirection.

- **Refactor**
- Streamlined the user redirection logic by consolidating parameters and
simplifying action dispatching.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Pawan Kumar 2025-04-03 16:48:45 +05:30 committed by GitHub
parent de2f24ca3e
commit c8c15270eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 34 deletions

View File

@ -0,0 +1,3 @@
export function useAgentsRedirect() {
return null;
}

View File

@ -1,7 +1,4 @@
import {
firstTimeUserOnboardingInit,
setCurrentApplicationIdForCreateNewApp,
} from "actions/onboardingActions";
import { setCurrentApplicationIdForCreateNewApp } from "actions/onboardingActions";
import {
SIGNUP_SUCCESS_URL,
BUILDER_PATH,
@ -19,19 +16,27 @@ import type {
SocialLoginType,
} from "ee/constants/SocialLogin";
import { SocialLoginButtonPropsList } from "ee/constants/SocialLogin";
import type { Dispatch } from "redux";
export interface RedirectUserAfterSignupProps {
redirectUrl: string;
shouldEnableFirstTimeUserOnboarding: string | null;
validLicense?: boolean;
dispatch: Dispatch;
isAiAgentFlowEnabled: boolean;
isOnLoginPage: boolean;
}
export const redirectUserAfterSignup = (
redirectUrl: string,
shouldEnableFirstTimeUserOnboarding: string | null,
_validLicense?: boolean,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch?: any,
isEnabledForCreateNew?: boolean, // is Enabled for only non-invited users
isOnLoginPage?: boolean,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any => {
props: RedirectUserAfterSignupProps,
) => {
const {
dispatch,
isOnLoginPage,
redirectUrl,
shouldEnableFirstTimeUserOnboarding,
} = props;
if (redirectUrl) {
try {
if (
@ -66,21 +71,10 @@ export const redirectUserAfterSignup = (
* passing baseApplicationId as applicationId should be fine
* **/
if (baseApplicationId || basePageId) {
if (isEnabledForCreateNew) {
dispatch(
setCurrentApplicationIdForCreateNewApp(
baseApplicationId as string,
),
);
history.replace(APPLICATIONS_URL);
} else {
dispatch(
firstTimeUserOnboardingInit(
baseApplicationId,
basePageId as string,
),
);
}
dispatch(
setCurrentApplicationIdForCreateNewApp(baseApplicationId as string),
);
history.replace(APPLICATIONS_URL);
} else {
if (!urlObject) {
try {

View File

@ -0,0 +1 @@
export * from "ce/pages/WidgetsEditor/hooks/useAgentsRedirect";

View File

@ -10,6 +10,7 @@ import { getCurrentApplication } from "ee/selectors/applicationSelectors";
import { WidgetEditorContainer } from "./WidgetEditorContainer";
import { WidgetEditorHeader } from "./WidgetEditorHeader";
import { WidgetEditorContent } from "./WidgetEditorContent";
import { useAgentsRedirect } from "ee/pages/WidgetsEditor/hooks/useAgentsRedirect";
/**
* WidgetsEditor
@ -25,6 +26,8 @@ function WidgetsEditor() {
const currentPageName = useSelector(getCurrentPageName);
const currentApp = useSelector(getCurrentApplication);
useAgentsRedirect();
useEffect(() => {
if (currentPageName !== undefined && currentPageId !== undefined) {
// Logging page load event

View File

@ -15,6 +15,7 @@ import {
import { redirectUserAfterSignup } from "ee/utils/signupHelpers";
import { setUserSignedUpFlag } from "utils/storage";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { getIsAiAgentFlowEnabled } from "ee/selectors/aiAgentSelectors";
export function SignupSuccess() {
const dispatch = useDispatch();
@ -23,6 +24,7 @@ export function SignupSuccess() {
const shouldEnableFirstTimeUserOnboarding = urlObject?.searchParams.get(
"enableFirstTimeUserExperience",
);
const isAiAgentFlowEnabled = useSelector(getIsAiAgentFlowEnabled);
const validLicense = useSelector(isValidLicense);
const user = useSelector(getCurrentUser);
const isOnLoginPage = !useSelector(isWithinAnOrganization);
@ -35,14 +37,14 @@ export function SignupSuccess() {
const redirectUsingQueryParam = useCallback(
() =>
redirectUserAfterSignup(
redirectUserAfterSignup({
redirectUrl,
shouldEnableFirstTimeUserOnboarding,
validLicense,
dispatch,
isNonInvitedUser,
isAiAgentFlowEnabled,
isOnLoginPage,
),
}),
[
dispatch,
isNonInvitedUser,
@ -79,7 +81,8 @@ export function SignupSuccess() {
if (
user?.isSuperUser ||
((user?.role || user?.proficiency) && user?.useCase) ||
shouldEnableFirstTimeUserOnboarding !== "true"
shouldEnableFirstTimeUserOnboarding !== "true" ||
isAiAgentFlowEnabled
) {
redirectUsingQueryParam();