This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch ranger-2.6
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit 5f5887bf897ba6d21157289b5faf13a419bb5a25
Author: Dhaval.Rajpara <[email protected]>
AuthorDate: Fri Nov 1 20:43:11 2024 +0530

    RANGER-4973 : Enhance Ranger UI to support a new user type for external 
users from Data Sharing
    
    Signed-off-by: Dhaval.Rajpara <[email protected]>
    (cherry picked from commit c2765370d58b002052e6ced823859b4000f945fb)
---
 .../main/webapp/react-webapp/src/utils/XAEnums.js  | 11 +++++---
 .../users_details/EditUserView.jsx                 |  3 +-
 .../users_details/UserFormComp.jsx                 | 33 ++++++++++------------
 .../users_details/UserListing.jsx                  | 27 ++++++------------
 4 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js 
b/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
index cd85f3b06..7b75c7669 100644
--- a/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
+++ b/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
@@ -61,14 +61,17 @@ export const UserTypes = {
   USER_INTERNAL: {
     value: 0,
     label: "Internal",
-    rbkey: "xa.enum.AccessResult.ACCESS_RESULT_ALLOWED",
-    tt: "lbl.AccessResult_ACCESS_RESULT_ALLOWED"
+    variant: "success"
   },
   USER_EXTERNAL: {
     value: 1,
     label: "External",
-    rbkey: "xa.enum.AccessResult.ACCESS_RESULT_DENIED",
-    tt: "lbl.AccessResult_ACCESS_RESULT_DENIED"
+    variant: "warning"
+  },
+  USER_FEDERATED: {
+    value: 2,
+    label: "Federated",
+    variant: "secondary"
   }
 };
 
diff --git 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/EditUserView.jsx
 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/EditUserView.jsx
index e08917bf2..7d04c71ce 100644
--- 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/EditUserView.jsx
+++ 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/EditUserView.jsx
@@ -133,7 +133,8 @@ function AddUserView() {
 
   return loader ? (
     <Loader />
-  ) : userInfo.userSource == UserTypes.USER_EXTERNAL.value ? (
+  ) : userInfo.userSource == UserTypes.USER_EXTERNAL.value ||
+    userInfo.userSource == UserTypes.USER_FEDERATED.value ? (
     <>
       <div className="header-wraper">
         <h3 className="wrap-header bold">User Detail</h3>
diff --git 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
index d57d6571c..9f5d642f2 100644
--- 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
+++ 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
@@ -28,7 +28,7 @@ import {
   ActivationStatus,
   RegexValidation,
   UserRoles,
-  UserSource
+  UserTypes
 } from "Utils/XAEnums";
 import { toast } from "react-toastify";
 import { getUserAccessRoleList, serverError } from "Utils/XAUtils";
@@ -71,6 +71,9 @@ function UserFormComp(props) {
   const { isEditView, userInfo } = props;
   const [preventUnBlock, setPreventUnblock] = useState(false);
   const toastId = React.useRef(null);
+  const isExternalOrFederatedUser =
+    userInfo?.userSource == UserTypes.USER_EXTERNAL.value ||
+    userInfo?.userSource == UserTypes.USER_FEDERATED.value;
 
   const handleSubmit = async (formData) => {
     let userFormData = {};
@@ -215,11 +218,7 @@ function UserFormComp(props) {
         defaultOptions
         isMulti
         isDisabled={
-          isEditView &&
-          userInfo &&
-          userInfo.userSource == UserSource.XA_USER.value
-            ? true
-            : false
+          isEditView && userInfo && isExternalOrFederatedUser ? true : false
         }
       />
     );
@@ -229,9 +228,12 @@ function UserFormComp(props) {
     const userProps = getUserProfile();
     let disabledUserRolefield;
     if (isEditView && userInfo) {
-      if (userInfo.userSource == UserSource.XA_USER.value) {
+      if (userInfo.userSource == UserTypes.USER_EXTERNAL.value) {
         disabledUserRolefield = true;
       }
+      if (userInfo.userSource == UserTypes.USER_FEDERATED.value) {
+        return (disabledUserRolefield = true);
+      }
       if (userProps.loginId != "admin") {
         if (userInfo.name != "admin") {
           if (
@@ -297,7 +299,7 @@ function UserFormComp(props) {
     if (
       isEditView &&
       userInfo &&
-      userInfo.userSource == UserSource.XA_USER.value &&
+      userInfo.userSource == UserTypes.USER_EXTERNAL.value &&
       e.label != input.value.label
     ) {
       toast.dismiss(toastId.current);
@@ -328,7 +330,8 @@ function UserFormComp(props) {
     if (isEditView) {
       if (
         !values.firstName &&
-        userInfo.userSource !== UserSource.XA_USER.value
+        userInfo.userSource !== UserTypes.USER_EXTERNAL.value &&
+        userInfo.userSource !== UserTypes.USER_FEDERATED.value
       ) {
         errors.firstName = "Required";
       }
@@ -568,9 +571,7 @@ function UserFormComp(props) {
                             : "form-control"
                         }
                         disabled={
-                          isEditView &&
-                          userInfo &&
-                          userInfo.userSource == UserSource.XA_USER.value
+                          isEditView && userInfo && isExternalOrFederatedUser
                             ? true
                             : false
                         }
@@ -607,9 +608,7 @@ function UserFormComp(props) {
                             : "form-control"
                         }
                         disabled={
-                          isEditView &&
-                          userInfo &&
-                          userInfo.userSource == UserSource.XA_USER.value
+                          isEditView && userInfo && isExternalOrFederatedUser
                             ? true
                             : false
                         }
@@ -652,9 +651,7 @@ function UserFormComp(props) {
                             : "form-control"
                         }
                         disabled={
-                          isEditView &&
-                          userInfo &&
-                          userInfo.userSource == UserSource.XA_USER.value
+                          isEditView && userInfo && isExternalOrFederatedUser
                             ? true
                             : false
                         }
diff --git 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
index 38b9abc40..8c2932598 100644
--- 
a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
+++ 
b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
@@ -29,12 +29,7 @@ import {
 } from "react-bootstrap";
 import moment from "moment-timezone";
 import XATableLayout from "Components/XATableLayout";
-import {
-  UserRoles,
-  UserSource,
-  UserTypes,
-  VisibilityStatus
-} from "Utils/XAEnums";
+import { UserRoles, UserTypes, VisibilityStatus } from "Utils/XAEnums";
 import { MoreLess, scrollToNewData } from "Components/CommonComponents";
 import {
   useNavigate,
@@ -371,19 +366,13 @@ function Users() {
         Header: "User Source",
         accessor: "userSource",
         Cell: (rawValue) => {
-          if (rawValue.value !== null && rawValue.value !== undefined) {
-            if (rawValue.value == UserSource.XA_PORTAL_USER.value)
-              return (
-                <h6 className="text-center">
-                  <Badge bg="success">{UserTypes.USER_INTERNAL.label}</Badge>
-                </h6>
-              );
-            else
-              return (
-                <h6 className="text-center">
-                  <Badge bg="warning">{UserTypes.USER_EXTERNAL.label}</Badge>
-                </h6>
-              );
+          if (rawValue?.value != null) {
+            const userSourceVal = find(UserTypes, { value: rawValue.value });
+            return (
+              <h6 className="text-center">
+                <Badge bg={userSourceVal.variant}>{userSourceVal.label}</Badge>
+              </h6>
+            );
           } else return "--";
         },
         width: 70

Reply via email to