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
1b3e7dba
Commit
1b3e7dba
authored
Oct 08, 2021
by
Peter Hegman
Committed by
Ezekiel Kigbo
Oct 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add local time to user popover
parent
21f2b8ce
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
11 deletions
+60
-11
app/assets/javascripts/user_popovers.js
app/assets/javascripts/user_popovers.js
+1
-0
app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue
...ripts/vue_shared/components/user_popover/user_popover.vue
+15
-7
lib/api/entities/user.rb
lib/api/entities/user.rb
+5
-0
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
...d/vue_shared/components/user_popover/user_popover_spec.js
+28
-2
spec/lib/api/entities/user_spec.rb
spec/lib/api/entities/user_spec.rb
+11
-2
No files found.
app/assets/javascripts/user_popovers.js
View file @
1b3e7dba
...
@@ -41,6 +41,7 @@ const populateUserInfo = (user) => {
...
@@ -41,6 +41,7 @@ const populateUserInfo = (user) => {
workInformation
:
userData
.
work_information
,
workInformation
:
userData
.
work_information
,
websiteUrl
:
userData
.
website_url
,
websiteUrl
:
userData
.
website_url
,
pronouns
:
userData
.
pronouns
,
pronouns
:
userData
.
pronouns
,
localTime
:
userData
.
local_time
,
loaded
:
true
,
loaded
:
true
,
});
});
}
}
...
...
app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue
View file @
1b3e7dba
...
@@ -93,19 +93,27 @@ export default {
...
@@ -93,19 +93,27 @@ export default {
</div>
</div>
<div
class=
"gl-text-gray-500"
>
<div
class=
"gl-text-gray-500"
>
<div
v-if=
"user.bio"
class=
"gl-display-flex gl-mb-2"
>
<div
v-if=
"user.bio"
class=
"gl-display-flex gl-mb-2"
>
<gl-icon
name=
"profile"
class=
"gl-
text-gray-400 gl-
flex-shrink-0"
/>
<gl-icon
name=
"profile"
class=
"gl-flex-shrink-0"
/>
<span
ref=
"bio"
class=
"gl-ml-2 gl-overflow-hidden"
>
{{
user
.
bio
}}
</span>
<span
ref=
"bio"
class=
"gl-ml-2 gl-overflow-hidden"
>
{{
user
.
bio
}}
</span>
</div>
</div>
<div
v-if=
"user.workInformation"
class=
"gl-display-flex gl-mb-2"
>
<div
v-if=
"user.workInformation"
class=
"gl-display-flex gl-mb-2"
>
<gl-icon
name=
"work"
class=
"gl-
text-gray-400 gl-
flex-shrink-0"
/>
<gl-icon
name=
"work"
class=
"gl-flex-shrink-0"
/>
<span
ref=
"workInformation"
class=
"gl-ml-2"
>
{{
user
.
workInformation
}}
</span>
<span
ref=
"workInformation"
class=
"gl-ml-2"
>
{{
user
.
workInformation
}}
</span>
</div>
</div>
<div
v-if=
"user.location"
class=
"gl-display-flex gl-mb-2"
>
<gl-icon
name=
"location"
class=
"gl-flex-shrink-0"
/>
<span
class=
"gl-ml-2"
>
{{
user
.
location
}}
</span>
</div>
<div
v-if=
"user.localTime && !user.bot"
class=
"gl-display-flex gl-mb-2"
data-testid=
"user-popover-local-time"
>
<gl-icon
name=
"clock"
class=
"gl-flex-shrink-0"
/>
<span
class=
"gl-ml-2"
>
{{
user
.
localTime
}}
</span>
</div>
</div>
</div>
<div
v-if=
"user.location"
class=
"js-location gl-text-gray-500 gl-display-flex"
>
<div
v-if=
"statusHtml"
class=
"gl-mb-2"
data-testid=
"user-popover-status"
>
<gl-icon
name=
"location"
class=
"gl-text-gray-400 flex-shrink-0"
/>
<span
class=
"gl-ml-2"
>
{{
user
.
location
}}
</span>
</div>
<div
v-if=
"statusHtml"
class=
"js-user-status gl-mt-3"
>
<span
v-safe-html:
[$
options.safeHtmlConfig]=
"statusHtml"
></span>
<span
v-safe-html:
[$
options.safeHtmlConfig]=
"statusHtml"
></span>
</div>
</div>
<div
v-if=
"user.bot"
class=
"gl-text-blue-500"
>
<div
v-if=
"user.bot"
class=
"gl-text-blue-500"
>
...
...
lib/api/entities/user.rb
View file @
1b3e7dba
...
@@ -4,6 +4,7 @@ module API
...
@@ -4,6 +4,7 @@ module API
module
Entities
module
Entities
class
User
<
UserBasic
class
User
<
UserBasic
include
UsersHelper
include
UsersHelper
include
TimeZoneHelper
include
ActionView
::
Helpers
::
SanitizeHelper
include
ActionView
::
Helpers
::
SanitizeHelper
expose
:created_at
,
if:
->
(
user
,
opts
)
{
Ability
.
allowed?
(
opts
[
:current_user
],
:read_user_profile
,
user
)
}
expose
:created_at
,
if:
->
(
user
,
opts
)
{
Ability
.
allowed?
(
opts
[
:current_user
],
:read_user_profile
,
user
)
}
...
@@ -24,6 +25,10 @@ module API
...
@@ -24,6 +25,10 @@ module API
expose
:bio_html
do
|
user
|
expose
:bio_html
do
|
user
|
strip_tags
(
user
.
bio
)
strip_tags
(
user
.
bio
)
end
end
expose
:local_time
do
|
user
|
local_time
(
user
.
timezone
)
end
end
end
end
end
end
end
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
View file @
1b3e7dba
...
@@ -9,6 +9,7 @@ const DEFAULT_PROPS = {
...
@@ -9,6 +9,7 @@ const DEFAULT_PROPS = {
username
:
'
root
'
,
username
:
'
root
'
,
name
:
'
Administrator
'
,
name
:
'
Administrator
'
,
location
:
'
Vienna
'
,
location
:
'
Vienna
'
,
localTime
:
'
2:30 PM
'
,
bot
:
false
,
bot
:
false
,
bio
:
null
,
bio
:
null
,
workInformation
:
null
,
workInformation
:
null
,
...
@@ -31,10 +32,11 @@ describe('User Popover Component', () => {
...
@@ -31,10 +32,11 @@ describe('User Popover Component', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
const
findUserStatus
=
()
=>
wrapper
.
find
(
'
.js-us
er-status
'
);
const
findUserStatus
=
()
=>
wrapper
.
find
ByTestId
(
'
user-popov
er-status
'
);
const
findTarget
=
()
=>
document
.
querySelector
(
'
.js-user-link
'
);
const
findTarget
=
()
=>
document
.
querySelector
(
'
.js-user-link
'
);
const
findUserName
=
()
=>
wrapper
.
find
(
UserNameWithStatus
);
const
findUserName
=
()
=>
wrapper
.
find
(
UserNameWithStatus
);
const
findSecurityBotDocsLink
=
()
=>
wrapper
.
findByTestId
(
'
user-popover-bot-docs-link
'
);
const
findSecurityBotDocsLink
=
()
=>
wrapper
.
findByTestId
(
'
user-popover-bot-docs-link
'
);
const
findUserLocalTime
=
()
=>
wrapper
.
findByTestId
(
'
user-popover-local-time
'
);
const
createWrapper
=
(
props
=
{},
options
=
{})
=>
{
const
createWrapper
=
(
props
=
{},
options
=
{})
=>
{
wrapper
=
mountExtended
(
UserPopover
,
{
wrapper
=
mountExtended
(
UserPopover
,
{
...
@@ -71,7 +73,6 @@ describe('User Popover Component', () => {
...
@@ -71,7 +73,6 @@ describe('User Popover Component', () => {
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
name
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
name
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
username
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
username
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
location
);
});
});
it
(
'
shows icon for location
'
,
()
=>
{
it
(
'
shows icon for location
'
,
()
=>
{
...
@@ -164,6 +165,25 @@ describe('User Popover Component', () => {
...
@@ -164,6 +165,25 @@ describe('User Popover Component', () => {
});
});
});
});
describe
(
'
local time
'
,
()
=>
{
it
(
'
should show local time when it is available
'
,
()
=>
{
createWrapper
();
expect
(
findUserLocalTime
().
exists
()).
toBe
(
true
);
});
it
(
'
should not show local time when it is not available
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
localTime
:
null
,
};
createWrapper
({
user
});
expect
(
findUserLocalTime
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
status data
'
,
()
=>
{
describe
(
'
status data
'
,
()
=>
{
it
(
'
should show only message
'
,
()
=>
{
it
(
'
should show only message
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
message_html
:
'
Hello World
'
}
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
message_html
:
'
Hello World
'
}
};
...
@@ -256,5 +276,11 @@ describe('User Popover Component', () => {
...
@@ -256,5 +276,11 @@ describe('User Popover Component', () => {
const
securityBotDocsLink
=
findSecurityBotDocsLink
();
const
securityBotDocsLink
=
findSecurityBotDocsLink
();
expect
(
securityBotDocsLink
.
text
()).
toBe
(
'
Learn more about %<>
\'
;"
'
);
expect
(
securityBotDocsLink
.
text
()).
toBe
(
'
Learn more about %<>
\'
;"
'
);
});
});
it
(
'
does not display local time
'
,
()
=>
{
createWrapper
({
user
:
SECURITY_BOT_USER
});
expect
(
findUserLocalTime
().
exists
()).
toBe
(
false
);
});
});
});
});
});
spec/lib/api/entities/user_spec.rb
View file @
1b3e7dba
...
@@ -3,10 +3,13 @@
...
@@ -3,10 +3,13 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
API
::
Entities
::
User
do
RSpec
.
describe
API
::
Entities
::
User
do
let
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:timezone
)
{
'America/Los_Angeles'
}
let
(
:user
)
{
create
(
:user
,
timezone:
timezone
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:entity
)
{
described_class
.
new
(
user
,
current_user:
current_user
)
}
subject
{
described_class
.
new
(
user
,
current_user:
current_user
)
.
as_json
}
subject
{
entity
.
as_json
}
it
'exposes correct attributes'
do
it
'exposes correct attributes'
do
expect
(
subject
).
to
include
(
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:job_title
,
:work_information
,
:pronouns
)
expect
(
subject
).
to
include
(
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:job_title
,
:work_information
,
:pronouns
)
...
@@ -35,4 +38,10 @@ RSpec.describe API::Entities::User do
...
@@ -35,4 +38,10 @@ RSpec.describe API::Entities::User do
expect
(
subject
[
:bot
]).
to
eq
(
true
)
expect
(
subject
[
:bot
]).
to
eq
(
true
)
end
end
end
end
it
'exposes local_time'
do
local_time
=
'2:30 PM'
expect
(
entity
).
to
receive
(
:local_time
).
with
(
timezone
).
and_return
(
local_time
)
expect
(
subject
[
:local_time
]).
to
eq
(
local_time
)
end
end
end
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