Skip to content

Commit

Permalink
Move EditMultiFactorAuthenticator component to admin.connections fe…
Browse files Browse the repository at this point in the history
…ature
  • Loading branch information
JayaShakthi97 committed Jun 18, 2024
1 parent 7967a62 commit c204320
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 3,496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import useAuthenticationFlow from "@wso2is/admin.authentication-flow-builder.v1/hooks/use-authentication-flow";
import { AuthenticatorManagementConstants } from "@wso2is/admin.connections.v1";
import { getMultiFactorAuthenticatorDetails } from "@wso2is/admin.connections.v1/api/authenticators";
import {
AppConstants,
AppState,
Expand All @@ -27,7 +28,6 @@ import {
history
} from "@wso2is/admin.core.v1";
import useGlobalVariables from "@wso2is/admin.core.v1/hooks/use-global-variables";
import { getMultiFactorAuthenticatorDetails } from "@wso2is/admin.identity-providers.v1/api";
import {
IdentityProviderManagementConstants
} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants";
Expand Down Expand Up @@ -72,6 +72,7 @@ import {
} from "../../../models";
import { AdaptiveScriptUtils } from "../../../utils/adaptive-script-utils";
import { ConnectionsJITUPConflictWithMFAReturnValue, SignInMethodUtils } from "../../../utils/sign-in-method-utils";

import "./sign-in-method-customization.scss";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022-2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -21,6 +21,7 @@ import {
identityProviderConfig
} from "@wso2is/admin.extensions.v1";
import { authenticatorConfig } from "@wso2is/admin.extensions.v1/configs/authenticator";
import { AuthenticatorFormFactory } from "@wso2is/admin.identity-providers.v1/components/forms";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { AlertLevels, LoadableComponentInterface, TestableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
Expand All @@ -31,10 +32,13 @@ import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { Dispatch } from "redux";
import { Grid, SemanticShorthandItem, TabPaneProps } from "semantic-ui-react";
import { AuthenticatorFormFactory } from "./forms/factories";
import { updateMultiFactorAuthenticatorDetails } from "../api";
import { IdentityProviderManagementConstants } from "../constants";
import { AuthenticatorInterface, AuthenticatorSettingsFormModes, MultiFactorAuthenticatorInterface } from "../models";
import { updateMultiFactorAuthenticatorDetails } from "../../api/authenticators";
import { AuthenticatorManagementConstants } from "../../constants/autheticator-constants";
import {
AuthenticatorInterface,
AuthenticatorSettingsFormModes,
MultiFactorAuthenticatorInterface
} from "../../models/authenticators";

/**
* Proptypes for the Multi-factor Authenticator edit component.
Expand Down Expand Up @@ -169,17 +173,17 @@ export const EditMultiFactorAuthenticator: FunctionComponent<EditMultiFactorAuth

const getI18nKeyForMultiFactorAuthenticator =
(authenticator: MultiFactorAuthenticatorInterface | AuthenticatorInterface) => {
if (authenticator.id === IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID) {
if (authenticator.id === AuthenticatorManagementConstants.SMS_OTP_AUTHENTICATOR_ID) {
return "updateSMSOTPAuthenticator";
} else if (authenticator.id === IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID) {
} else if (authenticator.id === AuthenticatorManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID) {
return "updateEmailOTPAuthenticator";
} else {
return "updateGenericAuthenticator";
}
};

const displayExternalResourcesButton = () => {
if (authenticator.id === IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID) {
if (authenticator.id === AuthenticatorManagementConstants.SMS_OTP_AUTHENTICATOR_ID) {
return true;
}

Expand Down Expand Up @@ -249,8 +253,8 @@ export const EditMultiFactorAuthenticator: FunctionComponent<EditMultiFactorAuth
// If the MFA is TOTP/Magic Link skip the settings tab.
if (
![
IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID,
IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID
AuthenticatorManagementConstants.TOTP_AUTHENTICATOR_ID,
AuthenticatorManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID
].includes(authenticator.id)
) {
panes.push({
Expand All @@ -271,8 +275,8 @@ export const EditMultiFactorAuthenticator: FunctionComponent<EditMultiFactorAuth
const resolveDefaultActiveIndex = (activeIndex: number): number => {

if (![
IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID,
IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID
AuthenticatorManagementConstants.TOTP_AUTHENTICATOR_ID,
AuthenticatorManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID
].includes(authenticator.id)) {
return activeIndex;
}
Expand Down
6 changes: 2 additions & 4 deletions features/admin.connections.v1/pages/connection-edit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -27,9 +27,6 @@ import {
AuthenticatorExtensionsConfigInterface,
identityProviderConfig
} from "@wso2is/admin.extensions.v1/configs";
import {
EditMultiFactorAuthenticator
} from "@wso2is/admin.identity-providers.v1/components/edit-multi-factor-authenticator";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { hasRequiredScopes } from "@wso2is/core/helpers";
import { AlertLevels, TestableComponentInterface } from "@wso2is/core/models";
Expand Down Expand Up @@ -71,6 +68,7 @@ import {
getConnectionTemplates
} from "../api/connections";
import { EditConnection } from "../components/edit/connection-edit";
import { EditMultiFactorAuthenticator } from "../components/edit/edit-multi-factor-authenticator";
import { AuthenticatorManagementConstants } from "../constants/autheticator-constants";
import { ConnectionManagementConstants } from "../constants/connection-constants";
import { useSetConnectionTemplates } from "../hooks/use-connection-templates";
Expand Down
Loading

0 comments on commit c204320

Please sign in to comment.