Defect #41715 » allow_custom_svg_icons_for_admin_menu.patch
| lib/redmine/menu_manager.rb | ||
|---|---|---|
|
end
|
||
|
label = if item.icon.present?
|
||
|
sprite_icon(item.icon, h(caption))
|
||
|
sprite_icon(item.icon, h(caption), plugin: item.plugin)
|
||
|
else
|
||
|
h(caption)
|
||
|
end
|
||
| ... | ... | |
|
class MenuItem < MenuNode
|
||
|
include Redmine::I18n
|
||
|
attr_reader :name, :url, :param, :condition, :parent,
|
||
|
:child_menus, :last, :permission, :icon
|
||
|
:child_menus, :last, :permission, :icon, :plugin
|
||
|
def initialize(name, url, options={})
|
||
|
if options[:if] && !options[:if].respond_to?(:call)
|
||
| ... | ... | |
|
@parent = options[:parent]
|
||
|
@child_menus = options[:children]
|
||
|
@last = options[:last] || false
|
||
|
@plugin = options[:plugin]
|
||
|
super(@name.to_sym)
|
||
|
end
|
||
| test/unit/lib/redmine/menu_manager/menu_helper_test.rb | ||
|---|---|---|
|
assert_select("a.testing", "This is a test")
|
||
|
end
|
||
|
def test_render_single_menu_node_with_plugin_icon
|
||
|
node = Redmine::MenuManager::MenuItem.new(:testing, '/test', { :icon => 'plugin_icon_name',:plugin => 'test_plugin_name' })
|
||
|
@output_buffer = render_single_menu_node(node, 'This is a test', node.url, false)
|
||
|
assert_select("a.testing", "This is a test") do
|
||
|
assert_select("svg.icon-svg") do
|
||
|
assert_select("use[href=?]", "/assets/plugin_assets/test_plugin_name/icons.svg#icon--plugin_icon_name")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_render_menu_node
|
||
|
single_node = Redmine::MenuManager::MenuItem.new(:single_node, '/test', {})
|
||
|
@output_buffer = render_menu_node(single_node, nil)
|
||
| test/unit/lib/redmine/menu_manager/menu_item_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_new_menu_item_should_allow_setting_the_plugin
|
||
|
menu_item = Redmine::MenuManager::MenuItem.new(
|
||
|
:test_plugin_menu, '/test', {:plugin => 'test_plugin_name'}
|
||
|
)
|
||
|
assert_equal 'test_plugin_name', menu_item.plugin
|
||
|
end
|
||
|
def test_has_children
|
||
|
parent_item = get_menu_item(:test_menu, :parent)
|
||
|
assert parent_item.children.present?
|
||
- « Previous
- 1
- 2
- Next »