Skip to content

Commit

Permalink
Merge pull request #7248 from dasuni-30/fix/27863-v2
Browse files Browse the repository at this point in the history
Fix issues in console settings and update admin profile
  • Loading branch information
dasuni-30 authored Jan 7, 2025
2 parents d6d753c + 033c1e0 commit 5f48648
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-peas-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@wso2is/admin.console-settings.v1": patch
"@wso2is/admin.users.v1": patch
"@wso2is/admin.core.v1": patch
---

Fix issues in console settings and update admin profile
4 changes: 2 additions & 2 deletions features/admin.core.v1/models/users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2020-2025, 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 @@ -45,7 +45,7 @@ export interface UserMetaInterface {
* Captures the basic details of the user.
*/
export interface UserBasicInterface {
id: string;
id?: string;
userName: string;
emails?: string[] | MultiValueAttributeInterface[];
name?: NameInterface;
Expand Down
46 changes: 40 additions & 6 deletions features/admin.users.v1/components/edit-user.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2020-2025, 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 @@ -18,7 +18,7 @@

import { useRequiredScopes } from "@wso2is/access-control";
import { FeatureConfigInterface } from "@wso2is/admin.core.v1/models";
import { store } from "@wso2is/admin.core.v1/store";
import { AppState, store } from "@wso2is/admin.core.v1/store";
import { SCIMConfigs } from "@wso2is/admin.extensions.v1/configs/scim";
import { userstoresConfig } from "@wso2is/admin.extensions.v1/configs/userstores";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
Expand All @@ -27,15 +27,16 @@ import { ConnectorPropertyInterface } from "@wso2is/admin.server-configurations.
import { isFeatureEnabled } from "@wso2is/core/helpers";
import { AlertInterface, AlertLevels, ProfileInfoInterface, SBACInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { ResourceTab } from "@wso2is/react-components";
import { Message, ResourceTab } from "@wso2is/react-components";
import { AxiosError } from "axios";
import React, { FunctionComponent, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { TabProps } from "semantic-ui-react";
import { Divider, Grid, TabProps } from "semantic-ui-react";
import { UserGroupsList } from "./user-groups-edit";
import { UserProfile } from "./user-profile";
import { UserRolesList } from "./user-roles-list";
import { UserSessions } from "./user-sessions";
import { AdminAccountTypes, UserManagementConstants } from "../constants";
import useUserManagement from "../hooks/use-user-management";
Expand Down Expand Up @@ -107,6 +108,10 @@ export const EditUser: FunctionComponent<EditUserPropsInterface> = (
const [ isUserManagedByParentOrg, setIsUserManagedByParentOrg ] = useState<boolean>(false);
const [ isUserProfileReadOnly, setIsUserProfileReadOnly ] = useState<boolean>(false);

const userRolesDisabledFeatures: string[] = useSelector((state: AppState) => {
return state.config.ui.features?.users?.disabledFeatures;
});

useEffect(() => {
const userStore: string = user?.userName?.split("/").length > 1
? user?.userName?.split("/")[0]
Expand All @@ -116,6 +121,7 @@ export const EditUser: FunctionComponent<EditUserPropsInterface> = (
|| readOnlyUserStores?.includes(userStore?.toString())
|| !hasUsersUpdatePermissions
|| user[ SCIMConfigs.scim.enterpriseSchema ]?.userSourceId
|| user[ UserManagementConstants.CUSTOMSCHEMA ]?.isReadOnlyUser === "true"
) {
setReadOnly(true);
}
Expand Down Expand Up @@ -211,11 +217,31 @@ export const EditUser: FunctionComponent<EditUserPropsInterface> = (
isReadOnlyUserStoresLoading={ isReadOnlyUserStoresLoading }
isUserManagedByParentOrg={ isUserManagedByParentOrg }
adminUserType={ AdminAccountTypes.INTERNAL }
allowDeleteOnly={
user[ UserManagementConstants.CUSTOMSCHEMA ]?.isReadOnlyUser === "true"
}
editUserDisclaimerMessage={ (
<Grid>
<Grid.Row columns={ 1 }>
<Grid.Column mobile={ 12 } tablet={ 12 } computer={ 6 }>
<Message
type="info"
content={ t("extensions:manage.users.editUserProfile.disclaimerMessage") }
/>
<Divider hidden />
</Grid.Column>
</Grid.Row>
</Grid>
) }
/>
</ResourceTab.Pane>
)
},
{
(
!userRolesDisabledFeatures?.includes(UserManagementConstants.FEATURE_DICTIONARY.get("USER_GROUPS"))
|| user?.userName?.split("/").length !== 1
)
&& {
menuItem: t("users:editUser.tab.menuItems.1"),
render: () => (
<ResourceTab.Pane controlledSegmentation attached={ false }>
Expand All @@ -228,6 +254,14 @@ export const EditUser: FunctionComponent<EditUserPropsInterface> = (
</ResourceTab.Pane>
)
},
{
menuItem: t("users:editUser.tab.menuItems.2"),
render: () => (
<ResourceTab.Pane controlledSegmentation attached={ false }>
<UserRolesList user={ user } />
</ResourceTab.Pane>
)
},
{
menuItem: t("users:editUser.tab.menuItems.3"),
render: () => (
Expand Down
5 changes: 4 additions & 1 deletion features/admin.users.v1/components/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,10 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
!isEmpty(profileInfo) && (
<EmphasizedSegment padded="very">
{
(isReadOnly && !isEmpty(tenantAdmin)) && editUserDisclaimerMessage
isReadOnly
&& (!isEmpty(tenantAdmin) || tenantAdmin !== null)
&& !user[ SCIMConfigs.scim.enterpriseSchema ]?.userSourceId
&& editUserDisclaimerMessage
}
<Forms
data-testid={ `${ testId }-form` }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2020-2025, 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 @@ -67,6 +67,7 @@ export class UserManagementConstants {
.set("USER_UPDATE", "users.update")
.set("USER_DELETE", "users.delete")
.set("USER_READ", "users.read")
.set("USER_GROUPS", "users.edit.groups")
.set("USER_ROLES", "users.edit.roles");

// API errors
Expand Down
4 changes: 2 additions & 2 deletions features/admin.users.v1/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2020-2025, 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 @@ -45,7 +45,7 @@ export interface UserBasicInterface {
/**
* ID of the user.
*/
id: string;
id?: string;
/**
* Username of the user.
*/
Expand Down

0 comments on commit 5f48648

Please sign in to comment.