Skip to content

Commit 0b07f37

Browse files
committed
Replace PNG icons with SVG for future Redmine compatibility
Redmine switched to SVG icons in version 6.0. This change updates the plugin icons accordingly while keeping PNG support for older Redmine versions.
1 parent fca18ce commit 0b07f37

File tree

7 files changed

+55
-8
lines changed

7 files changed

+55
-8
lines changed

app/helpers/view_customizes_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ def highlight_by_language(code, language)
55
Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
66
"</code></pre>").html_safe
77
end
8+
9+
def sprite_icon_or_label(icon_name, label, **options)
10+
if Gem::Version.new(Redmine::VERSION.to_s) >= Gem::Version.new('6.0.0')
11+
sprite_icon(icon_name, label, **options)
12+
else
13+
label
14+
end
15+
end
816
end

app/views/view_customizes/index.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="contextual">
2-
<%= link_to l(:label_view_customizes_new),
2+
<%= link_to sprite_icon_or_label(:add, l(:label_view_customizes_new)),
33
new_view_customize_path, :class => 'icon icon-add' %>
44
</div>
55

@@ -40,11 +40,11 @@
4040
</table>
4141

4242
<p class="buttons">
43-
<%= link_to l(:label_disable_all),
43+
<%= link_to sprite_icon_or_label(:view_customize_disable, l(:label_disable_all), plugin: :view_customize),
4444
view_customizes_path(view_customize: {is_enabled: 0}),
4545
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
4646
:class => 'icon icon-view_customize-disable' %>
47-
<%= link_to l(:label_enable_all),
47+
<%= link_to sprite_icon_or_label(:view_customize_enable, l(:label_enable_all), plugin: :view_customize),
4848
view_customizes_path(view_customize: {is_enabled: 1}),
4949
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
5050
:class => 'icon icon-view_customize-enable' %>

app/views/view_customizes/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<%= stylesheet_link_tag "scm" %>
22

33
<div class="contextual">
4-
<%= link_to(l(:button_edit),
4+
<%= link_to(sprite_icon_or_label(:edit, l(:button_edit)),
55
{:action => 'edit', :id => @view_customize.id},
66
:class => 'icon icon-edit') %>
7-
<%= link_to(l(:button_delete),
7+
<%= link_to(sprite_icon_or_label(:del, l(:button_delete)),
88
{:action => 'destroy', :id => @view_customize.id},
99
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,
1010
:class => 'icon icon-del') %>

assets/images/icons.svg

Lines changed: 25 additions & 0 deletions
Loading

assets/stylesheets/view_customize.css

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@ input#view_customize_comments {
5858
width: 95%;
5959
}
6060

61-
.icon-view_customize {
61+
.icon-view_customize:not(:has(svg)) {
6262
background-image: url("../images/view_customize.png");
6363
}
6464

65-
.icon-view_customize-disable {
65+
.icon-view_customize-disable:not(:has(svg)) {
6666
background-image: url("../images/disable.png");
6767
}
6868

69-
.icon-view_customize-enable {
69+
.icon-view_customize-enable:not(:has(svg)) {
7070
background-image: url("../images/enable.png");
7171
}
72+
73+
/* PNG icon support for Redmine 5.1 and earlier */
74+
.icon:not(:has(svg)) {
75+
background-position: 0% 50%;
76+
background-repeat: no-repeat;
77+
padding-left: 20px;
78+
}

config/icon_source.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: view_customize
2+
svg: file-settings
3+
- name: view_customize_enable
4+
svg: circle-check
5+
- name: view_customize_disable
6+
svg: xbox-x

init.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{ :controller => 'view_customizes', :action => 'index' },
1212
:caption => :label_view_customize,
1313
:html => { :class => 'icon icon-view_customize'},
14+
:icon => 'view_customize', :plugin => 'view_customize',
1415
:if => Proc.new { User.current.admin? }
1516

1617
settings :default => { 'create_api_access_key' => '' }, :partial => 'settings/view_customize_settings'

0 commit comments

Comments
 (0)