Skip to content

Commit

Permalink
remove redundent code
Browse files Browse the repository at this point in the history
  • Loading branch information
Chakravarthy7102 committed Nov 22, 2023
1 parent a6d640b commit 0c18fa8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/static/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ui/components/userDetail/userDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const UserDetail: React.FC<UserDetailProps> = (props) => {

<UserDetailInfoGrid {...props} />

<UserRolesList userId={user} />
<UserRolesList />

<LoginMethods refetchAllData={refetchAllData} />

Expand Down
18 changes: 9 additions & 9 deletions src/ui/components/userDetail/userRoles/UserRolesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import DeleteUserRoleDialog from "../../userroles/components/dialogs/DeleteUserR
import { useUserDetailContext } from "../context/UserDetailContext";
import "./userRolesList.scss";

type UserRolesListProps = {
userId: string;
};

export default function UserRolesList({ userId }: UserRolesListProps) {
export default function UserRolesList() {
const { getRolesForUser } = useUserRolesService();
const { userDetail } = useUserDetailContext();
const { showToast } = useContext(PopupContentContext);
Expand All @@ -47,7 +43,11 @@ export default function UserRolesList({ userId }: UserRolesListProps) {
const [showDeleteRoleDialog, setShowDeleteDialogRole] = useState(false);

const tenantIdsThatUserIsPartOf = userDetail.details.tenantIds;
const [currentlySelectedTenantId, setCurrentlySelectedTenantId] = useState(tenantIdsThatUserIsPartOf[0]);

const defaultTenantId =
tenantIdsThatUserIsPartOf.find((id) => id === "public") !== undefined ? "public" : tenantIdsThatUserIsPartOf[0];

const [currentlySelectedTenantId, setCurrentlySelectedTenantId] = useState(defaultTenantId);

const isLoading = isFeatureEnabled === undefined && assignedRoles === undefined;

Expand All @@ -58,7 +58,7 @@ export default function UserRolesList({ userId }: UserRolesListProps) {
setIsFeatureEnabled(undefined);
setIsEditing(false);

const response = await getRolesForUser(userId, currentlySelectedTenantId);
const response = await getRolesForUser(userDetail.userId, currentlySelectedTenantId);
if (response !== undefined) {
if (response.status === "OK") {
setIsFeatureEnabled(true);
Expand Down Expand Up @@ -161,7 +161,7 @@ export default function UserRolesList({ userId }: UserRolesListProps) {
{showAddRoleDialog ? (
<AssignRolesDialog
currentlySelectedTenantId={currentlySelectedTenantId}
userId={userId}
userId={userDetail.userId}
assignedRoles={assignedRoles}
setAssignedRoles={setAssignedRoles}
onCloseDialog={() => setShowAddRoleDialog(false)}
Expand All @@ -171,7 +171,7 @@ export default function UserRolesList({ userId }: UserRolesListProps) {
<DeleteUserRoleDialog
currentlySelectedTenantId={currentlySelectedTenantId}
roleToDelete={roleToDelete}
userId={userId}
userId={userDetail.userId}
assignedRoles={assignedRoles}
setAssignedRoles={setAssignedRoles}
onCloseDialog={() => {
Expand Down

0 comments on commit 0c18fa8

Please sign in to comment.