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
|
|
|
|
2019-11-26 07:06:18 -05:00
|
|
|
def service_event_action_field_name(action)
|
|
|
|
"#{action}_on_event_enabled"
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_action_title(action)
|
|
|
|
case action
|
|
|
|
when "comment"
|
|
|
|
s_("ProjectService|Comment")
|
|
|
|
else
|
|
|
|
action.humanize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_action_description(action)
|
|
|
|
case action
|
|
|
|
when "comment"
|
|
|
|
s_("ProjectService|Comment will be posted on each event")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-24 05:09:44 -04:00
|
|
|
def service_save_button
|
|
|
|
button_tag(class: 'btn btn-success', type: 'submit', 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
|
|
|
|
|
2020-03-26 02:08:40 -04:00
|
|
|
def scoped_integrations_path
|
|
|
|
if @project.present?
|
|
|
|
project_settings_integrations_path(@project)
|
|
|
|
elsif @group.present?
|
|
|
|
group_settings_integrations_path(@group)
|
|
|
|
else
|
|
|
|
integrations_admin_application_settings_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def scoped_integration_path(integration)
|
|
|
|
if @project.present?
|
2020-04-15 11:09:17 -04:00
|
|
|
project_service_path(@project, integration)
|
2020-03-26 02:08:40 -04:00
|
|
|
elsif @group.present?
|
|
|
|
group_settings_integration_path(@group, integration)
|
|
|
|
else
|
|
|
|
admin_application_settings_integration_path(integration)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:09:16 -04:00
|
|
|
def scoped_edit_integration_path(integration)
|
|
|
|
if @project.present?
|
|
|
|
edit_project_settings_integration_path(@project, integration)
|
|
|
|
elsif @group.present?
|
|
|
|
edit_group_settings_integration_path(@group, integration)
|
|
|
|
else
|
|
|
|
edit_admin_application_settings_integration_path(integration)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-26 02:08:40 -04:00
|
|
|
def scoped_test_integration_path(integration)
|
|
|
|
if @project.present?
|
|
|
|
test_project_settings_integration_path(@project, integration)
|
|
|
|
elsif @group.present?
|
|
|
|
test_group_settings_integration_path(@group, integration)
|
|
|
|
else
|
|
|
|
test_admin_application_settings_integration_path(integration)
|
|
|
|
end
|
|
|
|
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')
|