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
09060d19
Commit
09060d19
authored
Jul 02, 2020
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify user popover loading logic
There were a number of computed properties that did the same thing
parent
8dd8e6ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
73 deletions
+47
-73
app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue
...ripts/vue_shared/components/user_popover/user_popover.vue
+33
-52
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
...d/vue_shared/components/user_popover/user_popover_spec.js
+14
-21
No files found.
app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue
View file @
09060d19
...
...
@@ -22,11 +22,6 @@ export default {
required
:
true
,
default
:
null
,
},
loaded
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
computed
:
{
statusHtml
()
{
...
...
@@ -42,14 +37,8 @@ export default {
return
''
;
},
nameIsLoading
()
{
return
!
this
.
user
.
name
;
},
workInformationIsLoading
()
{
return
!
this
.
user
.
loaded
&&
this
.
user
.
workInformation
===
null
;
},
locationIsLoading
()
{
return
!
this
.
user
.
loaded
&&
this
.
user
.
location
===
null
;
userIsLoading
()
{
return
!
this
.
user
.
loaded
;
},
},
};
...
...
@@ -63,49 +52,41 @@ export default {
<user-avatar-image
:img-src=
"user.avatarUrl"
:size=
"60"
css-classes=
"mr-2"
/>
</div>
<div
class=
"p-1 w-100"
>
<h5
class=
"m-0"
>
<span
v-if=
"user.name"
>
{{
user
.
name
}}
</span>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"animation-container-small mb-1"
/>
</h5>
<div
class=
"text-secondary mb-2"
>
<span
v-if=
"user.username"
>
@
{{
user
.
username
}}
</span>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"animation-container-small mb-1"
/>
</div>
<div
class=
"text-secondary"
>
<div
v-if=
"user.bio"
class=
"d-flex mb-1"
>
<icon
name=
"profile"
class=
"category-icon flex-shrink-0"
/>
<span
ref=
"bio"
class=
"ml-1"
>
{{
user
.
bio
}}
</span>
</div>
<div
v-if=
"user.workInformation"
class=
"d-flex mb-1"
>
<icon
v-show=
"!workInformationIsLoading"
name=
"work"
class=
"category-icon flex-shrink-0"
/>
<span
ref=
"workInformation"
class=
"ml-1"
>
{{
user
.
workInformation
}}
</span>
</div>
<gl-skeleton-loading
v-if=
"workInformationIsLoading"
:lines=
"1"
class=
"animation-container-small mb-1"
/>
</div>
<div
class=
"js-location text-secondary d-flex"
>
<icon
v-show=
"!locationIsLoading && user.location"
name=
"location"
class=
"category-icon flex-shrink-0"
/>
<span
v-if=
"user.location"
class=
"ml-1"
>
{{
user
.
location
}}
</span>
<template
v-if=
"userIsLoading"
>
<gl-skeleton-loading
v-if=
"locationIsLoading"
v-for=
"n in 4"
:key=
"n"
:lines=
"1"
class=
"animation-container-small mb-1"
/>
</div>
<div
v-if=
"statusHtml"
class=
"js-user-status mt-2"
>
<span
v-html=
"statusHtml"
></span>
</div>
</
template
>
<
template
v-else
>
<div
class=
"mb-2"
>
<h5
class=
"m-0"
>
{{
user
.
name
}}
</h5>
<span
class=
"text-secondary"
>
@
{{
user
.
username
}}
</span>
</div>
<div
class=
"text-secondary"
>
<div
v-if=
"user.bio"
class=
"d-flex mb-1"
>
<icon
name=
"profile"
class=
"category-icon flex-shrink-0"
/>
<span
ref=
"bio"
class=
"ml-1"
>
{{
user
.
bio
}}
</span>
</div>
<div
v-if=
"user.workInformation"
class=
"d-flex mb-1"
>
<icon
name=
"work"
class=
"category-icon flex-shrink-0"
/>
<span
ref=
"workInformation"
class=
"ml-1"
>
{{
user
.
workInformation
}}
</span>
</div>
</div>
<div
class=
"js-location text-secondary d-flex"
>
<div
v-if=
"user.location"
>
<icon
name=
"location"
class=
"category-icon flex-shrink-0"
/>
<span
class=
"ml-1"
>
{{
user
.
location
}}
</span>
</div>
</div>
<div
v-if=
"statusHtml"
class=
"js-user-status mt-2"
>
<span
v-html=
"statusHtml"
></span>
</div>
</
template
>
</div>
</div>
</gl-popover>
...
...
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
View file @
09060d19
...
...
@@ -4,7 +4,6 @@ import UserPopover from '~/vue_shared/components/user_popover/user_popover.vue';
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
const
DEFAULT_PROPS
=
{
loaded
:
true
,
user
:
{
username
:
'
root
'
,
name
:
'
Administrator
'
,
...
...
@@ -12,6 +11,7 @@ const DEFAULT_PROPS = {
bio
:
null
,
workInformation
:
null
,
status
:
null
,
loaded
:
true
,
},
};
...
...
@@ -46,28 +46,21 @@ describe('User Popover Component', () => {
});
};
describe
(
'
Empty
'
,
()
=>
{
beforeEach
(()
=>
{
createWrapper
(
{},
{
propsData
:
{
target
:
findTarget
(),
user
:
{
name
:
null
,
username
:
null
,
location
:
null
,
bio
:
null
,
workInformation
:
null
,
status
:
null
,
},
},
describe
(
'
when user is loading
'
,
()
=>
{
it
(
'
displays skeleton loaders
'
,
()
=>
{
createWrapper
({
user
:
{
name
:
null
,
username
:
null
,
location
:
null
,
bio
:
null
,
workInformation
:
null
,
status
:
null
,
loaded
:
false
,
},
);
});
});
it
(
'
should return skeleton loaders
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlSkeletonLoading
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findAll
(
GlSkeletonLoading
)).
toHaveLength
(
4
);
});
});
...
...
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