2017-02-27 17:12:52 +00:00
|
|
|
module Issues
|
|
|
|
module ResolveDiscussions
|
|
|
|
attr_reader :merge_request_for_resolving_discussions_iid, :discussion_to_resolve_id
|
|
|
|
|
|
|
|
def filter_resolve_discussion_params
|
|
|
|
@merge_request_for_resolving_discussions_iid ||= params.delete(:merge_request_for_resolving_discussions)
|
|
|
|
@discussion_to_resolve_id ||= params.delete(:discussion_to_resolve)
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_for_resolving_discussions
|
2017-03-09 10:38:53 +00:00
|
|
|
return @merge_request_for_resolving_discussions if defined?(@merge_request_for_resolving_discussions)
|
|
|
|
|
|
|
|
@merge_request_for_resolving_discussions = MergeRequestsFinder.new(current_user, project_id: project.id).
|
2017-02-27 17:12:52 +00:00
|
|
|
execute.
|
|
|
|
find_by(iid: merge_request_for_resolving_discussions_iid)
|
|
|
|
end
|
|
|
|
|
|
|
|
def discussions_to_resolve
|
|
|
|
return [] unless merge_request_for_resolving_discussions
|
|
|
|
|
2017-03-08 00:39:11 +00:00
|
|
|
@discussions_to_resolve ||=
|
|
|
|
if discussion_to_resolve_id
|
|
|
|
discussion_or_nil = merge_request_for_resolving_discussions
|
|
|
|
.find_diff_discussion(discussion_to_resolve_id)
|
|
|
|
Array(discussion_or_nil)
|
|
|
|
else
|
|
|
|
merge_request_for_resolving_discussions
|
|
|
|
.resolvable_discussions
|
|
|
|
end
|
2017-02-27 17:12:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|