Revision a6005760
Added by Ondřej Pražák about 8 years ago
app/helpers/application_helper.rb | ||
---|---|---|
# +options+ : Hash containing options for authorized_for and link_to
|
||
# +html_options+ : Hash containing html options for the link or span
|
||
def display_link_if_authorized(name, options = {}, html_options = {})
|
||
enable_link = html_options.has_key?(:disabled) ? !html_options[:disabled] : true
|
||
if enable_link and authorized_for(options)
|
||
if authorized_for(options)
|
||
link_to(name, options, html_options)
|
||
else
|
||
""
|
app/views/hosts/edit.html.erb | ||
---|---|---|
<% title(_("Edit %s") % @host) %>
|
||
|
||
<% if SETTINGS[:unattended] %>
|
||
<% title_actions display_link_if_authorized((@host.managed? ? _("Unmanage host") : _("Manage host")),
|
||
hash_for_toggle_manage_host_path(:id => @host).merge(:auth_object => @host, :permission => 'edit_hosts'), {:class => 'btn btn-default', :method => :put}),
|
||
display_link_if_authorized(_("Disassociate host"),
|
||
hash_for_disassociate_host_path(:id => @host).merge(:auth_object => @host, :permission => 'edit_hosts'), :class => 'btn btn-default', :method => :put,
|
||
:disabled => !@host.compute?) %>
|
||
<% title_actions(
|
||
display_link_if_authorized((@host.managed? ? _("Unmanage host") : _("Manage host")),
|
||
hash_for_toggle_manage_host_path(:id => @host).merge(:auth_object => @host, :permission => 'edit_hosts'),
|
||
{:class => 'btn btn-default', :method => :put}),
|
||
(display_link_if_authorized(_("Disassociate host"),
|
||
hash_for_disassociate_host_path(:id => @host).merge(:auth_object => @host, :permission => 'edit_hosts'),
|
||
{:class => 'btn btn-default', :method => :put}) if @host.compute?)
|
||
)
|
||
%>
|
||
<% end %>
|
||
|
||
<%= render :partial => 'hosts/form' %>
|
Also available in: Unified diff
Fixes #14079 - display_link_if_authorized not hidden when disabled