All services can have templates.
This commit is contained in:
parent
f7e9024535
commit
9f33898f7a
4 changed files with 26 additions and 14 deletions
|
@ -26,18 +26,14 @@ class Admin::ServicesController < Admin::ApplicationController
|
|||
def services_templates
|
||||
templates = []
|
||||
|
||||
allowed_templates.each do |service|
|
||||
service_template = service.constantize
|
||||
Service.available_services_names.each do |service|
|
||||
service_template = service.concat("_service").camelize.constantize
|
||||
templates << service_template.where(template: true).first_or_create
|
||||
end
|
||||
|
||||
templates
|
||||
end
|
||||
|
||||
def allowed_templates
|
||||
%w( JiraService RedmineService CustomIssueTrackerService )
|
||||
end
|
||||
|
||||
def service
|
||||
@service ||= Service.where(id: params[:id], template: true).first
|
||||
end
|
||||
|
@ -45,7 +41,11 @@ class Admin::ServicesController < Admin::ApplicationController
|
|||
def application_services_params
|
||||
params.permit(:id,
|
||||
service: [
|
||||
:title, :project_url, :description, :issues_url, :new_issue_url
|
||||
:title, :token, :type, :active, :api_key, :subdomain,
|
||||
:room, :recipients, :project_url, :webhook,
|
||||
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password,
|
||||
:build_key, :server, :teamcity_url, :build_type,
|
||||
:description, :issues_url, :new_issue_url, :restrict_to_branch
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -355,7 +355,7 @@ class Project < ActiveRecord::Base
|
|||
def build_missing_services
|
||||
services_templates = Service.where(template: true)
|
||||
|
||||
available_services_names.each do |service_name|
|
||||
Service.available_services_names.each do |service_name|
|
||||
service = find_service(services, service_name)
|
||||
|
||||
# If service is available but missing in db
|
||||
|
@ -377,11 +377,6 @@ class Project < ActiveRecord::Base
|
|||
list.find { |service| service.to_param == name }
|
||||
end
|
||||
|
||||
def available_services_names
|
||||
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla asana
|
||||
emails_on_push gemnasium slack pushover buildbox bamboo teamcity jira redmine custom_issue_tracker)
|
||||
end
|
||||
|
||||
def gitlab_ci?
|
||||
gitlab_ci_service && gitlab_ci_service.active
|
||||
end
|
||||
|
|
|
@ -98,6 +98,11 @@ class Service < ActiveRecord::Base
|
|||
self.category == :issue_tracker
|
||||
end
|
||||
|
||||
def self.available_services_names
|
||||
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla asana
|
||||
emails_on_push gemnasium slack pushover buildbox bamboo teamcity jira redmine custom_issue_tracker)
|
||||
end
|
||||
|
||||
def self.create_from_template(project_id, template)
|
||||
service = template.dup
|
||||
service.template = false
|
||||
|
|
|
@ -12,13 +12,25 @@
|
|||
|
||||
- @service.fields.each do |field|
|
||||
- name = field[:name]
|
||||
- value = @service.send(name) unless field[:type] == 'password'
|
||||
- type = field[:type]
|
||||
- placeholder = field[:placeholder]
|
||||
- choices = field[:choices]
|
||||
- default_choice = field[:default_choice]
|
||||
|
||||
.form-group
|
||||
= f.label name, class: "control-label"
|
||||
.col-sm-10
|
||||
= f.text_field name, class: "form-control", placeholder: placeholder
|
||||
- if type == 'text'
|
||||
= f.text_field name, class: "form-control", placeholder: placeholder
|
||||
- elsif type == 'textarea'
|
||||
= f.text_area name, rows: 5, class: "form-control", placeholder: placeholder
|
||||
- elsif type == 'checkbox'
|
||||
= f.check_box name
|
||||
- elsif type == 'select'
|
||||
= f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" }
|
||||
- elsif type == 'password'
|
||||
= f.password_field name, class: 'form-control'
|
||||
|
||||
.form-actions
|
||||
= f.submit 'Save', class: 'btn btn-save'
|
||||
|
|
Loading…
Reference in a new issue