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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
ab9612df
Commit
ab9612df
authored
Jan 07, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial json requests instead of HTML
parent
f7164201
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
39 deletions
+66
-39
app/assets/javascripts/merge_request.js.coffee
app/assets/javascripts/merge_request.js.coffee
+6
-0
app/assets/javascripts/merge_request_widget.js.coffee
app/assets/javascripts/merge_request_widget.js.coffee
+3
-2
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+20
-4
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+9
-0
app/views/projects/merge_requests/widget/_closed.html.haml
app/views/projects/merge_requests/widget/_closed.html.haml
+1
-1
app/views/projects/merge_requests/widget/_locked.html.haml
app/views/projects/merge_requests/widget/_locked.html.haml
+1
-1
app/views/projects/merge_requests/widget/_merged.html.haml
app/views/projects/merge_requests/widget/_merged.html.haml
+1
-1
app/views/projects/merge_requests/widget/_open.html.haml
app/views/projects/merge_requests/widget/_open.html.haml
+19
-20
app/views/projects/merge_requests/widget/_show.html.haml
app/views/projects/merge_requests/widget/_show.html.haml
+5
-9
app/views/projects/merge_requests/widget/open/_archived.html.haml
...s/projects/merge_requests/widget/open/_archived.html.haml
+1
-1
No files found.
app/assets/javascripts/merge_request.js.coffee
View file @
ab9612df
...
...
@@ -63,12 +63,18 @@ class @MergeRequest
$
(
'a.btn-reopen'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-closed'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-open'
).
addClass
(
'hidden'
)
$
(
'div.mr-state-widget-closed'
).
removeClass
(
'hidden'
)
$
(
'div.mr-state-widget-opened'
).
addClass
(
'hidden'
)
else
$
(
'a.btn-reopen'
).
addClass
(
'hidden'
)
$
(
'a.issuable-edit'
).
removeClass
(
'hidden'
)
$
(
'a.btn-close'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-closed'
).
addClass
(
'hidden'
)
$
(
'div.status-box-open'
).
removeClass
(
'hidden'
)
$
(
'div.mr-state-widget-closed'
).
addClass
(
'hidden'
)
$
(
'div.mr-state-widget-opened'
).
removeClass
(
'hidden'
)
else
new
Flash
(
mergeRequestFailMessage
,
'alert'
)
$this
.
prop
(
'disabled'
,
false
)
...
...
app/assets/javascripts/merge_request_widget.js.coffee
View file @
ab9612df
...
...
@@ -28,8 +28,9 @@ class @MergeRequestWidget
getMergeStatus
:
->
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
->
$
(
'.mr-state-widget'
).
replaceWith
(
data
)
console
.
log
(
"data"
,
data
);
# $('div.mr-state-widget.mr-state-widget-opened').replaceWith(data)
getCiStatus
:
->
if
@
opts
.
ci_enable
$
.
get
@
opts
.
url_to_ci_check
,
(
data
)
=>
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
ab9612df
...
...
@@ -48,9 +48,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@note_counts
=
Note
.
where
(
commit_id:
@merge_request
.
commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
json_merge_request
=
@merge_requests
.
as_json
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
@merge_request
}
format
.
json
do
render
json:
{
hi:
"yes"
}
end
format
.
diff
{
render
text:
@merge_request
.
to_diff
(
current_user
)
}
format
.
patch
{
render
text:
@merge_request
.
to_patch
(
current_user
)
}
end
...
...
@@ -143,7 +149,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format
.
json
do
render
json:
{
saved:
@merge_request
.
valid?
,
assignee_avatar_url:
@merge_request
.
assignee
.
try
(
:avatar_url
)
assignee_avatar_url:
@merge_request
.
assignee
.
try
(
:avatar_url
),
closed_event:
@merge_request
.
closed_event
}
end
end
...
...
@@ -154,8 +161,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
merge_check
@merge_request
.
check_if_can_be_merged
if
@merge_request
.
unchecked?
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
puts
@merge_request
.
merge_status
respond_to
do
|
format
|
format
.
json
do
render
json:
{
can_be_merged:
@merge_request
.
merge_status
==
:can_be_merged
}
end
format
.
html
do
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
end
end
end
def
cancel_merge_when_build_succeeds
...
...
app/helpers/merge_requests_helper.rb
View file @
ab9612df
...
...
@@ -23,6 +23,15 @@ module MergeRequestsHelper
return
'hidden'
if
mr
.
closed?
==
closed
end
def
merge_request_widget_visibility
(
mr
,
*
states
)
states
.
each
do
|
state
|
if
mr
.
state
==
state
return
end
end
return
'hidden'
end
def
mr_css_classes
(
mr
)
classes
=
"merge-request"
classes
<<
" closed"
if
mr
.
closed?
...
...
app/views/projects/merge_requests/widget/_closed.html.haml
View file @
ab9612df
.mr-state-widget
.mr-state-widget
.mr-state-widget-closed
{
class:
merge_request_widget_visibility
(
@merge_request
,
'closed'
)}
=
render
'projects/merge_requests/widget/heading'
.mr-widget-body
%h4
...
...
app/views/projects/merge_requests/widget/_locked.html.haml
View file @
ab9612df
.mr-state-widget
.mr-state-widget
.mr-state-widget-locked
{
class:
merge_request_widget_visibility
(
@merge_request
,
'locked'
)}
=
render
'projects/merge_requests/widget/heading'
.mr-widget-body
%h4
...
...
app/views/projects/merge_requests/widget/_merged.html.haml
View file @
ab9612df
.mr-state-widget
.mr-state-widget
.mr-state-widget-merged
{
class:
merge_request_widget_visibility
(
@merge_request
,
'merged'
)}
=
render
'projects/merge_requests/widget/heading'
.mr-widget-body
%h4
...
...
app/views/projects/merge_requests/widget/_open.html.haml
View file @
ab9612df
.mr-state-widget
.mr-state-widget
.mr-state-widget-opened
{
class:
merge_request_widget_visibility
(
@merge_request
,
"opened"
,
"reopened"
)}
=
render
'projects/merge_requests/widget/heading'
.mr-widget-body
-
if
@project
.
archived?
=
render
'projects/merge_requests/widget/open/archived'
-
elsif
@merge_request
.
commits
.
blank?
=
render
'projects/merge_requests/widget/open/nothing'
-
elsif
@merge_request
.
branch_missing?
=
render
'projects/merge_requests/widget/open/missing_branch'
-
elsif
@merge_request
.
unchecked?
=
render
'projects/merge_requests/widget/open/check'
-
elsif
@merge_request
.
cannot_be_merged?
=
render
'projects/merge_requests/widget/open/conflicts'
-
elsif
@merge_request
.
work_in_progress?
=
render
'projects/merge_requests/widget/open/wip'
-
elsif
@merge_request
.
merge_when_build_succeeds?
=
render
'projects/merge_requests/widget/open/merge_when_build_succeeds'
-
elsif
!
@merge_request
.
can_be_merged_by?
(
current_user
)
=
render
'projects/merge_requests/widget/open/not_allowed'
-
elsif
@merge_request
.
can_be_merged?
=
render
'projects/merge_requests/widget/open/accept'
.mr-widget-body.merge-request-archived
{
class:
(
"hidden"
unless
@project
.
archived?
)}
=
render
'projects/merge_requests/widget/open/archived'
.mr-widget-body.merge-request-blank
{
class:
(
"hidden"
unless
@merge_request
.
commits
.
blank?
)}
=
render
'projects/merge_requests/widget/open/nothing'
.mr-widget-body.merge-request-branch-missing
{
class:
(
"hidden"
unless
@merge_request
.
branch_missing?
)}
=
render
'projects/merge_requests/widget/open/missing_branch'
.mr-widget-body.merge-request-unchecked
{
class:
(
"hidden"
unless
@merge_request
.
unchecked?
)}
=
render
'projects/merge_requests/widget/open/check'
.mr-widget-body.merge-request-cannot-be-merged
{
class:
(
"hidden"
unless
@merge_request
.
cannot_be_merged?
)}
=
render
'projects/merge_requests/widget/open/conflicts'
.mr-widget-body.merge-request-work-in-progress
{
class:
(
"hidden"
unless
@merge_request
.
work_in_progress?
)}
=
render
'projects/merge_requests/widget/open/wip'
.mr-widget-body.merge-request-merge-when-build-succeeds
{
class:
(
"hidden"
unless
@merge_request
.
merge_when_build_succeeds?
)}
=
render
'projects/merge_requests/widget/open/merge_when_build_succeeds'
.mr-widget-body.not-allowed
{
class:
(
"hidden"
if
@merge_request
.
can_be_merged_by?
(
current_user
))}
=
render
'projects/merge_requests/widget/open/not_allowed'
.mr-widget-body.merge-request-archived.can-be-merged
{
class:
(
"hidden"
unless
@merge_request
.
can_be_merged?
)}
=
render
'projects/merge_requests/widget/open/accept'
-
if
@closes_issues
.
present?
.mr-widget-footer
...
...
app/views/projects/merge_requests/widget/_show.html.haml
View file @
ab9612df
-
if
@merge_request
.
open?
=
render
'projects/merge_requests/widget/open'
-
elsif
@merge_request
.
merged?
=
render
'projects/merge_requests/widget/merged'
-
elsif
@merge_request
.
closed?
=
render
'projects/merge_requests/widget/closed'
-
elsif
@merge_request
.
locked?
=
render
'projects/merge_requests/widget/locked'
=
render
'projects/merge_requests/widget/open'
=
render
'projects/merge_requests/widget/merged'
=
render
'projects/merge_requests/widget/closed'
=
render
'projects/merge_requests/widget/locked'
:javascript
var
merge_request_widget
;
merge_request_widget
=
new
MergeRequestWidget
({
url_to_automerge_check
:
"
#{
merge_check_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
url_to_automerge_check
:
"
#{
merge_check_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
format: :json
)
}
"
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
ci_enable
:
#{
@project
.
ci_service
?
"true"
:
"false"
}
,
...
...
app/views/projects/merge_requests/widget/open/_archived.html.haml
View file @
ab9612df
%h4
%h4
Project is archived
%p
This merge request cannot be merged because archived projects cannot be written to.
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