Skip to content

Commit

Permalink
Fixes #22236 - Adds breadcrumbs to foreman UI
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfefer authored and ohadlevy committed Mar 29, 2018
1 parent 682269f commit 9738aa6
Show file tree
Hide file tree
Showing 53 changed files with 288 additions and 84 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/base.scss
Expand Up @@ -193,6 +193,12 @@ select {
padding-bottom: 12px;
}

.breadcrumb-line {
margin-top: -15px;
margin-right: -60px;
margin-left: -60px;
}

.grey,
.gray {
color: #808080 !important;
Expand Down
1 change: 1 addition & 0 deletions app/controllers/audits_controller.rb
Expand Up @@ -5,6 +5,7 @@ class AuditsController < ApplicationController

def index
@audits = resource_base_search_and_page.with_taxonomy_scope.preload(:user)
@host = resource_finder(Host.authorized(:view_hosts), params[:host_id]) if params[:host_id]
end

def show
Expand Down
1 change: 1 addition & 0 deletions app/controllers/config_reports_controller.rb
Expand Up @@ -7,6 +7,7 @@ class ConfigReportsController < ApplicationController
def index
respond_to do |format|
format.html do
@host = resource_finder(Host.authorized(:view_hosts), params[:host_id]) if params[:host_id]
@config_reports = resource_base_search_and_page(:host)
render :index
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/images_controller.rb
Expand Up @@ -8,7 +8,7 @@ def index
# Listing images in /hosts/new consumes this method as JSON
@images = resource_base.where(:compute_resource_id => @compute_resource.id).includes(:operatingsystem)
respond_to do |format|
format.html { render :partial => 'images/list' }
format.html { params[:partial] ? render(:partial => 'images/list') : render(:index) }
format.json { render :json => @images.where(:operatingsystem_id => params[:operatingsystem_id], :architecture_id => params[:architecture_id]).order(:name) }
end
end
Expand Down
15 changes: 15 additions & 0 deletions app/helpers/layout_helper.rb
Expand Up @@ -16,6 +16,21 @@ def search_bar(*elements)
content_for(:search_bar) { elements.join(" ").html_safe }
end

def mount_breadcrumbs(&block)
index_page = {caption: _(controller_name.humanize), url: try("#{controller_name}_path")}
default_menu = [(index_page unless action_name == 'index'),
{caption: @page_header, url: '#' }].compact unless block_given?

mount_react_component("Breadcrumb", "#breadcrumb",
{ menu: default_menu || yield }.to_json)
end

def breadcrumbs(&block)
content_for(:breadcrumbs) do
mount_breadcrumbs(&block)
end
end

def stylesheet(*args)
content_for(:stylesheets) { stylesheet_link_tag(*args.push("data-turbolinks-track" => true)) }
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/architectures/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Architecture") %>
<% title _("Edit %s") % @architecture.to_s %>
<%= render :partial => 'form' %>
9 changes: 9 additions & 0 deletions app/views/audits/index.html.erb
@@ -1,3 +1,12 @@
<%= if @host
breadcrumbs do
[
{caption: _("Hosts"), url: (url_for(hosts_path) if authorized_for(hash_for_hosts_path))},
{caption: @host.name, url: (host_path(@host) if authorized_for(hash_for_host_path(@host)))},
{caption: _('Audits'), url: url_for(audits_path)},
]
end
end %>
<% title _("Audits") %>
<% title_actions documentation_button('4.1.4Auditing') %>
<%= render :partial => 'list', :locals =>{:audits => @audits}%>
Expand Down
1 change: 0 additions & 1 deletion app/views/audits/show.html.erb
Expand Up @@ -8,7 +8,6 @@
hash_for_host_path(:id => @audit.associated.to_param).merge(:auth_object => @audit.associated, :auth_action => 'view'),
:title => _("Host details"),
:class => 'btn btn-default') if @audit.auditable_type.match(/^Nic/) && @audit.associated_type == 'Host::Base' && @audit.associated %>
<%= title_actions link_to 'Back', :back, :class=>'btn btn-default' %>
<% tmplt = audit_template?(@audit) %>

<div class="tabbable">
Expand Down
2 changes: 1 addition & 1 deletion app/views/auth_source_ldaps/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit LDAP Auth Source") %>
<% title _("Edit %s") % @auth_source_ldap.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/bookmarks/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Bookmark") %>
<% title _("Edit %s") % @bookmark.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/common_parameters/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Global Parameter") %>
<% title _("Edit %s") % @common_parameter.to_s %>
<%= render :partial => 'form' %>
10 changes: 8 additions & 2 deletions app/views/compute_attributes/edit.html.erb
@@ -1,3 +1,9 @@
<% title _("Edit compute profile on %s") % @set.compute_resource.to_label %>
<%= breadcrumbs do
[
{caption: _("Compute Resources"), url: (url_for(compute_resources_path) if authorized_for(hash_for_compute_resources_path))},
{caption: @set.compute_resource.to_label, url: (compute_resource_path(@set.compute_resource) if authorized_for(hash_for_compute_resource_path(@set.compute_resource)))},
{caption: _("Compute Profiles"), url: (url_for(compute_profiles_path) if authorized_for(hash_for_compute_profiles_path))},
{caption: _('Edit %s' % @set.compute_profile.to_label)}
]
end %>
<%= render 'form' %>
10 changes: 8 additions & 2 deletions app/views/compute_attributes/new.html.erb
@@ -1,3 +1,9 @@
<% title _("New compute profile on %s") % @set.compute_resource.to_label %>
<%= breadcrumbs do
[
{caption: _("Compute Resources"), url: (url_for(compute_resources_path) if authorized_for(hash_for_compute_resources_path))},
{caption: @set.compute_resource.to_label, url: (compute_resource_path(@set.compute_resource) if authorized_for(hash_for_compute_resource_path(@set.compute_resource)))},
{caption: _("Compute Profiles"), url: (url_for(compute_profiles_path) if authorized_for(hash_for_compute_profiles_path))},
{caption: _('New %s' % @set.compute_profile.to_label)}
]
end %>
<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/compute_profiles/show.html.erb
@@ -1,4 +1,4 @@
<% title(_("Edit Compute profile: %s") % @compute_profile.name) %>
<% title(@compute_profile.name) %>
<% title_actions display_link_if_authorized(_("Back"), hash_for_compute_profiles_path, :class => 'btn btn-default') %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/compute_resources/show.html.erb
Expand Up @@ -48,7 +48,7 @@
<% if @compute_resource.capabilities.include?(:image) %>
<div id="images" class="tab-pane">
<%= title_actions(new_link(_("Create Image"), { :compute_resource_id => @compute_resource.id, :controller => :images }, { :data=>{:target=>"full-page"} })) %>
<div id="images_list" data-url=<%= compute_resource_images_path(@compute_resource) %>>
<div id="images_list" data-url=<%= compute_resource_images_path(@compute_resource, { :partial => true }) %>>
<%= spinner(_('Loading images information ...')) %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/config_groups/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Config group") %>
<% title _("Edit %s") % @config_group.to_s %>
<%= render 'form' %>
9 changes: 9 additions & 0 deletions app/views/config_reports/index.html.erb
@@ -1,3 +1,12 @@
<%= if @host
breadcrumbs do
[
{caption: _("Hosts"), url: (url_for(hosts_path) if authorized_for(hash_for_hosts_path))},
{caption: @host.name, url: (host_path(@host) if authorized_for(hash_for_host_path(@host)))},
{caption: _('Reports'), url: url_for(config_reports_path(search: 'eventful=true'))},
]
end
end %>
<% title _("Reports") %>
<% title_actions csv_link, documentation_button('3.5.4PuppetReports') %>
<%= render :partial => 'list' %>
3 changes: 1 addition & 2 deletions app/views/config_reports/show.html.erb
Expand Up @@ -15,8 +15,7 @@
<%= render report_origin_output_partial(@config_report.origin), :logs => @config_report.logs %>
<%= render 'metrics', :status => @config_report.status, :metrics => @config_report.metrics["time"] if @config_report.metrics["time"] %>
<%= title_actions link_to(_('Back'), :back, :class => 'btn btn-default'),
display_delete_if_authorized(hash_for_config_report_path(:id => @config_report), :class=> "btn btn-danger"),
<%= title_actions display_delete_if_authorized(hash_for_config_report_path(:id => @config_report), :class=> "btn btn-danger"),
link_to(_("Host details"), @config_report.host, :class => 'btn btn-default'),
link_to(_("Other reports for this host"), host_config_reports_path(@config_report.host), :class => 'btn btn-default')
%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/domains/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Domain") %>
<% title _("Edit %s") % @domain.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/environments/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Environment") %>
<% title _("Edit %s") % @environment.to_s %>
<%= render :partial => 'form' %>
8 changes: 7 additions & 1 deletion app/views/fact_values/index.html.erb
@@ -1,7 +1,13 @@
<%= javascript 'charts' %>
<%
if params[:host_id].present?
title(_("Fact Values | %{host_name}") % {:host_name => params[:host_id]})
breadcrumbs do
[
{caption: _("Facts"), url: (url_for(fact_values_path) if authorized_for(hash_for_fact_values_path))},
{caption: params[:host_id], url: (host_path(params[:host_id]) if authorized_for(hash_for_host_path(params[:host_id])))},
{caption: _('values')}
]
end
else
title(_("Fact Values"))
end
Expand Down
8 changes: 7 additions & 1 deletion app/views/filters/edit.html.erb
@@ -1,3 +1,9 @@
<% title _("Edit Filter") %>
<%= breadcrumbs do
[
(@role.present? ? {caption: _('Roles'), url: (url_for(roles_path) if authorized_for(hash_for_roles_path))} : {caption: _("Filters"), url: filters_path}),
({caption: _("%s filters") % @role.to_s, url: filters_path(role_id: @role.id)} if @role.present?),
{caption: _('Edit %s') % @filter.to_s},
].compact
end %>
<%= render 'form' %>
7 changes: 6 additions & 1 deletion app/views/filters/index.html.erb
@@ -1,5 +1,10 @@
<% if @role
title _("Filters for role %s") % @role.to_s
breadcrumbs do
[
{caption: _("Roles"), url: (url_for(roles_path) if authorized_for(hash_for_roles_path))},
{caption: _("%s filters") % @role.to_s}
]
end
else
title _("Filters")
end %>
Expand Down
9 changes: 7 additions & 2 deletions app/views/filters/new.html.erb
@@ -1,3 +1,8 @@
<% title _("Create Filter") %>
<%= breadcrumbs do
[
(@role.present? ? {caption: _('Roles'), url: (url_for(roles_path) if authorized_for(hash_for_roles_path))} : {caption: _("Filters"), url: filters_path}),
({caption: _("%s filters") % @role.to_s, url: filters_path(role_id: @role.id)} if @role.present?),
{caption: _('Create Filter')},
].compact
end %>
<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/hosts/_form.html.erb
Expand Up @@ -9,7 +9,7 @@
<%= base_errors_for @host %>

<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Host') %></a></li>
<li class="active"><a href="#primary" id='host_tab' data-toggle="tab"><%= _('Host') %></a></li>

<% if SETTINGS[:unattended] and @host.managed %>
<% if authorized_for(:controller => "Compute::Resources::Vms", :action => :create) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/http_proxies/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit HTTP Proxy") %>
<% title _("Edit %s") % @http_proxy.to_s %>
<%= render :partial => 'form' %>
10 changes: 8 additions & 2 deletions app/views/images/edit.html.erb
@@ -1,3 +1,9 @@
<% title(_("Edit %s") % @image) %>
<%= breadcrumbs do
[
{caption: _("Compute Resources"), url: (url_for(compute_resources_path) if authorized_for(hash_for_compute_resources_path))},
{caption: _("#{@compute_resource.to_s}"), url: (url_for(compute_resource_path(@compute_resource)) if authorized_for(hash_for_compute_resources_path))},
{caption: _("Images"), url: (url_for(compute_resource_images_path(@compute_resource)) )},
{caption: _("Edit %s") % @image}
]
end %>
<%= render 'form' %>
11 changes: 11 additions & 0 deletions app/views/images/index.html.erb
@@ -0,0 +1,11 @@
<%= breadcrumbs do
[
{caption: _("Compute Resources"), url: (url_for(compute_resources_path) if authorized_for(hash_for_compute_resources_path))},
{caption: _("#{@compute_resource.to_s}"), url: (url_for(compute_resource_path(@compute_resource)) if authorized_for(hash_for_compute_resources_path))},
{caption: _("Images")}
]
end %>
<%= title_actions(new_link(_("Create Image"), { :compute_resource_id => @compute_resource.id, :controller => :images }, { :data=>{:target=>"full-page"} })) %>
<%= render :partial => 'list' %>
10 changes: 8 additions & 2 deletions app/views/images/new.html.erb
@@ -1,3 +1,9 @@
<% title _("Create Image") %>
<%= breadcrumbs do
[
{caption: _('Compute Resources'), url: (url_for(compute_resources_path) if authorized_for(hash_for_compute_resources_path))},
{caption: @compute_resource.to_s, url: (url_for(compute_resource_path(@compute_resource)) if authorized_for(hash_for_compute_resource_path(@compute_resource)))},
{caption: _('Images'), url: (url_for(compute_resource_images_path(@compute_resource)) )},
{caption: _('Create image')}
]
end %>
<%= render :partial => 'form' %>
44 changes: 27 additions & 17 deletions app/views/layouts/_application_content.html.erb
@@ -1,21 +1,31 @@
<div id="main">
<div id="content" >
<div id="content">
<%= notifications %>
<% unless @page_header.blank? %>
<div class="row form-group">
<h1 class="col-md-8"><%=h @page_header %></h1>
<div id="breadcrumb">
<% unless @page_header.blank? %>
<div class="row form-group">
<h1 class="col-md-8">
<%=h @page_header %>
</h1>
</div>
<% end %>
<% if content_for?(:breadcrumbs) %>
<%= yield(:breadcrumbs) %>
<% else %>
<%= mount_breadcrumbs %>
<% end %>
</div>
<div class="row">
<div class="title_filter <%= searchable? ? " col-md-6 " : "col-md-4 " %>">
<%= render "common/searchbar" if searchable? %>
<%= yield(:search_bar) %>&nbsp;
</div>
<div id="title_action" class= <%= searchable? ? "col-md-6" : "col-md-8" %>>
<div class="btn-toolbar pull-right">
<%=h yield(:title_actions) %>
</div>
</div>
</div>
<% end %>
<div class="row">
<div class="title_filter <%= searchable? ? "col-md-6" : "col-md-4" %>">
<%= render "common/searchbar" if searchable? %>
<%= yield(:search_bar) %>&nbsp;
</div>
<div id="title_action" class="<%= searchable? ? "col-md-6" : "col-md-8" %>">
<div class="btn-toolbar pull-right"><%=h yield(:title_actions) %></div>
</div>
</div>

<%= yield %>
<%= yield %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/media/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Medium") %>
<% title _("Edit %s") % @medium.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/models/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Model") %>
<% title _("Edit %s") % @model.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/provisioning_templates/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Template") %>
<% title _("Edit %s") % @template.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/ptables/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Partition Table") %>
<% title _("Edit %s") % @template.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/realms/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Realm") %>
<% title _("Edit %s") % @realm.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/roles/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Role") %>
<% title _("Edit %s") % @role.to_s %>
<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/smart_proxies/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Proxy") %>
<% title _("Edit %s") % @proxy.to_s %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/smart_proxies/show.html.erb
@@ -1,4 +1,4 @@
<% title(_('Smart Proxy: %s') % @smart_proxy.to_label) %>
<% title(@smart_proxy.to_label) %>
<%= javascript 'proxy_status', 'charts' %>
<%= smart_proxy_title_actions(@smart_proxy, authorizer) %>
<% service_features = services_tab_features(@smart_proxy) %>
Expand Down
12 changes: 5 additions & 7 deletions app/views/ssh_keys/new.html.erb
@@ -1,9 +1,7 @@
<% title _('Add SSH Key for %s') % @user.name %>

<ol class="breadcrumb">
<li class="breadcrumb-item"><%= link_to_if_authorized(_("Users"), hash_for_users_path) %></li>
<li class="breadcrumb-item"><%= link_to_if_authorized(@user.name, hash_for_edit_user_path(@user)) %></li>
<li class="breadcrumb-item active"><%= _('Add SSH Key') %></li>
</ol>

<%= breadcrumbs do %>
<% [{caption: _("Users"), url: (url_for(users_path) if authorized_for(hash_for_users_path))},
{caption: @user.name, url: (edit_user_path(@user) if authorized_for(hash_for_edit_user_path(@user)))},
{caption: _('Add SSH Key')}] %>
<% end %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/subnets/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit Subnet") %>
<% title _("Edit %s") % @subnet.to_label %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/usergroups/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit User group") %>
<% title _("Edit %s") % @usergroup.to_label %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/users/edit.html.erb
@@ -1,3 +1,3 @@
<% title _("Edit User") %>
<% title _("Edit %s") % @user.to_s %>
<%= render :partial => 'form' %>

0 comments on commit 9738aa6

Please sign in to comment.