Skip to content

Commit

Permalink
RANGER-4973 : Enhance Ranger UI to support a new user type for extern…
Browse files Browse the repository at this point in the history
…al users from Data Sharing

Signed-off-by: Dhaval.Rajpara <[email protected]>
  • Loading branch information
dhavaljrajpara committed Nov 3, 2024
1 parent 03bca8e commit c276537
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
11 changes: 7 additions & 4 deletions security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
ActivationStatus,
RegexValidation,
UserRoles,
UserSource
UserTypes
} from "Utils/XAEnums";
import { toast } from "react-toastify";
import { getUserAccessRoleList, serverError } from "Utils/XAUtils";
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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
}
/>
);
Expand All @@ -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 (
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -568,9 +571,7 @@ function UserFormComp(props) {
: "form-control"
}
disabled={
isEditView &&
userInfo &&
userInfo.userSource == UserSource.XA_USER.value
isEditView && userInfo && isExternalOrFederatedUser
? true
: false
}
Expand Down Expand Up @@ -607,9 +608,7 @@ function UserFormComp(props) {
: "form-control"
}
disabled={
isEditView &&
userInfo &&
userInfo.userSource == UserSource.XA_USER.value
isEditView && userInfo && isExternalOrFederatedUser
? true
: false
}
Expand Down Expand Up @@ -652,9 +651,7 @@ function UserFormComp(props) {
: "form-control"
}
disabled={
isEditView &&
userInfo &&
userInfo.userSource == UserSource.XA_USER.value
isEditView && userInfo && isExternalOrFederatedUser
? true
: false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c276537

Please sign in to comment.