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
96b83a58
Commit
96b83a58
authored
Sep 01, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve merge request version switch/compare dropdown
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
8b2e065b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
39 deletions
+65
-39
merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+5
-1
git_helper.rb
app/helpers/git_helper.rb
+4
-0
_versions.html.haml
app/views/projects/merge_requests/show/_versions.html.haml
+35
-34
merge_request_versions_spec.rb
spec/features/merge_requests/merge_request_versions_spec.rb
+21
-4
No files found.
app/assets/stylesheets/pages/merge_requests.scss
View file @
96b83a58
...
...
@@ -375,7 +375,7 @@
}
}
.mr-version-
switch
{
.mr-version-
controls
{
background
:
$background-color
;
padding
:
$gl-btn-padding
;
color
:
$gl-placeholder-color
;
...
...
@@ -383,6 +383,10 @@
a
.btn-link
{
color
:
$gl-dark-link-color
;
}
.compare-dots
{
margin
:
0
$btn-side-margin
;
}
}
.merge-request-details
{
...
...
app/helpers/git_helper.rb
View file @
96b83a58
...
...
@@ -2,4 +2,8 @@ module GitHelper
def
strip_gpg_signature
(
text
)
text
.
gsub
(
/-----BEGIN PGP SIGNATURE-----(.*)-----END PGP SIGNATURE-----/m
,
""
)
end
def
short_sha
(
text
)
text
[
0
...
8
]
end
end
app/views/projects/merge_requests/show/_versions.html.haml
View file @
96b83a58
-
merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
select_without_diff
-
compareable_diffs
=
merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
-
if
merge_request_diffs
.
size
>
1
.mr-version-
switch
Version
:
%span
.dropdown.inline
.mr-version-
controls
Version
%span
.dropdown.inline
.mr-version-dropdown
%a
.btn-link.dropdown-toggle
{
data:
{
toggle: :dropdown
}
}
%strong
.monospace
<
-
if
@merge_request_diff
.
latest?
#{
"latest"
}
Latest:
#{
short_sha
(
@merge_request_diff
.
head_commit_sha
)
}
-
else
#{
@merge_request_diff
.
head_commit
.
short_id
}
#{
short_sha
(
@merge_request_diff
.
head_commit_sha
)
}
%span
.caret
%ul
.dropdown-menu.dropdown-menu-selectable
-
merge_request_diffs
.
each
do
|
merge_request_diff
|
-
merge_request_diffs
.
each
_with_index
do
|
merge_request_diff
,
i
|
%li
=
link_to
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
diff_id:
merge_request_diff
.
id
),
class:
(
'is-active'
if
merge_request_diff
==
@merge_request_diff
)
do
%strong
.monospace
-
if
i
.
zero?
Latest:
-
else
#{
merge_request_diffs
.
size
-
i
}
.
#{
merge_request_diff
.
head_commit
.
short_id
}
%br
%small
#{
number_with_delimiter
(
merge_request_diff
.
commits
.
count
)
}
#{
'commit'
.
pluralize
(
merge_request_diff
.
commits
.
count
)
}
,
=
time_ago_with_tooltip
(
merge_request_diff
.
created_at
)
%span
.prepend-left-default
Compared
with:
%span
.dropdown.inline
%a
.btn-link.dropdown-toggle
{
data:
{
toggle: :dropdown
}
}
%strong
.monospace
<
-
if
params
[
:start_sha
].
present?
#{
params
[
:start_sha
][
0
...
8
]
}
-
else
#{
"base"
}
%span
.caret
%ul
.dropdown-menu.dropdown-menu-selectable
-
merge_request_diffs
.
each
do
|
merge_request_diff
|
-
next
if
merge_request_diff
.
id
>=
@merge_request_diff
.
id
%li
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
,
merge_request_diff
.
head_commit_sha
),
class:
(
'is-active'
if
merge_request_diff
.
head_commit_sha
==
params
[
:start_sha
])
do
%strong
.monospace
#{
merge_request_diff
.
head_commit
.
short_id
}
%br
%small
=
time_ago_with_tooltip
(
merge_request_diff
.
created_at
)
%span
.compare-dots
...
Compared
with
%span
.dropdown.inline.mr-version-compare-dropdown
%a
.btn-link.dropdown-toggle
{
data:
{
toggle: :dropdown
}
}
%strong
.monospace
<
-
if
params
[
:start_sha
].
present?
#{
short_sha
(
params
[
:start_sha
])
}
-
else
Base:
#{
short_sha
(
@merge_request_diff
.
base_commit_sha
)
}
%span
.caret
%ul
.dropdown-menu.dropdown-menu-selectable
-
compareable_diffs
.
each_with_index
do
|
merge_request_diff
,
i
|
%li
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
),
class:
(
'is-active'
unless
params
[
:start_sha
].
present?
)
do
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
,
merge_request_diff
.
head_commit_sha
),
class:
(
'is-active'
if
merge_request_diff
.
head_commit_sha
==
params
[
:start_sha
]
)
do
%strong
.monospace
base
#{
compareable_diffs
.
size
-
i
}
.
#{
short_sha
(
merge_request_diff
.
head_commit_sha
)
}
%br
%small
=
time_ago_with_tooltip
(
merge_request_diff
.
created_at
)
%li
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
),
class:
(
'is-active'
unless
params
[
:start_sha
].
present?
)
do
%strong
.monospace
Base:
#{
short_sha
(
@merge_request_diff
.
base_commit_sha
)
}
-
unless
@merge_request_diff
.
latest?
&&
params
[
:start_sha
].
blank?
.p
ull-right
.p
repend-top-10
=
icon
(
'info-circle'
)
-
if
params
[
:start_sha
].
present?
Comments
are
disabled
when
compare
with
version
different
from
base
-
else
This
version
is
not
the
latest
one
.
Comments
are
disabled
Comments
are
disabled
while
viewing
outdated
merge
versions
or
comparing
to
versions
other
than
base
.
spec/features/merge_requests/merge_request_versions_spec.rb
View file @
96b83a58
...
...
@@ -11,7 +11,7 @@ feature 'Merge Request versions', js: true, feature: true do
end
it
'show the latest version of the diff'
do
page
.
within
'.mr-version-
switch
'
do
page
.
within
'.mr-version-
dropdown
'
do
expect
(
page
).
to
have_content
'Version: latest'
end
...
...
@@ -20,15 +20,32 @@ feature 'Merge Request versions', js: true, feature: true do
describe
'switch between versions'
do
before
do
page
.
within
'.mr-version-
switch
'
do
page
.
within
'.mr-version-
dropdown
'
do
find
(
'.btn-link'
).
click
click_link
'6f6d7e7e'
end
end
it
'should show older version'
do
page
.
within
'.mr-version-switch'
do
expect
(
page
).
to
have_content
'Version: 6f6d7e7e'
page
.
within
'.mr-version-dropdown'
do
expect
(
page
).
to
have_content
'6f6d7e7e'
end
expect
(
page
).
to
have_content
'5 changed files'
end
end
describe
'compare with older version'
do
before
do
page
.
within
'.mr-version-compare-dropdown'
do
find
(
'.btn-link'
).
click
click_link
'6f6d7e7e'
end
end
it
'should show older version'
do
page
.
within
'.mr-version-compare-dropdown'
do
expect
(
page
).
to
have_content
'6f6d7e7e'
end
expect
(
page
).
to
have_content
'5 changed files'
...
...
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