Skip to content

Commit

Permalink
#2474 Adjust filtering for user tables, add fields to revocation table
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Nov 21, 2023
1 parent 3f184c2 commit 8f1c919
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
22 changes: 16 additions & 6 deletions dashboard/src/components/access/RevokeUserAccess.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License.
<b-card body-class="p-0">
<div class="row px-3 pt-3">
<div class="col-12">
<b-form-group label="User Id Filter" label-class="text-muted">
<b-input v-model="filters.userId" v-on:keydown.enter="applyFilters" data-cy="privateProjectUsers-userIdFilter" aria-label="user id filter"/>
<b-form-group label="User Filter" label-class="text-muted">
<b-input v-model="filters.user" v-on:keydown.enter="applyFilters" data-cy="privateProjectUsers-userIdFilter" aria-label="user filter"/>
</b-form-group>
</div>
<div class="col-md">
Expand Down Expand Up @@ -70,7 +70,7 @@ limitations under the License.
data() {
return {
filters: {
userId: '',
user: '',
},
table: {
items: [],
Expand All @@ -87,6 +87,16 @@ limitations under the License.
label: 'User Id',
sortable: true,
},
{
key: 'firstName',
label: 'First Name',
sortable: true,
},
{
key: 'lastName',
label: 'Last Name',
sortable: true,
},
],
pagination: {
hideUnnecessary: true,
Expand Down Expand Up @@ -123,11 +133,11 @@ limitations under the License.
applyFilters() {
this.table.options.pagination.currentPage = 1;
this.loadData().then(() => {
this.$nextTick(() => this.$announcer.polite(`Revoke user access table has been filtered by ${this.filters.userId}`));
this.$nextTick(() => this.$announcer.polite(`Revoke user access table has been filtered by ${this.filters.user}`));
});
},
reset() {
this.filters.userId = '';
this.filters.user = '';
this.table.options.pagination.currentPage = 1;
this.loadData().then(() => {
this.$nextTick(() => this.$announcer.polite('Revoke user access table filters have been removed'));
Expand All @@ -136,7 +146,7 @@ limitations under the License.
loadData() {
this.table.options.busy = true;
const pageParams = {
query: this.filters.userId,
query: this.filters.user,
limit: this.table.options.pagination.pageSize,
ascending: !this.table.options.sortDesc,
page: this.table.options.pagination.currentPage,
Expand Down
16 changes: 8 additions & 8 deletions dashboard/src/components/users/UsersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
<div>
<div class="row px-3 pt-3">
<div class="col-md-6">
<b-form-group label="User Id Filter" label-class="text-muted">
<b-input v-model="filters.userId" v-on:keydown.enter="applyFilters" data-cy="users-skillIdFilter" aria-label="user id filter"/>
<b-form-group label="User Filter" label-class="text-muted">
<b-input v-model="filters.user" v-on:keydown.enter="applyFilters" data-cy="users-skillIdFilter" aria-label="user filter"/>
</b-form-group>
</div>
<div class="col-md-6">
Expand Down Expand Up @@ -138,7 +138,7 @@ limitations under the License.
inviteOnlyProject: false,
data: [],
filters: {
userId: '',
user: '',
progress: 0,
minimumPoints: 0,
},
Expand Down Expand Up @@ -246,17 +246,17 @@ limitations under the License.
this.filters.minimumPoints = Math.floor(this.totalPoints * (this.filters.progress / 100));
this.loadData().then(() => {
let filterMessage = 'Users table has been filtered by';
if (this.filters.userId) {
filterMessage += ` ${this.filters.userId}`;
if (this.filters.user) {
filterMessage += ` ${this.filters.user}`;
}
if (this.filters.minimumPoints > 0) {
filterMessage += `${this.filters.userId ? ' and' : ''} users with at least ${this.filters.minimumPoints} points`;
filterMessage += `${this.filters.user ? ' and' : ''} users with at least ${this.filters.minimumPoints} points`;
}
this.$nextTick(() => this.$announcer.polite(filterMessage));
});
},
reset() {
this.filters.userId = '';
this.filters.user = '';
this.filters.minimumPoints = 0;
this.filters.progress = 0;
this.table.options.pagination.currentPage = 1;
Expand All @@ -268,7 +268,7 @@ limitations under the License.
this.table.options.busy = true;
const url = this.getUrl();
return UsersService.ajaxCall(url, {
query: this.filters.userId,
query: this.filters.user,
limit: this.table.options.pagination.pageSize,
ascending: !this.table.options.sortDesc,
page: this.table.options.pagination.currentPage,
Expand Down
10 changes: 8 additions & 2 deletions service/src/main/java/skills/storage/repos/UserRoleRepo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,21 @@ interface UserRoleRepo extends CrudRepository<UserRole, Integer> {
ur.userId = ua.userId and
ur.projectId = ?1 and
ur.roleName = ?2 and
ur.userId like lower(CONCAT('%', ?3, '%'))''')
(ur.userId like lower(CONCAT('%', ?3, '%')) or
lower(ua.firstName) like lower(CONCAT('%', ?3, '%')) or
lower(ua.lastName) like lower(CONCAT('%', ?3, '%')))
''')
List<UserRoleWithAttrs> findRoleWithAttrsByProjectIdAndRoleNameAndUserIdLike(String projectId, RoleName roleName, String userIdQuery, PageRequest pageRequest)

@Query('''SELECT count(ur.id) from UserRole ur, UserAttrs ua
where
ur.userId = ua.userId and
ur.projectId = ?1 and
ur.roleName = ?2 and
ur.userId like lower(CONCAT('%', ?3, '%'))''')
(ur.userId like lower(CONCAT('%', ?3, '%')) or
lower(ua.firstName) like lower(CONCAT('%', ?3, '%')) or
lower(ua.lastName) like lower(CONCAT('%', ?3, '%')))
''')
Integer countRoleWithAttrsByProjectIdAndRoleNameAndUserIdLike(String projectId, RoleName roleName, String userIdQuery)

@Query('''SELECT ur as role, ua as attrs
Expand Down

0 comments on commit 8f1c919

Please sign in to comment.