Module: IntegrationsHelper
- Extended by:
- IntegrationsHelper
- Included in:
- Admin::ApplicationSettingsController, IntegrationsHelper, OperationsHelper, Profiles::SlacksController
- Defined in:
- app/helpers/integrations_helper.rb
Instance Method Summary collapse
- #add_to_slack_link(project, slack_app_id) ⇒ Object
- #gitlab_slack_application_data(projects) ⇒ Object
- #instance_level_integrations? ⇒ Boolean
-
#integration_event_description(integration, event) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity.
- #integration_event_field_name(event) ⇒ Object
-
#integration_event_title(event) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
- #integration_form_data(integration, project: nil, group: nil) ⇒ Object
- #integration_issue_type(issue_type) ⇒ Object
- #integration_list_data(integrations, group: nil, project: nil) ⇒ Object
- #integration_overrides_data(integration, project: nil, group: nil) ⇒ Object
- #integration_todo_target_type(target_type) ⇒ Object
- #integration_webhook_event_human_name(event) ⇒ Object
- #integrations_help_page_path ⇒ Object
- #project_jira_issues_integration? ⇒ Boolean
- #scoped_edit_integration_path(integration, project: nil, group: nil) ⇒ Object
- #scoped_integration_path(integration, project: nil, group: nil) ⇒ Object
- #scoped_integrations_path(project: nil, group: nil) ⇒ Object
- #scoped_overrides_integration_path(integration, options = {}) ⇒ Object
- #scoped_reset_integration_path(integration, group: nil) ⇒ Object
- #scoped_test_integration_path(integration, project: nil, group: nil) ⇒ Object
Instance Method Details
#add_to_slack_link(project, slack_app_id) ⇒ Object
225 226 227 228 229 230 231 232 233 234 |
# File 'app/helpers/integrations_helper.rb', line 225 def add_to_slack_link(project, slack_app_id) query = { scope: SlackIntegration::SCOPES.join(','), client_id: slack_app_id, redirect_uri: slack_auth_project_settings_slack_url(project), state: form_authenticity_token } "#{::Projects::SlackApplicationInstallService::SLACK_AUTHORIZE_URL}?#{query.to_query}" end |
#gitlab_slack_application_data(projects) ⇒ Object
236 237 238 239 240 241 242 243 244 245 |
# File 'app/helpers/integrations_helper.rb', line 236 def gitlab_slack_application_data(projects) { projects: (projects || []).to_json(only: [:id, :name], methods: [:avatar_url, :name_with_namespace]), sign_in_path: new_session_path(:user, redirect_to_referer: 'yes'), is_signed_in: current_user.present?.to_s, slack_link_path: slack_link_profile_slack_path, gitlab_logo_path: image_path('illustrations/gitlab_logo.svg'), slack_logo_path: image_path('illustrations/slack_logo.svg') } end |
#instance_level_integrations? ⇒ Boolean
172 173 174 |
# File 'app/helpers/integrations_helper.rb', line 172 def instance_level_integrations? !Gitlab.com? end |
#integration_event_description(integration, event) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity
41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/integrations_helper.rb', line 41 def integration_event_description(integration, event) case integration when Integrations::Jira jira_integration_event_description(event) when Integrations::Teamcity teamcity_integration_event_description(event) else default_integration_event_description(event) end end |
#integration_event_field_name(event) ⇒ Object
52 53 54 55 |
# File 'app/helpers/integrations_helper.rb', line 52 def integration_event_field_name(event) event = event.pluralize if %w[merge_request issue confidential_issue].include?(event) "#{event}_events" end |
#integration_event_title(event) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
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 32 33 34 35 36 37 38 |
# File 'app/helpers/integrations_helper.rb', line 5 def integration_event_title(event) case event when "push", "push_events" _("Push") when "tag_push", "tag_push_events" _("Tag push") when "note", "note_events" _("Note") when "confidential_note", "confidential_note_events" _("Confidential note") when "issue", "issue_events" _("Issue") when "confidential_issue", "confidential_issue_events" _("Confidential issue") when "merge_request", "merge_request_events" _("Merge request") when "pipeline", "pipeline_events" _("Pipeline") when "wiki_page", "wiki_page_events" _("Wiki page") when "commit", "commit_events" _("Commit") when "deployment" _("Deployment") when "alert" _("Alert") when "incident" _("Incident") when "group_mention" _("Group mention in public") when "group_confidential_mention" _("Group mention in private") end end |
#integration_form_data(integration, project: nil, group: nil) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/helpers/integrations_helper.rb', line 111 def integration_form_data(integration, project: nil, group: nil) form_data = { id: integration.id, show_active: integration.show_active_box?.to_s, activated: (integration.active || (integration.new_record? && integration.activate_disabled_reason.nil?)).to_s, activate_disabled: integration.activate_disabled_reason.present?.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, about_pricing_url: Gitlab::Saas.about_pricing_url, trigger_events: trigger_events_for_integration(integration), sections: integration.sections.to_json, fields: fields_for_integration(integration), inherit_from_id: integration.inherit_from_id, integration_level: integration_level(integration), editable: integration.editable?.to_s, cancel_path: scoped_integrations_path(project: project, group: group), can_test: integration.testable?.to_s, test_path: scoped_test_integration_path(integration, project: project, group: group), reset_path: scoped_reset_integration_path(integration, group: group), form_path: scoped_integration_path(integration, project: project, group: group), redirect_to: request.referer } if integration.is_a?(Integrations::Jira) form_data[:jira_issue_transition_automatic] = integration.jira_issue_transition_automatic form_data[:jira_issue_transition_id] = integration.jira_issue_transition_id end if integration.is_a?(::Integrations::GitlabSlackApplication) form_data[:upgrade_slack_url] = add_to_slack_link(project, slack_app_id) form_data[:should_upgrade_slack] = integration.upgrade_needed?.to_s end form_data end |
#integration_issue_type(issue_type) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'app/helpers/integrations_helper.rb', line 176 def integration_issue_type(issue_type) issue_type_i18n_map = { 'issue' => _('Issue'), 'incident' => _('Incident'), 'test_case' => _('Test case'), 'requirement' => _('Requirement'), 'task' => _('Task'), 'ticket' => _('Service Desk Ticket') } issue_type_i18n_map[issue_type] || issue_type end |
#integration_list_data(integrations, group: nil, project: nil) ⇒ Object
158 159 160 161 162 |
# File 'app/helpers/integrations_helper.rb', line 158 def integration_list_data(integrations, group: nil, project: nil) { integrations: integrations.map { |i| serialize_integration(i, group: group, project: project) }.to_json } end |
#integration_overrides_data(integration, project: nil, group: nil) ⇒ Object
151 152 153 154 155 156 |
# File 'app/helpers/integrations_helper.rb', line 151 def integration_overrides_data(integration, project: nil, group: nil) { edit_path: scoped_edit_integration_path(integration, project: project, group: group), overrides_path: scoped_overrides_integration_path(integration, format: :json) } end |
#integration_todo_target_type(target_type) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'app/helpers/integrations_helper.rb', line 189 def integration_todo_target_type(target_type) target_type_i18n_map = { 'Commit' => _('Commit'), 'Issue' => _('Issue'), 'MergeRequest' => _('Merge Request'), 'Epic' => _('Epic'), DesignManagement::Design.name => _('design'), AlertManagement::Alert.name => _('alert') } target_type_i18n_map[target_type] || target_type end |
#integration_webhook_event_human_name(event) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'app/helpers/integrations_helper.rb', line 202 def integration_webhook_event_human_name(event) event_i18n_map = { repository_update_events: _('Repository update events'), push_events: _('Push events'), tag_push_events: s_('Webhooks|Tag push events'), note_events: _('Comments'), confidential_note_events: s_('Webhooks|Confidential comments'), issues_events: s_('Webhooks|Issues events'), confidential_issues_events: s_('Webhooks|Confidential issues events'), subgroup_events: s_('Webhooks|Subgroup events'), member_events: s_('Webhooks|Member events'), merge_requests_events: s_('Webhooks|Merge request events'), job_events: s_('Webhooks|Job events'), pipeline_events: s_('Webhooks|Pipeline events'), wiki_page_events: s_('Webhooks|Wiki page events'), deployment_events: s_('Webhooks|Deployment events'), feature_flag_events: s_('Webhooks|Feature flag events'), releases_events: s_('Webhooks|Releases events') } event_i18n_map[event] || event.to_s.humanize end |
#integrations_help_page_path ⇒ Object
164 165 166 |
# File 'app/helpers/integrations_helper.rb', line 164 def integrations_help_page_path help_page_path('administration/settings/project_integration_management') end |
#project_jira_issues_integration? ⇒ Boolean
168 169 170 |
# File 'app/helpers/integrations_helper.rb', line 168 def project_jira_issues_integration? false end |
#scoped_edit_integration_path(integration, project: nil, group: nil) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'app/helpers/integrations_helper.rb', line 77 def scoped_edit_integration_path(integration, project: nil, group: nil) 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 |
#scoped_integration_path(integration, project: nil, group: nil) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/integrations_helper.rb', line 67 def scoped_integration_path(integration, project: nil, group: nil) if project.present? project_settings_integration_path(project, integration) elsif group.present? group_settings_integration_path(group, integration) else admin_application_settings_integration_path(integration) end end |
#scoped_integrations_path(project: nil, group: nil) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/integrations_helper.rb', line 57 def scoped_integrations_path(project: nil, group: nil) 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_overrides_integration_path(integration, options = {}) ⇒ Object
87 88 89 |
# File 'app/helpers/integrations_helper.rb', line 87 def scoped_overrides_integration_path(integration, = {}) overrides_admin_application_settings_integration_path(integration, ) end |
#scoped_reset_integration_path(integration, group: nil) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'app/helpers/integrations_helper.rb', line 101 def scoped_reset_integration_path(integration, group: nil) return '' unless integration.persisted? if group.present? reset_group_settings_integration_path(group, integration) else reset_admin_application_settings_integration_path(integration) end end |
#scoped_test_integration_path(integration, project: nil, group: nil) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'app/helpers/integrations_helper.rb', line 91 def scoped_test_integration_path(integration, project: nil, group: nil) 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 |