From: Fabrice Bellingard Date: Wed, 24 Aug 2011 13:00:07 +0000 (+0200) Subject: SONAR-2702 New "Exclusions" service in the "CONFIGURATION" section X-Git-Tag: 2.11^2~131 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=89391aba6ca7a49a24fd402f92d5875d51138397;p=sonarqube.git SONAR-2702 New "Exclusions" service in the "CONFIGURATION" section --- diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index a61de34dc63..c0754fd8e2f 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -278,6 +278,8 @@ manual_measures.page=Manual Measures my_profile.page=My Profile project_roles.page=Project Roles project_settings.page=Settings +project_links.page=Links +project_exclusions.page=Exclusions quality_profiles.page=Quality Profiles reviews.page=Reviews settings.page=General Settings diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 1ad83db4518..fe22aa979cd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -37,6 +37,16 @@ class ProjectController < ApplicationController redirect_to_default end + def links + @project=Project.by_key(params[:id]) + return access_denied unless is_admin?(@project) + + @snapshot=@project.last_snapshot + if !@project.project? + redirect_to :action => 'index', :id => params[:id] + end + end + def set_links project = Project.by_key(params[:project_id]) return access_denied unless is_admin?(project) @@ -60,9 +70,10 @@ class ProjectController < ApplicationController project.save! flash[:notice] = 'Links updated.' - redirect_to :action => 'settings', :id => project.id + redirect_to :action => 'links', :id => project.id end + def settings @project=Project.by_key(params[:id]) return access_denied unless is_admin?(@project) @@ -102,6 +113,16 @@ class ProjectController < ApplicationController end + def exclusions + @project=Project.by_key(params[:id]) + return access_denied unless is_admin?(@project) + + @snapshot=@project.last_snapshot + if !@project.project? && !@project.module? + redirect_to :action => 'index', :id => params[:id] + end + end + def set_exclusions @project = Project.find(params[:id]) return access_denied unless is_admin?(@project) @@ -114,7 +135,7 @@ class ProjectController < ApplicationController Property.set('sonar.exclusions', patterns.collect{|x| x.strip}.join(','), @project.id) end flash[:notice]='Filters added' - redirect_to :action => 'settings', :id => @project.id + redirect_to :action => 'exclusions', :id => @project.id end def delete_exclusions @@ -123,7 +144,7 @@ class ProjectController < ApplicationController Property.clear('sonar.exclusions', @project.id) flash[:notice]='Filters deleted' - redirect_to :action => 'settings', :id => @project.id + redirect_to :action => 'exclusions', :id => @project.id end protected diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 871641fa03a..587c367f4ca 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -54,6 +54,12 @@ <% if (@project.project? || @project.module?) %>
  • <%= message('project_settings.page') -%>
  • <% end %> + <% if (@project.project? || @project.module?) %> +
  • <%= message('project_exclusions.page') -%>
  • + <% end %> + <% if (@project.project?) %> +
  • <%= message('project_links.page') -%>
  • + <% end %> <% if (@project.project? || @project.view? || @project.subview?) %>
  • <%= message('project_roles.page') -%>
  • <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/exclusions.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/exclusions.html.erb new file mode 100644 index 00000000000..19161bb8b50 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/exclusions.html.erb @@ -0,0 +1,58 @@ +

    Exclude sources from code analysis

    +
    +
    + + +
    +

    Changes will be applied during next code analysis.

    + <% form_for( 'set_exclusions', :url => { :action => 'set_exclusions', :id => @project.id } ) do |form| + pattern_index=0 + %> + + <% patterns = Property.value('sonar.exclusions', @project.id, '').split(',') + patterns.each do |pattern| + %> + + + + <% pattern_index += 1 + end + %> + + + +
    + +
    + +
    +
    +
    • com/mycompany/**/*.java
    • **/*Dummy.java
    +
    + <%= submit_tag( "Save filters", :id => 'submit_exclusions') %> + <%= link_to 'Delete all filters', {:action => 'delete_exclusions', :id => @project.id}, :method => 'POST', :confirm => "Are you sure you want to delete all exclusion filters ?", :id => 'delete_exclusions' %> +
    + <% end %> +
    + +
    +
    +

    Wildcards

    + + + + + + + + + + + + + + +
    *Match zero or more characters
    **Match zero or more directories
    ?Match a single character
    +
    +
    +
    \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/links.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/links.html.erb new file mode 100644 index 00000000000..727687e91d9 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/links.html.erb @@ -0,0 +1,88 @@ +

    Project links

    +
    + \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings.html.erb index 16f30eb7022..c361a478aeb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings.html.erb @@ -1,12 +1,8 @@
    <%= render :partial => 'project/settings/plugins' %> -
    -<%= render :partial => 'project/settings/exclusions' %> <% if @project.project? %>
    -<%= render :partial => 'project/settings/links' %> -
    <%= render :partial => 'project/settings/delete_project' %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_exclusions.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_exclusions.html.erb deleted file mode 100644 index b2208db0f2b..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_exclusions.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -

    Exclude sources from code analysis

    -
    - - -
    -

    Changes will be applied during next code analysis.

    - <% form_for( 'set_exclusions', :url => { :action => 'set_exclusions', :id => @project.id } ) do |form| - pattern_index=0 - %> - - <% patterns = Property.value('sonar.exclusions', @project.id, '').split(',') - patterns.each do |pattern| - %> - - - - <% pattern_index += 1 - end - %> - - - -
    - -
    - -
    -
    -
    • com/mycompany/**/*.java
    • **/*Dummy.java
    -
    - <%= submit_tag( "Save filters", :id => 'submit_exclusions') %> - <%= link_to 'Delete all filters', {:action => 'delete_exclusions', :id => @project.id}, :method => 'POST', :confirm => "Are you sure you want to delete all exclusion filters ?", :id => 'delete_exclusions' %> -
    - <% end %> -
    - -
    -
    -

    Wildcards

    - - - - - - - - - - - - - - -
    *Match zero or more characters
    **Match zero or more directories
    ?Match a single character
    -
    -
    -
    \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_links.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_links.html.erb deleted file mode 100644 index 8f79d83807e..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_links.html.erb +++ /dev/null @@ -1,87 +0,0 @@ -

    Project links

    - \ No newline at end of file