Skip to content

Commit

Permalink
Merge pull request #6827 from DonOmalVindula/fix/test-10.04
Browse files Browse the repository at this point in the history
Fix issues in the user assignment modal in groups edit
  • Loading branch information
DonOmalVindula authored Aug 27, 2024
2 parents 9c69125 + 72aff56 commit c8dd63a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/weak-wombats-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.groups.v1": patch
"@wso2is/theme": patch
---

Fix issues in the user assignment modal in groups edit
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ export const AddGroupUserModal: FunctionComponent<AddGroupUserModalProps> = (
const {
data: originalUserList,
isLoading: isUserListFetchRequestLoading,
isValidating: isUserListFetchRequestValidating,
error: userListFetchRequestError
} = useUsersList(
null,
null,
20,
0,
!isEmpty(searchQuery) ? searchQuery : null,
null,
userstore,
Expand All @@ -105,17 +106,28 @@ export const AddGroupUserModal: FunctionComponent<AddGroupUserModalProps> = (
}

if (originalUserList.Resources) {
setUserList(originalUserList.Resources);
const filteredUsers: UserBasicInterface[] = [];

originalUserList.Resources.map((user: UserBasicInterface) => {
let isUserExistInGroup: boolean = false;

if (user?.groups?.length > 0) {
user.groups.map((userGroup: UserRoleInterface) => {
if (userGroup.display === group.displayName) {
setSelectedUsers((selectedUsers: UserBasicInterface[]) => [ ...selectedUsers, user ]);
isUserExistInGroup = true;
}
});
}

// Do not show the user if the user is already assigned to the group.
if (!isUserExistInGroup) {
filteredUsers.push(user);
}
});

setUserList(filteredUsers);
} else {
setUserList([]);
}
}, [ originalUserList, isUserListFetchRequestLoading ]);

Expand Down Expand Up @@ -228,7 +240,7 @@ export const AddGroupUserModal: FunctionComponent<AddGroupUserModalProps> = (
className="one-column-selection"
selectionComponent
searchPlaceholder={ t("groups:edit.users.searchUsers") }
isLoading={ isUserListFetchRequestLoading }
isLoading={ isUserListFetchRequestLoading || isUserListFetchRequestValidating }
handleHeaderCheckboxChange={ () => selectAllAssignedList() }
isHeaderCheckboxChecked={ isSelectAllUsers }
handleUnelectedListSearch={ (e: FormEvent<HTMLInputElement>, { value }: { value: string }) => {
Expand All @@ -240,7 +252,7 @@ export const AddGroupUserModal: FunctionComponent<AddGroupUserModalProps> = (
<TransferList
selectionComponent
isListEmpty={ userList.length <= 0 }
isLoading={ isUserListFetchRequestLoading }
isLoading={ isUserListFetchRequestLoading || isUserListFetchRequestValidating }
listType="unselected"
selectAllCheckboxLabel={ t("groups:edit.users.selectAllUsers") }
data-testid={ `${ componentId }-unselected-transfer-list` }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const GroupUsersList: FunctionComponent<GroupUsersListProps> = (props: Gr

const groupData: PatchGroupDataInterface = {
Operations: [ {
"op": "replace",
"op": "add",
"value": {
"members": newUsers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
.ui.segment {
&.transfer-segment {
margin-top: @userRolesListSegmentMarginTop;
height: @userRolesListSegmentHeight;
width: @TransferComponentSegmentWidth;
}

Expand Down

0 comments on commit c8dd63a

Please sign in to comment.