Skip to content

Commit

Permalink
Merge pull request #6116 from DonOmalVindula/master
Browse files Browse the repository at this point in the history
Disable AI features in sub-organizations
  • Loading branch information
DonOmalVindula authored Apr 30, 2024
2 parents db13c6c + e894787 commit 2243ce3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-flowers-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/console": patch
"@wso2is/features": patch
---

Disable AI features in sub-organizations
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 @@ -16,7 +16,6 @@
* under the License.
*/


import { AlertInterface, AlertLevels } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import React, { PropsWithChildren, useEffect, useState } from "react";
Expand All @@ -25,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 @@ -48,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 @@ -132,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 2243ce3

Please sign in to comment.