Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issues in set Password via Email option from Add User form #4361

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-kids-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

Fix the issues in set Password via Email option from Add User form
47 changes: 47 additions & 0 deletions apps/console/src/features/users/pages/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { AccessControlConstants, Show } from "@wso2is/access-control";
import { CommonHelpers } from "@wso2is/core/helpers";
import {
AlertInterface,
AlertLevels,
IdentifiableComponentInterface,
MultiValueAttributeInterface,
Expand Down Expand Up @@ -67,8 +68,13 @@ import {
import { RootOnlyComponent } from "../../organizations/components";
import { OrganizationUtils } from "../../organizations/utils";
import {
ConnectorPropertyInterface,
GovernanceConnectorCategoryInterface,
GovernanceConnectorInterface,
RealmConfigInterface,
ServerConfigurationsConstants,
ServerConfigurationsInterface,
getConnectorCategory,
getServerConfigs
} from "../../server-configurations";
import { getUserStoreList } from "../../userstores/api";
Expand Down Expand Up @@ -564,6 +570,15 @@ const UsersPage: FunctionComponent<UsersPageInterface> = (
getList(listItemLimit, listOffset, null, null, null);
};

/**
* Dispatches the alert object to the redux store.
*
* @param alert - Alert object.
*/
const handleAlerts = (alert: AlertInterface) => {
dispatch(addAlert(alert));
};

/**
* The following method set the list of columns selected by the user to
* the state.
Expand Down Expand Up @@ -609,7 +624,38 @@ const UsersPage: FunctionComponent<UsersPageInterface> = (
setListUpdated(true);
};

/**
* Handles the click event of the create new user button.
*/
const handleAddNewUserWizardClick = (): void => {

getConnectorCategory(ServerConfigurationsConstants.USER_ONBOARDING_CONNECTOR_ID)
.then((response: GovernanceConnectorCategoryInterface) => {
const connectors: GovernanceConnectorInterface[] = response?.connectors;
const userOnboardingConnector: GovernanceConnectorInterface = connectors.find(
(connector: GovernanceConnectorInterface) => connector.id
=== ServerConfigurationsConstants.USER_EMAIL_VERIFICATION_CONNECTOR_ID
);

const emailVerification: ConnectorPropertyInterface = userOnboardingConnector.properties.find(
(property: ConnectorPropertyInterface) =>
property.name === ServerConfigurationsConstants.EMAIL_VERIFICATION_ENABLED);

setEmailVerificationEnabled(emailVerification.value === "true");
}).catch((error: AxiosError) => {
handleAlerts({
description: error?.response?.data?.description ?? t(
"console:manage.features.governanceConnectors.notifications." +
"getConnector.genericError.description"
),
level: AlertLevels.ERROR,
message: error?.response?.data?.message ?? t(
"console:manage.features.governanceConnectors.notifications." +
"getConnector.genericError.message"
)
});
});
};

const addUserDropdownTrigger: ReactElement = (
<PrimaryButton
Expand Down Expand Up @@ -784,6 +830,7 @@ const UsersPage: FunctionComponent<UsersPageInterface> = (

const handleDropdownItemChange = (value: string): void => {
if (value === UserAccountTypesMain.INTERNAL) {
handleAddNewUserWizardClick();
eventPublisher.publish("manage-users-click-create-new", {
type: "user"
});
Expand Down
Loading