summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-06 23:20:01 +0000
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-07 16:25:19 +0000
commit8a9b4cfd34305c1f13eb4a071e31ed820d387c49 (patch)
tree4c4e64c630180ba6ddf14eefedcc9af1998700e8
parent7f39b0f78c2a811ddf2f6d04c8016dca90bf2f1c (diff)
downloadgitlab-ce-ce-jej/github-project-service-for-ci.tar.gz
Hides Triggers if integration only has one eventce-jej/github-project-service-for-ci
Removes confusing/unnecessary checkboxes when trying to configure an integration. If there is only one supported event we don't need to allow these to be individually disabled since the integration can be disabled instead. E.g. Project Integrations for GitHub, Bugzilla, Asana, Pipeline emails and Gemnasium Allows integrations to override which triggers are configurable
-rw-r--r--app/models/service.rb11
-rw-r--r--app/views/shared/_service_settings.html.haml4
2 files changed, 13 insertions, 2 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index 369cae2e85f..99bf757ae44 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -129,6 +129,17 @@ class Service < ActiveRecord::Base
fields
end
+ def configurable_events
+ events = self.class.supported_events
+
+ # No need to disable individual triggers when there is only one
+ if events.count == 1
+ []
+ else
+ events
+ end
+ end
+
def supported_events
self.class.supported_events
end
diff --git a/app/views/shared/_service_settings.html.haml b/app/views/shared/_service_settings.html.haml
index 61b39afb5d4..355b3ac75ae 100644
--- a/app/views/shared/_service_settings.html.haml
+++ b/app/views/shared/_service_settings.html.haml
@@ -13,12 +13,12 @@
.col-sm-10
= form.check_box :active, disabled: disable_fields_service?(@service)
- - if @service.supported_events.present?
+ - if @service.configurable_events.present?
.form-group
= form.label :url, "Trigger", class: 'control-label'
.col-sm-10
- - @service.supported_events.each do |event|
+ - @service.configurable_events.each do |event|
%div
= form.check_box service_event_field_name(event), class: 'pull-left'
.prepend-left-20