Extend #parse to accept a suggestions_filter_enabled param
This will allow the front end to specify the behavior as needed.
This commit is contained in:
parent
f44eba8c0e
commit
fb3d40cb61
2 changed files with 7 additions and 3 deletions
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in a new issue