Commit 4500c94e authored by Robert Speicher's avatar Robert Speicher

Merge branch 'diff-view-speed' into 'master'

Lower allocations in _collapsed partial

See merge request gitlab-org/gitlab!53233
parents be9193bf d6008937
......@@ -203,6 +203,17 @@ module DiffHelper
set_secure_cookie(:diff_view, params.delete(:view), type: CookiesHelper::COOKIE_TYPE_PERMANENT) if params[:view].present?
end
def collapsed_diff_url(diff_file)
url_for(
safe_params.merge(
action: :diff_for_path,
old_path: diff_file.old_path,
new_path: diff_file.new_path,
file_identifier: diff_file.file_identifier
)
)
end
private
def diff_btn(title, name, selected)
......
- diff_file = viewer.diff_file
- url = url_for(safe_params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path, file_identifier: diff_file.file_identifier))
.nothing-here-block.diff-collapsed{ data: { diff_for_path: url } }
.nothing-here-block.diff-collapsed{ data: { diff_for_path: collapsed_diff_url(viewer.diff_file) } }
= _("This diff is collapsed.")
%button.click-to-expand.btn.btn-link= _("Click to expand it.")
---
title: Lower allocations in _collapsed partial
merge_request: 53233
author:
type: performance
......@@ -358,4 +358,24 @@ RSpec.describe DiffHelper do
expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb")
end
end
describe "#collapsed_diff_url" do
let(:params) do
{
controller: "projects/commit",
action: "show",
namespace_id: "foo",
project_id: "bar",
id: commit.sha
}
end
subject { helper.collapsed_diff_url(diff_file) }
it "returns a valid URL" do
allow(helper).to receive(:safe_params).and_return(params)
expect(subject).to match(/foo\/bar\/-\/commit\/#{commit.sha}\/diff_for_path/)
end
end
end
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