Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
disable own delete btn (#214)
Browse files Browse the repository at this point in the history
* disable own delete btn

* format
  • Loading branch information
ggrund-tsi authored Aug 6, 2021
1 parent 9ef964d commit a62de99
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/user-management.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const UserManagement = (props: any) => {
const [isUserData, setIsUserData] = React.useState(false);
const [editUser, setEditUser] = React.useState<IUser>(emptyUser);
const [isGroupEdit, setIsGroupEdit] = React.useState(false);
const [ownUserId, setOwnUserId] = React.useState<string>('');
const [editGroupId, setEditGroupId] = React.useState<string>('');
const [editGroupParentId, setEditGroupParentId] = React.useState<string>('');

Expand All @@ -78,6 +79,15 @@ const UserManagement = (props: any) => {
const [confirmTitle, setConfirmTitle] = React.useState('');
const [confirmHandle, setConfirmHandle] = React.useState<() => void>();

// set user name from keycloak
React.useEffect(() => {

if (keycloak.idTokenParsed) {
setOwnUserId((keycloak.idTokenParsed as any).sub ?? '');
}

}, [keycloak])

React.useEffect(() => {
if (bUsers) {
setUsers(bUsers);
Expand Down Expand Up @@ -381,6 +391,7 @@ const UserManagement = (props: any) => {
</Button>
<Button className="btn-icon delete-icon"
onClick={() => handleDeleteUser(u)}
disabled={!(ownUserId && u.id !== ownUserId)}
/>
</Row>
</td>
Expand Down

0 comments on commit a62de99

Please sign in to comment.