Module: ServicesHelper

Extended by:
ServicesHelper
Included in:
Admin::ApplicationSettingsController, Admin::IntegrationsController, ServicesHelper
Defined in:
app/helpers/services_helper.rb

Instance Method Summary collapse

Instance Method Details

#fields_for_service(integration) ⇒ Object


105
106
107
# File 'app/helpers/services_helper.rb', line 105

def fields_for_service(integration)
  ServiceFieldSerializer.new(service: integration).represent(integration.global_fields).to_json
end

#group_level_integrations?Boolean

Returns:

  • (Boolean)

117
118
119
# File 'app/helpers/services_helper.rb', line 117

def group_level_integrations?
  @group.present? && Feature.enabled?(:group_level_integrations, @group, default_enabled: true)
end

#instance_level_integrations?Boolean

Returns:

  • (Boolean)

121
122
123
# File 'app/helpers/services_helper.rb', line 121

def instance_level_integrations?
  !Gitlab.com?
end

#integration_form_data(integration) ⇒ Object


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/helpers/services_helper.rb', line 78

def integration_form_data(integration)
  {
    id: integration.id,
    show_active: integration.show_active_box?.to_s,
    activated: (integration.active || integration.new_record?).to_s,
    type: integration.to_param,
    merge_request_events: integration.merge_requests_events.to_s,
    commit_events: integration.commit_events.to_s,
    enable_comments: integration.comment_on_event_enabled.to_s,
    comment_detail: integration.comment_detail,
    learn_more_path: integrations_help_page_path,
    trigger_events: trigger_events_for_service(integration),
    fields: fields_for_service(integration),
    inherit_from_id: integration.inherit_from_id,
    integration_level: integration_level(integration),
    editable: integration.editable?.to_s,
    cancel_path: scoped_integrations_path,
    can_test: integration.can_test?.to_s,
    test_path: scoped_test_integration_path(integration),
    reset_path: ''
  }
end

#integrations_help_page_pathObject


109
110
111
# File 'app/helpers/services_helper.rb', line 109

def integrations_help_page_path
  help_page_path('user/admin_area/settings/project_integration_management')
end

#project_jira_issues_integration?Boolean

Returns:

  • (Boolean)

113
114
115
# File 'app/helpers/services_helper.rb', line 113

def project_jira_issues_integration?
  false
end

#scoped_edit_integration_path(integration) ⇒ Object


58
59
60
61
62
63
64
65
66
# File 'app/helpers/services_helper.rb', line 58

def scoped_edit_integration_path(integration)
  if @project.present?
    edit_project_service_path(@project, integration)
  elsif @group.present?
    edit_group_settings_integration_path(@group, integration)
  else
    edit_admin_application_settings_integration_path(integration)
  end
end

#scoped_integration_path(integration) ⇒ Object


48
49
50
51
52
53
54
55
56
# File 'app/helpers/services_helper.rb', line 48

def scoped_integration_path(integration)
  if @project.present?
    project_service_path(@project, integration)
  elsif @group.present?
    group_settings_integration_path(@group, integration)
  else
    admin_application_settings_integration_path(integration)
  end
end

#scoped_integrations_pathObject


38
39
40
41
42
43
44
45
46
# File 'app/helpers/services_helper.rb', line 38

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

#scoped_test_integration_path(integration) ⇒ Object


68
69
70
71
72
73
74
75
76
# File 'app/helpers/services_helper.rb', line 68

def scoped_test_integration_path(integration)
  if @project.present?
    test_project_service_path(@project, integration)
  elsif @group.present?
    test_group_settings_integration_path(@group, integration)
  else
    test_admin_application_settings_integration_path(integration)
  end
end

#service_event_description(event) ⇒ Object


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
# File 'app/helpers/services_helper.rb', line 4

def service_event_description(event)
  case event
  when "push", "push_events"
    s_("ProjectService|Event will be triggered by a push to the repository")
  when "tag_push", "tag_push_events"
    s_("ProjectService|Event will be triggered when a new tag is pushed to the repository")
  when "note", "note_events"
    s_("ProjectService|Event will be triggered when someone adds a comment")
  when "confidential_note", "confidential_note_events"
    s_("ProjectService|Event will be triggered when someone adds a comment on a confidential issue")
  when "issue", "issue_events"
    s_("ProjectService|Event will be triggered when an issue is created/updated/closed")
  when "confidential_issue", "confidential_issue_events"
    s_("ProjectService|Event will be triggered when a confidential issue is created/updated/closed")
  when "merge_request", "merge_request_events"
    s_("ProjectService|Event will be triggered when a merge request is created/updated/merged")
  when "pipeline", "pipeline_events"
    s_("ProjectService|Event will be triggered when a pipeline status changes")
  when "wiki_page", "wiki_page_events"
    s_("ProjectService|Event will be triggered when a wiki page is created/updated")
  when "commit", "commit_events"
    s_("ProjectService|Event will be triggered when a commit is created/updated")
  when "deployment"
    s_("ProjectService|Event will be triggered when a deployment starts or finishes")
  when "alert"
    s_("ProjectService|Event will be triggered when a new, unique alert is recorded")
  end
end

#service_event_field_name(event) ⇒ Object


33
34
35
36
# File 'app/helpers/services_helper.rb', line 33

def service_event_field_name(event)
  event = event.pluralize if %w[merge_request issue confidential_issue].include?(event)
  "#{event}_events"
end

#trigger_events_for_service(integration) ⇒ Object


101
102
103
# File 'app/helpers/services_helper.rb', line 101

def trigger_events_for_service(integration)
  ServiceEventSerializer.new(service: integration).represent(integration.configurable_events).to_json
end