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
762901c9
Commit
762901c9
authored
Apr 22, 2021
by
Marius Bobin
Committed by
Nick Thomas
Apr 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add generic avatar method for users and groups
parent
280776b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
4 deletions
+48
-4
app/helpers/avatars_helper.rb
app/helpers/avatars_helper.rb
+10
-1
changelogs/unreleased/300874-follow-up-from-trying-to-open-ci-cd-settings-on-gitlab-project-fai.yml
...m-trying-to-open-ci-cd-settings-on-gitlab-project-fai.yml
+5
-0
ee/app/views/projects/settings/subscriptions/_index.html.haml
...pp/views/projects/settings/subscriptions/_index.html.haml
+1
-1
ee/app/views/projects/settings/subscriptions/_project.html.haml
.../views/projects/settings/subscriptions/_project.html.haml
+3
-2
spec/helpers/avatars_helper_spec.rb
spec/helpers/avatars_helper_spec.rb
+29
-0
No files found.
app/helpers/avatars_helper.rb
View file @
762901c9
...
...
@@ -98,6 +98,14 @@ module AvatarsHelper
end
end
def
avatar_without_link
(
resource
,
options
=
{})
if
resource
.
is_a?
(
User
)
user_avatar_without_link
(
options
.
merge
(
user:
resource
))
elsif
resource
.
is_a?
(
Group
)
group_icon
(
resource
,
options
.
merge
(
class:
'avatar'
))
end
end
private
def
avatar_icon_by_user_email_or_gravatar
(
email
,
size
,
scale
,
only_path
:)
...
...
@@ -136,9 +144,10 @@ module AvatarsHelper
def
source_identicon
(
source
,
options
=
{})
bg_key
=
(
source
.
id
%
7
)
+
1
size_class
=
"s
#{
options
[
:size
]
}
"
if
options
[
:size
]
options
[
:class
]
=
[
*
options
[
:class
],
"identicon bg
#{
bg_key
}
"
]
.
join
(
' '
)
[
*
options
[
:class
],
"identicon bg
#{
bg_key
}
"
,
size_class
].
compact
.
join
(
' '
)
content_tag
(
:div
,
class:
options
[
:class
].
strip
)
do
source
.
name
[
0
,
1
].
upcase
...
...
changelogs/unreleased/300874-follow-up-from-trying-to-open-ci-cd-settings-on-gitlab-project-fai.yml
0 → 100644
View file @
762901c9
---
title
:
Add generic avatar method for users and groups
merge_request
:
59758
author
:
type
:
fixed
ee/app/views/projects/settings/subscriptions/_index.html.haml
View file @
762901c9
...
...
@@ -19,7 +19,7 @@
%thead
%tr
%th
=
_
(
"Project"
)
%th
=
_
(
"
Autho
r"
)
%th
=
_
(
"
Owne
r"
)
%th
%tbody
-
@project
.
upstream_project_subscriptions
.
each
do
|
subscription
|
...
...
ee/app/views/projects/settings/subscriptions/_project.html.haml
View file @
762901c9
...
...
@@ -3,8 +3,9 @@
%td
=
project
.
name
%td
=
user_avatar_without_link
(
user:
project
.
owner
,
size:
32
)
=
project
.
owner
.
name
.gl-display-flex.gl-align-items-center
=
avatar_without_link
(
project
.
owner
,
size:
32
)
=
project
.
owner
.
name
%td
.gl-text-right
=
link_to
project_subscription_path
(
@project
,
subscription
.
id
),
method: :delete
,
data:
{
toggle:
'tooltip'
,
title:
tooltip
,
container:
'body'
,
testid:
'delete-subscription'
},
class:
"gl-button btn btn-danger"
do
=
sprite_icon
(
'close'
,
size:
16
,
css_class:
'gl-icon'
)
spec/helpers/avatars_helper_spec.rb
View file @
762901c9
...
...
@@ -409,4 +409,33 @@ RSpec.describe AvatarsHelper do
end
end
end
describe
'#avatar_without_link'
do
let
(
:options
)
{
{
size:
32
}
}
subject
{
helper
.
avatar_without_link
(
resource
,
options
)
}
context
'with users'
do
let
(
:resource
)
{
user
}
it
'displays user avatar'
do
is_expected
.
to
eq
tag
(
:img
,
alt:
"
#{
user
.
name
}
's avatar"
,
src:
avatar_icon_for_user
(
user
,
32
),
data:
{
container:
'body'
},
class:
'avatar s32 has-tooltip'
,
title:
user
.
name
)
end
end
context
'with groups'
do
let
(
:resource
)
{
build_stubbed
(
:group
,
name:
'foo'
)
}
it
'displays group avatar'
do
is_expected
.
to
match
(
%r{<div class="avatar identicon bg
\d
+ s32">F</div>}
)
end
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