Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
93f2d6ee
Commit
93f2d6ee
authored
Feb 03, 2021
by
Robert May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lower allocations in _collapsed partial
parent
e8525082
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
3 deletions
+32
-3
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+11
-0
app/views/projects/diffs/viewers/_collapsed.html.haml
app/views/projects/diffs/viewers/_collapsed.html.haml
+1
-3
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+20
-0
No files found.
app/helpers/diff_helper.rb
View file @
93f2d6ee
...
...
@@ -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
)
...
...
app/views/projects/diffs/viewers/_collapsed.html.haml
View file @
93f2d6ee
-
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."
)
spec/helpers/diff_helper_spec.rb
View file @
93f2d6ee
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment