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
Boxiang Sun
gitlab-ce
Commits
9c096ddf
Commit
9c096ddf
authored
Sep 20, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add view replaced file link for image diffs
parent
727f51b8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
12 deletions
+53
-12
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+4
-2
app/views/projects/diffs/_file.html.haml
app/views/projects/diffs/_file.html.haml
+6
-0
app/views/projects/diffs/viewers/_image.html.haml
app/views/projects/diffs/viewers/_image.html.haml
+2
-4
changelogs/unreleased/add-view-replaced-file-link.yml
changelogs/unreleased/add-view-replaced-file-link.yml
+5
-0
features/steps/project/commits/commits.rb
features/steps/project/commits/commits.rb
+1
-1
spec/features/projects/diffs/diff_show_spec.rb
spec/features/projects/diffs/diff_show_spec.rb
+35
-5
No files found.
app/helpers/commits_helper.rb
View file @
9c096ddf
...
@@ -176,13 +176,15 @@ module CommitsHelper
...
@@ -176,13 +176,15 @@ module CommitsHelper
end
end
end
end
def
view_file_button
(
commit_sha
,
diff_new_path
,
project
)
def
view_file_button
(
commit_sha
,
diff_new_path
,
project
,
replaced:
false
)
title
=
replaced
?
_
(
'View replaced file @ '
)
:
_
(
'View file @ '
)
link_to
(
link_to
(
project_blob_path
(
project
,
project_blob_path
(
project
,
tree_join
(
commit_sha
,
diff_new_path
)),
tree_join
(
commit_sha
,
diff_new_path
)),
class:
'btn view-file js-view-file'
class:
'btn view-file js-view-file'
)
do
)
do
raw
(
'View file @ '
)
+
content_tag
(
:span
,
Commit
.
truncate_sha
(
commit_sha
),
raw
(
title
)
+
content_tag
(
:span
,
Commit
.
truncate_sha
(
commit_sha
),
class:
'commit-sha'
)
class:
'commit-sha'
)
end
end
end
end
...
...
app/views/projects/diffs/_file.html.haml
View file @
9c096ddf
-
environment
=
local_assigns
.
fetch
(
:environment
,
nil
)
-
environment
=
local_assigns
.
fetch
(
:environment
,
nil
)
-
file_hash
=
hexdigest
(
diff_file
.
file_path
)
-
file_hash
=
hexdigest
(
diff_file
.
file_path
)
-
image_diff
=
diff_file
.
rich_viewer
&&
diff_file
.
rich_viewer
.
partial_name
==
'image'
-
image_replaced
=
diff_file
.
old_content_sha
&&
diff_file
.
old_content_sha
!=
diff_file
.
content_sha
.diff-file.file-holder
{
id:
file_hash
,
data:
diff_file_html_data
(
project
,
diff_file
.
file_path
,
diff_file
.
content_sha
)
}
.diff-file.file-holder
{
id:
file_hash
,
data:
diff_file_html_data
(
project
,
diff_file
.
file_path
,
diff_file
.
content_sha
)
}
.js-file-title.file-title-flex-parent
.js-file-title.file-title-flex-parent
.file-header-content
.file-header-content
...
@@ -17,6 +20,9 @@
...
@@ -17,6 +20,9 @@
=
edit_blob_link
(
@merge_request
.
source_project
,
@merge_request
.
source_branch
,
diff_file
.
new_path
,
=
edit_blob_link
(
@merge_request
.
source_project
,
@merge_request
.
source_branch
,
diff_file
.
new_path
,
blob:
blob
,
link_opts:
link_opts
)
blob:
blob
,
link_opts:
link_opts
)
-
if
image_diff
&&
image_replaced
=
view_file_button
(
diff_file
.
old_content_sha
,
diff_file
.
old_path
,
project
,
replaced:
true
)
=
view_file_button
(
diff_file
.
content_sha
,
diff_file
.
file_path
,
project
)
=
view_file_button
(
diff_file
.
content_sha
,
diff_file
.
file_path
,
project
)
=
view_on_environment_button
(
diff_file
.
content_sha
,
diff_file
.
file_path
,
environment
)
if
environment
=
view_on_environment_button
(
diff_file
.
content_sha
,
diff_file
.
file_path
,
environment
)
if
environment
...
...
app/views/projects/diffs/viewers/_image.html.haml
View file @
9c096ddf
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
.two-up.view
.two-up.view
%span
.wrap
%span
.wrap
.frame.deleted
.frame.deleted
%a
{
href:
project_blob_path
(
@project
,
tree_join
(
diff_file
.
old_content_sha
,
diff_file
.
old_path
))
}
=
image_tag
(
old_blob_raw_path
,
alt:
diff_file
.
old_path
)
=
image_tag
(
old_blob_raw_path
,
alt:
diff_file
.
old_path
)
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
number_to_human_size
(
old_blob
.
size
)
%span
.meta-filesize
=
number_to_human_size
(
old_blob
.
size
)
...
@@ -27,7 +26,6 @@
...
@@ -27,7 +26,6 @@
%span
.meta-height
%span
.meta-height
%span
.wrap
%span
.wrap
.frame.added
.frame.added
%a
{
href:
project_blob_path
(
@project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
new_path
))
}
=
image_tag
(
blob_raw_path
,
alt:
diff_file
.
new_path
)
=
image_tag
(
blob_raw_path
,
alt:
diff_file
.
new_path
)
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
number_to_human_size
(
blob
.
size
)
%span
.meta-filesize
=
number_to_human_size
(
blob
.
size
)
...
...
changelogs/unreleased/add-view-replaced-file-link.yml
0 → 100644
View file @
9c096ddf
---
title
:
Add view replaced file link for image diffs
merge_request
:
author
:
type
:
changed
features/steps/project/commits/commits.rb
View file @
9c096ddf
...
@@ -139,7 +139,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
...
@@ -139,7 +139,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end
end
step
'The diff links to both the previous and current image'
do
step
'The diff links to both the previous and current image'
do
links
=
page
.
all
(
'.
two-up span div
a'
)
links
=
page
.
all
(
'.
file-actions
a'
)
expect
(
links
[
0
][
'href'
]).
to
match
%r{blob/
#{
sample_image_commit
.
old_blob_id
}
}
expect
(
links
[
0
][
'href'
]).
to
match
%r{blob/
#{
sample_image_commit
.
old_blob_id
}
}
expect
(
links
[
1
][
'href'
]).
to
match
%r{blob/
#{
sample_image_commit
.
new_blob_id
}
}
expect
(
links
[
1
][
'href'
]).
to
match
%r{blob/
#{
sample_image_commit
.
new_blob_id
}
}
end
end
...
...
spec/features/projects/diffs/diff_show_spec.rb
View file @
9c096ddf
...
@@ -62,6 +62,7 @@ feature 'Diff file viewer', :js do
...
@@ -62,6 +62,7 @@ feature 'Diff file viewer', :js do
end
end
context
'Image file'
do
context
'Image file'
do
context
'Replaced'
do
before
do
before
do
visit_commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
visit_commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
end
end
...
@@ -71,6 +72,35 @@ feature 'Diff file viewer', :js do
...
@@ -71,6 +72,35 @@ feature 'Diff file viewer', :js do
expect
(
page
).
to
have_css
(
'img[alt="files/images/6049019_460s.jpg"]'
)
expect
(
page
).
to
have_css
(
'img[alt="files/images/6049019_460s.jpg"]'
)
end
end
end
end
it
'shows view replaced and view file links'
do
expect
(
page
.
all
(
'.file-actions a'
).
length
).
to
eq
2
expect
(
page
.
all
(
'.file-actions a'
)[
0
]).
to
have_content
'View replaced file @'
expect
(
page
.
all
(
'.file-actions a'
)[
1
]).
to
have_content
'View file @'
end
end
context
'Added'
do
before
do
visit_commit
(
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
)
end
it
'shows view file link'
do
expect
(
page
.
all
(
'.file-actions a'
).
length
).
to
eq
1
expect
(
page
.
all
(
'.file-actions a'
)[
0
]).
to
have_content
'View file @'
end
end
context
'Deleted'
do
before
do
visit_commit
(
'7fd7a459706ee87be6f855fd98ce8c552b15529a'
)
end
it
'shows view file link'
do
expect
(
page
.
all
(
'.file-actions a'
).
length
).
to
eq
1
expect
(
page
.
all
(
'.file-actions a'
)[
0
]).
to
have_content
'View file @'
end
end
end
end
context
'ISO file (stored in LFS)'
do
context
'ISO file (stored in LFS)'
do
...
...
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