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
892b02e8
Commit
892b02e8
authored
Oct 02, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created group_icon and group_icon_url
Tests for these new helper methods
parent
79c80de9
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
79 additions
and
17 deletions
+79
-17
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+24
-5
app/models/concerns/avatarable.rb
app/models/concerns/avatarable.rb
+1
-1
app/serializers/group_entity.rb
app/serializers/group_entity.rb
+1
-1
app/views/admin/groups/_group.html.haml
app/views/admin/groups/_group.html.haml
+1
-1
app/views/admin/groups/show.html.haml
app/views/admin/groups/show.html.haml
+1
-1
app/views/groups/_home_panel.html.haml
app/views/groups/_home_panel.html.haml
+1
-1
app/views/groups/edit.html.haml
app/views/groups/edit.html.haml
+1
-1
app/views/layouts/nav/sidebar/_group.html.haml
app/views/layouts/nav/sidebar/_group.html.haml
+1
-1
app/views/shared/groups/_group.html.haml
app/views/shared/groups/_group.html.haml
+1
-1
app/views/shared/members/_group.html.haml
app/views/shared/members/_group.html.haml
+1
-1
app/views/users/_groups.html.haml
app/views/users/_groups.html.haml
+1
-1
spec/helpers/groups_helper_spec.rb
spec/helpers/groups_helper_spec.rb
+45
-2
No files found.
app/helpers/groups_helper.rb
View file @
892b02e8
require
'uri'
module
GroupsHelper
module
GroupsHelper
include
Gitlab
::
CurrentSettings
def
can_change_group_visibility_level?
(
group
)
def
can_change_group_visibility_level?
(
group
)
can?
(
current_user
,
:change_visibility_level
,
group
)
can?
(
current_user
,
:change_visibility_level
,
group
)
end
end
...
@@ -7,12 +11,28 @@ module GroupsHelper
...
@@ -7,12 +11,28 @@ module GroupsHelper
can?
(
current_user
,
:change_share_with_group_lock
,
group
)
can?
(
current_user
,
:change_share_with_group_lock
,
group
)
end
end
def
group_icon
(
group
)
# = project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile')
# = image_tag group_icon(@group), alt: '', class: 'avatar group-avatar s160'
def
group_icon
(
group
,
options
=
{})
img_path
=
group_icon_url
(
group
,
options
)
image_tag
img_path
,
options
end
def
group_icon_url
(
group
,
options
=
{})
if
group
.
is_a?
(
String
)
if
group
.
is_a?
(
String
)
group
=
Group
.
find_by_full_path
(
group
)
group
=
Group
.
find_by_full_path
(
group
)
end
end
group
.
try
(
:avatar_url
,
use_asset_path:
false
)
||
ActionController
::
Base
.
helpers
.
image_path
(
'no_group_avatar.png'
)
if
group
.
avatar_url
if
group
.
private?
options
[
:use_original_source
]
=
true
group
.
avatar_url
(
use_asset_path:
false
)
else
group
.
avatar_url
end
else
# No Avatar Icon
ActionController
::
Base
.
helpers
.
image_path
(
'no_group_avatar.png'
)
end
end
end
def
group_title
(
group
,
name
=
nil
,
url
=
nil
)
def
group_title
(
group
,
name
=
nil
,
url
=
nil
)
...
@@ -90,10 +110,9 @@ module GroupsHelper
...
@@ -90,10 +110,9 @@ module GroupsHelper
output
=
output
=
if
(
group
.
try
(
:avatar_url
)
||
show_avatar
)
&&
!
Rails
.
env
.
test?
if
(
group
.
try
(
:avatar_url
)
||
show_avatar
)
&&
!
Rails
.
env
.
test?
if
group
.
private?
if
group
.
private?
puts
"GROUP IS PRIVATE : "
+
group_icon
(
group
)
group_icon
(
group
,
class:
"avatar-tile"
,
width:
15
,
height:
15
,
use_original_source:
true
)
image_tag
(
group_icon
(
group
),
class:
"avatar-tile"
,
width:
15
,
height:
15
,
use_original_source:
true
)
else
else
image_tag
(
group_icon
(
group
)
,
class:
"avatar-tile"
,
width:
15
,
height:
15
)
group_icon
(
group
,
class:
"avatar-tile"
,
width:
15
,
height:
15
)
end
end
else
else
""
""
...
...
app/models/concerns/avatarable.rb
View file @
892b02e8
...
@@ -16,7 +16,7 @@ module Avatarable
...
@@ -16,7 +16,7 @@ module Avatarable
[
host
,
avatar
.
url
].
join
[
host
,
avatar
.
url
].
join
else
else
avatar
.
url
[
host
,
avatar
.
url
].
join
end
end
end
end
end
end
app/serializers/group_entity.rb
View file @
892b02e8
...
@@ -45,6 +45,6 @@ class GroupEntity < Grape::Entity
...
@@ -45,6 +45,6 @@ class GroupEntity < Grape::Entity
end
end
expose
:avatar_url
do
|
group
|
expose
:avatar_url
do
|
group
|
group_icon
(
group
)
group_icon
_url
(
group
)
end
end
end
end
app/views/admin/groups/_group.html.haml
View file @
892b02e8
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
=
visibility_level_icon
(
group
.
visibility_level
,
fw:
false
)
=
visibility_level_icon
(
group
.
visibility_level
,
fw:
false
)
.avatar-container.s40
.avatar-container.s40
=
image_tag
group_icon
(
group
),
class:
"avatar s40 hidden-xs"
=
group_icon
(
group
,
class:
"avatar s40 hidden-xs"
)
.title
.title
=
link_to
[
:admin
,
group
],
class:
'group-name'
do
=
link_to
[
:admin
,
group
],
class:
'group-name'
do
=
group
.
full_name
=
group
.
full_name
...
...
app/views/admin/groups/show.html.haml
View file @
892b02e8
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%ul
.well-list
%ul
.well-list
%li
%li
.avatar-container.s60
.avatar-container.s60
=
image_tag
group_icon
(
@group
),
class:
"avatar s60"
=
group_icon
(
@group
,
class:
"avatar s60"
)
%li
%li
%span
.light
Name:
%span
.light
Name:
%strong
=
@group
.
name
%strong
=
@group
.
name
...
...
app/views/groups/_home_panel.html.haml
View file @
892b02e8
.group-home-panel.text-center
.group-home-panel.text-center
%div
{
class:
container_class
}
%div
{
class:
container_class
}
.avatar-container.s70.group-avatar
.avatar-container.s70.group-avatar
=
image_tag
group_icon
(
@group
),
class:
"avatar s70 avatar-tile"
=
group_icon
(
@group
,
class:
"avatar s70 avatar-tile"
)
%h1
.group-title
%h1
.group-title
=
@group
.
name
=
@group
.
name
%span
.visibility-icon.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@group
)
}
%span
.visibility-icon.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@group
)
}
...
...
app/views/groups/edit.html.haml
View file @
892b02e8
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
.form-group
.form-group
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
.avatar-container.s160
.avatar-container.s160
=
image_tag
group_icon
(
@group
),
alt:
''
,
class:
'avatar group-avatar s160'
=
group_icon
(
@group
,
alt:
''
,
class:
'avatar group-avatar s160'
)
%p
.light
%p
.light
-
if
@group
.
avatar?
-
if
@group
.
avatar?
You can change your group avatar here
You can change your group avatar here
...
...
app/views/layouts/nav/sidebar/_group.html.haml
View file @
892b02e8
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
.context-header
.context-header
=
link_to
group_path
(
@group
),
title:
@group
.
name
do
=
link_to
group_path
(
@group
),
title:
@group
.
name
do
.avatar-container.s40.group-avatar
.avatar-container.s40.group-avatar
=
image_tag
group_icon
(
@group
),
class:
"avatar s40 avatar-tile"
=
group_icon
(
@group
,
class:
"avatar s40 avatar-tile"
)
.sidebar-context-title
.sidebar-context-title
=
@group
.
name
=
@group
.
name
%ul
.sidebar-top-level-items
%ul
.sidebar-top-level-items
...
...
app/views/shared/groups/_group.html.haml
View file @
892b02e8
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
.avatar-container.s40
.avatar-container.s40
=
link_to
group
do
=
link_to
group
do
=
image_tag
group_icon
(
group
),
class:
"avatar s40 hidden-xs"
=
group_icon
(
group
,
class:
"avatar s40 hidden-xs"
)
.title
.title
=
link_to
group_name
,
group
,
class:
'group-name'
=
link_to
group_name
,
group
,
class:
'group-name'
...
...
app/views/shared/members/_group.html.haml
View file @
892b02e8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
-
dom_id
=
"group_member_
#{
group_link
.
id
}
"
-
dom_id
=
"group_member_
#{
group_link
.
id
}
"
%li
.member.group_member
{
id:
dom_id
}
%li
.member.group_member
{
id:
dom_id
}
%span
.list-item-name
%span
.list-item-name
=
image_tag
group_icon
(
group
),
class:
"avatar s40"
,
alt:
''
=
group_icon
(
group
,
class:
"avatar s40"
,
alt:
''
)
%strong
%strong
=
link_to
group
.
full_name
,
group_path
(
group
)
=
link_to
group
.
full_name
,
group_path
(
group
)
.cgray
.cgray
...
...
app/views/users/_groups.html.haml
View file @
892b02e8
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
-
groups
.
each
do
|
group
|
-
groups
.
each
do
|
group
|
=
link_to
group
,
class:
'profile-groups-avatars inline'
,
title:
group
.
name
do
=
link_to
group
,
class:
'profile-groups-avatars inline'
,
title:
group
.
name
do
.avatar-container.s40
.avatar-container.s40
=
image_tag
group_icon
(
group
),
class:
'avatar group-avatar s40'
=
group_icon
(
group
,
class:
'avatar group-avatar s40'
)
spec/helpers/groups_helper_spec.rb
View file @
892b02e8
...
@@ -3,6 +3,7 @@ require 'spec_helper'
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
GroupsHelper
do
describe
GroupsHelper
do
include
ApplicationHelper
include
ApplicationHelper
describe
'group_icon'
do
describe
'group_icon'
do
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
...
@@ -10,14 +11,56 @@ describe GroupsHelper do
...
@@ -10,14 +11,56 @@ describe GroupsHelper do
group
=
create
(
:group
)
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
save!
group
.
save!
expect
(
group_icon
(
group
.
path
).
to_s
)
avatar_url
=
"/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
expect
(
group_icon
(
group
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab_host
)
avatar_url
=
"
#{
gitlab_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
expect
(
group_icon
(
group
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
end
end
describe
'group_icon_url'
do
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
it
'returns an url for the avatar'
do
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
save!
expect
(
group_icon_url
(
group
.
path
).
to_s
)
.
to
match
(
"/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
it
'returns an CDN url for the avatar'
do
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab_host
)
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
save!
expect
(
group_icon_url
(
group
.
path
).
to_s
)
.
to
match
(
"
#{
gitlab_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
it
'returns an based url for the avatar if private'
do
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab_host
)
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
private
=
true
group
.
save!
expect
(
group_icon_url
(
group
.
path
).
to_s
)
.
to
match
(
"/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
.
to
match
(
"/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
end
it
'gives default avatar_icon when no avatar is present'
do
it
'gives default avatar_icon when no avatar is present'
do
group
=
create
(
:group
)
group
=
create
(
:group
)
group
.
save!
group
.
save!
expect
(
group_icon
(
group
.
path
)).
to
match_asset_path
(
'group_avatar.png'
)
expect
(
group_icon
_url
(
group
.
path
)).
to
match_asset_path
(
'group_avatar.png'
)
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