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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
d8d00b5b
Commit
d8d00b5b
authored
Mar 23, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Hide/show whitespace changes button on diff and commit view
parent
18e00e3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+22
-0
app/views/projects/diffs/_diffs.html.haml
app/views/projects/diffs/_diffs.html.haml
+4
-0
No files found.
app/helpers/diff_helper.rb
View file @
d8d00b5b
...
@@ -128,4 +128,26 @@ module DiffHelper
...
@@ -128,4 +128,26 @@ module DiffHelper
title
title
end
end
end
end
def
hide_whitespaces?
params
[
:w
]
==
'1'
end
def
params_with_whitespace
hide_whitespaces?
?
request
.
query_parameters
.
except
(
:w
)
:
request
.
query_parameters
.
merge
(
w:
1
)
end
def
toggle_whitespace_link
(
url
)
link_to
"
#{
hide_whitespaces?
?
'Show'
:
'Hide'
}
whitespace changes"
,
url
,
class:
"btn btn-default"
end
def
commit_diff_whitespace_link
(
project
,
commit
)
url
=
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
.
id
,
params_with_whitespace
)
toggle_whitespace_link
(
url
)
end
def
diff_merge_request_whitespace_link
(
project
,
merge_request
)
url
=
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
params_with_whitespace
)
toggle_whitespace_link
(
url
)
end
end
end
app/views/projects/diffs/_diffs.html.haml
View file @
d8d00b5b
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
.content-block.oneline-block.files-changed
.content-block.oneline-block.files-changed
.inline-parallel-buttons
.inline-parallel-buttons
-
if
current_controller?
(
:commit
)
=
commit_diff_whitespace_link
(
@project
,
@commit
)
-
if
current_controller?
(
:merge_requests
)
=
diff_merge_request_whitespace_link
(
@project
,
@merge_request
)
.btn-group
.btn-group
=
inline_diff_btn
=
inline_diff_btn
=
parallel_diff_btn
=
parallel_diff_btn
...
...
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