From 2676c084282e9533676c63423af213296bf1bb91 Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Wed, 9 Oct 2024 16:22:18 +0530 Subject: [PATCH 1/2] Fix bug with AI login flow not reverting properly --- .../sign-on-methods/sign-in-method-customization.tsx | 4 ++++ .../components/authentication-flow-builder.tsx | 8 +++++++- .../context/ai-login-flow-context.tsx | 5 +++++ .../providers/ai-login-flow-provider.tsx | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-customization.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-customization.tsx index e9225ccaeaf..b9ae1ed929e 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-customization.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-customization.tsx @@ -28,6 +28,7 @@ import { } from "@wso2is/admin.core.v1"; import useGlobalVariables from "@wso2is/admin.core.v1/hooks/use-global-variables"; import { GenericAuthenticatorInterface } from "@wso2is/admin.identity-providers.v1/models/identity-provider"; +import useAILoginFlow from "@wso2is/admin.login-flow.ai.v1/hooks/use-ai-login-flow"; import { OrganizationType } from "@wso2is/admin.organizations.v1/constants"; import { ConnectorPropertyInterface, @@ -157,6 +158,8 @@ export const SignInMethodCustomization: FunctionComponent state?.organization?.organizationType); @@ -390,6 +393,7 @@ export const SignInMethodCustomization: FunctionComponent { setIsLoading(false); + setAiGeneratedLoginFlow(undefined); }); }; diff --git a/features/admin.authentication-flow-builder.v1/components/authentication-flow-builder.tsx b/features/admin.authentication-flow-builder.v1/components/authentication-flow-builder.tsx index 0e28b95e3ef..513ceeb69d4 100644 --- a/features/admin.authentication-flow-builder.v1/components/authentication-flow-builder.tsx +++ b/features/admin.authentication-flow-builder.v1/components/authentication-flow-builder.tsx @@ -35,6 +35,7 @@ import { import { AdaptiveScriptUtils } from "@wso2is/admin.applications.v1/utils/adaptive-script-utils"; import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { AppState } from "@wso2is/admin.core.v1/store"; +import useAILoginFlow from "@wso2is/admin.login-flow.ai.v1/hooks/use-ai-login-flow"; import { OrganizationType } from "@wso2is/admin.organizations.v1/constants/organization-constants"; import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; @@ -110,6 +111,8 @@ const AuthenticationFlowBuilder: FunctionComponent refetchApplication()); + }).finally(() => { + setAiGeneratedLoginFlow(undefined); + refetchApplication(); + }); }; /** diff --git a/features/admin.login-flow.ai.v1/context/ai-login-flow-context.tsx b/features/admin.login-flow.ai.v1/context/ai-login-flow-context.tsx index 101fe06bc18..71515b5b387 100644 --- a/features/admin.login-flow.ai.v1/context/ai-login-flow-context.tsx +++ b/features/admin.login-flow.ai.v1/context/ai-login-flow-context.tsx @@ -38,6 +38,11 @@ export interface AILoginFlowContextProps { * State to hold the generated login flow. */ aiGeneratedLoginFlow: AuthenticationSequenceInterface; + /** + * Set the generated login flow. + * @param flow - Login flow to be set. + */ + setAiGeneratedLoginFlow: (flow: AuthenticationSequenceInterface) => void; /** * Operation ID of the login flow generation process. */ diff --git a/features/admin.login-flow.ai.v1/providers/ai-login-flow-provider.tsx b/features/admin.login-flow.ai.v1/providers/ai-login-flow-provider.tsx index 341f0ce8ecd..b06d867e177 100644 --- a/features/admin.login-flow.ai.v1/providers/ai-login-flow-provider.tsx +++ b/features/admin.login-flow.ai.v1/providers/ai-login-flow-provider.tsx @@ -139,6 +139,7 @@ const AILoginFlowProvider = (props: PropsWithChildren) loginFlowGenerationCompleted, operationId, promptHistory, + setAiGeneratedLoginFlow, setBannerState, setGeneratingLoginFlow, setLoginFlowGenerationCompleted, From 4a2604ab0ec989c2fcebd12583f8222643f78b61 Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Wed, 9 Oct 2024 16:23:31 +0530 Subject: [PATCH 2/2] Add changeset --- .changeset/curly-hairs-pretend.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/curly-hairs-pretend.md diff --git a/.changeset/curly-hairs-pretend.md b/.changeset/curly-hairs-pretend.md new file mode 100644 index 00000000000..042953674c1 --- /dev/null +++ b/.changeset/curly-hairs-pretend.md @@ -0,0 +1,7 @@ +--- +"@wso2is/admin.authentication-flow-builder.v1": patch +"@wso2is/admin.login-flow.ai.v1": patch +"@wso2is/admin.applications.v1": patch +--- + +Fix bug with AI login flow not reverting properly