summaryrefslogtreecommitdiff
path: root/app
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-08 00:09:26 +0000
commit93af1af67fc6af2805f3342aed1fc15a4360870d (patch)
tree5064b0355d44be4ad9d166b876e1176752f4af2b /app
parentef15668d8214e8cce5732525c872d5b8f57e337a (diff)
downloadgitlab-ce-93af1af67fc6af2805f3342aed1fc15a4360870d.tar.gz
Hides Triggers if integration only has one event
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
Diffstat (limited to 'app')
-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