summaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2013-09-25 18:29:37 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2013-09-26 14:21:47 +0200
commita0c84b3c8e9a31d409a0803dc248a649e3ce13e9 (patch)
tree54c765a0b8cfc0e6f40677fd7f0b02eb6f981dd2 /sonar-server/src
parent0cfee49fbfa1b5b0eac94fbb397a2a5f48117bc2 (diff)
downloadsonarqube-a0c84b3c8e9a31d409a0803dc248a649e3ce13e9.tar.gz
sonarqube-a0c84b3c8e9a31d409a0803dc248a649e3ce13e9.zip
SONAR-4711 Initial version of provisioning page in settings
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb35
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb30
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb65
6 files changed, 131 insertions, 19 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
index fb81864132d..3fd456cb3f5 100644
--- a/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
+++ b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
@@ -50,6 +50,7 @@ public class DefaultRubyComponentService implements RubyComponentService {
new ResourceDto()
.setKey(kee)
.setName(name)
+ .setLongName(name)
.setScope(scope)
.setQualifier(qualifier)
.setCreatedAt(new Date()));
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
index 7e2deb3eca1..4159c2c8d62 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
@@ -19,9 +19,10 @@
#
class ProvisioningController < ApplicationController
- SECTION=Navigation::SECTION_CONFIGURATION
-
before_filter :admin_required
+ verify :method => :delete, :only => [:delete], :redirect_to => {:action => :index}
+
+ SECTION=Navigation::SECTION_CONFIGURATION
def index
@tabs = provisionable_qualifiers
@@ -32,7 +33,35 @@ class ProvisioningController < ApplicationController
params['pageSize'] = 20
params['qualifiers'] = @selected_tab
- @query_results = Internal.component_api.findProvisioned(:qualifiers)
+ @query_result = Internal.component_api.findProvisionedProjects(params)
+ end
+
+ def create
+ verify_post_request
+ access_denied unless is_admin?
+ @key = params[:key]
+ @name = params[:name]
+ @qualifier = params[:qualifier]
+
+ begin
+ bad_request('provisioning.missing.key') if @key.blank?
+ bad_request('provisioning.missing.name') if @name.blank?
+
+ Internal.component_api.createComponent(@key, @name, 'PRJ', @qualifier)
+ Internal.permissions.applyDefaultPermissionTemplate(@key)
+
+ redirect_to :action => 'index'
+ rescue Exception => e
+ flash[:error]= Api::Utils.message(e.message)
+ render :partial => 'create_form', :qualifier => @qualifier, :key => @key, :name => @name, :status => 400
+ end
+ end
+
+ def create_form
+ @key = params[:key]
+ @name = params[:name]
+ @qualifier = params[:qualifier]
+ render :partial => 'create_form'
end
private
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb
index c618d86d29b..817ee0c470e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb
@@ -61,12 +61,16 @@
# ======== Path for resources ========
- if displayed_resource && displayed_resource.last_snapshot
- resources=[]
- s=displayed_resource.last_snapshot
- while (s!=nil) do
- resources.insert(0, s.project)
- s=s.parent
+ if displayed_resource
+ if displayed_resource.last_snapshot
+ resources=[]
+ s=displayed_resource.last_snapshot
+ while (s!=nil) do
+ resources.insert(0, s.project)
+ s=s.parent
+ end
+ else
+ resources = [displayed_resource]
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 6d5a385a75d..4846e47b609 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
@@ -85,7 +85,8 @@
<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>
- <% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, @project.last_snapshot.metric_keys.to_java(:string)).each do |page|
+ <% 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) -%>">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb
new file mode 100644
index 00000000000..1b4edee5e04
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb
@@ -0,0 +1,30 @@
+<form id="create-resource-form" method="post" action="<%= ApplicationController.root_context -%>/provisioning/create">
+ <input type="hidden" name="qualifier" value="<%= @qualifier -%>"/>
+ <fieldset>
+ <% if flash[:error] %>
+ <p class="error"><%= h flash[:error] -%></p>
+ <% end %>
+ <div class="modal-head">
+ <h2><%= message('qualifiers.new.' + @qualifier) -%></h2>
+ </div>
+ <div class="modal-body">
+ <div class="modal-field">
+ <label for="key"><%= h message('key') -%> <em class="mandatory">*</em></label>
+ <input id="key" name="key" value="<%= @key -%>" type="text" size="50" maxlength="400" autofocus="autofocus"/>
+ </div>
+ <div class="modal-field">
+ <label for="name"><%= h message('name') -%> <em class="mandatory">*</em></label>
+ <input id="name" name="name" value="<%= @name -%>" type="text" size="50" maxlength="256" value=""/>
+ </div>
+ </div>
+ <div class="modal-foot">
+ <input type="submit" value="<%= h message('qualifiers.create.' + @qualifier) -%>" id="save-submit"/>
+ <a href="#" onclick="return closeModalWindow()" id="save-cancel"><%= h message('cancel') -%></a>
+ </div>
+ </fieldset>
+</form>
+
+<script>
+ $j("#create-resource-form").modalForm();
+</script>
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
index 1639ec74647..652ebb56803 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
@@ -1,13 +1,60 @@
-<h1 class="marginbottom10"><%= message('provisioning.page') -%></h1>
+<div class="admin_page">
+ <ul style="float: right" class="horizontal">
+ <li class="marginleft10 add">
+ <%= link_to message('create'), {:action => :create_form, :qualifier => @selected_tab}, :id => "create-link-provisioning", :class => 'open-modal link-action' %>
+ </li>
+ </ul>
-<ul class="tabs">
-<% @tabs.each do |tab| %>
- <li>
- <a href="<%= url_for :action => 'index', :qualifiers => tab %>" <%= "class='selected'" if @selected_tab==tab -%> id="tab-<%= u tab -%>"><%= message('qualifiers.' + tab) -%></a>
- </li>
-<% end %>
-</ul>
+ <h1 class="marginbottom10"><%= message('provisioning.page') -%></h1>
-<div class="tabs-panel marginbottom10">
+ <ul class="tabs">
+ <% @tabs.each do |tab| %>
+ <li>
+ <a href="<%= url_for :action => 'index', :qualifiers => tab %>" <%= "class='selected'" if @selected_tab==tab -%> id="tab-<%= u tab -%>"><%= message('qualifiers.' + tab) -%></a>
+ </li>
+ <% end %>
+ </ul>
+
+ <div class="tabs-panel marginbottom10">
+
+ <%
+ found_resources_count = @query_result.paging.total
+ found_resources_ids = @query_result.components.map {|r| r.id.to_s}.join(',')
+ %>
+
+ <% if @query_result.components.empty? %>
+ <br/>
+ <%= message('no_results') -%>
+ <% else %>
+
+ <table class="data" id="provisioned-resources">
+ <thead>
+ <tr>
+ <th><%= message('name') -%> <span class="small gray"><%= message('key') -%></span></th>
+ <th><%= message('created') -%></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @query_result.components.each_with_index do |resource, index| %>
+ <tr id="<%= h @selected_tab -%>-<%= h resource.key -%>" class="<%= cycle 'even', 'odd' -%>">
+ <td>
+ <%= link_to h(resource.name), {:controller => :project, :action => :settings, :id => resource.key},
+ :id => "view-#{u resource.key}" %>
+ <span class="small gray"><%= h resource.key -%></span></td>
+ </td>
+ <td></td>
+ </tr>
+ <% end %>
+ </tbody>
+ <%= paginate_java(@query_result.paging, :colspan => 3, :id => 'resource-provisioning-foot', :include_loading_icon => true) { |label, page_id|
+ link_to(label, params.merge({:pageIndex => page_id}))
+ }
+ %>
+ </table>
+
+ <% end %>
+
+ </div>
</div>
+