2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-06 16:52:00 -04:00
|
|
|
module ServicesHelper
|
2018-04-03 07:00:33 -04:00
|
|
|
def service_event_description(event)
|
|
|
|
case event
|
|
|
|
when "push", "push_events"
|
|
|
|
"Event will be triggered by a push to the repository"
|
|
|
|
when "tag_push", "tag_push_events"
|
|
|
|
"Event will be triggered when a new tag is pushed to the repository"
|
|
|
|
when "note", "note_events"
|
|
|
|
"Event will be triggered when someone adds a comment"
|
|
|
|
when "confidential_note", "confidential_note_events"
|
|
|
|
"Event will be triggered when someone adds a comment on a confidential issue"
|
|
|
|
when "issue", "issue_events"
|
|
|
|
"Event will be triggered when an issue is created/updated/closed"
|
|
|
|
when "confidential_issue", "confidential_issues_events"
|
|
|
|
"Event will be triggered when a confidential issue is created/updated/closed"
|
|
|
|
when "merge_request", "merge_request_events"
|
|
|
|
"Event will be triggered when a merge request is created/updated/merged"
|
|
|
|
when "pipeline", "pipeline_events"
|
|
|
|
"Event will be triggered when a pipeline status changes"
|
|
|
|
when "wiki_page", "wiki_page_events"
|
|
|
|
"Event will be triggered when a wiki page is created/updated"
|
|
|
|
when "commit", "commit_events"
|
|
|
|
"Event will be triggered when a commit is created/updated"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-06 16:52:00 -04:00
|
|
|
def service_event_field_name(event)
|
2016-08-30 17:39:25 -04:00
|
|
|
event = event.pluralize if %w[merge_request issue confidential_issue].include?(event)
|
2016-07-06 16:52:00 -04:00
|
|
|
"#{event}_events"
|
|
|
|
end
|
2017-01-12 17:33:04 -05:00
|
|
|
|
2018-01-04 04:33:51 -05:00
|
|
|
def service_save_button(service)
|
2019-10-29 08:06:40 -04:00
|
|
|
button_tag(class: 'btn btn-success', type: 'submit', disabled: service.deprecated?, data: { qa_selector: 'save_changes_button' }) do
|
2018-01-04 04:33:51 -05:00
|
|
|
icon('spinner spin', class: 'hidden js-btn-spinner') +
|
|
|
|
content_tag(:span, 'Save changes', class: 'js-btn-label')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable_fields_service?(service)
|
2019-08-01 02:20:35 -04:00
|
|
|
!current_controller?("admin/services") && service.deprecated?
|
2018-01-04 04:33:51 -05:00
|
|
|
end
|
|
|
|
|
2017-01-12 17:33:04 -05:00
|
|
|
extend self
|
2016-07-06 16:52:00 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
ServicesHelper.prepend_if_ee('EE::ServicesHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
|
|
|
|
|
|
|
# The methods in `EE::ServicesHelper` should be available as both instance and
|
|
|
|
# class methods.
|
|
|
|
ServicesHelper.extend_if_ee('EE::ServicesHelper')
|