]> source.dussan.org Git - sonarqube.git/commitdiff
Add breadcrumb to profiles console
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 28 Nov 2012 20:04:38 +0000 (21:04 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 28 Nov 2012 20:04:38 +0000 (21:04 +0100)
19 files changed:
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
sonar-server/src/main/webapp/WEB-INF/app/views/alerts/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb
sonar-server/src/main/webapp/stylesheets/layout.css

index 95436a19e3b62814d4147bce34032def722988a6..c882eef84357d4020816535779da90541e1704bc 100644 (file)
@@ -297,7 +297,6 @@ layout.evaluation=Embedded database should be used for evaluation purpose only
 layout.ie6_warn=Your web browser is outdated. This website may not display correctly.
 layout.dashboards=Dashboards
 layout.tools=Tools
-layout.tools.quality_profiles=Quality Profiles
 layout.user_panel.my_profile=My profile
 layout.user_panel.recent_history.title=Recent history
 layout.user_panel.recent_history.clear=Clear
@@ -1226,10 +1225,10 @@ cloud.top_risk=Top risk
 #
 #------------------------------------------------------------------------------
 
-quality_profiles.quality_profiles=Quality profiles
-quality_profiles.new_profile=New profile
-quality_profiles.compare_profiles=Compare profiles
-quality_profiles.restore_profile=Restore profile
+quality_profiles.quality_profiles=Quality Profiles
+quality_profiles.new_profile=New Profile
+quality_profiles.compare_profiles=Compare Profiles
+quality_profiles.restore_profile=Restore Profile
 quality_profiles.restore_submit=Restore
 quality_profiles.x_language_profiles={0} Profiles
 quality_profiles.optional_configuration_file=Optional configuration file
index c27ca5a90ebd862b2f273dbc8490553a4a9f74f3..586e91dca1fa0ac457dd5e69907b9be0eeec3d86 100644 (file)
@@ -29,9 +29,11 @@ class AlertsController < ApplicationController
   #
   #
   def index
+    require_parameters :id
     @profile = Profile.find(params[:id])
     @alerts = @profile.alerts.sort
     @alert=Alert.new
+    add_breadcrumbs ProfilesController::ROOT_BREADCRUMB, Api::Utils.language_name(@profile.language), @profile.name
   end
 
   #
index fa0dc0a07a53f406437914758af109cff57e95ee..0c6084981ac6d300218472d2f5551401c49130e5 100644 (file)
@@ -174,7 +174,7 @@ class ApplicationController < ActionController::Base
 
 
   #
-  # FILTERS
+  # RAILS FILTERS
   #
   def init_resource_for_user_role
     init_resource_for_role :user
@@ -194,4 +194,11 @@ class ApplicationController < ActionController::Base
 
     access_denied unless has_role?(role, @resource)
   end
+
+
+  # BREADCRUMBS
+  def add_breadcrumbs(*breadcrumbs)
+    @breadcrumbs ||= []
+    @breadcrumbs.concat(breadcrumbs)
+  end
 end
index 53fc617c2453ab8700df248dd955b4b9660bd043..7475ad4e4013c6bb37f8033e43aac3bb547846ae 100644 (file)
@@ -19,6 +19,7 @@
 #
 class MeasuresController < ApplicationController
 
+
   # GET /measures/index
   def index
     @filter = MeasureFilter.new
@@ -191,5 +192,4 @@ class MeasuresController < ApplicationController
   def owner?(filter)
     current_user && (filter.user_id==current_user.id || (filter.user_id==nil && has_role?(:admin)))
   end
-
 end
index 821b6313b56a94330dee68348d87f9d0b738df51..f05ebdaa0d049efbb6366f9893dfda28bdec99d3 100644 (file)
@@ -22,20 +22,16 @@ class ProfilesController < ApplicationController
   # the backup action is allow to non-admin users : see http://jira.codehaus.org/browse/SONAR-2039
   before_filter :admin_required, :only => ['create', 'delete', 'set_as_default', 'copy', 'restore', 'change_parent', 'set_projects', 'rename_form', 'rename']
 
+  ROOT_BREADCRUMB = {:name => Api::Utils.message('quality_profiles.page'), :url => {:controller => 'profiles', :action => 'index'}}
+
   # GET /profiles/index
   def index
+    add_breadcrumbs ROOT_BREADCRUMB
     @profiles = Profile.find(:all)
     Api::Utils.insensitive_sort!(@profiles){|profile| profile.name}
   end
 
 
-  # GET /profiles/show/<id>
-  def show
-    require_parameters 'id'
-    @profile = Profile.find(params[:id])
-  end
-
-
   # GET /profiles/create_form?language=<language>
   def create_form
     require_parameters 'language'
@@ -124,7 +120,6 @@ class ProfilesController < ApplicationController
     end
   end
 
-
   # POST /profiles/backup?id=<profile id>
   def backup
     verify_post_request
@@ -185,6 +180,8 @@ class ProfilesController < ApplicationController
 
     profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?)', @profile.language, @profile.id, @profile.name], :order => 'name')
     @select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name, profile.name] }
+
+    set_profile_breadcrumbs
   end
 
   # GET /profiles/changelog?id=<profile id>
@@ -214,6 +211,8 @@ class ProfilesController < ApplicationController
 
       @select_versions = versions.map { |u| [message(u.profile_version == last_version ? 'quality_profiles.last_version_x_with_date' : 'quality_profiles.version_x_with_date', :params => [u.profile_version.to_s, l(u.change_date)]), u.profile_version] } | [[message('quality_profiles.no_version'), 0]];
     end
+
+    set_profile_breadcrumbs
   end
 
 
@@ -242,6 +241,7 @@ class ProfilesController < ApplicationController
   def permalinks
     require_parameters 'id'
     @profile = Profile.find(params[:id])
+    set_profile_breadcrumbs
   end
 
 
@@ -253,6 +253,7 @@ class ProfilesController < ApplicationController
   def projects
     require_parameters 'id'
     @profile = Profile.find(params[:id])
+    set_profile_breadcrumbs
   end
 
 
@@ -321,7 +322,6 @@ class ProfilesController < ApplicationController
     end
   end
 
-
   # GET /profiles/compare?id1=<profile1 id>&id2=<profile2 id>
   def compare
     @profiles = Profile.find(:all, :order => 'language asc, name')
@@ -363,6 +363,7 @@ class ProfilesController < ApplicationController
         end
       end
     end
+    add_breadcrumbs ROOT_BREADCRUMB, Api::Utils.message('compare')
   end
 
   DIFF_IN1=1
@@ -506,4 +507,8 @@ class ProfilesController < ApplicationController
       flash[:notice]=messages.getInfos().to_a[0...4].join('<br/>')
     end
   end
+
+  def set_profile_breadcrumbs
+    add_breadcrumbs ROOT_BREADCRUMB, Api::Utils.language_name(@profile.language), @profile.name
+  end
 end
index 5d0ad9c1b68fb26d271bc1763b8749bbcc9a6098..3282b6192ce58bc02809d87d59599a3ba1cb13af 100644 (file)
@@ -34,16 +34,10 @@ class RulesConfigurationController < ApplicationController
   before_filter :admin_required, :except => ['index', 'export']
 
   def index
-    if params[:id].to_i<=0
-      redirect_to :controller => 'profiles'
-      return
-    end
-    begin
-      @profile = Profile.find(params[:id].to_i)
-    rescue
-      redirect_to :controller => 'profiles'
-      return
-    end
+    require_parameters :id
+
+    @profile = Profile.find(params[:id])
+    add_breadcrumbs ProfilesController::ROOT_BREADCRUMB, Api::Utils.language_name(@profile.language), @profile.name
 
     init_params()
 
index e7419d5d5111808a6ffec9f559db3f38cd38e23a..b96e859c9ac34be5e39123ef21bce6767994ccad 100644 (file)
@@ -176,7 +176,8 @@ class Api::Utils
   end
 
   def self.language_name(key)
-    language(key) ? language(key).name : key
+    l = language(key)
+    l ? l.name : key
   end
 
 end
index dbab2ebbca17b65ce01428811873ebd606841e27..2b8b029a0f974ab63082e4231e6a05628af83215 100644 (file)
@@ -1,4 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Alerts'} %>
 
 <% if is_admin? %>
index cac01887b8fa9f9e4bad175e28ba08214929b52f..2a5ee916434333df75539b58703daeb756c4ca31 100644 (file)
@@ -3,9 +3,11 @@
 %>
   <div id="crumbs">
     <% if !@review %>
-    <ul id="crumbs-ops">
-      <li><a href="<%= url_for(:overwrite_params => {:id => displayed_resource.key})-%>"><img src="<%= ApplicationController.root_context -%>/images/permalink.png" width="16" height="16" title="<%= message('permalink') -%>"/></a></li>
-    </ul>
+      <ul id="crumbs-ops">
+        <li>
+          <a href="<%= url_for(:overwrite_params => {:id => displayed_resource.key}) -%>"><img src="<%= ApplicationController.root_context -%>/images/permalink.png" width="16" height="16" title="<%= message('permalink') -%>"/></a>
+        </li>
+      </ul>
     <% end %>
     <ul id="bc">
       <%
       %>
     </ul>
   </div>
+<% elsif @breadcrumbs %>
+  <div id="crumbs">
+    <ul id="bc">
+      <%
+         @breadcrumbs.each_with_index do |breadcrumb, index|
+      %>
+        <li<%= ' class=first' if index==0 -%>>
+          <% if breadcrumb.is_a?(String) %>
+            <span><%= h breadcrumb -%></span>
+          <%
+             elsif breadcrumb.is_a?(Hash)
+               name = breadcrumb[:name]
+               url = breadcrumb[:url]
+               icon = breadcrumb[:icon]
+          %>
+            <%= image_tag icon if icon %>
+            <%= link_to_if url, name, url -%>
+          <% elsif breadcrumb.respond_to?(:html) %>
+            <%= breadcrumb.html -%>
+          <% end %>
+        </li>
+      <% end %>
+    </ul>
+  </div>
 <% end %>
\ No newline at end of file
index 90b62d1f25ce7c6ad7ae514833bfc4ecf80d1ef1..9fb3b7bb9cbf33d43a85adc22248e7e657f595dc 100644 (file)
@@ -18,7 +18,7 @@
         <a href="<%= ApplicationController.root_context -%>/measures"><%= message('layout.measures') -%></a>
       </li>
       <li>
-        <a href="<%= ApplicationController.root_context -%>/profiles"><%= message('layout.tools.quality_profiles') -%></a>
+        <a href="<%= ApplicationController.root_context -%>/profiles"><%= message('quality_profiles.page') -%></a>
       </li>
       <%= render 'layouts/tools' -%>
     </ul>
@@ -43,7 +43,7 @@
   </div>
   <div id="searchResourcesResults" class="autocomplete" style="display:none"></div>
 </div>
-<%= render 'layouts/breadcrumb' if selected_section==Navigation::SECTION_RESOURCE -%>
+<%= render 'layouts/breadcrumb' if @breadcrumbs || selected_section==Navigation::SECTION_RESOURCE -%>
 <div id="body">
   <% if selected_section || @sidebar %>
     <div id="sb">
index 38521ea84a64b6fa497eb43228ec1e6eed8ecaa3..af89534c49d8dc127c155e13ad123a6fab12209d 100644 (file)
@@ -1,4 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
 
 <div class="tabs-panel marginbottom10">
index 7cda38ad0c0bcdeefe07c9d71bd883c48de1f505..012cb6a341f0c91362c57517888e44b6b2b5e489 100644 (file)
@@ -1,6 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> /
-  <%= message('compare') -%></h1>
-
 <form method="GET" class="marginbottom10">
   <select name="id1" class="small">
     <option value=""></option>
index 39601a348b056b5fe6cb49c1eb3902c9cde98687..c581f4f1e5cf0bc04fc2021967b29b00551fc4bd 100644 (file)
@@ -11,7 +11,6 @@
       </li>
     <% end %>
   </ul>
-  <h1 class="marginbottom10"><%= message('quality_profiles.page') -%></h1>
 </div>
 
 <%
index 7a0e624eb734a40b29001f994811dd4ffc0a1c36..4ea2afefae5c0c9decec52b1ebef35b853b01b49 100644 (file)
@@ -1,4 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'inheritance'} %>
 
 <div class="tabs-panel marginbottom10">
index fd4f42eb9935328bcb4916612310ba041ec15e5f..7bbb6cbc5f09dabb40fba0c3eb64b4f09ac676ff 100644 (file)
@@ -1,4 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Permalinks'} %>
 
 <div class="tabs-panel marginbottom10 ">
index 177c0d1f32c09cf4b774b6615898f0d6d9198dfa..743c59f8d892f1277e0fadd9930a773f2da264ae 100644 (file)
@@ -1,4 +1,3 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab => 'Projects'} %>
 
 <div class="tabs-panel">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb
deleted file mode 100644 (file)
index 72303b0..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<p>
-  <b>message('name'):</b>
-  <%=h @profile.name %>
-</p>
-
-<p>
-  <b>message('active'):</b>
-  <%=h @profile.active %>
-</p>
-
-
-<%= link_to message('edit'), edit_profile_path(@profile) %> |
-<%= link_to message('back'), profiles_path %>
index 9d3e2e7805e04e09044dc5a1e09296ec1d76015a..0dd282703776891d575fd45d396f117af9bedaab 100644 (file)
@@ -31,8 +31,6 @@
   }
 </script>
 
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
-
 <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Coding rules'} %>
 
 <% enable_modification = is_admin? %>
index df7dadddd53500e1efd9780b1888d610296d8e5a..85d36ff3970252b54e17f4d3be5361aed1ab4427 100644 (file)
@@ -123,7 +123,7 @@ body, a {
   margin: 0;
   background: #EFEFEF url("../images/bc-gray.png") no-repeat left;
   border-bottom: 1px solid #CCC;
-  padding: 0 10px 0 20px;
+  padding: 0 10px 0 25px;
 }
 
 #bc li.first {