Class: Integrations::GitlabSlackApplication

Inherits:
Integration show all
Includes:
Base::SlackNotification, SlackMattermostFields
Defined in:
app/models/integrations/gitlab_slack_application.rb

Constant Summary

Constants included from Base::SlackNotification

Base::SlackNotification::SUPPORTED_EVENTS_FOR_USAGE_LOG

Constants included from Base::ChatNotification

Base::ChatNotification::EVENT_CHANNEL, Base::ChatNotification::GROUP_ONLY_SUPPORTED_EVENTS, Base::ChatNotification::LABEL_NOTIFICATION_BEHAVIOURS, Base::ChatNotification::SECRET_MASK, Base::ChatNotification::SUPPORTED_EVENTS, Base::ChatNotification::SUPPORTED_EVENTS_FOR_LABEL_FILTER

Constants included from NotificationPipelineStatusSelection

NotificationPipelineStatusSelection::FIELD

Constants included from Base::Integration

Base::Integration::BASE_ATTRIBUTES, Base::Integration::BASE_CLASSES, Base::Integration::DEV_INTEGRATION_NAMES, Base::Integration::ENCRYPTED_PROPERTIES_MAX_SIZE, Base::Integration::INSTANCE_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::INTEGRATION_NAMES, Base::Integration::PROJECT_AND_GROUP_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::PROJECT_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::SECTION_TYPE_CONFIGURATION, Base::Integration::SECTION_TYPE_CONNECTION, Base::Integration::SECTION_TYPE_TRIGGER, Base::Integration::SNOWPLOW_EVENT_ACTION, Base::Integration::SNOWPLOW_EVENT_LABEL, Base::Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::SlackNotification

#configurable_channels?, #default_channel_placeholder, #get_message, #supported_events

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Base::ChatNotification

#api_field_names, #channel_limit_per_event, #confidential_issue_channel, #confidential_note_channel, #configurable_channels?, #default_channel_placeholder, #event_channel_names, #event_channel_value, #execute, #form_fields, #initialize_properties, #mask_configurable_channels?, #webhook_help

Methods included from NotificationBranchSelection

#notify_for_branch?

Methods included from Base::Integration

#activate!, #activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, #attribution_notice, #category, #chat?, #ci?, #deactivate!, #default_test_event, #description, #dup, #event_channel_names, #event_names, #execute, #form_fields, #group_level?, #help, #inheritable?, #initialize_properties, #instance_level?, #json_fields, #operating?, #organization_id_from_parent, #parent, #project_level?, #reencrypt_properties, #reset_updated_properties, #secret_fields, #supported_events, #supports_data_fields?, #testable?, #title, #to_database_hash, #to_param, #toggle!, #updated_properties, #validate_encrypted_properties_size_limit

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.descriptionObject



33
34
35
# File 'app/models/integrations/gitlab_slack_application.rb', line 33

def self.description
  s_('Integrations|Enable slash commands and notifications for a Slack workspace.')
end

.requires_webhook?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'app/models/integrations/gitlab_slack_application.rb', line 103

def self.requires_webhook?
  false
end

.titleObject



29
30
31
# File 'app/models/integrations/gitlab_slack_application.rb', line 29

def self.title
  s_('Integrations|GitLab for Slack app')
end

.to_paramObject



37
38
39
# File 'app/models/integrations/gitlab_slack_application.rb', line 37

def self.to_param
  'gitlab_slack_application'
end

.webhook_helpObject



74
75
76
# File 'app/models/integrations/gitlab_slack_application.rb', line 74

def self.webhook_help
  # no-op
end

Instance Method Details

#after_build_from_integration(new_integration) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/models/integrations/gitlab_slack_application.rb', line 85

def after_build_from_integration(new_integration)
  return unless slack_integration

  new_integration.slack_integration = slack_integration.dup.tap do |entity|
    entity.alias = new_integration.parent&.full_path ||
      SlackIntegration.organization_alias(new_integration.organization_id)

    # The sharding key of the slack_integrations table is derived from the
    # sharding key set on the related Integration record
    entity.organization_id = new_integration.organization_id
    entity.project_id = new_integration.project_id
    entity.group_id = new_integration.group_id

    entity.authorized_scope_names = slack_integration.authorized_scope_names
  end
end

#configurable_eventsObject



79
80
81
82
83
# File 'app/models/integrations/gitlab_slack_application.rb', line 79

def configurable_events
  return [] unless editable?

  super
end

#editable?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/integrations/gitlab_slack_application.rb', line 56

def editable?
  activated?
end

#fieldsObject



61
62
63
64
65
# File 'app/models/integrations/gitlab_slack_application.rb', line 61

def fields
  return [] unless editable?

  super
end

#manual_activation?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/integrations/gitlab_slack_application.rb', line 42

def manual_activation?
  false
end

#sectionsObject



68
69
70
71
72
# File 'app/models/integrations/gitlab_slack_application.rb', line 68

def sections
  return [] unless editable?

  super.drop(1)
end

#test(_data) ⇒ Object



47
48
49
50
51
# File 'app/models/integrations/gitlab_slack_application.rb', line 47

def test(_data)
  failures = test_notification_channels

  { success: failures.blank?, result: failures }
end

#upgrade_needed?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'app/models/integrations/gitlab_slack_application.rb', line 107

def upgrade_needed?
  slack_integration.present? && slack_integration.upgrade_needed?
end