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 { import { setCurrentApplicationIdForCreateNewApp } from "actions/onboardingActions";
firstTimeUserOnboardingInit,
setCurrentApplicationIdForCreateNewApp,
} from "actions/onboardingActions";
import { import {
SIGNUP_SUCCESS_URL, SIGNUP_SUCCESS_URL,
BUILDER_PATH, BUILDER_PATH,
@ -19,19 +16,27 @@ import type {
SocialLoginType, SocialLoginType,
} from "ee/constants/SocialLogin"; } from "ee/constants/SocialLogin";
import { SocialLoginButtonPropsList } 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 = ( export const redirectUserAfterSignup = (
redirectUrl: string, props: RedirectUserAfterSignupProps,
shouldEnableFirstTimeUserOnboarding: string | null, ) => {
_validLicense?: boolean, const {
// TODO: Fix this the next time the file is edited dispatch,
// eslint-disable-next-line @typescript-eslint/no-explicit-any isOnLoginPage,
dispatch?: any, redirectUrl,
isEnabledForCreateNew?: boolean, // is Enabled for only non-invited users shouldEnableFirstTimeUserOnboarding,
isOnLoginPage?: boolean, } = props;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any => {
if (redirectUrl) { if (redirectUrl) {
try { try {
if ( if (
@ -66,21 +71,10 @@ export const redirectUserAfterSignup = (
* passing baseApplicationId as applicationId should be fine * passing baseApplicationId as applicationId should be fine
* **/ * **/
if (baseApplicationId || basePageId) { if (baseApplicationId || basePageId) {
if (isEnabledForCreateNew) {
dispatch( dispatch(
setCurrentApplicationIdForCreateNewApp( setCurrentApplicationIdForCreateNewApp(baseApplicationId as string),
baseApplicationId as string,
),
); );
history.replace(APPLICATIONS_URL); history.replace(APPLICATIONS_URL);
} else {
dispatch(
firstTimeUserOnboardingInit(
baseApplicationId,
basePageId as string,
),
);
}
} else { } else {
if (!urlObject) { if (!urlObject) {
try { 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 { WidgetEditorContainer } from "./WidgetEditorContainer";
import { WidgetEditorHeader } from "./WidgetEditorHeader"; import { WidgetEditorHeader } from "./WidgetEditorHeader";
import { WidgetEditorContent } from "./WidgetEditorContent"; import { WidgetEditorContent } from "./WidgetEditorContent";
import { useAgentsRedirect } from "ee/pages/WidgetsEditor/hooks/useAgentsRedirect";
/** /**
* WidgetsEditor * WidgetsEditor
@ -25,6 +26,8 @@ function WidgetsEditor() {
const currentPageName = useSelector(getCurrentPageName); const currentPageName = useSelector(getCurrentPageName);
const currentApp = useSelector(getCurrentApplication); const currentApp = useSelector(getCurrentApplication);
useAgentsRedirect();
useEffect(() => { useEffect(() => {
if (currentPageName !== undefined && currentPageId !== undefined) { if (currentPageName !== undefined && currentPageId !== undefined) {
// Logging page load event // Logging page load event

View File

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