summaryrefslogtreecommitdiff
path: root/app/views/projects/services/_form.html.haml
blob: ce6b7a0737a8c0fa344687710d8f2d2f0cae0666 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
%h3.page-title
  = @service.title
  = boolean_to_icon @service.activated?

%p= @service.description

.back-link
  = link_to namespace_project_services_path(@project.namespace, @project) do
    ← to services

%hr

= form_for(@service, as: :service, url: namespace_project_service_path(@project.namespace, @project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f|
  - if @service.errors.any?
    .alert.alert-danger
      %ul
        - @service.errors.full_messages.each do |msg|
          %li= msg

  - if @service.help.present?
    .well
      = preserve do
        = markdown @service.help

  .form-group
    = f.label :active, "Active", class: "control-label"
    .col-sm-10
      = f.check_box :active

  - if @service.supported_events.length > 1
    .form-group
      = f.label :url, "Trigger", class: 'control-label'
      .col-sm-10
        - if @service.supported_events.include?("push")
          %div
            = f.check_box :push_events, class: 'pull-left'
            .prepend-left-20
              = f.label :push_events, class: 'list-label' do
                %strong Push events
              %p.light
                This url will be triggered by a push to the repository
        - if @service.supported_events.include?("tag_push")
          %div
            = f.check_box :tag_push_events, class: 'pull-left'
            .prepend-left-20
              = f.label :tag_push_events, class: 'list-label' do
                %strong Tag push events
              %p.light
                This url will be triggered when a new tag is pushed to the repository
        - if @service.supported_events.include?("note")
          %div
            = f.check_box :note_events, class: 'pull-left'
            .prepend-left-20
              = f.label :note_events, class: 'list-label' do
                %strong Comments
              %p.light
                This url will be triggered when someone adds a comment
        - if @service.supported_events.include?("issue")
          %div
            = f.check_box :issues_events, class: 'pull-left'
            .prepend-left-20
              = f.label :issues_events, class: 'list-label' do
                %strong Issues events
              %p.light
                This url will be triggered when an issue is created
        - if @service.supported_events.include?("merge_request")
          %div
            = f.check_box :merge_requests_events, class: 'pull-left'
            .prepend-left-20
              = f.label :merge_requests_events, class: 'list-label' do
                %strong Merge Request events
              %p.light
                This url will be triggered when a merge request is created

  - @service.fields.each do |field|
    - name = field[:name]
    - title = field[:title] || name.humanize
    - value = service_field_value(field[:type], @service.send(name))
    - type = field[:type]
    - placeholder = field[:placeholder]
    - choices = field[:choices]
    - default_choice = field[:default_choice]
    - help = field[:help]

    .form-group
      = f.label name, title, class: "control-label"
      .col-sm-10
        - 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, placeholder: value, class: 'form-control'
        - if help
          %span.help-block= help

  .form-actions
    = f.submit 'Save', class: 'btn btn-save'
     
    - if @service.valid? && @service.activated?
      - disabled = @service.can_test? ? '':'disabled'
      = link_to 'Test settings', test_namespace_project_service_path(@project.namespace, @project, @service.to_param), class: "btn #{disabled}"