-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add backend support for Manage Users pagination #8370
Changes from 1 commit
3c5d502
bfb92d5
ee111f6
d3166f1
89e4c6b
c595f42
a6bfa4e
a8eb38a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -638,6 +638,33 @@ public Page<ApiUserWithStatus> getPagedUsersAndStatusInCurrentOrg(int pageNumber | |
return new PageImpl<>(userWithStatusList, pageRequest, userCountInOrg); | ||
} | ||
|
||
public Page<ApiUserWithStatus> searchUsersAndStatusInCurrentOrgPaged( | ||
int pageNumber, int pageSize, String searchQuery) { | ||
List<ApiUserWithStatus> allUsers = getUsersAndStatusInCurrentOrg(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See earlier comment |
||
|
||
List<ApiUserWithStatus> filteredUsersList = | ||
allUsers.stream() | ||
.filter( | ||
u -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we are purposefully excluding suffix based on the existing frontend search in |
||
String firstName = | ||
u.getFirstName() == null ? "" : String.format("%s ", u.getFirstName()); | ||
String middleName = | ||
u.getMiddleName() == null ? "" : String.format("%s ", u.getMiddleName()); | ||
String fullName = firstName + middleName + u.getLastName(); | ||
return fullName.toLowerCase().contains(searchQuery.toLowerCase()); | ||
}) | ||
.toList(); | ||
|
||
int totalResults = filteredUsersList.size(); | ||
int startIndex = pageNumber * pageSize; | ||
int endIndex = Math.min((startIndex + pageSize), filteredUsersList.size()); | ||
|
||
List<ApiUserWithStatus> pageContent = filteredUsersList.subList(startIndex, endIndex); | ||
PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); | ||
|
||
return new PageImpl<>(pageContent, pageRequest, totalResults); | ||
} | ||
|
||
// To be addressed in #8108 | ||
@AuthorizationConfiguration.RequirePermissionManageUsers | ||
public List<ApiUserWithStatus> getUsersAndStatusInCurrentOrg() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,17 @@ void getPagedUsersAndStatusInCurrentOrg_success() { | |
users2ndList.get(2), "[email protected]", "Reynolds", UserStatus.ACTIVE); | ||
} | ||
|
||
@Test | ||
@WithSimpleReportOrgAdminUser | ||
void searchUsersAndStatusInCurrentOrgPaged_success() { | ||
initSampleData(); | ||
Page<ApiUserWithStatus> usersPage = | ||
_service.searchUsersAndStatusInCurrentOrgPaged(0, 10, "Bob"); | ||
List<ApiUserWithStatus> users = usersPage.stream().toList(); | ||
assertEquals(1, users.size()); | ||
checkApiUserWithStatus(users.get(0), "[email protected]", "Bobberoo", UserStatus.ACTIVE); | ||
} | ||
|
||
@Test | ||
@WithSimpleReportOrgAdminUser | ||
void getUser_withAdminUser_withOktaMigrationDisabled_success() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search is being handled by a different service method here only as an intermediate step between now and the rest of the Okta migration. Currently, we have to fetch the entire organization's user list from Okta in order to do this search. Once we switch to getting users from our database, we can have the other method below use the search filter easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to confirm, we aren't using this search functionality on the frontend just yet, right? That's being introduced with your frontend PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, so this new endpoint is not currently being used anywhere in the app until the frontend PR