Skip to content

Commit

Permalink
Merge pull request #6968 from DonOmalVindula/fix/26839
Browse files Browse the repository at this point in the history
Fix bug with AI login flow not reverting properly
  • Loading branch information
DonOmalVindula authored Oct 10, 2024
2 parents 98cee21 + 4a2604a commit 4d0bd67
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/curly-hairs-pretend.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -157,6 +158,8 @@ export const SignInMethodCustomization: FunctionComponent<SignInMethodCustomizat

const { isSystemApplication } = useAuthenticationFlow();

const { setAiGeneratedLoginFlow } = useAILoginFlow();

const orgType: OrganizationType = useSelector((state: AppState) =>
state?.organization?.organizationType);

Expand Down Expand Up @@ -390,6 +393,7 @@ export const SignInMethodCustomization: FunctionComponent<SignInMethodCustomizat
})
.finally(() => {
setIsLoading(false);
setAiGeneratedLoginFlow(undefined);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -110,6 +111,8 @@ const AuthenticationFlowBuilder: FunctionComponent<AuthenticationFlowBuilderProp
onActiveFlowModeChange
} = useAuthenticationFlow();

const { setAiGeneratedLoginFlow } = useAILoginFlow();

const FlowModes: AuthenticationFlowBuilderModesInterface[] = readOnly ? [
{
id: 0,
Expand Down Expand Up @@ -290,7 +293,10 @@ const AuthenticationFlowBuilder: FunctionComponent<AuthenticationFlowBuilderProp
message: t("applications:notifications.updateAuthenticationFlow" +
".genericError.message")
}));
}).finally(() => refetchApplication());
}).finally(() => {
setAiGeneratedLoginFlow(undefined);
refetchApplication();
});
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const AILoginFlowProvider = (props: PropsWithChildren<AILoginFlowProviderProps>)
loginFlowGenerationCompleted,
operationId,
promptHistory,
setAiGeneratedLoginFlow,
setBannerState,
setGeneratingLoginFlow,
setLoginFlowGenerationCompleted,
Expand Down

0 comments on commit 4d0bd67

Please sign in to comment.