Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
62f6a6c9
Commit
62f6a6c9
authored
Feb 05, 2021
by
Jiaan Louw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update user_avatar.vue to use label links
parent
5dabb296
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
app/assets/javascripts/admin/users/components/user_avatar.vue
...assets/javascripts/admin/users/components/user_avatar.vue
+11
-6
spec/frontend/admin/users/components/user_avatar_spec.js
spec/frontend/admin/users/components/user_avatar_spec.js
+14
-9
No files found.
app/assets/javascripts/admin/users/components/user_avatar.vue
View file @
62f6a6c9
<
script
>
import
{
GlAvatarL
ink
,
GlAvatarL
abeled
,
GlBadge
,
GlIcon
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
GlAvatarLabeled
,
GlBadge
,
GlIcon
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
truncate
}
from
'
~/lib/utils/text_utility
'
;
import
{
USER_AVATAR_SIZE
,
LENGTH_OF_USER_NOTE_TOOLTIP
}
from
'
../constants
'
;
...
...
@@ -8,7 +8,6 @@ export default {
GlTooltip
:
GlTooltipDirective
,
},
components
:
{
GlAvatarLink
,
GlAvatarLabeled
,
GlBadge
,
GlIcon
,
...
...
@@ -27,6 +26,11 @@ export default {
adminUserHref
()
{
return
this
.
adminUserPath
.
replace
(
'
id
'
,
this
.
user
.
username
);
},
adminUserMailto
()
{
// NOTE: 'mailto:' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/require-i18n-strings
return
`mailto:
${
this
.
user
.
email
}
`
;
},
userNoteShort
()
{
return
truncate
(
this
.
user
.
note
,
LENGTH_OF_USER_NOTE_TOOLTIP
);
},
...
...
@@ -36,10 +40,9 @@ export default {
</
script
>
<
template
>
<
gl-avatar-link
<
div
v-if=
"user"
class=
"js-user-link"
:href=
"adminUserHref"
class=
"js-user-link gl-display-inline-block"
:data-user-id=
"user.id"
:data-username=
"user.username"
>
...
...
@@ -48,6 +51,8 @@ export default {
:src=
"user.avatarUrl"
:label=
"user.name"
:sub-label=
"user.email"
:label-link=
"adminUserHref"
:sub-label-link=
"adminUserMailto"
>
<template
#meta
>
<div
v-if=
"user.note"
class=
"gl-text-gray-500 gl-p-1"
>
...
...
@@ -60,5 +65,5 @@ export default {
</div>
</
template
>
</gl-avatar-labeled>
</
gl-avatar-link
>
</
div
>
</template>
spec/frontend/admin/users/components/user_avatar_spec.js
View file @
62f6a6c9
import
{
GlAvatarL
ink
,
GlAvatarL
abeled
,
GlBadge
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlAvatarLabeled
,
GlBadge
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
...
...
@@ -14,7 +14,7 @@ describe('AdminUserAvatar component', () => {
const
findNote
=
()
=>
wrapper
.
find
(
GlIcon
);
const
findAvatar
=
()
=>
wrapper
.
find
(
GlAvatarLabeled
);
const
find
AvatarLink
=
()
=>
wrapper
.
find
(
GlAvatarLink
);
const
find
UserLink
=
()
=>
wrapper
.
find
(
'
.js-user-link
'
);
const
findAllBadges
=
()
=>
wrapper
.
findAll
(
GlBadge
);
const
findTooltip
=
()
=>
getBinding
(
findNote
().
element
,
'
gl-tooltip
'
);
...
...
@@ -44,20 +44,25 @@ describe('AdminUserAvatar component', () => {
initComponent
();
});
it
(
"
links to the user's admin path
"
,
()
=>
{
expect
(
findAvatarLink
().
attributes
()).
toMatchObject
({
href
:
adminUserPath
.
replace
(
'
id
'
,
user
.
username
),
it
(
'
adds a user link hover card
'
,
()
=>
{
expect
(
findUserLink
().
attributes
()).
toMatchObject
({
'
data-user-id
'
:
user
.
id
.
toString
(),
'
data-username
'
:
user
.
username
,
});
});
it
(
"
renders the user's name
"
,
()
=>
{
expect
(
findAvatar
().
props
(
'
label
'
)).
toBe
(
user
.
name
);
it
(
"
renders the user's name with an admin path link
"
,
()
=>
{
const
avatar
=
findAvatar
();
expect
(
avatar
.
props
(
'
label
'
)).
toBe
(
user
.
name
);
expect
(
avatar
.
props
(
'
labelLink
'
)).
toBe
(
adminUserPath
.
replace
(
'
id
'
,
user
.
username
));
});
it
(
"
renders the user's email
"
,
()
=>
{
expect
(
findAvatar
().
props
(
'
subLabel
'
)).
toBe
(
user
.
email
);
it
(
"
renders the user's email with a mailto link
"
,
()
=>
{
const
avatar
=
findAvatar
();
expect
(
avatar
.
props
(
'
subLabel
'
)).
toBe
(
user
.
email
);
expect
(
avatar
.
props
(
'
subLabelLink
'
)).
toBe
(
`mailto:
${
user
.
email
}
`
);
});
it
(
"
renders the user's avatar image
"
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment