Skip to content

Commit

Permalink
refs #3811 alerts messages cleanup and minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadlevy authored and abenari committed Jan 14, 2014
1 parent ad07d9a commit ede5687
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 67 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/application.js
Expand Up @@ -25,7 +25,7 @@ function onContentLoad(){
}

$('.flash.error').each(function(index, item) {
if ($('.alert-message.alert-danger.base').length == 0) {
if ($('.alert.alert-danger.base').length == 0) {
if ($('#host-conflicts-modal').length == 0) {
notify(item, 'error');
}
Expand All @@ -52,7 +52,7 @@ function onContentLoad(){
}

// highlight tabs with errors
$(".tab-content").find(".form-group.error").each(function() {
$(".tab-content").find(".form-group.has-error").each(function() {
var id = $(this).parentsUntil(".tab-content").last().attr("id");
$("a[href=#"+id+"]").addClass("tab-error");
})
Expand Down Expand Up @@ -170,7 +170,9 @@ function template_info(div, url) {
$(div).load(url + "?operatingsystem_id=" + os_id + "&hostgroup_id=" + hostgroup_id + "&environment_id=" + env_id+"&provisioning="+build,
function(response, status, xhr) {
if (status == "error") {
$(div).html("<div class='alert alert-warning'><a class='close' data-dismiss='alert'>&times;</a><p>" + _('Sorry but no templates were configured.') + "</p></div>");
$(div).html('<div class="alert alert-warning alert-dismissable">' +
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' +
_('Sorry but no templates were configured.') + '</div>');
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/compute_resource.js
Expand Up @@ -37,7 +37,7 @@ function testConnection(item) {
success:function (result) {
var res = $('<div>' + result + '</div>');
$('#compute_connection').html(res.find("#compute_connection"));
$('#compute_connection').prepend(res.find(".alert-message"));
$('#compute_connection').prepend(res.find(".alert"));
},
complete:function (result) {
//we need to restore the password field as it is not sent back from the server.
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/layout_helper.rb
Expand Up @@ -169,17 +169,17 @@ def submit_or_cancel f, overwrite = false, args = { }

def base_errors_for obj
unless obj.errors[:base].blank?
content_tag(:div, :class => "alert alert-message alert-block alert-danger base in fade") do
("<a class='close' href='#' data-dismiss='alert'>&times;</a><h4>" + _("Unable to save") + "</h4> " + obj.errors[:base].map {|e| "<li>".html_safe + e + "</li>".html_safe}.join).html_safe
end
alert :header => _("Unable to save"),
:class => 'alert-danger base in fade',
:text => obj.errors[:base].map { |e| '<li>'.html_safe + e + '</li>'.html_safe }.join.html_safe
end
end

def popover title, msg, options = {}
link_to icon_text("info-sign", title), {}, { :remote => true, :rel => "popover", :data => {"content" => msg, "original-title" => title} }.merge(options)
end

def will_paginate(collection = nil, options = {})
def will_paginate(collection = nil, options = {})
options.merge!(:class=>"col-md-7")
options[:renderer] ||= "WillPaginate::ActionView::BootstrapLinkRenderer"
options[:inner_window] ||= 2
Expand Down Expand Up @@ -231,7 +231,7 @@ def alert opts = {}
opts[:close] ||= true
opts[:header] ||= _("Warning!")
opts[:text] ||= _("Alert")
content_tag :div, :class => "alert #{opts[:class]}" do
content_tag :div, :class => "alert #{opts[:class]} alert-dismissable" do
result = "".html_safe
result += alert_close if opts[:close]
result += alert_header(opts[:header])
Expand All @@ -245,7 +245,7 @@ def alert_header text
end

def alert_close
"<a class='close' href='#' data-dismiss='alert'>&times;</a>".html_safe
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'.html_safe
end

end
2 changes: 1 addition & 1 deletion app/views/common/403.html.erb
@@ -1,4 +1,4 @@
<div class="alert alert-message alert-block alert-danger base in fade">
<div class="alert alert-block alert-danger base in fade">
<h2><%= _("Permission denied") %></h2>

<p><strong><%= _("You are not authorized to perform this action") %></strong></p>
Expand Down
8 changes: 3 additions & 5 deletions app/views/common/500.html.erb
@@ -1,17 +1,15 @@
<% title _("Oops, we're sorry but something went wrong") %>
<div class="alert alert-message alert-block alert-danger base in fade">
<a class="close" href="#" data-dismiss="alert">x</a>
<%= h exception.message %>
</div>
<%= alert :class => 'alert-block alert-danger base in fade', :text => exception.message %>

<p>
<%= _("If you feel this is an error with Foreman itself, please open a new issue with") %> <%= link_to _("Foreman ticketing system"), "http://theforeman.org/projects/foreman/issues", :rel => "external" %>,
<%= _("You would probably need to attach the") %>
<%= link_to_function(_("Full trace"), "$('#backtrace').toggle()")%> <%= _("and relevant log entries.") %>
</p>

<div id="backtrace" class="alert alert-message alert-block alert-danger base in fade hide">
<div id="backtrace" class="alert alert-block alert-danger base in fade hide">
<em><%= exception.class %></em><br>
<strong><%= exception.message %></strong><br>
<%= Rails.backtrace_cleaner.clean(exception.backtrace).join("<br>").html_safe %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/compute_resources_vms/_error.html.erb
@@ -1,5 +1,5 @@
<table>
<tr>
<td class='alert'><%= _("There was an error listing VMs: %s" % errors) %></td>
<td class='alert alert-danger'><%= _("There was an error listing VMs: %s" % errors) %></td>
</tr>
</table>
6 changes: 3 additions & 3 deletions app/views/config_templates/_form.html.erb
Expand Up @@ -70,11 +70,11 @@


<div class="tab-pane" id="template_associations">
<p id="snippet_message" class="alert alert-message" <%= display? !@config_template.snippet %> ><%= _("Not relevant for snippet") %></p>
<p id="snippet_message" class="alert alert-info" <%= display? !@config_template.snippet %> ><%= _("Not relevant for snippet") %></p>

<div id="association" <%= display? @config_template.snippet %> >
<div class="alert alert-message alert-success">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-success alert-dismissable">
<%= alert_close %>

<h3><%= _("How templates are determined") %><br></h3>

Expand Down
2 changes: 1 addition & 1 deletion app/views/hostgroups/_form.html.erb
Expand Up @@ -36,7 +36,7 @@
<% if @environment or @hostgroup.environment %>
<%= render 'puppetclasses/class_selection', :obj => @hostgroup %>
<% else %>
<p class="alert alert-message"><%= _('Please select an environment first') %></p>
<%= alert :class => 'alert-warning', :text => _('Please select an environment first') %><
<% end %>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/views/hosts/_compute.html.erb
@@ -1,10 +1,10 @@
<%= fields_for "#{type}[compute_attributes]", @host ? @host.compute_object : compute_resource.new_vm(vm_attrs) do |compute| %>
<% if compute.object %>
<div id='update_not_supported' class='alert hide'><%= _("VM editing is not implemented for this provider") %></div>
<div id='update_not_supported' class='alert alert-info hide'><%= _("VM editing is not implemented for this provider") %></div>
<%= render :partial => "compute_resources_vms/form/#{compute_resource.provider.downcase}",
:locals => { :f => compute, :compute_resource => compute_resource}.merge(args_for_compute_resource_partial(@host)) %>
<% else %>
<div class="alert alert-message alert-block alert-danger base in fade">
<div class="alert alert-block alert-danger base in fade">
<% if @host %>
<h4><%= _("'%{host}' not found on '%{resource}'") % { :host => @host.name, :resource => compute_resource } %></h4>
<p><%= _("'%{host}' could be deleted or '%{resource}' is not responding.") % {:host => @host.name, :resource => compute_resource} %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hosts/_conflicts.html.erb
Expand Up @@ -10,7 +10,7 @@

<p><%= _('Please review them carefully, if you are certain that they should be removed, please click on overwrite.') %></p>

<div class="alert alert-message alert-block base">
<div class="alert alert-warning alert-block base">
<% conflict_objects(@host.errors).each do |obj| %>
<% @host.errors[obj].each do |e| %>
<li><%= e %></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hosts/_form.html.erb
Expand Up @@ -80,7 +80,7 @@
<% if @environment or @hostgroup %>
<%= render 'puppetclasses/class_selection', :obj => @host %>
<% else %>
<p class="alert alert-message"><%= _('Please select an environment first') %></p>
<%= alert :class => 'alert-warning', :text => _('Please select an environment first') %><
<% end %>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/views/hosts/_progress.html.erb
@@ -1,5 +1,5 @@
<div id="host-progress" class="alert alert-message alert-block alert-success base in fade hide">
<a class='close' href='#' data-dismiss='alert'>&times</a>
<div id="host-progress" class="alert alert-block alert-success base in fade hide alert-dismissable">
<%= alert_close %>
<h3><%= action_name %> <%= _('In Progress') %></h3>
<p id="tasks_progress"><%= action_name %> in progress.</p>
<div class="progress progress-striped active">
Expand Down
4 changes: 2 additions & 2 deletions app/views/hosts/_provisioning.html.erb
@@ -1,5 +1,5 @@
<div class="alert alert-success">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-success alert-dismissable">
<%= alert_close %>
<% templates.sort{|t,x| t.template_kind <=> x.template_kind}.each do |tmplt| %>
<div class="form-group">
<div class="control-label col-md-4"> <%= _("%s Template") % tmplt.template_kind %> </div>
Expand Down
5 changes: 1 addition & 4 deletions app/views/hosts/console/log.html.erb
Expand Up @@ -4,10 +4,7 @@
<% title "#{@console[:name]}" %>
</div>
<% if @host && (@host.installed_at.nil? or (@console['timestamp'] - @host.installed_at < 5.minutes)) %>
<div class='alert'>
<a class="close" href="#" data-dismiss="alert">&times;</a>
Console output may be out of date
</div>
<%= alert :class => 'alert-info', :text => _('Console output may be out of date') %>
<% end %>
<pre class="pre-scrollable">
<code>
Expand Down
2 changes: 1 addition & 1 deletion app/views/locations/welcome.html.erb
@@ -1,7 +1,7 @@
<% title_actions link_to(_("New Location"), new_location_path) %>
<% title _("Location configuration") %>
<div id="welcome">
<div class="alert alert-message alert-block alert-info">
<div class="alert alert-block alert-info">
<p><strong><%= _("Notice") %></strong> <%= _("You must create a location before continuing.") %></p>
</div>
<p><%= _("Locations are used to manage and differentiate the physical place where a system managed via Foreman is housed.") %></p>
Expand Down
6 changes: 3 additions & 3 deletions app/views/operatingsystems/_template_defaults.html.erb
@@ -1,13 +1,13 @@
<div class="tab-pane" id="templates">
<% if @operatingsystem.new_record? %>
<div class="alert alert-message alert-block alert-warning">
<div class="alert alert-block alert-warning">
<p><strong><%= _("Notice") %></strong> <%= _("It is not possible to assign provisioning templates at this stage") %></p>
<p><%= _("Please save the Operating System first and try again.") %></p>
</div>
<% else %>
<% if ConfigTemplate.joins(:operatingsystems).where(:operatingsystems => { :id => @operatingsystem.id }).empty? %>
<div class="alert alert-message alert-warning">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-warning alert-dismissable">
<%= alert_close %>
<p><strong><%= _("No templates found!") %></strong> <%= (_("you probably need to configure your %s first.") % link_to("templates", config_templates_path)).html_safe %></p>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/welcome.html.erb
@@ -1,7 +1,7 @@
<% title_actions link_to(_("New Organization"), new_organization_path) %>
<% title _("Organization configuration") %>
<div id="welcome">
<div class="alert alert-message alert-block alert-info">
<div class="alert alert-block alert-info">
<p><strong><%= _('Notice') %></strong>
<%= _('You must create an organization before continuing.') %>
</p>
Expand Down
6 changes: 2 additions & 4 deletions app/views/puppetclasses/_class_selection.html.erb
@@ -1,9 +1,7 @@
<div class="row">
<% if obj.errors[:puppetclasses].any? %>
<div class="alert alert-message alert-block alert-danger base in fade">
<a class='close' href='#' data-dismiss="alert">×</a>
<%= obj.errors[:puppetclasses].map {|e| "<li>#{e}</li>"}.to_s.html_safe %>
</div>
<%= alert :class => "alert-block alert-danger base in fade",
:text => obj.errors[:puppetclasses].map { |e| "<li>#{e}</li>" }.to_s.html_safe %>
<% end %>
<div class="col-md-4 classes">
<h3><%= _('Included Classes') %></h3>
Expand Down
35 changes: 19 additions & 16 deletions app/views/puppetclasses/_form.html.erb
Expand Up @@ -16,14 +16,14 @@
</div>
<div class="tab-pane lookup-keys-container" id="smart_class_param">
<% if @puppetclass.class_params.empty? %>
<div class="alert alert-message alert-success">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-success alert-dismissable">
<%= alert_close %>
<p><strong>
<%= _('This Puppet class has no parameters in its signature.') %>
</strong><br><%= _('To update the class signature, go to the Puppet Classes page and select "Import".') %></p>
</div>
<% else %>
<div class="undo-smart-vars alert alert-message hide">
<div class="undo-smart-vars alert alert-info hide">
<%= _('Undo remove') %>
</div>
<div class="row">
Expand All @@ -38,16 +38,19 @@
</div>
</div>
</div>
<ul class="nav nav-pills nav-stacked smart-var-tabs col-md-3" data-tabs="pills">
<% @puppetclass.class_params.all(:include => :environments).each do |key| %>
<li data-used-environments=<%= key.environments.map(&:to_s).to_json %> >
<a data-toggle="tab" id="pill_<%= key.to_s.gsub(' ','_') %>" href="#<%= key.to_s.gsub(' ','_') %>" >
<%= icon_text((key.override ? "flag": ""), key.to_s.gsub('_',' ')) %>
<span class="badge close pull-right">&times;</span>
</a>
</li>
<% end %>
</ul>
<div class='col-md-3'>
<ul class="nav nav-pills nav-stacked smart-var-tabs" data-tabs="pills">
<% @puppetclass.class_params.all(:include => :environments).each do |key| %>
<li data-used-environments=<%= key.environments.map(&:to_s).to_json %> >
<a data-toggle="tab" id="pill_<%= key.to_s.gsub(' ','_') %>" href="#<%= key.to_s.gsub(' ','_') %>" >
<%= icon_text((key.override ? "flag": ""), key.to_s.gsub('_',' ')) %>
<span class="label label-danger close pull-right">&times;</span>
</a>
</li>
<% end %>
</ul>

</div>
<div class="tab-content col-md-9 smart-var-content">
<%= f.fields_for :class_params do |lookup_keys_form| %>
<%= render 'lookup_keys/fields', :f => lookup_keys_form %>
Expand All @@ -57,14 +60,14 @@
</div>
<div class="tab-pane lookup-keys-container" id="smart_vars">
<% if @puppetclass.lookup_keys.empty? %>
<div class="alert alert-message alert-warning">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-warning alert-dismissable">
<%= alert_close %>
<p><strong><%= _('Help!') %></strong>
<%= (_('What is a <a href="%s" rel="external">Smart variable</a>?') % "http://www.theforeman.org/manuals/#{SETTINGS[:version].short}/index.html#4.2.4SmartVariables").html_safe %>
</p>
</div>
<% end %>
<div class="undo-smart-vars alert alert-message hide">
<div class="undo-smart-vars alert alert-info hide">
<%= _('Undo remove') %>
</div>
<ul class="nav nav-pills nav-stacked smart-var-tabs col-md-3" data-tabs="pills">
Expand Down
2 changes: 1 addition & 1 deletion app/views/puppetclasses/no_route.html.erb
@@ -1,7 +1,7 @@
<%= stylesheet_link_tag 'jquery-ui', 'jquery.jnotify', 'bootstrap.min', 'style' %>
<%= javascript_include_tag :defaults %>
<div id="content" class="container">
<div class="alert alert-message alert-block alert-danger">
<div class="alert alert-block alert-danger">
<h3><%= _('Oops') %></h3>
<p>
<%= _('Either you didn''t generate the puppetdocs (see <a rel="external" href="%{url}">here</a>) or the class <strong>%{name}</strong> could not be found in environment <strong>%{environment}</strong><br/> Please ensure that the class <strong>%{name}</strong>''s declaration is accessible via the modulepath associated with <strong>%{environment}</strong>.') % { :name => name, :environment => environment, :url => 'http://theforeman.org/projects/foreman/wiki/Puppet_class_browser' } %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/reports/show.html.erb
Expand Up @@ -3,8 +3,8 @@

<p class='ra'> <%= _("Reported at %s ") % @report.reported_at.getlocal %> </p>
<% if @offset > 10 %>
<div class="alert alert-message alert-block alert-danger">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-block alert-danger alert-dismissable">
<%= alert_close %>
<h3><%= _("Host times seems to be adrift!") %></h3>
<%= (_("Host reported time is <em>%s</em>") % @report.reported_at).html_safe %> <br/>
<%= (_("Foreman report creation time is <em>%s</em>") % @report.created_at).html_safe %> <br/>
Expand Down
2 changes: 1 addition & 1 deletion app/views/taxonomies/index.html.erb
Expand Up @@ -3,7 +3,7 @@
<% title_actions display_link_if_authorized((_("New %s") % taxonomy_title), hash_for_new_taxonomy_path), link_to(_("Mismatches Report"), mismatches_taxonomies_path, :class => 'btn btn-default'), help_path %>
<% if @count_nil_hosts > 0 %>
<div class="alert alert-message alert-block alert">
<div class="alert alert-warning alert-block">
<strong><%= _("Notice:") %></strong>
<%= n_('There is', 'There are', @count_nil_hosts) %>
<%= link_to n_("%{count} host with no %{taxonomy_single} assigned", "%{count} hosts with no %{taxonomy_single} assigned", @count_nil_hosts) % {:count => @count_nil_hosts , :taxonomy_single => taxonomy_single }, hosts_path(:search => "not has #{controller_name.singularize}") %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/trends/index.html.erb
Expand Up @@ -2,8 +2,8 @@
<% title_actions display_link_if_authorized(_("Add Trend Counter"), hash_for_new_trend_path) %>
<% if @trends.empty? %>
<div class="alert alert-message alert-info">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-info">
<%= alert_close %>

<p><strong><%= _("No trend counter defined.") %></strong></p>

Expand All @@ -13,10 +13,10 @@
<% end %>
<% if @trends.any? and TrendCounter.unconfigured? %>
<div class="alert alert-message alert-info">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<div class="alert alert-info alert-dismissable">
<%= alert_close %>

<p><strong><%= _("No trend counter found.") %></strong></p>
<p><strong><%= _("No trend counter found.") %></strong></p>

<p><%= ( _("To start collecting trend data, set a cron job to execute <span class='black'>RAILS_ENV=production bundle exec rake trends:counter</span> every Puppet Interval (%s minutes)") % Setting.puppet_interval).html_safe %>
</p>
Expand Down

0 comments on commit ede5687

Please sign in to comment.