summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2013-09-27 16:01:54 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2013-09-30 15:44:52 +0200
commitdee90c9cf4cece22fc8744d2d275d047eeb0bcda (patch)
tree6b922a840e6b2075e22a72c1b3f4e774d84683d2
parent1ed170a10d9e45037feba2bb40f3a3c23b74cf89 (diff)
downloadsonarqube-dee90c9cf4cece22fc8744d2d275d047eeb0bcda.tar.gz
sonarqube-dee90c9cf4cece22fc8744d2d275d047eeb0bcda.zip
SONAR-4712 Ensure most pages work without snapshot
Add message for pages available to empty (provisioned) projects Modify layouts that don't depend explicitly on last snapshot Hide 'Tools' section from the navigation sidebar on empty projects Ensure 'Tools' section is available when last snapshot exists
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb92
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb3
10 files changed, 77 insertions, 60 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index e1f4a99751d..5dc68304c8b 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -1716,6 +1716,7 @@ bulk_deletion.delete_all_ghosts=Delete all ghosts
#------------------------------------------------------------------------------
provisioning.missing.key=Key is missing
provisioning.missing.name=Name is missing
+provisioning.no_analysis=No analysis has been performed since creation. The only available section is configuration.
#------------------------------------------------------------------------------
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
index 579e250b930..bb4392c3db0 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
@@ -77,8 +77,9 @@ class ActionPlansController < ApplicationController
def load_resource
@resource=Project.by_key(params[:id])
- return redirect_to home_path unless @resource
+ return redirect_to(home_path) unless @resource
access_denied unless has_role?(:admin, @resource)
+ @snapshot=@resource.last_snapshot
end
def load_action_plans
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
index 0c13f71d1e2..f24b4314c37 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
@@ -234,7 +234,6 @@ class ApplicationController < ActionController::Base
@resource=@resource.permanent_resource
@snapshot=@resource.last_snapshot
- not_found("Snapshot not found") unless @snapshot
access_denied unless has_role?(role, @resource)
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
index 6ec1fe7f223..92819c4ce0b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
@@ -187,7 +187,7 @@ class DashboardController < ApplicationController
@resource=@resource.permanent_resource
@snapshot=@resource.last_snapshot
- return project_not_found unless @snapshot
+ return project_not_analyzed unless @snapshot
access_denied unless has_role?(:user, @resource)
@@ -200,6 +200,10 @@ class DashboardController < ApplicationController
redirect_to :action => :index
end
+ def project_not_analyzed
+ redirect_to :controller => :project, :action => :settings, :id => @resource
+ end
+
def load_authorized_widget_definitions
@authorized_widget_definitions=java_facade.getWidgets().select do |widget|
roles = widget.getUserRoles()
@@ -209,13 +213,13 @@ class DashboardController < ApplicationController
def load_widget_definitions(filter_on_category)
@widget_definitions=java_facade.getWidgets().sort {|w1,w2| widgetL10nName(w1) <=> widgetL10nName(w2)}
-
+
@widget_categories=@widget_definitions.map(&:getWidgetCategories).flatten.uniq.sort
unless filter_on_category.blank?
@widget_definitions=@widget_definitions.select { |definition| definition.getWidgetCategories().to_a.include?(filter_on_category) }
end
end
-
+
def widgetL10nName(widget)
Api::Utils.message('widget.' + widget.id + '.name')
end
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 cc4d9901857..5fc629a33e4 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
@@ -79,6 +79,7 @@ class ProjectController < ApplicationController
def profile
require_parameters :id
@project=get_current_project_for_profile(params[:id])
+ @snapshot=@project.last_snapshot
end
# POST /project/set_profile?id=<project id>&language=<language>[&profile_id=<profile id>]
@@ -109,6 +110,7 @@ class ProjectController < ApplicationController
def key
@project = get_current_project(params[:id])
+ @snapshot = @project.last_snapshot
end
def update_key
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
index 3ada58fecef..d0787d925e3 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
@@ -26,6 +26,7 @@ class ProjectRolesController < ApplicationController
def index
@project=Project.by_key(params[:id])
access_denied unless is_admin?(@project)
+ @snapshot=@project.last_snapshot
end
end
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 4846e47b609..2ef018270a4 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
@@ -77,6 +77,8 @@
<a href="<%= ApplicationController.root_context -%>/dashboard/index/<%= @project.id -%>?did=<%= active_dashboard.dashboard_id -%><%= "&"+period_param if period_param -%>"><%= h active_dashboard.dashboard.name(true) -%></a>
</li>
<% end %>
+
+ <% if @snapshot %>
<li class="spacer"></li>
<li class="sidebar-title"><%= message('sidebar.tools') -%></li>
<li class="<%= 'active' if request.request_uri.include?('/components/index') -%>">
@@ -85,24 +87,24 @@
<li class="<%= 'active' if request.request_uri.include?('/drilldown/issues') -%>">
<a href="<%= ApplicationController.root_context -%>/drilldown/issues/<%= @project.id -%><%= "?"+period_param if period_param -%>"><%= message('issues_drilldown.page') -%></a>
</li>
- <% project_metrics = @project.last_snapshot.metric_keys.to_java(:string) if @project.last_snapshot
- controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, project_metrics).each do |page|
- page_url = (page.isController() ? "#{page.getId()}?id=#{@project.id}" : "/plugins/resource/#{@project.id}?page=#{page.getId()}")
- %>
+ <% project_metrics = @project.last_snapshot.metric_keys.to_java(:string) if @project.last_snapshot
+ controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, project_metrics).each do |page|
+ page_url = (page.isController() ? "#{page.getId()}?id=#{@project.id}" : "/plugins/resource/#{@project.id}?page=#{page.getId()}")
+ %>
<li class="<%= 'active' if request.request_uri.include?(page_url) -%>">
<a href="<%= ApplicationController.root_context -%><%= page_url -%>"><%= h message(page.getId() + '.page', :default => page.getTitle()) -%></a>
</li>
- <% end %>
+ <% end %>
<li class="<%= 'active' if controller.controller_path=='cloud' -%>">
<a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>"><%= message('clouds.page') -%></a>
</li>
- <% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'comparable') %>
+ <% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'comparable') %>
<li class="<%= 'active' if request.request_uri.include?('/comparison/index') -%>">
<a href="<%= ApplicationController.root_context -%>/comparison/index?resource=<%= @project.key -%>"><%= message('comparison.page') -%></a>
</li>
+ <% end %>
<% end %>
-
<% elsif selected_section==Navigation::SECTION_CONFIGURATION %>
<% if is_admin? %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
index c0023528bf9..8644fb5769e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
@@ -1,5 +1,5 @@
-<%
- if @snapshot.root?
+<%
+ if !@snapshot || @snapshot.root?
resource_name = message('qualifier.' + @project.qualifier)
delete_resource_message = message('project_deletion.delete_resource', :params => resource_name)
%>
@@ -22,9 +22,9 @@
<%= message('project_deletion.operation_cannot_be_undone') -%>
<br/>
- <%= submit_tag delete_resource_message, :id => 'delete_resource', :class => 'action red-button',
+ <%= submit_tag delete_resource_message, :id => 'delete_resource', :class => 'action red-button',
:confirm => message('project_deletion.delete_resource_confirmation', :params => resource_name) %>
</form>
</div>
</div>
-<% end %> \ No newline at end of file
+<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
index 09317d0a1e1..005c2ba322d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
@@ -1,4 +1,10 @@
-<% if @snapshot.root? %>
+<h1><%= message('project_history.page') -%></h1>
+
+<% if !@snapshot %>
+
+<p class="info"><%= message('provisioning.no_analysis') -%></p>
+
+<% elsif @snapshot.root? %>
<style>
.snapshot .edit_actions a {
visibility: hidden;
@@ -16,8 +22,6 @@
}
</style>
-<h1><%= message('project_history.page') -%></h1>
-
<p style="margin: 15px 0px">
<%= message('project_history.description') -%>
</p>
@@ -37,7 +41,7 @@
</tr>
</thead>
<tbody>
- <%
+ <%
current_year = nil
current_month = nil
@snapshots.each_with_index do |snapshot, index|
@@ -48,15 +52,15 @@
other_events = snapshot.events.select{|e| e.category!=EventCategory::KEY_VERSION && e.category!=EventCategory::KEY_ALERT && e.category!=EventCategory::KEY_PROFILE}
%>
<tr class="<%= cycle 'even','odd' -%> hoverable snapshot">
-
+
<td class="thin nowrap"><b><%= time.year unless time.year == current_year -%></b></td>
-
+
<td class="thin nowrap"><b><%= l(time, :format => '%B').capitalize unless time.month == current_month -%></b></td>
<td class="thin nowrap"><%= l(time, :format => '%d') -%></td>
-
+
<td class="thin nowrap"><%= l(time, :format => '%H:%M') -%></td>
-
+
<td class="thin nowrap" style="padding-left: 20px;">
<table class="width100">
<tr id="version_<%= index -%>">
@@ -65,9 +69,9 @@
<td class="small edit_actions" style="padding-left:20px">
<a id="version_<%= index -%>_change" href="#" onclick="$j('#version_<%= index -%>').hide();$j('#version_<%= index -%>_form').show();$j('#version_name_<%= index -%>').focus();return false;"><%= message('project_history.rename_version') -%></a>
<% if version_event && !snapshot.islast? %>
- <%= link_to( message('project_history.remove_version'),
- { :action => 'delete_version', :sid => snapshot.id},
- :confirm => message('project_history.do_you_want_to_remove_version', :params => version_event.name) ) -%>
+ <%= link_to( message('project_history.remove_version'),
+ { :action => 'delete_version', :sid => snapshot.id},
+ :confirm => message('project_history.do_you_want_to_remove_version', :params => version_event.name) ) -%>
<% end %>
</td>
<% else %>
@@ -79,7 +83,7 @@
<tr id="version_<%= index -%>_form" style="display:none;">
<td coslpan="2" class="admin">
<% form_tag( {:action => 'update_version', :sid => snapshot.id }) do -%>
- <input id="version_name_<%= index -%>" name="version_name" type="text" value="<%= version_event ? version_event.name : '' -%>"
+ <input id="version_name_<%= index -%>" name="version_name" type="text" value="<%= version_event ? version_event.name : '' -%>"
onKeyUp="if (this.value=='') $j('#save_version_<%= index -%>').disabled='true'; else $j('#save_version_<%= index -%>').disabled='';"/>
<%= submit_tag message('save'), :id => 'save_version_' + index.to_s %>
<a href="#" onclick="$j('#version_<%= index -%>').show();$j('#version_<%= index -%>_form').hide();"><%= message('cancel') -%></a>
@@ -88,50 +92,50 @@
</tr>
</table>
</td>
-
+
<td class="thin nowrap" style="padding-left: 20px;">
<table class="width100">
- <%
+ <%
other_events.each_with_index do |event, index2|
- event_index = index.to_s + '-' + index2.to_s
+ event_index = index.to_s + '-' + index2.to_s
%>
- <tr id="event_<%= event_index -%>">
- <td class="width100"><%= event.name -%></td>
- <td class="small edit_actions" style="padding-left:20px">
+ <tr id="event_<%= event_index -%>">
+ <td class="width100"><%= event.name -%></td>
+ <td class="small edit_actions" style="padding-left:20px">
<a id="event_<%= event_index -%>_change" href="#" onclick="$j('#event_<%= event_index -%>').hide();$j('#event_<%= event_index -%>_form').show();$j('#event_name_<%= event_index -%>').focus();return false;"><%= message('project_history.rename_event') -%></a>
- <%= link_to( message('project_history.remove_version'),
- { :action => 'delete_event', :id => event.id},
- :confirm => message('project_history.do_you_want_to_remove_version', :params => event.name) ) -%>
- </td>
- </tr>
- <tr id="event_<%= event_index -%>_form" style="display:none;">
+ <%= link_to( message('project_history.remove_version'),
+ { :action => 'delete_event', :id => event.id},
+ :confirm => message('project_history.do_you_want_to_remove_version', :params => event.name) ) -%>
+ </td>
+ </tr>
+ <tr id="event_<%= event_index -%>_form" style="display:none;">
<td colspan="2" class="admin">
<% form_tag( {:action => 'update_event', :id => event.id }) do -%>
- <input id="event_name_<%= event_index -%>" name="event_name" type="text" value="<%= event.name -%>"
+ <input id="event_name_<%= event_index -%>" name="event_name" type="text" value="<%= event.name -%>"
onKeyUp="if (this.value=='') $j('#save_event_<%= event_index -%>').disabled='true'; else $j('#save_event_<%= event_index -%>').disabled='';"/>
<%= submit_tag message('save'), :id => 'save_event_' + event_index %>
<a href="#" onclick="$j('#event_<%= event_index -%>').show();$j('#event_<%= event_index -%>_form').hide();"><%= message('cancel') -%></a>
<% end %>
</td>
- </tr>
- <% end %>
- <tr id="create_event_<%= index -%>">
- <td colspan="2" class="create_actions">
- <span class="small">
+ </tr>
+ <% end %>
+ <tr id="create_event_<%= index -%>">
+ <td colspan="2" class="create_actions">
+ <span class="small">
<a id="create_event_<%= index -%>_change" href="#" onclick="$j('#create_event_<%= index -%>').hide();$j('#create_event_<%= index -%>_form').show();$j('#create_event_name_<%= index -%>').focus();return false;"><%= message('project_history.create_event') -%></a>
</span>
- </td>
- </tr>
- <tr id="create_event_<%= index -%>_form" style="display:none;">
- <td colspan="2" class="admin">
+ </td>
+ </tr>
+ <tr id="create_event_<%= index -%>_form" style="display:none;">
+ <td colspan="2" class="admin">
<% form_tag( {:action => 'create_event', :sid => snapshot.id }) do -%>
- <input id="create_event_name_<%= index -%>" name="event_name" type="text" value=""
+ <input id="create_event_name_<%= index -%>" name="event_name" type="text" value=""
onKeyUp="if (this.value=='') $j('#create_save_event_<%= index -%>').disabled='true'; else $j('#create_save_event_<%= index -%>').disabled='';"/>
<%= submit_tag message('save'), :id => 'create_save_event_' + index.to_s %>
<a href="#" onclick="$j('#create_event_<%= index -%>').show();$j('#create_event_<%= index -%>_form').hide();"><%= message('cancel') -%></a>
<% end %>
- </td>
- </tr>
+ </td>
+ </tr>
</table>
</td>
@@ -149,10 +153,10 @@
if snapshot.islast?
cell_content = "<b>" + message('project_history.last_snapshot') + "</b>"
else
- cell_content = button_to( message('project_history.delete_snapshot'),
- { :action => "delete_snapshot_history", :id => @project.id, :snapshot_id => snapshot.id },
- :class => 'action red-button',
- :confirm => message('project_history.are_you_sure_delete_snapshot_x', :params => l(time, :format => :long)) )
+ cell_content = button_to( message('project_history.delete_snapshot'),
+ { :action => "delete_snapshot_history", :id => @project.id, :snapshot_id => snapshot.id },
+ :class => 'action red-button',
+ :confirm => message('project_history.are_you_sure_delete_snapshot_x', :params => l(time, :format => :long)) )
end
%>
<%= cell_content -%>
@@ -160,10 +164,10 @@
</tr>
<%
current_year = time.year
- current_month = time.month
- end
+ current_month = time.month
+ end
%>
</tbody>
</table>
-<% end %> \ No newline at end of file
+<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb
index 323ea8e0e05..5809c89db54 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb
@@ -1,5 +1,8 @@
<div id="plugins">
<h1 class="marginbottom10"><%= message(@resource ? 'project_settings.page' : 'settings.page') -%></h1>
+ <% if @resource and !@snapshot %>
+ <p class="info marginbottom10"><%= message('provisioning.no_analysis') -%></p>
+ <% end %>
<table width="100%">
<tr>