Welcome to mirror list, hosted at ThFree Co, Russian Federation.

services_controller.rb « admin « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 76a938c5fe4fd8587c4a75659946dad255edfe2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Admin::ServicesController < Admin::ApplicationController
  before_filter :service, only: [:edit, :update]

  def index
    @services = services_templates
  end

  def edit
    unless service.present?
      redirect_to admin_application_settings_services_path,
        alert: "Service is unknown or it doesn't exist"
    end
  end

  def update
    if service.update_attributes(application_services_params[:service])
      redirect_to admin_application_settings_services_path,
        notice: 'Application settings saved successfully'
    else
      render :edit
    end
  end

  private

  def services_templates
    templates = []

    Service.available_services_names.each do |service_name|
      service_template = service_name.concat("_service").camelize.constantize
      templates << service_template.where(template: true).first_or_create
    end

    templates
  end

  def service
    @service ||= Service.where(id: params[:id], template: true).first
  end

  def application_services_params
    params.permit(:id,
      service: [
        :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,
        :send_from_committer_email, :disable_diffs,
        :push_events, :tag_push_events, :note_events, :issues_events,
        :merge_requests_events
    ])
  end
end