Skip to content

Commit ed1eea0

Browse files
committed
feat(admin-settings): highlight the search term in the user name and email of users
1 parent 0eb5721 commit ed1eea0

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎packages/web-app-admin-settings/src/components/Users/UsersList.vue‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@
4848
:user-name="item.displayName"
4949
:width="32"
5050
/>
51-
<span class="pl-2 truncate" v-text="item.onPremisesSamAccountName" />
51+
<span class="pl-2 truncate">
52+
<oc-filter-highlight :text="item.onPremisesSamAccountName" :term="filterTerm" />
53+
</span>
5254
</div>
5355
</template>
5456
<template #displayName="{ item }">
5557
<oc-filter-highlight :text="item.displayName" :term="filterTerm" />
5658
</template>
59+
<template #mail="{ item }">
60+
<oc-filter-highlight :text="item.mail" :term="filterTerm" />
61+
</template>
5762
<template #role="{ item }">
5863
<template v-if="item.appRoleAssignments">{{ getRoleDisplayNameByUser(item) }}</template>
5964
</template>
@@ -236,6 +241,7 @@ const fields = computed<FieldType[]>(() => [
236241
{
237242
name: 'mail',
238243
title: $gettext('Email'),
244+
type: 'slot',
239245
sortable: true
240246
},
241247
{

‎packages/web-app-admin-settings/tests/unit/components/Users/UsersList.spec.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ describe('UsersList', () => {
114114
await wrapper.find('.users-table-btn-edit').trigger('click')
115115
expect(openSideBarPanel).toHaveBeenCalledWith('EditPanel')
116116
})
117+
describe('search term', () => {
118+
it('is highlighted in the user name, the display name and the email', () => {
119+
const users = [
120+
{
121+
id: '1',
122+
onPremisesSamAccountName: 'alex',
123+
displayName: 'Alex Dragan',
124+
mail: 'alex@x.org'
125+
}
126+
] as User[]
127+
const { wrapper } = getWrapper({ mountType: mount, users, searchTerm: 'ALEX' })
128+
const matches = (cell: string) =>
129+
wrapper
130+
.findAll(`.oc-table-data-cell-${cell} .oc-filter-highlight-match`)
131+
.map((m) => m.text())
132+
expect(matches('onPremisesSamAccountName')).toEqual(['alex'])
133+
expect(matches('displayName')).toEqual(['Alex'])
134+
expect(matches('mail')).toEqual(['alex'])
135+
})
136+
})
117137
describe('squashed table', () => {
118138
it.each([true, false])(
119139
'sets the squashed class depending on the side bar being open (%s)',
@@ -179,13 +199,20 @@ function getWrapper({
179199
mountType = shallowMount,
180200
users = [],
181201
selectedUsers = [],
182-
query = {}
202+
query = {},
203+
searchTerm
183204
}: {
184205
mountType?: typeof mount
185206
users?: User[]
186207
selectedUsers?: User[]
187208
query?: Record<string, string>
209+
searchTerm?: string
188210
} = {}) {
211+
if (searchTerm) {
212+
// the search term is the first query value read, drop the values left over by other tests
213+
vi.mocked(queryItemAsString).mockReset()
214+
vi.mocked(queryItemAsString).mockImplementationOnce(() => searchTerm)
215+
}
189216
vi.mocked(queryItemAsString).mockImplementationOnce(() => '1')
190217
vi.mocked(queryItemAsString).mockImplementationOnce(() => '100')
191218
const mocks = defaultComponentMocks({

0 commit comments

Comments
 (0)