Skip to content

Commit

Permalink
Merge pull request wso2#4468 from DonOmalVindula/fix/email-provider-s…
Browse files Browse the repository at this point in the history
…ub-org

Add config to disable email provider in super org
  • Loading branch information
DonOmalVindula authored Nov 1, 2023
2 parents 53153b4 + f0bbe0f commit 853016c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-lies-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

Add config to disable email provider in super org
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import Grid from "@oxygen-ui/react/Grid";
import { OrganizationType } from "@wso2is/common";
import { IdentifiableComponentInterface } from "@wso2is/core/models";
import { PageLayout } from "@wso2is/react-components";
import React, { FunctionComponent, ReactElement } from "react";
Expand All @@ -26,6 +27,7 @@ import { Divider } from "semantic-ui-react";
import { ReactComponent as EmailIcon } from "../../../themes/default/assets/images/icons/email-icon.svg";
import { ReactComponent as SMSIcon } from "../../../themes/default/assets/images/icons/sms-icon.svg";
import { AppConstants, AppState, FeatureConfigInterface, history } from "../../core";
import { useGetOrganizationType } from "../../organizations/hooks/use-get-organization-type";
import { SettingsSection } from "../settings/settings-section";

/**
Expand All @@ -45,6 +47,8 @@ export const NotificationChannelPage: FunctionComponent<NotificationChannelPageI
const { ["data-componentid"]: componentid } = props;

const { t } = useTranslation();
const orgType: OrganizationType = useGetOrganizationType();

const featureConfig : FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);

/**
Expand All @@ -65,8 +69,10 @@ export const NotificationChannelPage: FunctionComponent<NotificationChannelPageI
description={ t("extensions:develop.notificationChannel.description") }
data-testid={ `${componentid}-page-layout` }
>
<>
{ featureConfig.emailProviders?.enabled ? (
{ featureConfig.emailProviders?.enabled
&& !(featureConfig?.emailProviders?.disabledFeatures?.includes("superTenantProvider")
&& orgType === OrganizationType.SUPER_ORGANIZATION) && (
<>
<Grid xs={ 12 } lg={ 6 }>
<SettingsSection
data-componentid={ "account-login-page-section" }
Expand All @@ -78,24 +84,24 @@ export const NotificationChannelPage: FunctionComponent<NotificationChannelPageI
primaryAction={ t("common:configure") }
/>
</Grid>
) : null }
<Divider hidden/>
{ featureConfig.smsProviders?.enabled ? (
<Grid xs={ 12 } lg={ 6 }>
<SettingsSection
data-componentid={ "account-login-page-section" }
data-testid={ "account-login-page-section" }
description={ t("extensions:develop.smsProviders.description") }
icon={ SMSIcon }
header={
t("extensions:develop.smsProviders.heading")
}
onPrimaryActionClick={ handleSMSSelection }
primaryAction={ t("common:configure") }
/>
</Grid>
): null }
</>
<Divider hidden/>
</>
) }
{ featureConfig.smsProviders?.enabled && (
<Grid xs={ 12 } lg={ 6 }>
<SettingsSection
data-componentid={ "account-login-page-section" }
data-testid={ "account-login-page-section" }
description={ t("extensions:develop.smsProviders.description") }
icon={ SMSIcon }
header={
t("extensions:develop.smsProviders.heading")
}
onPrimaryActionClick={ handleSMSSelection }
primaryAction={ t("common:configure") }
/>
</Grid>
) }
</PageLayout>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { hasRequiredScopes } from "@wso2is/core/helpers";
import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { Field, Form, FormPropsInterface } from "@wso2is/form";
import { EmphasizedSegment, PageLayout, PrimaryButton } from "@wso2is/react-components";
import { EmphasizedSegment, PageLayout } from "@wso2is/react-components";
import React, { FunctionComponent, MutableRefObject, ReactElement, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -65,7 +65,6 @@ export const WSFederationConfigurationPage: FunctionComponent<WSFederationConfig

const { t } = useTranslation();

const [ isSubmitting, setIsSubmitting ] = useState<boolean>(false);
const [ wsFederationConfig , setWSFederationConfig ] =
useState<WSFederationConfigFormValuesInterface>(undefined);

Expand Down Expand Up @@ -141,18 +140,16 @@ export const WSFederationConfigurationPage: FunctionComponent<WSFederationConfig
/**
* Handle WSFederation form submit.
*/
const handleSubmit = (values: WSFederationConfigFormValuesInterface) => {
setIsSubmitting(true);
const handleSubmit = (value: boolean) => {
const data: WSFederationConfigAPIResponseInterface = {
enableRequestSigning: values.enableRequestSigning
enableRequestSigning: value
};

updateWSFederationConfigurations(data).then(() => {
handleUpdateSuccess();
}).catch(() => {
handleUpdateError();
}).finally(() => {
setIsSubmitting(false);
mutateWSFederationConfig();
});
};
Expand Down Expand Up @@ -223,7 +220,7 @@ export const WSFederationConfigurationPage: FunctionComponent<WSFederationConfig
<Form
id={ FORM_ID }
uncontrolledForm={ true }
onSubmit={ handleSubmit }
onSubmit={ null }
initialValues={ wsFederationConfig }
enableReinitialize={ true }
ref={ formRef }
Expand All @@ -243,28 +240,14 @@ export const WSFederationConfigurationPage: FunctionComponent<WSFederationConfig
data-componentid={
`${componentId}-enable-request-signing` }
toggle
listen={ (value: boolean) => {
handleSubmit(value);
} }
/>
</Grid.Column>
</Grid.Row>
</Grid>
</Form>
<Divider hidden />
<Grid.Row columns={ 1 } className="mt-6">
<Grid.Column mobile={ 16 } tablet={ 16 } computer={ 16 }>
<PrimaryButton
size="small"
loading={ isSubmitting }
disabled={ isReadOnly }
onClick={ () => {
formRef?.current?.triggerSubmit();
} }
ariaLabel="WSFederation Configuration form update button"
data-componentid={ `${ componentId }-update-button` }
>
{ t("common:update") }
</PrimaryButton>
</Grid.Column>
</Grid.Row>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/console/src/public/deployment.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
}
},
"emailProviders": {
"disabledFeatures": [],
"disabledFeatures": [ "superTenantProvider" ],
"enabled": true,
"scopes": {
"update": [
Expand Down

0 comments on commit 853016c

Please sign in to comment.