Skip to content

Commit

Permalink
Add locked status for locked users in user list
Browse files Browse the repository at this point in the history
  • Loading branch information
DonOmalVindula committed Nov 13, 2024
1 parent d2a7ed0 commit daa4fe5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
39 changes: 37 additions & 2 deletions features/admin.users.v1/components/users-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { Header, Icon, Label, ListItemProps, SemanticICONS } from "semantic-ui-react";
import { deleteUser } from "../api";
import { UserManagementConstants } from "../constants";
import { ACCOUNT_LOCK_REASON_MAP, UserManagementConstants } from "../constants";
import { UserBasicInterface, UserListInterface } from "../models";
import { UserManagementUtils } from "../utils/user-management-utils";

Expand Down Expand Up @@ -251,6 +251,40 @@ export const UsersList: React.FunctionComponent<UsersListProps> = (props: UsersL
}
};

/**
* Returns a locked icon if the account is locked.
*
* @param user - each admin user belonging to a row of the table.
* @returns the locked icon.
*/
const resolveAccountLockStatus = (user: UserBasicInterface): ReactNode => {
const accountLocked: boolean = user[userConfig.userProfileSchema]?.accountLocked === "true" ||
user[userConfig.userProfileSchema]?.accountLocked === true;
const accountLockedReason: string = user[userConfig.userProfileSchema]?.lockedReason;

const accountLockedReasonContent: string = ACCOUNT_LOCK_REASON_MAP[accountLockedReason]
?? ACCOUNT_LOCK_REASON_MAP["DEFAULT"];

if (accountLocked) {
return (
<Popup
trigger={ (
<Icon
className="locked-icon"
name="lock"
size="small"
color="grey"
/>
) }
content={ t(accountLockedReasonContent) }
inverted
/>
);
}

return null;
};

/**
* Resolves data table columns.
*
Expand Down Expand Up @@ -284,7 +318,8 @@ export const UsersList: React.FunctionComponent<UsersListProps> = (props: UsersL
spaced="right"
data-suppress=""
/>
<Header.Content>
{ resolveAccountLockStatus(user) }
<Header.Content className="pl-0">
<div>
{ header as ReactNode }
{
Expand Down
15 changes: 13 additions & 2 deletions modules/theme/src/themes/default/elements/icon.overrides
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2019-2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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 @@ -54,14 +54,25 @@ i.icon {
font-size: .74em!important;
}

&.locked-icon {
position: absolute;
z-index: 1;
top: 25px;
left: 25px;
font-size: 12px !important;
background-color: white;
padding: 0px;
border-radius: 50%;
}

&.map-icon {
margin: 18px 0 0 0;
}

&.padded-icon{
padding-top: 0.7em;
}

&.primary {
color: @primaryColor;
}
Expand Down

0 comments on commit daa4fe5

Please sign in to comment.