Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /app/models/integrations
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'app/models/integrations')
-rw-r--r--app/models/integrations/base_issue_tracker.rb2
-rw-r--r--app/models/integrations/jira.rb54
-rw-r--r--app/models/integrations/shimo.rb13
3 files changed, 41 insertions, 28 deletions
diff --git a/app/models/integrations/base_issue_tracker.rb b/app/models/integrations/base_issue_tracker.rb
index 3fd67205e92..42a6a3a19c8 100644
--- a/app/models/integrations/base_issue_tracker.rb
+++ b/app/models/integrations/base_issue_tracker.rb
@@ -128,7 +128,7 @@ module Integrations
false
end
- def create_cross_reference_note(mentioned, noteable, author)
+ def create_cross_reference_note(external_issue, mentioned_in, author)
# implement inside child
end
diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb
index 42c291abf55..d46299de1be 100644
--- a/app/models/integrations/jira.rb
+++ b/app/models/integrations/jira.rb
@@ -234,19 +234,19 @@ module Integrations
end
override :create_cross_reference_note
- def create_cross_reference_note(mentioned, noteable, author)
- unless can_cross_reference?(noteable)
- return s_("JiraService|Events for %{noteable_model_name} are disabled.") % { noteable_model_name: noteable.model_name.plural.humanize(capitalize: false) }
+ def create_cross_reference_note(external_issue, mentioned_in, author)
+ unless can_cross_reference?(mentioned_in)
+ return s_("JiraService|Events for %{noteable_model_name} are disabled.") % { noteable_model_name: mentioned_in.model_name.plural.humanize(capitalize: false) }
end
- jira_issue = find_issue(mentioned.id)
+ jira_issue = find_issue(external_issue.id)
return unless jira_issue.present?
- noteable_id = noteable.respond_to?(:iid) ? noteable.iid : noteable.id
- noteable_type = noteable_name(noteable)
- entity_url = build_entity_url(noteable_type, noteable_id)
- entity_meta = build_entity_meta(noteable)
+ mentioned_in_id = mentioned_in.respond_to?(:iid) ? mentioned_in.iid : mentioned_in.id
+ mentioned_in_type = mentionable_name(mentioned_in)
+ entity_url = build_entity_url(mentioned_in_type, mentioned_in_id)
+ entity_meta = build_entity_meta(mentioned_in)
data = {
user: {
@@ -259,9 +259,9 @@ module Integrations
},
entity: {
id: entity_meta[:id],
- name: noteable_type.humanize.downcase,
+ name: mentioned_in_type.humanize.downcase,
url: entity_url,
- title: noteable.title,
+ title: mentioned_in.title,
description: entity_meta[:description],
branch: entity_meta[:branch]
}
@@ -302,11 +302,11 @@ module Integrations
private
- def branch_name(noteable)
+ def branch_name(commit)
if Feature.enabled?(:jira_use_first_ref_by_oid, project, default_enabled: :yaml)
- noteable.first_ref_by_oid(project.repository)
+ commit.first_ref_by_oid(project.repository)
else
- noteable.ref_names(project.repository).first
+ commit.ref_names(project.repository).first
end
end
@@ -316,8 +316,8 @@ module Integrations
end
end
- def can_cross_reference?(noteable)
- case noteable
+ def can_cross_reference?(mentioned_in)
+ case mentioned_in
when Commit then commit_events
when MergeRequest then merge_requests_events
else true
@@ -487,36 +487,36 @@ module Integrations
"#{Settings.gitlab.base_url.chomp("/")}#{resource}"
end
- def build_entity_url(noteable_type, entity_id)
+ def build_entity_url(entity_type, entity_id)
polymorphic_url(
[
self.project,
- noteable_type.to_sym
+ entity_type.to_sym
],
id: entity_id,
host: Settings.gitlab.base_url
)
end
- def build_entity_meta(noteable)
- if noteable.is_a?(Commit)
+ def build_entity_meta(entity)
+ if entity.is_a?(Commit)
{
- id: noteable.short_id,
- description: noteable.safe_message,
- branch: branch_name(noteable)
+ id: entity.short_id,
+ description: entity.safe_message,
+ branch: branch_name(entity)
}
- elsif noteable.is_a?(MergeRequest)
+ elsif entity.is_a?(MergeRequest)
{
- id: noteable.to_reference,
- branch: noteable.source_branch
+ id: entity.to_reference,
+ branch: entity.source_branch
}
else
{}
end
end
- def noteable_name(noteable)
- name = noteable.model_name.singular
+ def mentionable_name(mentionable)
+ name = mentionable.model_name.singular
# ProjectSnippet inherits from Snippet class so it causes
# routing error building the URL.
diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb
index 4f42fda2577..0e1023bb7a7 100644
--- a/app/models/integrations/shimo.rb
+++ b/app/models/integrations/shimo.rb
@@ -5,7 +5,11 @@ module Integrations
prop_accessor :external_wiki_url
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
+ after_commit :cache_project_has_shimo
+
def render?
+ return false unless Feature.enabled?(:shimo_integration, project)
+
valid? && activated?
end
@@ -43,5 +47,14 @@ module Integrations
}
]
end
+
+ private
+
+ def cache_project_has_shimo
+ return unless project && !project.destroyed?
+
+ project.project_setting.save! unless project.project_setting.persisted?
+ project.project_setting.update_column(:has_shimo, activated?)
+ end
end
end