Commit fb3d40cb authored by Kerri Miller's avatar Kerri Miller

Extend #parse to accept a suggestions_filter_enabled param

This will allow the front end to specify the behavior as needed.
parent f44eba8c
......@@ -38,7 +38,9 @@ class PreviewMarkdownService < BaseService
head_sha: params[:head_sha],
start_sha: params[:start_sha])
Gitlab::Diff::SuggestionsParser.parse(text, position: position, project: project)
Gitlab::Diff::SuggestionsParser.parse(text, position: position,
project: project,
supports_suggestion: params[:preview_suggestions])
end
def preview_sugestions?
......
......@@ -10,10 +10,12 @@ module Gitlab
# Returns an array of Gitlab::Diff::Suggestion which represents each
# suggestion in the given text.
#
def parse(text, position:, project:)
def parse(text, position:, project:, supports_suggestion: true)
return [] unless position.complete?
html = Banzai.render(text, project: nil, no_original_data: true)
html = Banzai.render(text, project: nil,
no_original_data: true,
suggestions_filter_enabled: supports_suggestion)
doc = Nokogiri::HTML(html)
suggestion_nodes = doc.search('pre.suggestion')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment