BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
12 deletions
+53
-12
commits_helper.rb
app/helpers/commits_helper.rb
+4
-2
_file.html.haml
app/views/projects/diffs/_file.html.haml
+6
-0
_image.html.haml
app/views/projects/diffs/viewers/_image.html.haml
+2
-4
add-view-replaced-file-link.yml
changelogs/unreleased/add-view-replaced-file-link.yml
+5
-0
commits.rb
features/steps/project/commits/commits.rb
+1
-1
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
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
(
project_blob_path
(
project
,
tree_join
(
commit_sha
,
diff_new_path
)),
class:
'btn view-file js-view-file'
)
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'
)
end
end
...
...
app/views/projects/diffs/_file.html.haml
View file @
9c096ddf
-
environment
=
local_assigns
.
fetch
(
:environment
,
nil
)
-
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
)
}
.js-file-title.file-title-flex-parent
.file-header-content
...
...
@@ -17,6 +20,9 @@
=
edit_blob_link
(
@merge_request
.
source_project
,
@merge_request
.
source_branch
,
diff_file
.
new_path
,
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_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,8 +15,7 @@
.two-up.view
%span
.wrap
.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
%span
.meta-filesize
=
number_to_human_size
(
old_blob
.
size
)
|
...
...
@@ -27,8 +26,7 @@
%span
.meta-height
%span
.wrap
.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
%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
end
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
[
1
][
'href'
]).
to
match
%r{blob/
#{
sample_image_commit
.
new_blob_id
}
}
end
...
...
spec/features/projects/diffs/diff_show_spec.rb
View file @
9c096ddf
...
...
@@ -62,13 +62,43 @@ feature 'Diff file viewer', :js do
end
context
'Image file'
do
before
do
visit_commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
context
'Replaced'
do
before
do
visit_commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
end
it
'shows a rendered image'
do
within
(
'.diff-file[id="e986451b8f7397b617dbb6fffcb5539328c56921"]'
)
do
expect
(
page
).
to
have_css
(
'img[alt="files/images/6049019_460s.jpg"]'
)
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
it
'shows a rendered image'
do
within
(
'.diff-file[id="e986451b8f7397b617dbb6fffcb5539328c56921"]'
)
do
expect
(
page
).
to
have_css
(
'img[alt="files/images/6049019_460s.jpg"]'
)
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
...
...
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