Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with AI login flow not reverting properly #6968

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading