diff options
Diffstat (limited to 'app/models/integrations')
37 files changed, 148 insertions, 225 deletions
diff --git a/app/models/integrations/apple_app_store.rb b/app/models/integrations/apple_app_store.rb index 6f96626718f..ef12fc6bf6f 100644 --- a/app/models/integrations/apple_app_store.rb +++ b/app/models/integrations/apple_app_store.rb @@ -4,8 +4,8 @@ require 'app_store_connect' module Integrations class AppleAppStore < Integration - ISSUER_ID_REGEX = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/.freeze - KEY_ID_REGEX = /\A(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]+\z/.freeze + ISSUER_ID_REGEX = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/ + KEY_ID_REGEX = /\A(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]+\z/ IS_KEY_CONTENT_BASE64 = "true" SECTION_TYPE_APPLE_APP_STORE = 'apple_app_store' diff --git a/app/models/integrations/asana.rb b/app/models/integrations/asana.rb index 7436c08aa38..859522670ef 100644 --- a/app/models/integrations/asana.rb +++ b/app/models/integrations/asana.rb @@ -12,8 +12,7 @@ module Integrations help: -> { s_('AsanaService|User Personal Access Token. User must have access to the task. All comments are attributed to this user.') }, non_empty_password_title: -> { s_('ProjectService|Enter new API key') }, non_empty_password_help: -> { s_('ProjectService|Leave blank to use your current API key.') }, - # Example Personal Access Token from Asana docs - placeholder: '0/68a9e79b868c6789e79a124c30b0', + placeholder: '0/68a9e79b868c6789e79a124c30b0', # Example Personal Access Token from Asana docs required: true field :restrict_to_branch, @@ -38,7 +37,7 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def client diff --git a/app/models/integrations/assembla.rb b/app/models/integrations/assembla.rb index 6831fac32e6..1d3616b4c3b 100644 --- a/app/models/integrations/assembla.rb +++ b/app/models/integrations/assembla.rb @@ -28,7 +28,7 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb index 4d207574ca7..2c929dc2cb3 100644 --- a/app/models/integrations/base_chat_notification.rb +++ b/app/models/integrations/base_chat_notification.rb @@ -31,12 +31,12 @@ module Integrations # Custom serialized properties initialization prop_accessor(*SUPPORTED_EVENTS.map { |event| EVENT_CHANNEL[event] }) - boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch + boolean_accessor :notify_only_default_branch validates :webhook, presence: true, public_url: true, - if: -> (integration) { integration.activated? && integration.requires_webhook? } + if: -> (integration) { integration.activated? && integration.class.requires_webhook? } validates :labels_to_be_notified_behavior, inclusion: { in: LABEL_NOTIFICATION_BEHAVIOURS }, allow_blank: true, if: :activated? validate :validate_channel_limit, if: :activated? @@ -44,7 +44,7 @@ module Integrations super if properties.empty? - self.notify_only_broken_pipelines = true + self.notify_only_broken_pipelines = true if self.respond_to?(:notify_only_broken_pipelines) self.branches_to_be_notified = "default" self.labels_to_be_notified_behavior = MATCH_ANY_LABEL elsif !self.notify_only_default_branch.nil? @@ -72,48 +72,7 @@ module Integrations end def fields - default_fields + build_event_channels - end - - def default_fields - [ - { - type: :checkbox, - section: SECTION_TYPE_CONFIGURATION, - name: 'notify_only_broken_pipelines', - help: 'Do not send notifications for successful pipelines.' - }.freeze, - { - type: :select, - section: SECTION_TYPE_CONFIGURATION, - name: 'branches_to_be_notified', - title: s_('Integrations|Branches for which notifications are to be sent'), - choices: self.class.branch_choices - }.freeze, - { - type: :text, - section: SECTION_TYPE_CONFIGURATION, - name: 'labels_to_be_notified', - placeholder: '~backend,~frontend', - help: 'Send notifications for issue, merge request, and comment events with the listed labels only. Leave blank to receive notifications for all events.' - }.freeze, - { - type: :select, - section: SECTION_TYPE_CONFIGURATION, - name: 'labels_to_be_notified_behavior', - choices: [ - ['Match any of the labels', MATCH_ANY_LABEL], - ['Match all of the labels', MATCH_ALL_LABELS] - ] - }.freeze - ].tap do |fields| - next unless requires_webhook? - - fields.unshift( - { type: :text, name: 'webhook', help: webhook_help, required: true }.freeze, - { type: :text, name: 'username', placeholder: 'GitLab-integration' }.freeze - ) - end.freeze + self.class.fields + build_event_channels end def execute(data) @@ -154,6 +113,15 @@ module Integrations supported_events.map { |event| event_channel_name(event) } end + override :api_field_names + def api_field_names + if mask_configurable_channels? + super - event_channel_names + else + super + end + end + def form_fields super.reject { |field| field[:name].end_with?('channel') } end @@ -166,6 +134,10 @@ module Integrations raise NotImplementedError end + def help + raise NotImplementedError + end + # With some integrations the webhook is already tied to a specific channel, # for others the channels are configurable for each event. def configurable_channels? @@ -181,7 +153,7 @@ module Integrations self.public_send(field_name) # rubocop:disable GitlabSecurity/PublicSend end - def requires_webhook? + def self.requires_webhook? true end @@ -193,11 +165,32 @@ module Integrations false end + override :sections + def sections + [ + { + type: SECTION_TYPE_CONNECTION, + title: s_('Integrations|Connection details'), + description: help + }, + { + type: SECTION_TYPE_TRIGGER, + title: s_('Integrations|Trigger'), + description: s_('Integrations|An event will be triggered when one of the following items happen.') + }, + { + type: SECTION_TYPE_CONFIGURATION, + title: s_('Integrations|Notification settings'), + description: s_('Integrations|Configure the scope of notifications.') + } + ] + end + private def should_execute?(object_kind) supported_events.include?(object_kind) && - (!requires_webhook? || webhook.present?) + (!self.class.requires_webhook? || webhook.present?) end def log_usage(_, _) @@ -264,7 +257,7 @@ module Integrations def build_event_channels event_channel_names.map do |channel_field| - { type: :text, name: channel_field, placeholder: default_channel_placeholder } + Field.new(name: channel_field, type: :text, placeholder: default_channel_placeholder, integration_class: self) end end diff --git a/app/models/integrations/base_issue_tracker.rb b/app/models/integrations/base_issue_tracker.rb index 7a54d354007..b59aee6743d 100644 --- a/app/models/integrations/base_issue_tracker.rb +++ b/app/models/integrations/base_issue_tracker.rb @@ -88,7 +88,7 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/integrations/base_monitoring.rb b/app/models/integrations/base_monitoring.rb index b0bebb5a859..12ea57f59a3 100644 --- a/app/models/integrations/base_monitoring.rb +++ b/app/models/integrations/base_monitoring.rb @@ -9,7 +9,7 @@ module Integrations attribute :category, default: 'monitoring' def self.supported_events - %w() + %w[] end def can_query? diff --git a/app/models/integrations/base_slack_notification.rb b/app/models/integrations/base_slack_notification.rb index 29a20419809..65aec8b278f 100644 --- a/app/models/integrations/base_slack_notification.rb +++ b/app/models/integrations/base_slack_notification.rb @@ -25,20 +25,24 @@ module Integrations override :supported_events def supported_events - additional = %w[alert] - - if group_level? && Feature.enabled?(:group_mentions, group) - additional += %w[group_mention group_confidential_mention] - end + additional = group_level? ? %w[group_mention group_confidential_mention] : [] (super + additional).freeze end + def self.supported_events + super + %w[alert] + end + override :configurable_channels? def configurable_channels? true end + def help + # noop + end + private override :log_usage diff --git a/app/models/integrations/base_slash_commands.rb b/app/models/integrations/base_slash_commands.rb index 7662da933ba..58821e5fb4e 100644 --- a/app/models/integrations/base_slash_commands.rb +++ b/app/models/integrations/base_slash_commands.rb @@ -13,7 +13,7 @@ module Integrations end def self.supported_events - %w() + %w[] end def testable? diff --git a/app/models/integrations/base_third_party_wiki.rb b/app/models/integrations/base_third_party_wiki.rb index 8df172e9a53..dee3706c518 100644 --- a/app/models/integrations/base_third_party_wiki.rb +++ b/app/models/integrations/base_third_party_wiki.rb @@ -9,7 +9,7 @@ module Integrations after_commit :cache_project_has_integration def self.supported_events - %w() + %w[] end private diff --git a/app/models/integrations/buildkite.rb b/app/models/integrations/buildkite.rb index 6cd36e545a5..82a5142e8c2 100644 --- a/app/models/integrations/buildkite.rb +++ b/app/models/integrations/buildkite.rb @@ -29,7 +29,7 @@ module Integrations validates :token, presence: true, if: :activated? def self.supported_events - %w(push merge_request tag_push) + %w[push merge_request tag_push] end # This is a stub method to work with deprecated API response diff --git a/app/models/integrations/campfire.rb b/app/models/integrations/campfire.rb index 007578e5830..8b5797a9d24 100644 --- a/app/models/integrations/campfire.rb +++ b/app/models/integrations/campfire.rb @@ -2,7 +2,7 @@ module Integrations class Campfire < Integration - SUBDOMAIN_REGEXP = %r{\A[a-z](?:[a-z0-9-]*[a-z0-9])?\z}i.freeze + SUBDOMAIN_REGEXP = %r{\A[a-z](?:[a-z0-9-]*[a-z0-9])?\z}i validates :token, presence: true, if: :activated? validates :room, @@ -26,12 +26,9 @@ module Integrations placeholder: '', exposes_secrets: true, help: -> do - ERB::Util.html_escape( + format(ERB::Util.html_escape( s_('CampfireService|The %{code_open}.campfirenow.com%{code_close} subdomain.') - ) % { - code_open: '<code>'.html_safe, - code_close: '</code>'.html_safe - } + ), code_open: '<code>'.html_safe, code_close: '</code>'.html_safe) end field :room, @@ -48,13 +45,16 @@ module Integrations end def help - docs_link = ActionController::Base.helpers.link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('api/services', anchor: 'campfire'), target: '_blank', rel: 'noopener noreferrer' - - ERB::Util.html_escape( + docs_link = ActionController::Base.helpers.link_to( + _('Learn more.'), + Rails.application.routes.url_helpers.help_page_url('api/integrations', anchor: 'campfire'), + target: '_blank', + rel: 'noopener noreferrer' + ) + + format(ERB::Util.html_escape( s_('CampfireService|Send notifications about push events to Campfire chat rooms. %{docs_link}') - ) % { - docs_link: docs_link.html_safe - } + ), docs_link: docs_link.html_safe) end def self.to_param @@ -62,14 +62,14 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def execute(data) return unless supported_events.include?(data[:object_kind]) message = create_message(data) - speak(self.room, message, auth) + speak(room, message, auth) end private @@ -96,7 +96,7 @@ module Integrations room = rooms(auth).find { |r| r["name"] == room_name } return unless room - path = "/room/#{room["id"]}/speak.json" + path = "/room/#{room['id']}/speak.json" body = { body: { message: { diff --git a/app/models/integrations/chat_message/base_message.rb b/app/models/integrations/chat_message/base_message.rb index 501b214a769..600f07b97f1 100644 --- a/app/models/integrations/chat_message/base_message.rb +++ b/app/models/integrations/chat_message/base_message.rb @@ -3,7 +3,7 @@ module Integrations module ChatMessage class BaseMessage - RELATIVE_LINK_REGEX = %r{!\[[^\]]*\]\((/uploads/[^\)]*)\)}.freeze + RELATIVE_LINK_REGEX = %r{!\[[^\]]*\]\((/uploads/[^\)]*)\)} attr_reader :markdown attr_reader :user_full_name diff --git a/app/models/integrations/chat_message/deployment_message.rb b/app/models/integrations/chat_message/deployment_message.rb index b28edeecb4d..0367459dfcb 100644 --- a/app/models/integrations/chat_message/deployment_message.rb +++ b/app/models/integrations/chat_message/deployment_message.rb @@ -26,8 +26,10 @@ module Integrations end def attachments + return description_message if markdown + [{ - text: "#{project_link} with job #{deployment_link} by #{user_link}\n#{commit_link}: #{strip_markup(commit_title)}", + text: format(description_message), color: color }] end @@ -82,6 +84,10 @@ module Integrations def running? status == 'running' end + + def description_message + "#{project_link} with job #{deployment_link} by #{user_link}\n#{commit_link}: #{strip_markup(commit_title)}" + end end end end diff --git a/app/models/integrations/confluence.rb b/app/models/integrations/confluence.rb index 31e9a171d1b..eda8c37fc72 100644 --- a/app/models/integrations/confluence.rb +++ b/app/models/integrations/confluence.rb @@ -2,9 +2,9 @@ module Integrations class Confluence < BaseThirdPartyWiki - VALID_SCHEME_MATCH = %r{\Ahttps?\Z}.freeze - VALID_HOST_MATCH = %r{\A.+\.atlassian\.net\Z}.freeze - VALID_PATH_MATCH = %r{\A/wiki(/|\Z)}.freeze + VALID_SCHEME_MATCH = %r{\Ahttps?\Z} + VALID_HOST_MATCH = %r{\A.+\.atlassian\.net\Z} + VALID_PATH_MATCH = %r{\A/wiki(/|\Z)} validates :confluence_url, presence: true, if: :activated? validate :validate_confluence_url_is_cloud, if: :activated? @@ -14,6 +14,10 @@ module Integrations placeholder: 'https://example.atlassian.net/wiki', required: true + def avatar_url + ActionController::Base.helpers.image_path('confluence.svg') + end + def self.to_param 'confluence' end diff --git a/app/models/integrations/datadog.rb b/app/models/integrations/datadog.rb index 1a56763fe57..b1f1361afcd 100644 --- a/app/models/integrations/datadog.rb +++ b/app/models/integrations/datadog.rb @@ -12,7 +12,7 @@ module Integrations pipeline build archive_trace ].freeze - TAG_KEY_VALUE_RE = %r{\A [\w-]+ : .*\S.* \z}x.freeze + TAG_KEY_VALUE_RE = %r{\A [\w-]+ : .*\S.* \z}x field :datadog_site, exposes_secrets: true, @@ -40,7 +40,7 @@ module Integrations ERB::Util.html_escape( s_('DatadogIntegration|%{linkOpen}API key%{linkClose} used for authentication with Datadog.') ) % { - linkOpen: %{<a href="#{URL_API_KEYS_DOCS}" target="_blank" rel="noopener noreferrer">}.html_safe, + linkOpen: %(<a href="#{URL_API_KEYS_DOCS}" target="_blank" rel="noopener noreferrer">).html_safe, linkClose: '</a>'.html_safe } end, diff --git a/app/models/integrations/discord.rb b/app/models/integrations/discord.rb index 7cae3ca20f9..815e3669d78 100644 --- a/app/models/integrations/discord.rb +++ b/app/models/integrations/discord.rb @@ -4,9 +4,7 @@ require "discordrb/webhooks" module Integrations class Discord < BaseChatNotification - ATTACHMENT_REGEX = /: (?<entry>.*?)\n - (?<name>.*)\n*/.freeze - - undef :notify_only_broken_pipelines + ATTACHMENT_REGEX = /: (?<entry>.*?)\n - (?<name>.*)\n*/ field :webhook, section: SECTION_TYPE_CONNECTION, @@ -35,10 +33,6 @@ module Integrations "discord" end - def fields - self.class.fields + build_event_channels - end - def help docs_link = ActionController::Base.helpers.link_to _('How do I set up this service?'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/discord_notifications'), target: '_blank', rel: 'noopener noreferrer' s_('Send notifications about project events to a Discord channel. %{docs_link}').html_safe % { docs_link: docs_link.html_safe } @@ -52,26 +46,6 @@ module Integrations %w[push issue confidential_issue merge_request note confidential_note tag_push pipeline wiki_page] end - def sections - [ - { - type: SECTION_TYPE_CONNECTION, - title: s_('Integrations|Connection details'), - description: help - }, - { - type: SECTION_TYPE_TRIGGER, - title: s_('Integrations|Trigger'), - description: s_('Integrations|An event will be triggered when one of the following items happen.') - }, - { - type: SECTION_TYPE_CONFIGURATION, - title: s_('Integrations|Notification settings'), - description: s_('Integrations|Configure the scope of notifications.') - } - ] - end - def configurable_channels? true end diff --git a/app/models/integrations/drone_ci.rb b/app/models/integrations/drone_ci.rb index ac464c020dd..f6a12c4bb1a 100644 --- a/app/models/integrations/drone_ci.rb +++ b/app/models/integrations/drone_ci.rb @@ -43,7 +43,7 @@ module Integrations end def self.supported_events - %w(push merge_request tag_push) + %w[push merge_request tag_push] end def commit_status_path(sha, ref) diff --git a/app/models/integrations/emails_on_push.rb b/app/models/integrations/emails_on_push.rb index eb893ae45d0..144d1a07b04 100644 --- a/app/models/integrations/emails_on_push.rb +++ b/app/models/integrations/emails_on_push.rb @@ -52,7 +52,7 @@ module Integrations end def self.supported_events - %w(push tag_push) + %w[push tag_push] end def initialize_properties diff --git a/app/models/integrations/external_wiki.rb b/app/models/integrations/external_wiki.rb index 75fe6b6f164..acacab2528e 100644 --- a/app/models/integrations/external_wiki.rb +++ b/app/models/integrations/external_wiki.rb @@ -47,7 +47,7 @@ module Integrations end def self.supported_events - %w() + %w[] end end end diff --git a/app/models/integrations/gitlab_slack_application.rb b/app/models/integrations/gitlab_slack_application.rb index b0f54f39e8c..2d520eaf7e7 100644 --- a/app/models/integrations/gitlab_slack_application.rb +++ b/app/models/integrations/gitlab_slack_application.rb @@ -20,6 +20,8 @@ module Integrations has_one :slack_integration, foreign_key: :integration_id, inverse_of: :integration delegate :bot_access_token, :bot_user_id, to: :slack_integration, allow_nil: true + include SlackMattermostFields + def update_active_status update(active: !!slack_integration) end @@ -66,18 +68,7 @@ module Integrations def sections return [] unless editable? - [ - { - type: SECTION_TYPE_TRIGGER, - title: s_('Integrations|Trigger'), - description: s_('Integrations|An event will be triggered when one of the following items happen.') - }, - { - type: SECTION_TYPE_CONFIGURATION, - title: s_('Integrations|Notification settings'), - description: s_('Integrations|Configure the scope of notifications.') - } - ] + super.drop(1) end override :configurable_events @@ -88,7 +79,7 @@ module Integrations end override :requires_webhook? - def requires_webhook? + def self.requires_webhook? false end diff --git a/app/models/integrations/hangouts_chat.rb b/app/models/integrations/hangouts_chat.rb index 037c689c75e..680752c3d56 100644 --- a/app/models/integrations/hangouts_chat.rb +++ b/app/models/integrations/hangouts_chat.rb @@ -2,8 +2,6 @@ module Integrations class HangoutsChat < BaseChatNotification - undef :notify_only_broken_pipelines - field :webhook, section: SECTION_TYPE_CONNECTION, help: 'https://chat.googleapis.com/v1/spaces…', @@ -36,10 +34,6 @@ module Integrations s_('Before enabling this integration, create a webhook for the room in Google Chat where you want to receive notifications from this project. %{docs_link}').html_safe % { docs_link: docs_link.html_safe } end - def fields - self.class.fields + build_event_channels - end - def default_channel_placeholder end diff --git a/app/models/integrations/jenkins.rb b/app/models/integrations/jenkins.rb index 7769ea7d2dd..0683c8408bc 100644 --- a/app/models/integrations/jenkins.rb +++ b/app/models/integrations/jenkins.rb @@ -66,7 +66,7 @@ module Integrations end def self.supported_events - %w(push merge_request tag_push) + %w[push merge_request tag_push] end def title diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb index faf0a378a17..d8d1f860e9a 100644 --- a/app/models/integrations/jira.rb +++ b/app/models/integrations/jira.rb @@ -126,7 +126,7 @@ module Integrations # When these are false GitLab does not create cross reference # comments on Jira except when an issue gets transitioned. def self.supported_events - %w(commit merge_request) + %w[commit merge_request] end # {PROJECT-KEY}-{NUMBER} Examples: JIRA-1, PROJECT-1 diff --git a/app/models/integrations/mattermost.rb b/app/models/integrations/mattermost.rb index e3c5c22ad3a..7e391b11d82 100644 --- a/app/models/integrations/mattermost.rb +++ b/app/models/integrations/mattermost.rb @@ -3,6 +3,7 @@ module Integrations class Mattermost < BaseChatNotification include SlackMattermostNotifier + include SlackMattermostFields def title _('Mattermost notifications') @@ -25,7 +26,7 @@ module Integrations 'my-channel' end - def webhook_help + def self.webhook_help 'http://mattermost.example.com/hooks/' end diff --git a/app/models/integrations/microsoft_teams.rb b/app/models/integrations/microsoft_teams.rb index 25308948d51..208172d6303 100644 --- a/app/models/integrations/microsoft_teams.rb +++ b/app/models/integrations/microsoft_teams.rb @@ -2,8 +2,6 @@ module Integrations class MicrosoftTeams < BaseChatNotification - undef :notify_only_broken_pipelines - field :webhook, section: SECTION_TYPE_CONNECTION, help: 'https://outlook.office.com/webhook/…', @@ -44,30 +42,6 @@ module Integrations pipeline wiki_page] end - def fields - self.class.fields + build_event_channels - end - - def sections - [ - { - type: SECTION_TYPE_CONNECTION, - title: s_('Integrations|Connection details'), - description: help - }, - { - type: SECTION_TYPE_TRIGGER, - title: s_('Integrations|Trigger'), - description: s_('Integrations|An event will be triggered when one of the following items happen.') - }, - { - type: SECTION_TYPE_CONFIGURATION, - title: s_('Integrations|Notification settings'), - description: s_('Integrations|Configure the scope of notifications.') - } - ] - end - private def notify(message, opts) diff --git a/app/models/integrations/packagist.rb b/app/models/integrations/packagist.rb index c9c08ec9771..c0acb6c87b4 100644 --- a/app/models/integrations/packagist.rb +++ b/app/models/integrations/packagist.rb @@ -42,7 +42,7 @@ module Integrations end def self.supported_events - %w(push merge_request tag_push) + %w[push merge_request tag_push] end def execute(data) diff --git a/app/models/integrations/pivotaltracker.rb b/app/models/integrations/pivotaltracker.rb index 0d9a3f05a86..f42a872c49e 100644 --- a/app/models/integrations/pivotaltracker.rb +++ b/app/models/integrations/pivotaltracker.rb @@ -38,7 +38,7 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/integrations/prometheus.rb b/app/models/integrations/prometheus.rb index 736318ed707..8474a5b7adf 100644 --- a/app/models/integrations/prometheus.rb +++ b/app/models/integrations/prometheus.rb @@ -41,6 +41,7 @@ module Integrations before_save :synchronize_service_state after_save :clear_reactive_cache! + after_commit :sync_http_integration! after_commit :track_events @@ -180,5 +181,16 @@ module Integrations nil end strong_memoize_attr :iap_client + + # Remove in next required stop after %16.4 + # https://gitlab.com/gitlab-org/gitlab/-/issues/338838 + def sync_http_integration! + return unless manual_configuration_changed? + + project.alert_management_http_integrations + .for_endpoint_identifier('legacy-prometheus') + .take + &.update_columns(active: manual_configuration) + end end end diff --git a/app/models/integrations/pumble.rb b/app/models/integrations/pumble.rb index 8f0dddcc5c5..09e011023ed 100644 --- a/app/models/integrations/pumble.rb +++ b/app/models/integrations/pumble.rb @@ -2,8 +2,6 @@ module Integrations class Pumble < BaseChatNotification - undef :notify_only_broken_pipelines - field :webhook, section: SECTION_TYPE_CONNECTION, help: 'https://api.pumble.com/workspaces/x/...', @@ -52,10 +50,6 @@ module Integrations pipeline wiki_page] end - def fields - self.class.fields + build_event_channels - end - private def notify(message, opts) diff --git a/app/models/integrations/pushover.rb b/app/models/integrations/pushover.rb index 006b731c6c2..e97c7e5e738 100644 --- a/app/models/integrations/pushover.rb +++ b/app/models/integrations/pushover.rb @@ -47,19 +47,19 @@ module Integrations [ ['Device default sound', nil], ['Pushover (default)', 'pushover'], - %w(Bike bike), - %w(Bugle bugle), + %w[Bike bike], + %w[Bugle bugle], ['Cash Register', 'cashregister'], - %w(Classical classical), - %w(Cosmic cosmic), - %w(Falling falling), - %w(Gamelan gamelan), - %w(Incoming incoming), - %w(Intermission intermission), - %w(Magic magic), - %w(Mechanical mechanical), + %w[Classical classical], + %w[Cosmic cosmic], + %w[Falling falling], + %w[Gamelan gamelan], + %w[Incoming incoming], + %w[Intermission intermission], + %w[Magic magic], + %w[Mechanical mechanical], ['Piano Bar', 'pianobar'], - %w(Siren siren), + %w[Siren siren], ['Space Alarm', 'spacealarm'], ['Tug Boat', 'tugboat'], ['Alien Alarm (long)', 'alien'], @@ -84,7 +84,7 @@ module Integrations end def self.supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index f5b6595fff2..227fdca5c91 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -8,6 +8,10 @@ module Integrations title: -> { s_('Shimo|Shimo Workspace URL') }, required: true + def avatar_url + ActionController::Base.helpers.image_path('logos/shimo.svg') + end + def render? valid? && activated? end diff --git a/app/models/integrations/slack.rb b/app/models/integrations/slack.rb index 07d2d802915..f70376e2f0d 100644 --- a/app/models/integrations/slack.rb +++ b/app/models/integrations/slack.rb @@ -3,6 +3,7 @@ module Integrations class Slack < BaseSlackNotification include SlackMattermostNotifier + include SlackMattermostFields def title 'Slack notifications' @@ -16,8 +17,7 @@ module Integrations 'slack' end - override :webhook_help - def webhook_help + def self.webhook_help 'https://hooks.slack.com/services/…' end diff --git a/app/models/integrations/teamcity.rb b/app/models/integrations/teamcity.rb index c74e0aab030..575c3b8a334 100644 --- a/app/models/integrations/teamcity.rb +++ b/app/models/integrations/teamcity.rb @@ -6,7 +6,7 @@ module Integrations include ReactivelyCached prepend EnableSslVerification - TEAMCITY_SAAS_HOSTNAME = /\A[^\.]+\.teamcity\.com\z/i.freeze + TEAMCITY_SAAS_HOSTNAME = /\A[^\.]+\.teamcity\.com\z/i field :teamcity_url, title: -> { s_('ProjectService|TeamCity server URL') }, @@ -43,7 +43,7 @@ module Integrations end def supported_events - %w(push merge_request) + %w[push merge_request] end end diff --git a/app/models/integrations/telegram.rb b/app/models/integrations/telegram.rb index 9af12c712c6..7c196720386 100644 --- a/app/models/integrations/telegram.rb +++ b/app/models/integrations/telegram.rb @@ -21,6 +21,11 @@ module Integrations placeholder: '@channelusername', required: true + field :notify_only_broken_pipelines, + type: :checkbox, + section: SECTION_TYPE_CONFIGURATION, + help: 'If selected, successful pipelines do not trigger a notification event.' + with_options if: :activated? do validates :token, :room, presence: true end @@ -51,34 +56,10 @@ module Integrations ) end - def fields - self.class.fields + build_event_channels - end - def self.supported_events super - ['deployment'] end - def sections - [ - { - type: SECTION_TYPE_CONNECTION, - title: s_('Integrations|Connection details'), - description: help - }, - { - type: SECTION_TYPE_TRIGGER, - title: s_('Integrations|Trigger'), - description: s_('Integrations|An event will be triggered when one of the following items happen.') - }, - { - type: SECTION_TYPE_CONFIGURATION, - title: s_('Integrations|Notification settings'), - description: s_('Integrations|Configure the scope of notifications.') - } - ] - end - private def set_webhook diff --git a/app/models/integrations/unify_circuit.rb b/app/models/integrations/unify_circuit.rb index 6de693b5278..3b4bcfa28d3 100644 --- a/app/models/integrations/unify_circuit.rb +++ b/app/models/integrations/unify_circuit.rb @@ -2,8 +2,6 @@ module Integrations class UnifyCircuit < BaseChatNotification - undef :notify_only_broken_pipelines - field :webhook, section: SECTION_TYPE_CONNECTION, help: 'https://yourcircuit.com/rest/v2/webhooks/incoming/…', @@ -31,10 +29,6 @@ module Integrations 'unify_circuit' end - def fields - self.class.fields + build_event_channels - end - def help docs_link = ActionController::Base.helpers.link_to _('How do I set up this service?'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/unify_circuit'), target: '_blank', rel: 'noopener noreferrer' s_('Integrations|Send notifications about project events to a Unify Circuit conversation. %{docs_link}').html_safe % { docs_link: docs_link.html_safe } diff --git a/app/models/integrations/webex_teams.rb b/app/models/integrations/webex_teams.rb index 21c65cc2b32..3ef8ab39352 100644 --- a/app/models/integrations/webex_teams.rb +++ b/app/models/integrations/webex_teams.rb @@ -2,8 +2,6 @@ module Integrations class WebexTeams < BaseChatNotification - undef :notify_only_broken_pipelines - field :webhook, section: SECTION_TYPE_CONNECTION, help: 'https://api.ciscospark.com/v1/webhooks/incoming/...', @@ -31,10 +29,6 @@ module Integrations 'webex_teams' end - def fields - self.class.fields + build_event_channels - end - def help docs_link = ActionController::Base.helpers.link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/webex_teams'), target: '_blank', rel: 'noopener noreferrer' s_("WebexTeamsService|Send notifications about project events to a Webex Teams conversation. %{docs_link}") % { docs_link: docs_link.html_safe } diff --git a/app/models/integrations/zentao.rb b/app/models/integrations/zentao.rb index fd2c741bd6b..58ec4abf30c 100644 --- a/app/models/integrations/zentao.rb +++ b/app/models/integrations/zentao.rb @@ -34,6 +34,10 @@ module Integrations validates :api_token, presence: true, if: :activated? validates :zentao_product_xid, presence: true, if: :activated? + def avatar_url + ActionController::Base.helpers.image_path('logos/zentao.svg') + end + def self.issues_license_available?(project) project&.licensed_feature_available?(:zentao_issues_integration) end @@ -82,7 +86,7 @@ module Integrations end def self.supported_events - %w() + %w[] end private |