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
Jérome Perrin
gitlab-ce
Commits
1567572e
Commit
1567572e
authored
Dec 08, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Builds tab to MR detail page
parent
a17ba43b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
16 deletions
+69
-16
app/assets/javascripts/merge_request_tabs.js.coffee
app/assets/javascripts/merge_request_tabs.js.coffee
+21
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+29
-12
app/views/projects/merge_requests/_new_submit.html.haml
app/views/projects/merge_requests/_new_submit.html.haml
+8
-0
app/views/projects/merge_requests/_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+8
-2
app/views/projects/merge_requests/show/_builds.html.haml
app/views/projects/merge_requests/show/_builds.html.haml
+1
-0
app/views/projects/merge_requests/widget/_heading.html.haml
app/views/projects/merge_requests/widget/_heading.html.haml
+1
-1
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/assets/javascripts/merge_request_tabs.js.coffee
View file @
1567572e
...
...
@@ -43,6 +43,7 @@
#
class
@
MergeRequestTabs
diffsLoaded
:
false
buildsLoaded
:
false
commitsLoaded
:
false
constructor
:
(
@
opts
=
{})
->
...
...
@@ -54,6 +55,12 @@ class @MergeRequestTabs
bindEvents
:
->
$
(
document
).
on
'shown.bs.tab'
,
'.merge-request-tabs a[data-toggle="tab"]'
,
@
tabShown
$
(
document
).
on
'click'
,
'.js-show-tab'
,
@
showTab
showTab
:
(
event
)
=>
event
.
preventDefault
()
@
activateTab
$
(
event
.
target
).
data
(
'action'
)
tabShown
:
(
event
)
=>
$target
=
$
(
event
.
target
)
...
...
@@ -61,6 +68,8 @@ class @MergeRequestTabs
if
action
==
'commits'
@
loadCommits
(
$target
.
attr
(
'href'
))
else
if
action
==
'builds'
@
loadBuilds
(
$target
.
attr
(
'href'
))
else
if
action
==
'diffs'
@
loadDiff
(
$target
.
attr
(
'href'
))
...
...
@@ -101,7 +110,7 @@ class @MergeRequestTabs
action
=
'notes'
if
action
==
'show'
# Remove a trailing '/commits' or '/diffs'
new_state
=
@
_location
.
pathname
.
replace
(
/\/(commits|diffs)(\.html)?\/?$/
,
''
)
new_state
=
@
_location
.
pathname
.
replace
(
/\/(commits|
builds|
diffs)(\.html)?\/?$/
,
''
)
# Append the new action if we're on a tab other than 'notes'
unless
action
==
'notes'
...
...
@@ -129,6 +138,17 @@ class @MergeRequestTabs
@
commitsLoaded
=
true
@
scrollToElement
(
"#commits"
)
loadBuilds
:
(
source
)
->
return
if
@
buildsLoaded
@
_get
url
:
"
#{
source
}
.json"
success
:
(
data
)
=>
document
.
getElementById
(
'builds'
).
innerHTML
=
data
.
html
$
(
'.js-timeago'
).
timeago
()
@
buildsLoaded
=
true
@
scrollToElement
(
"#builds"
)
loadDiff
:
(
source
)
->
return
if
@
diffsLoaded
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
1567572e
class
Projects::MergeRequestsController
<
Projects
::
ApplicationController
before_action
:module_enabled
before_action
:merge_request
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:merge
,
:merge_check
,
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:
builds
,
:
merge
,
:merge_check
,
:ci_status
,
:toggle_subscription
]
before_action
:closes_issues
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
]
before_action
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:commits
]
before_action
:define_show_vars
,
only:
[
:show
,
:diffs
,
:commits
]
before_action
:ensure_ref_fetched
,
only:
[
:show
,
:
commits
,
:diff
s
]
before_action
:closes_issues
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:define_show_vars
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:ensure_ref_fetched
,
only:
[
:show
,
:
diffs
,
:commits
,
:build
s
]
# Allow read any merge_request
before_action
:authorize_read_merge_request!
...
...
@@ -79,6 +79,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
builds
@ci_project
=
@merge_request
.
source_project
.
gitlab_ci_project
respond_to
do
|
format
|
format
.
html
{
render
'show'
}
format
.
json
{
render
json:
{
html:
view_to_html_string
(
'projects/merge_requests/show/_builds'
)
}
}
end
end
def
new
params
[
:merge_request
]
||=
ActionController
::
Parameters
.
new
(
source_project:
@project
)
@merge_request
=
MergeRequests
::
BuildService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
...
...
@@ -91,20 +100,19 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@target_project
=
merge_request
.
target_project
@source_project
=
merge_request
.
source_project
@commits
=
@merge_request
.
compare_commits
@commits
=
@merge_request
.
compare_commits
.
reverse
@commit
=
@merge_request
.
last_commit
@first_commit
=
@merge_request
.
first_commit
@diffs
=
@merge_request
.
compare_diffs
@ci_project
=
@source_project
.
gitlab_ci_project
@ci_commit
=
@merge_request
.
ci_commit
@statuses
=
@ci_commit
.
statuses
if
@ci_commit
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
end
def
edit
@source_project
=
@merge_request
.
source_project
@target_project
=
@merge_request
.
target_project
@target_branches
=
@merge_request
.
target_project
.
repository
.
branch_names
end
def
create
@target_branches
||=
[]
@merge_request
=
MergeRequests
::
CreateService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
...
...
@@ -118,6 +126,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
edit
@source_project
=
@merge_request
.
source_project
@target_project
=
@merge_request
.
target_project
@target_branches
=
@merge_request
.
target_project
.
repository
.
branch_names
end
def
update
@merge_request
=
MergeRequests
::
UpdateService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
(
@merge_request
)
...
...
@@ -264,6 +278,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff
=
@merge_request
.
merge_request_diff
@ci_commit
=
@merge_request
.
ci_commit
@statuses
=
@ci_commit
.
statuses
if
@ci_commit
if
@merge_request
.
locked_long_ago?
@merge_request
.
unlock_mr
@merge_request
.
close
...
...
app/views/projects/merge_requests/_new_submit.html.haml
View file @
1567572e
...
...
@@ -23,6 +23,11 @@
=
link_to
url_for
(
params
),
data:
{
target:
'#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
Commits
%span
.badge
=
@commits
.
size
-
if
@ci_commit
%li
.builds-tab.active
=
link_to
url_for
(
params
),
data:
{
target:
'#builds'
,
action:
'builds'
,
toggle:
'tab'
}
do
Builds
%span
.badge
=
@statuses
.
size
%li
.diffs-tab.active
=
link_to
url_for
(
params
),
data:
{
target:
'#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}
do
Changes
...
...
@@ -31,6 +36,9 @@
.tab-content
#commits
.commits.tab-pane
=
render
"projects/merge_requests/show/commits"
-
if
@ci_commit
#builds
.builds.tab-pane
=
render
"projects/merge_requests/show/builds"
#diffs
.diffs.tab-pane.active
-
if
@diffs
.
present?
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
,
project:
@project
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
1567572e
...
...
@@ -26,8 +26,7 @@
%li
=
link_to
"Plain Diff"
,
merge_request_path
(
@merge_request
,
format: :diff
)
.normal
%span
Request to merge
%span
.label-branch
=
source_branch_with_namespace
(
@merge_request
)
%span
.label-branch
=
source_branch_with_namespace
(
@merge_request
)
%span
into
=
link_to
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@merge_request
.
target_branch
),
class:
"label-branch"
do
=
@merge_request
.
target_branch
...
...
@@ -51,6 +50,11 @@
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
Commits
%span
.badge
=
@commits
.
size
-
if
@ci_commit
%li
.builds-tab
=
link_to
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#builds'
,
action:
'builds'
,
toggle:
'tab'
}
do
Builds
%span
.badge
=
@statuses
.
size
%li
.diffs-tab
=
link_to
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}
do
Changes
...
...
@@ -61,6 +65,8 @@
=
render
"projects/merge_requests/discussion"
#commits
.commits.tab-pane
-
# This tab is always loaded via AJAX
#builds
.builds.tab-pane
-
# This tab is always loaded via AJAX
#diffs
.diffs.tab-pane
-
# This tab is always loaded via AJAX
...
...
app/views/projects/merge_requests/show/_builds.html.haml
0 → 100644
View file @
1567572e
=
render
"projects/commit/builds"
,
link_to_commit:
true
app/views/projects/merge_requests/widget/_heading.html.haml
View file @
1567572e
...
...
@@ -7,7 +7,7 @@
%span
CI build
#{
status
}
for
#{
@merge_request
.
last_commit_short_sha
}
.
%span
.ci-coverage
=
link_to
"View build details"
,
ci_status_path
(
ci_commit
)
=
link_to
"View build details"
,
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
"js-show-tab"
,
data:
{
action:
'builds'
}
-
elsif
@merge_request
.
has_ci?
-
# Compatibility with old CI integrations (ex jenkins) when you request status from CI server via AJAX
...
...
config/routes.rb
View file @
1567572e
...
...
@@ -570,6 +570,7 @@ Rails.application.routes.draw do
resources
:merge_requests
,
constraints:
{
id:
/\d+/
},
except:
[
:destroy
]
do
member
do
get
:diffs
get
:builds
get
:commits
post
:merge
get
:merge_check
...
...
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