diff --git a/app/helpers/profile_editor_helper.rb b/app/helpers/profile_editor_helper.rb index d08a3f1..30f4f35 100644 --- a/app/helpers/profile_editor_helper.rb +++ b/app/helpers/profile_editor_helper.rb @@ -141,8 +141,9 @@ module ProfileEditorHelper ) end - def control_panel_button(title, icon, url) - link_to title, url, :class => 'control-panel-%s' % icon + def control_panel_button(title, icon, url, html_options = {}) + html_options ||= {} + link_to title, url, html_options.merge(:class => 'control-panel-%s' % icon) end def unchangeable_privacy_field(profile) diff --git a/app/views/profile_editor/index.html.erb b/app/views/profile_editor/index.html.erb index 31c757d..7d3db97 100644 --- a/app/views/profile_editor/index.html.erb +++ b/app/views/profile_editor/index.html.erb @@ -73,7 +73,7 @@ <%= control_panel_button(_('Edit welcome page'), 'welcome-page', :action => 'welcome_page') if has_welcome_page %> <% @plugins.dispatch(:control_panel_buttons).each do |button| %> - <%= control_panel_button(button[:title], button[:icon], button[:url]) %> + <%= control_panel_button(button[:title], button[:icon], button[:url], button[:html_options]) %> <% end %> <% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 8625909..f2ad07b 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -253,10 +253,11 @@ class Noosfero::Plugin end # -> Adds buttons to the control panel - # returns = { :title => title, :icon => icon, :url => url } - # title = name that will be displayed. - # icon = css class name (for customized icons include them in a css file). - # url = url or route to which the button will redirect. + # returns = { :title => title, :icon => icon, :url => url } + # title = name that will be displayed. + # icon = css class name (for customized icons include them in a css file). + # url = url or route to which the button will redirect. + # html_options = aditional html options. def control_panel_buttons nil end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 3ba7b76..fde38e3 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -941,7 +941,7 @@ class ProfileEditorControllerTest < ActionController::TestCase class TestControlPanelButtons1 < Noosfero::Plugin def control_panel_buttons - {:title => "Plugin1 button", :icon => 'plugin1_icon', :url => 'plugin1_url'} + {:title => "Plugin1 button", :icon => 'plugin1_icon', :url => 'plugin1_url', :html_options => { :data => {extra: true} }} end end class TestControlPanelButtons2 < Noosfero::Plugin @@ -955,8 +955,8 @@ class ProfileEditorControllerTest < ActionController::TestCase get :index, :profile => profile.identifier - assert_tag :tag => 'a', :content => 'Plugin1 button', :attributes => {:class => /plugin1_icon/, :href => /plugin1_url/} - assert_tag :tag => 'a', :content => 'Plugin2 button', :attributes => {:class => /plugin2_icon/, :href => /plugin2_url/} + assert_tag :tag => 'a', :content => 'Plugin1 button', :attributes => {:class => /plugin1_icon/, :href => /plugin1_url/, :'data-extra' => true} + assert_tag :tag => 'a', :content => 'Plugin2 button', :attributes => {:class => /plugin2_icon/, :href => /plugin2_url/, :'data-extra' => nil} end should 'add extra content provided by plugins on edit' do -- libgit2 0.21.2