Don't use params[:view] directly.
This commit is contained in:
parent
1c040b3f0a
commit
e49190cad9
6 changed files with 12 additions and 9 deletions
|
@ -1,4 +1,8 @@
|
||||||
module DiffHelper
|
module DiffHelper
|
||||||
|
def diff_view
|
||||||
|
params[:view] == 'parallel' ? 'parallel' : 'inline'
|
||||||
|
end
|
||||||
|
|
||||||
def allowed_diff_size
|
def allowed_diff_size
|
||||||
if diff_hard_limit_enabled?
|
if diff_hard_limit_enabled?
|
||||||
Commit::DIFF_HARD_LIMIT_FILES
|
Commit::DIFF_HARD_LIMIT_FILES
|
||||||
|
@ -137,7 +141,7 @@ module DiffHelper
|
||||||
# Always use HTML to handle case where JSON diff rendered this button
|
# Always use HTML to handle case where JSON diff rendered this button
|
||||||
params_copy.delete(:format)
|
params_copy.delete(:format)
|
||||||
|
|
||||||
link_to url_for(params_copy), id: "inline-diff-btn", class: (params[:view] != 'parallel' ? 'btn active' : 'btn') do
|
link_to url_for(params_copy), id: "inline-diff-btn", class: (diff_view == 'inline' ? 'btn active' : 'btn') do
|
||||||
'Inline'
|
'Inline'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -148,7 +152,7 @@ module DiffHelper
|
||||||
# Always use HTML to handle case where JSON diff rendered this button
|
# Always use HTML to handle case where JSON diff rendered this button
|
||||||
params_copy.delete(:format)
|
params_copy.delete(:format)
|
||||||
|
|
||||||
link_to url_for(params_copy), id: "parallel-diff-btn", class: (params[:view] == 'parallel' ? 'btn active' : 'btn') do
|
link_to url_for(params_copy), id: "parallel-diff-btn", class: (diff_view == 'parallel' ? 'btn active' : 'btn') do
|
||||||
'Side-by-side'
|
'Side-by-side'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
= render "commit_box"
|
= render "commit_box"
|
||||||
= render "ci_menu" if @ci_commit
|
= render "ci_menu" if @ci_commit
|
||||||
= render "projects/diffs/diffs", diffs: @diffs, project: @project
|
= render "projects/diffs/diffs", diffs: @diffs, project: @project
|
||||||
= render "projects/notes/notes_with_form", view: params[:view]
|
= render "projects/notes/notes_with_form"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- if params[:view] == 'parallel'
|
- if diff_view == 'parallel'
|
||||||
- fluid_layout true
|
- fluid_layout true
|
||||||
|
|
||||||
- diff_files = safe_diff_files(diffs)
|
- diff_files = safe_diff_files(diffs)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
-# Skipp all non non-supported blobs
|
-# Skipp all non non-supported blobs
|
||||||
- return unless blob.respond_to?('text?')
|
- return unless blob.respond_to?('text?')
|
||||||
- if blob.text?
|
- if blob.text?
|
||||||
- if params[:view] == 'parallel'
|
- if diff_view == 'parallel'
|
||||||
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob, index: i
|
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob, index: i
|
||||||
- else
|
- else
|
||||||
= render "projects/diffs/text_file", diff_file: diff_file, index: i
|
= render "projects/diffs/text_file", diff_file: diff_file, index: i
|
||||||
|
@ -42,4 +42,3 @@
|
||||||
= render "projects/diffs/image", diff_file: diff_file, old_file: old_file, file: blob, index: i
|
= render "projects/diffs/image", diff_file: diff_file, old_file: old_file, file: blob, index: i
|
||||||
- else
|
- else
|
||||||
.nothing-here-block No preview for this file type
|
.nothing-here-block No preview for this file type
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
= form_for [@project.namespace.becomes(Namespace), @project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form gfm-form" }, authenticity_token: true do |f|
|
= form_for [@project.namespace.becomes(Namespace), @project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form gfm-form" }, authenticity_token: true do |f|
|
||||||
= hidden_field_tag :view, params[:view]
|
= hidden_field_tag :view, diff_view
|
||||||
= hidden_field_tag :line_type
|
= hidden_field_tag :line_type
|
||||||
= note_target_fields(@note)
|
= note_target_fields(@note)
|
||||||
= f.hidden_field :commit_id
|
= f.hidden_field :commit_id
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
.js-main-target-form
|
.js-main-target-form
|
||||||
- if can? current_user, :create_note, @project
|
- if can? current_user, :create_note, @project
|
||||||
= render "projects/notes/form", view: params[:view]
|
= render "projects/notes/form", view: diff_view
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
window._notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{params[:view]}")
|
window._notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}")
|
||||||
|
|
Loading…
Reference in a new issue