diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 15:24:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 15:24:19 +0300 |
commit | 72cb3bee798655c2d370dfedf3c04665aaa43aa3 (patch) | |
tree | 4f57c272abd6067ed3dfdf38bca9220b3ea13bf5 /app/services/issuable_links | |
parent | 70c1d0352e39c3c04caaa3082c3ffb4ad5c29b32 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/issuable_links')
-rw-r--r-- | app/services/issuable_links/create_service.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/issuable_links/create_service.rb b/app/services/issuable_links/create_service.rb index f244f54b25f..1069c9e0915 100644 --- a/app/services/issuable_links/create_service.rb +++ b/app/services/issuable_links/create_service.rb @@ -19,6 +19,10 @@ module IssuableLinks return error(issuables_already_assigned_message, 409) end + if render_no_permission_error? + return error(issuables_no_permission_error_message, 403) + end + if render_not_found_error? return error(issuables_not_found_message, 404) end @@ -46,6 +50,7 @@ module IssuableLinks link end + # rubocop: enable CodeReuse/ActiveRecord private @@ -54,6 +59,10 @@ module IssuableLinks referenced_issuables.present? && (referenced_issuables - previous_related_issuables).empty? end + def render_no_permission_error? + readonly_issuables(referenced_issuables).present? && linkable_issuables(referenced_issuables).empty? + end + def render_not_found_error? linkable_issuables(referenced_issuables).empty? end @@ -116,6 +125,10 @@ module IssuableLinks _('%{issuable}(s) already assigned' % { issuable: target_issuable_type.capitalize }) end + def issuables_no_permission_error_message + _("Couldn't link %{issuable}. You must have at least the Reporter role in both projects." % { issuable: target_issuable_type }) + end + def issuables_not_found_message _('No matching %{issuable} found. Make sure that you are adding a valid %{issuable} URL.' % { issuable: target_issuable_type }) end @@ -133,6 +146,10 @@ module IssuableLinks raise NotImplementedError end + def readonly_issuables(_issuables) + [] # default to empty for non-issues + end + def previous_related_issuables raise NotImplementedError end |