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
>
<
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
{
truncate
}
from
'
~/lib/utils/text_utility
'
;
import
{
USER_AVATAR_SIZE
,
LENGTH_OF_USER_NOTE_TOOLTIP
}
from
'
../constants
'
;
import
{
USER_AVATAR_SIZE
,
LENGTH_OF_USER_NOTE_TOOLTIP
}
from
'
../constants
'
;
...
@@ -8,7 +8,6 @@ export default {
...
@@ -8,7 +8,6 @@ export default {
GlTooltip
:
GlTooltipDirective
,
GlTooltip
:
GlTooltipDirective
,
},
},
components
:
{
components
:
{
GlAvatarLink
,
GlAvatarLabeled
,
GlAvatarLabeled
,
GlBadge
,
GlBadge
,
GlIcon
,
GlIcon
,
...
@@ -27,6 +26,11 @@ export default {
...
@@ -27,6 +26,11 @@ export default {
adminUserHref
()
{
adminUserHref
()
{
return
this
.
adminUserPath
.
replace
(
'
id
'
,
this
.
user
.
username
);
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
()
{
userNoteShort
()
{
return
truncate
(
this
.
user
.
note
,
LENGTH_OF_USER_NOTE_TOOLTIP
);
return
truncate
(
this
.
user
.
note
,
LENGTH_OF_USER_NOTE_TOOLTIP
);
},
},
...
@@ -36,10 +40,9 @@ export default {
...
@@ -36,10 +40,9 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<
gl-avatar-link
<
div
v-if=
"user"
v-if=
"user"
class=
"js-user-link"
class=
"js-user-link gl-display-inline-block"
:href=
"adminUserHref"
:data-user-id=
"user.id"
:data-user-id=
"user.id"
:data-username=
"user.username"
:data-username=
"user.username"
>
>
...
@@ -48,6 +51,8 @@ export default {
...
@@ -48,6 +51,8 @@ export default {
:src=
"user.avatarUrl"
:src=
"user.avatarUrl"
:label=
"user.name"
:label=
"user.name"
:sub-label=
"user.email"
:sub-label=
"user.email"
:label-link=
"adminUserHref"
:sub-label-link=
"adminUserMailto"
>
>
<template
#meta
>
<template
#meta
>
<div
v-if=
"user.note"
class=
"gl-text-gray-500 gl-p-1"
>
<div
v-if=
"user.note"
class=
"gl-text-gray-500 gl-p-1"
>
...
@@ -60,5 +65,5 @@ export default {
...
@@ -60,5 +65,5 @@ export default {
</div>
</div>
</
template
>
</
template
>
</gl-avatar-labeled>
</gl-avatar-labeled>
</
gl-avatar-link
>
</
div
>
</template>
</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
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
...
@@ -14,7 +14,7 @@ describe('AdminUserAvatar component', () => {
...
@@ -14,7 +14,7 @@ describe('AdminUserAvatar component', () => {
const
findNote
=
()
=>
wrapper
.
find
(
GlIcon
);
const
findNote
=
()
=>
wrapper
.
find
(
GlIcon
);
const
findAvatar
=
()
=>
wrapper
.
find
(
GlAvatarLabeled
);
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
findAllBadges
=
()
=>
wrapper
.
findAll
(
GlBadge
);
const
findTooltip
=
()
=>
getBinding
(
findNote
().
element
,
'
gl-tooltip
'
);
const
findTooltip
=
()
=>
getBinding
(
findNote
().
element
,
'
gl-tooltip
'
);
...
@@ -44,20 +44,25 @@ describe('AdminUserAvatar component', () => {
...
@@ -44,20 +44,25 @@ describe('AdminUserAvatar component', () => {
initComponent
();
initComponent
();
});
});
it
(
"
links to the user's admin path
"
,
()
=>
{
it
(
'
adds a user link hover card
'
,
()
=>
{
expect
(
findAvatarLink
().
attributes
()).
toMatchObject
({
expect
(
findUserLink
().
attributes
()).
toMatchObject
({
href
:
adminUserPath
.
replace
(
'
id
'
,
user
.
username
),
'
data-user-id
'
:
user
.
id
.
toString
(),
'
data-user-id
'
:
user
.
id
.
toString
(),
'
data-username
'
:
user
.
username
,
'
data-username
'
:
user
.
username
,
});
});
});
});
it
(
"
renders the user's name
"
,
()
=>
{
it
(
"
renders the user's name with an admin path link
"
,
()
=>
{
expect
(
findAvatar
().
props
(
'
label
'
)).
toBe
(
user
.
name
);
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
"
,
()
=>
{
it
(
"
renders the user's email with a mailto link
"
,
()
=>
{
expect
(
findAvatar
().
props
(
'
subLabel
'
)).
toBe
(
user
.
email
);
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
"
,
()
=>
{
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