Skip to content

Commit

Permalink
Merge pull request #6114 from DonOmalVindula/ai-features-hotfix-conso…
Browse files Browse the repository at this point in the history
…le-2.15.9

[Hotfix][console] Disable AI features in sub-organizations
  • Loading branch information
DonOmalVindula authored Apr 30, 2024
2 parents f66775e + 6397a51 commit f30bb7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useSelector } from "react-redux";
import { SignOnMethodsCore } from "./sign-on-methods-core";
import { AppState, FeatureConfigInterface } from "../../../../../admin.core.v1";
import useAILoginFlow from "../../../../../admin.login-flow.ai.v1/hooks/use-ai-login-flow";
import { useGetCurrentOrganizationType } from "../../../../../admin.organizations.v1/hooks/use-get-organization-type";
import {
ApplicationInterface,
AuthenticationSequenceInterface
Expand Down Expand Up @@ -96,12 +97,14 @@ export const SignOnMethodsWrapper: FunctionComponent<SignOnMethodsWrapperPropsIn

const { aiGeneratedLoginFlow } = useAILoginFlow();

const { isSubOrganization } = useGetCurrentOrganizationType();

const applicationDisabledFeatures: string[] = useSelector((state: AppState) =>
state.config.ui.features?.applications?.disabledFeatures);

let processedAuthenticationSequence: AuthenticationSequenceInterface = authenticationSequence;

if (!applicationDisabledFeatures?.includes(LOGIN_FLOW_AI_FEATURE_TAG)) {
if (!applicationDisabledFeatures?.includes(LOGIN_FLOW_AI_FEATURE_TAG) && !isSubOrganization()) {
processedAuthenticationSequence = aiGeneratedLoginFlow ?? authenticationSequence;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { AdaptiveScriptUtils } from "../../../admin.applications.v1/utils/adapti
import { AppState } from "../../../admin.core.v1/store";
import { LOGIN_FLOW_AI_FEATURE_TAG } from "../../../admin.login-flow.ai.v1/constants/login-flow-ai-constants";
import useAILoginFlow from "../../../admin.login-flow.ai.v1/hooks/use-ai-login-flow";
import { useGetCurrentOrganizationType } from "../../../admin.organizations.v1/hooks/use-get-organization-type";
import useAuthenticationFlow from "../../hooks/use-authentication-flow";
import "./script-based-flow-switch.scss";

Expand Down Expand Up @@ -72,6 +73,8 @@ const ScriptBasedFlowSwitch = (props: PropsWithChildren<ScriptBasedFlowSwitchPro

const { aiGeneratedLoginFlow } = useAILoginFlow();

const { isSubOrganization } = useGetCurrentOrganizationType();

const [ showScriptResetWarning, setShowScriptResetWarning ] = useState<boolean>(false);

const applicationDisabledFeatures: string[] = useSelector((state: AppState) =>
Expand All @@ -84,6 +87,7 @@ const ScriptBasedFlowSwitch = (props: PropsWithChildren<ScriptBasedFlowSwitchPro
useEffect(() => {
// Enable conditional authentication script for AI generated authentication sequence.
if (!applicationDisabledFeatures?.includes(LOGIN_FLOW_AI_FEATURE_TAG)
&& !isSubOrganization()
&& aiGeneratedLoginFlow?.script
&& !AdaptiveScriptUtils.isDefaultScript(
aiGeneratedLoginFlow.script,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { LoadingScreen } from "../../admin.ai.v1/components/branding-ai-loading-
import useAIBrandingPreference from "../../admin.ai.v1/hooks/use-ai-branding-preference";
import { AppState } from "../../admin.core.v1/store";
import { ExtendedFeatureConfigInterface } from "../../admin.extensions.v1/configs/models";
import { useGetCurrentOrganizationType } from "../../admin.organizations.v1/hooks/use-get-organization-type";
import { AI_BRANDING_FEATURE_ID } from "../constants/ai-branding-constants";

type BrandingPageLayoutInterface = IdentifiableComponentInterface;
Expand All @@ -49,6 +50,8 @@ const BrandingPageLayout: FunctionComponent<BrandingPageLayoutInterface> = (
mergedBrandingPreference
} = useAIBrandingPreference();

const { isSubOrganization } = useGetCurrentOrganizationType();

return (
<PageLayout
pageTitle={ t("extensions:develop.branding.pageHeader.title") }
Expand All @@ -74,7 +77,7 @@ const BrandingPageLayout: FunctionComponent<BrandingPageLayoutInterface> = (
className="branding-page"
>
{
!disabledFeatures.includes(AI_BRANDING_FEATURE_ID) && (
!disabledFeatures.includes(AI_BRANDING_FEATURE_ID) && !isSubOrganization() && (
<BrandingAIBanner/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { AuthenticationSequenceInterface } from "../../admin.applications.v1/models/application";
import { AppState } from "../../admin.core.v1";
import { useGetCurrentOrganizationType } from "../../admin.organizations.v1/hooks/use-get-organization-type";
import { useAILoginFlowGenerationResult } from "../api/use-ai-login-flow-generation-result";
import LoginFlowAIBanner from "../components/login-flow-ai-banner";
import LoginFlowAILoadingScreen from "../components/login-flow-ai-loading-screen";
Expand All @@ -47,6 +48,8 @@ const AILoginFlowProvider = (props: PropsWithChildren<AILoginFlowProviderProps>)

const dispatch: Dispatch = useDispatch();

const { isSubOrganization } = useGetCurrentOrganizationType();

const applicationDisabledFeatures: string[] = useSelector((state: AppState) =>
state.config.ui.features?.applications?.disabledFeatures);

Expand Down Expand Up @@ -131,7 +134,8 @@ const AILoginFlowProvider = (props: PropsWithChildren<AILoginFlowProviderProps>)
) : (
<>
{
!applicationDisabledFeatures?.includes(LOGIN_FLOW_AI_FEATURE_TAG) && (
!applicationDisabledFeatures?.includes(LOGIN_FLOW_AI_FEATURE_TAG) &&
!isSubOrganization() && (
<LoginFlowAIBanner/>
)
}
Expand Down

0 comments on commit f30bb7c

Please sign in to comment.