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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
b73959a9
Commit
b73959a9
authored
May 17, 2017
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes per feedback on user avatar components.
parent
3c668fa0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
92 deletions
+26
-92
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue
...s/vue_shared/components/user_avatar/user_avatar_image.vue
+7
-6
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_size_mixin.js
...e_shared/components/user_avatar/user_avatar_size_mixin.js
+0
-13
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_svg.vue
...pts/vue_shared/components/user_avatar/user_avatar_svg.vue
+7
-4
spec/javascripts/vue_shared/components/user_avatar_image_spec.js
...vascripts/vue_shared/components/user_avatar_image_spec.js
+10
-16
spec/javascripts/vue_shared/components/user_avatar_link_spec.js
...avascripts/vue_shared/components/user_avatar_link_spec.js
+2
-10
spec/javascripts/vue_shared/components/user_avatar_size_mixin_spec.js
...ipts/vue_shared/components/user_avatar_size_mixin_spec.js
+0
-37
spec/javascripts/vue_shared/components/user_avatar_svg_spec.js
...javascripts/vue_shared/components/user_avatar_svg_spec.js
+0
-6
No files found.
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue
View file @
b73959a9
...
...
@@ -16,12 +16,11 @@
*/
import
defaultAvatarUrl
from
'
images/no_avatar.png
'
;
import
UserAvatarSizeMixin
from
'
./user_avatar_size_mixin
'
;
import
TooltipMixin
from
'
../../mixins/tooltip
'
;
export
default
{
name
:
'
UserAvatarImage
'
,
mixins
:
[
UserAvatarSizeMixin
,
TooltipMixin
],
mixins
:
[
TooltipMixin
],
props
:
{
imgSrc
:
{
type
:
String
,
...
...
@@ -58,8 +57,8 @@ export default {
tooltipContainer
()
{
return
this
.
tooltipText
?
'
body
'
:
null
;
},
imgCssClasse
s
()
{
return
`
avatar
${
this
.
avatarSizeClass
}
${
this
.
cssClasses
}
`
;
avatarSizeClas
s
()
{
return
`
s
${
this
.
size
}
`
;
},
},
};
...
...
@@ -67,9 +66,11 @@ export default {
<
template
>
<img
:class=
"imgCssClasses"
class=
"avatar"
:class=
"[avatarSizeClass, cssClasses]"
:src=
"imgSrc"
:style=
"avatarSizeStylesMap"
:width=
"size"
:height=
"size"
:alt=
"imgAlt"
:data-container=
"tooltipContainer"
:data-placement=
"tooltipPlacement"
...
...
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_size_mixin.js
deleted
100644 → 0
View file @
3c668fa0
export
default
{
computed
:
{
avatarSizeStylesMap
()
{
return
{
width
:
`
${
this
.
size
}
px`
,
height
:
`
${
this
.
size
}
px`
,
};
},
avatarSizeClass
()
{
return
`s
${
this
.
size
}
`
;
},
},
};
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_svg.vue
View file @
b73959a9
...
...
@@ -14,10 +14,7 @@
*/
import
UserAvatarSizeMixin
from
'
./user_avatar_size_mixin
'
;
export
default
{
mixins
:
[
UserAvatarSizeMixin
],
props
:
{
svg
:
{
type
:
String
,
...
...
@@ -29,13 +26,19 @@ export default {
default
:
20
,
},
},
computed
:
{
avatarSizeClass
()
{
return
`s
${
this
.
size
}
`
;
},
},
};
</
script
>
<
template
>
<svg
:class=
"avatarSizeClass"
:style=
"avatarSizeStylesMap"
:height=
"size"
:width=
"size"
v-html=
"svg"
>
</svg>
</
template
>
...
...
spec/javascripts/vue_shared/components/user_avatar_image_spec.js
View file @
b73959a9
...
...
@@ -18,8 +18,6 @@ describe('User Avatar Image Component', function () {
this
.
userAvatarImage
=
new
UserAvatarImageComponent
({
propsData
:
this
.
propsData
,
}).
$mount
();
this
.
imageElement
=
this
.
userAvatarImage
.
$el
.
outerHTML
;
});
it
(
'
should return a defined Vue component
'
,
function
()
{
...
...
@@ -27,14 +25,7 @@ describe('User Avatar Image Component', function () {
});
it
(
'
should have <img> as a child element
'
,
function
()
{
const
componentImgTag
=
this
.
userAvatarImage
.
$el
.
outerHTML
;
expect
(
componentImgTag
).
toContain
(
'
<img
'
);
});
it
(
'
should return neccessary props as defined
'
,
function
()
{
_
.
each
(
this
.
propsData
,
(
val
,
key
)
=>
{
expect
(
this
.
userAvatarImage
[
key
]).
toBeDefined
();
});
expect
(
this
.
userAvatarImage
.
$el
.
tagName
).
toBe
(
'
IMG
'
);
});
it
(
'
should properly compute tooltipContainer
'
,
function
()
{
...
...
@@ -42,19 +33,22 @@ describe('User Avatar Image Component', function () {
});
it
(
'
should properly render tooltipContainer
'
,
function
()
{
expect
(
this
.
imageElement
).
toContain
(
'
data-container="body"
'
);
expect
(
this
.
userAvatarImage
.
$el
.
getAttribute
(
'
data-container
'
)).
toBe
(
'
body
'
);
});
it
(
'
should properly compute avatarSizeClass
'
,
function
()
{
expect
(
this
.
userAvatarImage
.
avatarSizeClass
).
toBe
(
'
s99
'
);
});
it
(
'
should properly compute imgCssClasses
'
,
function
()
{
expect
(
this
.
userAvatarImage
.
imgCssClasses
).
toBe
(
'
avatar s99 myextraavatarclass
'
);
});
it
(
'
should properly render img css
'
,
function
()
{
const
classList
=
this
.
userAvatarImage
.
$el
.
classList
;
const
containsAvatar
=
classList
.
contains
(
'
avatar
'
);
const
containsSizeClass
=
classList
.
contains
(
'
s99
'
);
const
containsCustomClass
=
classList
.
contains
(
'
myextraavatarclass
'
);
it
(
'
should properly render imgCssClasses
'
,
function
()
{
expect
(
this
.
imageElement
).
toContain
(
'
avatar s99 myextraavatarclass
'
);
expect
(
containsAvatar
).
toBe
(
true
);
expect
(
containsSizeClass
).
toBe
(
true
);
expect
(
containsCustomClass
).
toBe
(
true
);
});
});
});
spec/javascripts/vue_shared/components/user_avatar_link_spec.js
View file @
b73959a9
...
...
@@ -35,13 +35,11 @@ describe('User Avatar Link Component', function () {
});
it
(
'
should render <a> as a child element
'
,
function
()
{
const
componentLinkTag
=
this
.
userAvatarLink
.
$el
.
outerHTML
;
expect
(
componentLinkTag
).
toContain
(
'
<a
'
);
expect
(
this
.
userAvatarLink
.
$el
.
tagName
).
toBe
(
'
A
'
);
});
it
(
'
should have <img> as a child element
'
,
function
()
{
const
componentImgTag
=
this
.
userAvatarLink
.
$el
.
outerHTML
;
expect
(
componentImgTag
).
toContain
(
'
<img
'
);
expect
(
this
.
userAvatarLink
.
$el
.
querySelector
(
'
img
'
)).
not
.
toBeNull
();
});
it
(
'
should return neccessary props as defined
'
,
function
()
{
...
...
@@ -49,10 +47,4 @@ describe('User Avatar Link Component', function () {
expect
(
this
.
userAvatarLink
[
key
]).
toBeDefined
();
});
});
it
(
'
should include props in the rendered output
'
,
function
()
{
_
.
each
(
this
.
propsData
,
(
val
)
=>
{
expect
(
this
.
userAvatarLink
.
$el
.
outerHTML
).
toContain
(
val
);
});
});
});
spec/javascripts/vue_shared/components/user_avatar_size_mixin_spec.js
deleted
100644 → 0
View file @
3c668fa0
import
Vue
from
'
vue
'
;
import
UserAvatarSizeMixin
from
'
~/vue_shared/components/user_avatar/user_avatar_size_mixin
'
;
describe
(
'
User Avatar Size Mixin
'
,
()
=>
{
beforeEach
(()
=>
{
this
.
vueInstance
=
new
Vue
({
data
:
{
size
:
99
,
},
mixins
:
[
UserAvatarSizeMixin
],
});
});
describe
(
'
#avatarSizeClass
'
,
()
=>
{
it
(
'
should be a defined computed value
'
,
()
=>
{
expect
(
this
.
vueInstance
.
avatarSizeClass
).
toBeDefined
();
});
it
(
'
should correctly transform size into the class name
'
,
()
=>
{
expect
(
this
.
vueInstance
.
avatarSizeClass
).
toBe
(
'
s99
'
);
});
});
describe
(
'
#avatarSizeStylesMap
'
,
()
=>
{
it
(
'
should be a defined computed value
'
,
()
=>
{
expect
(
this
.
vueInstance
.
avatarSizeStylesMap
).
toBeDefined
();
});
it
(
'
should return a correctly formatted styles width
'
,
()
=>
{
expect
(
this
.
vueInstance
.
avatarSizeStylesMap
.
width
).
toBe
(
'
99px
'
);
});
it
(
'
should return a correctly formatted styles height
'
,
()
=>
{
expect
(
this
.
vueInstance
.
avatarSizeStylesMap
.
height
).
toBe
(
'
99px
'
);
});
});
});
spec/javascripts/vue_shared/components/user_avatar_svg_spec.js
View file @
b73959a9
...
...
@@ -25,11 +25,5 @@ describe('User Avatar Svg Component', function () {
expect
(
this
.
userAvatarSvg
.
$el
.
tagName
).
toEqual
(
'
svg
'
);
expect
(
this
.
userAvatarSvg
.
$el
.
innerHTML
).
toContain
(
'
<path
'
);
});
it
(
'
should return neccessary props as defined
'
,
function
()
{
_
.
each
(
this
.
propsData
,
(
val
,
key
)
=>
{
expect
(
this
.
userAvatarSvg
[
key
]).
toBeDefined
();
});
});
});
});
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