Module: IntegrationsHelper
- Extended by:
- IntegrationsHelper
- Defined in:
- app/helpers/integrations_helper.rb
Instance Method Summary collapse
- #instance_level_integrations? ⇒ Boolean
- #integration_event_description(integration, event) ⇒ Object
- #integration_event_field_name(event) ⇒ Object
- #integration_event_title(event) ⇒ Object
- #integration_form_data(integration, project: nil, group: nil) ⇒ Object
- #integration_list_data(integrations, group: nil, project: nil) ⇒ Object
- #integration_overrides_data(integration, project: nil, group: nil) ⇒ Object
- #integrations_help_page_path ⇒ Object
- #jira_issue_breadcrumb_link(issue_reference) ⇒ 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
- #zentao_issue_breadcrumb_link(issue) ⇒ Object
- #zentao_issues_show_data ⇒ Object
Instance Method Details
#instance_level_integrations? ⇒ Boolean
158 159 160 |
# File 'app/helpers/integrations_helper.rb', line 158 def instance_level_integrations? !Gitlab.com? end |
#integration_event_description(integration, event) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/helpers/integrations_helper.rb', line 33 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
44 45 46 47 |
# File 'app/helpers/integrations_helper.rb', line 44 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
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/integrations_helper.rb', line 4 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") end end |
#integration_form_data(integration, project: nil, group: nil) ⇒ Object
103 104 105 106 107 108 109 110 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 |
# File 'app/helpers/integrations_helper.rb', line 103 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, 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 form_data end |
#integration_list_data(integrations, group: nil, project: nil) ⇒ Object
144 145 146 147 148 |
# File 'app/helpers/integrations_helper.rb', line 144 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
137 138 139 140 141 142 |
# File 'app/helpers/integrations_helper.rb', line 137 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 |
#integrations_help_page_path ⇒ Object
150 151 152 |
# File 'app/helpers/integrations_helper.rb', line 150 def integrations_help_page_path help_page_path('user/admin_area/settings/project_integration_management') end |
#jira_issue_breadcrumb_link(issue_reference) ⇒ Object
162 163 164 165 166 167 |
# File 'app/helpers/integrations_helper.rb', line 162 def (issue_reference) link_to '', { class: 'gl-display-flex gl-align-items-center gl-white-space-nowrap' } do icon = image_tag image_path('illustrations/logos/jira.svg'), width: 15, height: 15, class: 'gl-mr-2' [icon, html_escape(issue_reference)].join.html_safe end end |
#project_jira_issues_integration? ⇒ Boolean
154 155 156 |
# File 'app/helpers/integrations_helper.rb', line 154 def project_jira_issues_integration? false end |
#scoped_edit_integration_path(integration, project: nil, group: nil) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/helpers/integrations_helper.rb', line 69 def scoped_edit_integration_path(integration, project: nil, group: nil) if project.present? edit_project_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
59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/integrations_helper.rb', line 59 def scoped_integration_path(integration, project: nil, group: nil) if project.present? project_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
49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/integrations_helper.rb', line 49 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
79 80 81 |
# File 'app/helpers/integrations_helper.rb', line 79 def scoped_overrides_integration_path(integration, = {}) overrides_admin_application_settings_integration_path(integration, ) end |
#scoped_reset_integration_path(integration, group: nil) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'app/helpers/integrations_helper.rb', line 93 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
83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/integrations_helper.rb', line 83 def scoped_test_integration_path(integration, project: nil, group: nil) if project.present? test_project_integration_path(project, integration) elsif group.present? test_group_settings_integration_path(group, integration) else test_admin_application_settings_integration_path(integration) end end |
#zentao_issue_breadcrumb_link(issue) ⇒ Object
169 170 171 172 173 174 |
# File 'app/helpers/integrations_helper.rb', line 169 def (issue) link_to issue[:web_url], { target: '_blank', rel: 'noopener noreferrer', class: 'gl-display-flex gl-align-items-center gl-white-space-nowrap' } do icon = image_tag image_path('logos/zentao.svg'), width: 15, height: 15, class: 'gl-mr-2' [icon, html_escape(issue[:id])].join.html_safe end end |
#zentao_issues_show_data ⇒ Object
176 177 178 179 180 181 |
# File 'app/helpers/integrations_helper.rb', line 176 def zentao_issues_show_data { issues_show_path: project_integrations_zentao_issue_path(@project, params[:id], format: :json), issues_list_path: project_integrations_zentao_issues_path(@project) } end |