aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-01-09 16:56:43 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-01-09 16:56:43 +0100
commit3f0b47d2b8a96a8465b2861eb8ce14cceefdb4b9 (patch)
treec574eabe828e00a60785a75db7d41c8a50d84a3c /server/sonar-web
parent14e00a716f783b926027d57350b6c8a1af34748c (diff)
parentdbddd10fdd42d1a8b09c393a1a6a218affb4c646 (diff)
downloadsonarqube-3f0b47d2b8a96a8465b2861eb8ce14cceefdb4b9.tar.gz
sonarqube-3f0b47d2b8a96a8465b2861eb8ce14cceefdb4b9.zip
Merge remote-tracking branch 'origin/branch-5.0'
Conflicts: server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb10
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb19
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb11
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb3
4 files changed, 14 insertions, 29 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
index 9e26b80df1f..cfd97e37cb5 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
@@ -71,20 +71,16 @@ class Api::ProjectsController < Api::ApiController
# POST /api/projects/create?key=<key>&name=<name>
#
# -- Example
- # curl -v -u admin:admin -X POST 'http://localhost:9000/api/projects/create?key=project1&name=Project%20One'
+ # curl -v -u admin:admin -X POST 'http://localhost:9000/api/projects/create?key=project1&name=Project%20One&branch=origin/master'
#
# since 4.0
#
def create
verify_post_request
require_parameters :key, :name
- access_denied unless has_role?("provisioning")
- key = params[:key]
- name = params[:name]
- Internal.component_api.createComponent(key, name, 'TRK')
- Internal.permissions.applyDefaultPermissionTemplate(key)
- result = Project.by_key(key)
+ id = Internal.component_api.createComponent(params[:key], params[:branch], params[:name], nil)
+ result = Project.find(id.to_i)
respond_to do |format|
format.json { render :json => jsonp(to_json_hash(result)) }
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
index 4eb61160379..1b91cc25eca 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb
@@ -33,34 +33,23 @@ class ProvisioningController < ApplicationController
) { |p| p.key }
end
- def create_or_update
+ def create
verify_post_request
- access_denied unless has_role?("provisioning")
@id = params[:id]
@key = params[:key]
@name = params[:name]
+ @branch = params[:branch]
begin
bad_request('provisioning.missing.key') if @key.blank?
bad_request('provisioning.missing.name') if @name.blank?
- if @id.nil? or @id.empty?
- Internal.component_api.createComponent(@key, @name, 'TRK')
- begin
- Internal.permissions.applyDefaultPermissionTemplate(@key)
- rescue
- # Programmatic transaction rollback
- Java::OrgSonarServerUi::JRubyFacade.getInstance().deleteResourceTree(@key)
- raise
- end
- else
- Internal.component_api.updateComponent(@id.to_i, @key, @name)
- end
+ Internal.component_api.createComponent(@key, @branch, @name, nil)
redirect_to :action => 'index'
rescue Exception => e
flash.now[:error]= Api::Utils.message(e.message)
- render :partial => 'create_form', :id => @id, :key => @key, :name => @name, :status => 400
+ render :partial => 'create_form', :key => @key, :branch => @branch, :name => @name, :status => 400
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb
index b96dbce2506..5b2bd449e40 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/_create_form.html.erb
@@ -1,8 +1,7 @@
-<form id="create-resource-form" method="post" action="<%= ApplicationController.root_context -%>/provisioning/create_or_update">
- <input type="hidden" name="id" value="<%= @id -%>"/>
+<form id="create-resource-form" method="post" action="<%= ApplicationController.root_context -%>/provisioning/create">
<fieldset>
<div class="modal-head">
- <h2><%= message((@id.nil? || @id.empty?) ? 'qualifiers.new.TRK' : 'qualifiers.update.TRK') -%></h2>
+ <h2><%= message('qualifiers.new.TRK') -%></h2>
</div>
<div class="modal-body">
<% if flash.now[:error] %>
@@ -13,12 +12,16 @@
<input id="key" name="key" value="<%= h @key -%>" type="text" size="50" maxlength="400" autofocus="autofocus"/>
</div>
<div class="modal-field">
+ <label for="branch"><%= h message('branch') -%></label>
+ <input id="branch" name="branch" value="<%= h @branch -%>" 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="<%= h @name -%>" type="text" size="50" maxlength="256" value=""/>
</div>
</div>
<div class="modal-foot">
- <input type="submit" value="<%= h message((@id.nil? || @id.empty?) ? 'qualifiers.create.TRK' : 'qualifiers.update.TRK') -%>" id="save-submit"/>
+ <input type="submit" value="<%= h message('qualifiers.create.TRK') -%>" id="save-submit"/>
<a href="#" onclick="return closeModalWindow()" id="save-cancel"><%= h message('cancel') -%></a>
</div>
</fieldset>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
index 39ae046435f..633629c0a24 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/provisioning/index.html.erb
@@ -33,9 +33,6 @@
<td><%= h resource.name -%></td>
<td><%= format_datetime(resource.created_at) -%></td>
<td class="operations">
- <%= link_to message('edit'), {:action => :create_form, :id => resource.id, :key => resource.key, :name => resource.name},
- {:id => "edit-#{resource.key.parameterize}", :class => 'open-modal link-action'} -%>
- &nbsp;
<%= link_to message('delete'), {:action => :delete_form, :id => resource.id},
{:id => "delete-#{resource.key.parameterize}", :class => 'open-modal link-action link-red'} -%>
</td>