Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues in the user assignment modal in groups edit #6827

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading