Skip to content

Commit

Permalink
Merge pull request #7435 from Shenali-SJ/custom-auth-disable
Browse files Browse the repository at this point in the history
Enable hiding connection template based on hiddenConnectionTemplates config
  • Loading branch information
ashanthamara authored Jan 28, 2025
2 parents ffd6eaa + 5697a01 commit a506715
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-penguins-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.connections.v1": patch
---

Enable hiding connection template based on hiddenConnectionTemplates config #7435
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/

import { AppState } from "@wso2is/admin.core.v1/store";
import { isFeatureEnabled } from "@wso2is/core/helpers";
import { FeatureAccessConfigInterface, IdentifiableComponentInterface } from "@wso2is/core/models";
import { IdentifiableComponentInterface } from "@wso2is/core/models";
import isEmpty from "lodash-es/isEmpty";
import React, { FC, ReactElement, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -28,7 +27,6 @@ import CustomAuthenticationCreateWizard from "./custom-authentication-create-wiz
import { EnterpriseConnectionCreateWizard } from "./enterprise-connection-create-wizard";
import { useGetConnectionTemplate, useGetConnections } from "../../api/connections";
import { CommonAuthenticatorConstants } from "../../constants/common-authenticator-constants";
import { ConnectionUIConstants } from "../../constants/connection-ui-constants";
import {
ConnectionTemplateInterface,
GenericConnectionCreateWizardPropsInterface,
Expand Down Expand Up @@ -100,12 +98,6 @@ export const AuthenticatorCreateWizardFactory: FC<AuthenticatorCreateWizardFacto
...rest
} = props;

const identityProviderFeatureConfig: FeatureAccessConfigInterface = useSelector(
(state: AppState) => state.config.ui.features?.identityProviders
);

const { FEATURE_DICTIONARY } = ConnectionUIConstants;

const [ possibleListOfDuplicateIDPs, setPossibleListOfDuplicateIDPs ] = useState<string[]>(undefined);
const [ selectedTemplate, setSelectedTemplate ] = useState<ConnectionTemplateInterface>(undefined);
const [ selectedTemplateWithUniqueName, setSelectedTemplateWithUniqueName ] = useState<ConnectionTemplateInterface>(
Expand Down Expand Up @@ -324,25 +316,21 @@ export const AuthenticatorCreateWizardFactory: FC<AuthenticatorCreateWizardFacto
);

case CommonAuthenticatorConstants.CONNECTION_TEMPLATE_IDS.CUSTOM_AUTHENTICATION:
if (isFeatureEnabled(identityProviderFeatureConfig, FEATURE_DICTIONARY["CUSTOM_AUTHENTICATION"])) {
return (
<CustomAuthenticationCreateWizard
title={ t("customAuthentication:fields.createWizard.title") }
subTitle={ t("customAuthentication:fields.createWizard.subTitle") }
onWizardClose={ () => {
setSelectedTemplateWithUniqueName(undefined);
setSelectedTemplate(undefined);
handleModalVisibility(false);
onWizardClose();
} }
template={ selectedTemplateWithUniqueName }
data-componentid={ selectedTemplate?.templateId }
{ ...rest }
/>
);
}

break;
return (
<CustomAuthenticationCreateWizard
title={ t("customAuthentication:fields.createWizard.title") }
subTitle={ t("customAuthentication:fields.createWizard.subTitle") }
onWizardClose={ () => {
setSelectedTemplateWithUniqueName(undefined);
setSelectedTemplate(undefined);
handleModalVisibility(false);
onWizardClose();
} }
template={ selectedTemplateWithUniqueName }
data-componentid={ selectedTemplate?.templateId }
{ ...rest }
/>
);

case CommonAuthenticatorConstants.CONNECTION_TEMPLATE_IDS.EXPERT_MODE:
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,6 @@ export class ConnectionUIConstants {
TWO_FACTOR_CUSTOM_AUTHENTICATOR_ID: "two-factor-custom-authentication"
};

/**
* Set of keys used to enable/disable features.
*/
public static readonly FEATURE_DICTIONARY: Map<string, string> = new Map<string, string>().set(
"CUSTOM_AUTHENTICATION",
"identityProviders.customAuthentication"
);

public static readonly AUTH_TYPES: AuthenticationTypeDropdownOption[] = [
{
key: EndpointAuthenticationType.NONE,
Expand Down
5 changes: 5 additions & 0 deletions features/admin.connections.v1/pages/connection-templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ const ConnectionTemplatesPage: FC<ConnectionTemplatePagePropsInterface> = (
return null;
}

if (UIConfig?.hiddenConnectionTemplates?.includes(template.id)) {

return null;
}

let isTemplateDisabled: boolean = template.disabled;
let disabledHint: ReactNode = undefined;

Expand Down

0 comments on commit a506715

Please sign in to comment.