diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2016-10-26 23:21:50 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2016-12-05 20:55:45 +0100 |
commit | 1123057ab792ac73b1611f4d3a9faf79369dd6da (patch) | |
tree | ae88332a5d2d47d5a814583fbe874582ebaf859c /app/services/discussions | |
parent | 5fedc46343d054df28ce81a320f33d1d43d02bc8 (diff) | |
download | gitlab-ce-1123057ab792ac73b1611f4d3a9faf79369dd6da.tar.gz |
Feature: delegate all open discussions to Issue
When a merge request can only be merged when all discussions are
resolved. This feature allows to easily delegate those discussions to a
new issue, while marking them as resolved in the merge request.
The user is presented with a new issue, prepared with mentions of all
unresolved discussions, including the first unresolved note of the
discussion, time and link to the note.
When the issue is created, the discussions in the merge request will get
a system note directing the user to the newly created issue.
Diffstat (limited to 'app/services/discussions')
-rw-r--r-- | app/services/discussions/base_service.rb | 4 | ||||
-rw-r--r-- | app/services/discussions/resolve_service.rb | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/app/services/discussions/base_service.rb b/app/services/discussions/base_service.rb new file mode 100644 index 00000000000..e4dfe6e71bb --- /dev/null +++ b/app/services/discussions/base_service.rb @@ -0,0 +1,4 @@ +module Discussions + class BaseService < ::BaseService + end +end diff --git a/app/services/discussions/resolve_service.rb b/app/services/discussions/resolve_service.rb new file mode 100644 index 00000000000..0437195f588 --- /dev/null +++ b/app/services/discussions/resolve_service.rb @@ -0,0 +1,24 @@ +module Discussions + class ResolveService < Discussions::BaseService + def execute(one_or_more_discussions) + Array(one_or_more_discussions).each { |discussion| resolve_discussion(discussion) } + end + + def resolve_discussion(discussion) + return unless discussion.can_resolve?(current_user) + + discussion.resolve!(current_user) + + MergeRequests::ResolvedDiscussionNotificationService.new(project, current_user).execute(merge_request) + SystemNoteService.discussion_continued_in_issue(discussion, project, current_user, follow_up_issue) if follow_up_issue + end + + def merge_request + params[:merge_request] + end + + def follow_up_issue + params[:follow_up_issue] + end + end +end |