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
Tatuya Kamada
gitlab-ce
Commits
a1566a9c
Commit
a1566a9c
authored
Jan 05, 2013
by
Koen Punt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted merge_requests.js to coffeescript and updated code
parent
0a94640e
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
142 additions
and
183 deletions
+142
-183
app/assets/javascripts/merge_requests.js
app/assets/javascripts/merge_requests.js
+0
-132
app/assets/javascripts/merge_requests.js.coffee
app/assets/javascripts/merge_requests.js.coffee
+97
-0
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+1
-1
app/assets/stylesheets/sections/merge_requests.scss
app/assets/stylesheets/sections/merge_requests.scss
+2
-2
app/views/merge_requests/_form.html.haml
app/views/merge_requests/_form.html.haml
+4
-3
app/views/merge_requests/_show.html.haml
app/views/merge_requests/_show.html.haml
+27
-30
app/views/merge_requests/automerge.js.haml
app/views/merge_requests/automerge.js.haml
+1
-1
app/views/merge_requests/commits.js.haml
app/views/merge_requests/commits.js.haml
+1
-1
app/views/merge_requests/diffs.js.haml
app/views/merge_requests/diffs.js.haml
+2
-4
app/views/merge_requests/index.html.haml
app/views/merge_requests/index.html.haml
+1
-3
app/views/merge_requests/show.js.haml
app/views/merge_requests/show.js.haml
+1
-1
app/views/merge_requests/show/_commits.html.haml
app/views/merge_requests/show/_commits.html.haml
+4
-4
app/views/merge_requests/show/_mr_accept.html.haml
app/views/merge_requests/show/_mr_accept.html.haml
+1
-1
No files found.
app/assets/javascripts/merge_requests.js
deleted
100644 → 0
View file @
0a94640e
var
MergeRequest
=
{
diffs_loaded
:
false
,
commits_loaded
:
false
,
opts
:
false
,
init
:
function
(
opts
)
{
var
self
=
this
;
self
.
opts
=
opts
;
self
.
initTabs
();
self
.
initMergeWidget
();
$
(
"
.mr_show_all_commits
"
).
bind
(
"
click
"
,
function
()
{
self
.
showAllCommits
();
});
},
initMergeWidget
:
function
()
{
var
self
=
this
;
self
.
showState
(
self
.
opts
.
current_state
);
if
(
$
(
"
.automerge_widget
"
).
length
&&
self
.
opts
.
check_enable
){
$
.
get
(
self
.
opts
.
url_to_automerge_check
,
function
(
data
){
self
.
showState
(
data
.
state
);
},
"
json
"
);
}
if
(
self
.
opts
.
ci_enable
){
$
.
get
(
self
.
opts
.
url_to_ci_check
,
function
(
data
){
self
.
showCiState
(
data
.
status
);
},
"
json
"
);
}
},
initTabs
:
function
()
{
$
(
"
.mr_nav_tabs a
"
).
live
(
"
click
"
,
function
()
{
$
(
"
.mr_nav_tabs a
"
).
parent
().
removeClass
(
"
active
"
);
$
(
this
).
parent
().
addClass
(
"
active
"
);
});
var
current_tab
;
if
(
this
.
opts
.
action
==
"
diffs
"
)
{
current_tab
=
$
(
"
.mr_nav_tabs .merge-diffs-tab
"
);
}
else
{
current_tab
=
$
(
"
.mr_nav_tabs .merge-notes-tab
"
);
}
current_tab
.
parent
().
addClass
(
"
active
"
);
this
.
initNotesTab
();
this
.
initDiffTab
();
},
initNotesTab
:
function
()
{
$
(
"
.mr_nav_tabs a.merge-notes-tab
"
).
live
(
"
click
"
,
function
(
e
)
{
$
(
"
.merge-request-diffs
"
).
hide
();
$
(
"
.merge_request_notes
"
).
show
();
var
mr_path
=
$
(
"
.merge-notes-tab
"
).
attr
(
"
data-url
"
);
history
.
pushState
({
path
:
mr_path
},
''
,
mr_path
);
e
.
preventDefault
();
});
},
initDiffTab
:
function
()
{
$
(
"
.mr_nav_tabs a.merge-diffs-tab
"
).
live
(
"
click
"
,
function
(
e
)
{
if
(
!
MergeRequest
.
diffs_loaded
)
{
MergeRequest
.
loadDiff
();
}
$
(
"
.merge_request_notes
"
).
hide
();
$
(
"
.merge-request-diffs
"
).
show
();
var
mr_diff_path
=
$
(
"
.merge-diffs-tab
"
).
attr
(
"
data-url
"
);
history
.
pushState
({
path
:
mr_diff_path
},
''
,
mr_diff_path
);
e
.
preventDefault
();
});
},
showState
:
function
(
state
){
$
(
"
.automerge_widget
"
).
hide
();
$
(
"
.automerge_widget.
"
+
state
).
show
();
},
showCiState
:
function
(
state
){
$
(
"
.ci_widget
"
).
hide
();
$
(
"
.ci_widget.ci-
"
+
state
).
show
();
},
loadDiff
:
function
()
{
$
(
"
.dashboard-loader
"
).
show
();
$
.
ajax
({
type
:
"
GET
"
,
url
:
$
(
"
.merge-diffs-tab
"
).
attr
(
"
data-url
"
),
beforeSend
:
function
(){
$
(
'
.status
'
).
addClass
(
"
loading
"
)},
complete
:
function
(){
MergeRequest
.
diffs_loaded
=
true
;
$
(
"
.merge_request_notes
"
).
hide
();
$
(
'
.status
'
).
removeClass
(
"
loading
"
);
},
dataType
:
"
script
"
});
},
showAllCommits
:
function
()
{
$
(
"
.first_mr_commits
"
).
remove
();
$
(
"
.all_mr_commits
"
).
removeClass
(
"
hide
"
);
},
already_cannot_be_merged
:
function
(){
$
(
"
.automerge_widget
"
).
hide
();
$
(
"
.merge_in_progress
"
).
hide
();
$
(
"
.automerge_widget.already_cannot_be_merged
"
).
show
();
}
};
/*
* Filter merge requests
*/
function
merge_requestsPage
()
{
$
(
"
#assignee_id
"
).
chosen
();
$
(
"
#milestone_id
"
).
chosen
();
$
(
"
#milestone_id, #assignee_id
"
).
on
(
"
change
"
,
function
(){
$
(
this
).
closest
(
"
form
"
).
submit
();
});
}
app/assets/javascripts/merge_requests.js.coffee
0 → 100644
View file @
a1566a9c
#
# * Filter merge requests
#
@
merge_requestsPage
=
->
$
(
'#assignee_id'
).
chosen
()
$
(
'#milestone_id'
).
chosen
()
$
(
'#milestone_id, #assignee_id'
).
on
'change'
,
->
$
(
this
).
closest
(
'form'
).
submit
()
class
MergeRequest
constructor
:
(
@
opts
)
->
this
.
$el
=
$
(
'.merge-request'
)
@
diffs_loaded
=
false
@
commits_loaded
=
false
this
.
activateTab
(
@
opts
.
action
)
this
.
bindEvents
()
this
.
initMergeWidget
()
this
.
$
(
'.show-all-commits'
).
on
'click'
,
=>
this
.
showAllCommits
()
# Local jQuery finder
$
:
(
selector
)
->
this
.
$el
.
find
(
selector
)
initMergeWidget
:
->
this
.
showState
(
@
opts
.
current_state
)
if
this
.
$
(
'.automerge_widget'
).
length
and
@
opts
.
check_enable
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
=>
this
.
showState
(
data
.
state
)
,
'json'
if
@
opts
.
ci_enable
$
.
get
self
.
opts
.
url_to_ci_check
,
(
data
)
=>
this
.
showCiState
data
.
status
,
'json'
bindEvents
:
->
this
.
$
(
'.nav-tabs'
).
on
'click'
,
'a'
,
(
event
)
=>
a
=
$
(
event
.
currentTarget
)
href
=
a
.
attr
(
'href'
)
History
.
replaceState
{
path
:
href
},
document
.
title
,
href
event
.
preventDefault
()
this
.
$
(
'.nav-tabs'
).
on
'click'
,
'li'
,
(
event
)
=>
this
.
activateTab
(
$
(
event
.
currentTarget
).
data
(
'action'
))
activateTab
:
(
action
)
->
this
.
$
(
'.nav-tabs li'
).
removeClass
'active'
this
.
$
(
'.tab-content'
).
hide
()
switch
action
when
'diffs'
this
.
$
(
'.nav-tabs .diffs-tab'
).
addClass
'active'
this
.
loadDiff
()
unless
@
diffs_loaded
this
.
$
(
'.diffs'
).
show
()
else
this
.
$
(
'.nav-tabs .notes-tab'
).
addClass
'active'
this
.
$
(
'.notes'
).
show
()
showState
:
(
state
)
->
$
(
'.automerge_widget'
).
hide
()
$
(
'.automerge_widget.'
+
state
).
show
()
showCiState
:
(
state
)
->
$
(
'.ci_widget'
).
hide
()
$
(
'.ci_widget.ci-'
+
state
).
show
()
loadDiff
:
(
event
)
->
$
(
'.dashboard-loader'
).
show
()
$
.
ajax
type
:
'GET'
url
:
this
.
$
(
'.nav-tabs .diffs-tab a'
).
attr
(
'href'
)
beforeSend
:
=>
this
.
$
(
'.status'
).
addClass
'loading'
complete
:
=>
@
diffs_loaded
=
true
this
.
$
(
'.status'
).
removeClass
'loading'
dataType
:
'script'
showAllCommits
:
->
this
.
$
(
'.first-commits'
).
remove
()
this
.
$
(
'.all-commits'
).
removeClass
'hide'
alreadyOrCannotBeMerged
:
->
this
.
$
(
'.automerge_widget'
).
hide
()
this
.
$
(
'.merge-in-progress'
).
hide
()
this
.
$
(
'.automerge_widget.already_cannot_be_merged'
).
show
()
this
.
MergeRequest
=
MergeRequest
\ No newline at end of file
app/assets/stylesheets/common.scss
View file @
a1566a9c
...
...
@@ -425,7 +425,7 @@ li.note {
.supp_diff_link
,
.
mr_show_all_
commits
{
.
show-all-
commits
{
cursor
:
pointer
;
}
...
...
app/assets/stylesheets/sections/merge_requests.scss
View file @
a1566a9c
...
...
@@ -43,7 +43,7 @@
}
}
.m
r_nav_tabs
{
.m
erge-request
.nav-tabs
{
li
{
a
{
font-weight
:
bold
;
...
...
@@ -65,7 +65,7 @@ li.merge_request {
}
}
.merge
_in_
progress
{
.merge
-in-
progress
{
@extend
.padded
;
@extend
.append-bottom-10
;
}
...
...
app/views/merge_requests/_form.html.haml
View file @
a1566a9c
=
form_for
[
@project
,
@merge_request
],
html:
{
class:
"
new_merge_
request form-horizontal"
}
do
|
f
|
=
form_for
[
@project
,
@merge_request
],
html:
{
class:
"
#{
controller
.
action_name
}
-merge-
request form-horizontal"
}
do
|
f
|
-
if
@merge_request
.
errors
.
any?
.alert-message.block-message.error
%ul
...
...
@@ -61,8 +61,9 @@
:javascript
$
(
function
(){
disableButtonIfEmptyField
(
"
#merge_request_title
"
,
"
.save-btn
"
);
var
source_branch
=
$
(
"
#merge_request_source_branch
"
);
var
target_branch
=
$
(
"
#merge_request_target_branch
"
);
var
source_branch
=
$
(
"
#merge_request_source_branch
"
)
,
target_branch
=
$
(
"
#merge_request_target_branch
"
);
$
.
get
(
"
#{
branch_from_project_merge_requests_path
(
@project
)
}
"
,
{
ref
:
source_branch
.
val
()
});
$
.
get
(
"
#{
branch_to_project_merge_requests_path
(
@project
)
}
"
,
{
ref
:
target_branch
.
val
()
});
...
...
app/views/merge_requests/_show.html.haml
View file @
a1566a9c
=
render
"merge_requests/show/mr_title"
=
render
"merge_requests/show/how_to_merge"
=
render
"merge_requests/show/mr_box"
=
render
"merge_requests/show/mr_accept"
-
if
@project
.
gitlab_ci?
.merge-request
=
render
"merge_requests/show/mr_title"
=
render
"merge_requests/show/how_to_merge"
=
render
"merge_requests/show/mr_box"
=
render
"merge_requests/show/mr_accept"
-
if
@project
.
gitlab_ci?
=
render
"merge_requests/show/mr_ci"
=
render
"merge_requests/show/commits"
=
render
"merge_requests/show/commits"
-
if
@commits
.
present?
%ul
.nav.nav-tabs.mr_nav_
tabs
%li
=
link_to
"#notes"
,
"data-url"
=>
project_merge_request_path
(
@project
,
@merge_request
),
class:
"merge-notes-tab tab"
do
-
if
@commits
.
present?
%ul
.nav.nav-
tabs
%li
.notes-tab
{
data:
{
action:
'notes'
}}
=
link_to
project_merge_request_path
(
@project
,
@merge_request
)
do
%i
.icon-comment
Comments
%li
=
link_to
"#diffs"
,
"data-url"
=>
diffs_project_merge_request_path
(
@project
,
@merge_request
),
class:
"merge-diffs-tab tab"
do
%li
.diffs-tab
{
data:
{
action:
'diffs'
}}
=
link_to
diffs_project_merge_request_path
(
@project
,
@merge_request
)
do
%i
.icon-list-alt
Diff
.merge_request_notes
.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
.notes.tab-content
.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
=
render
(
"notes/notes_with_form"
,
tid:
@merge_request
.
id
,
tt:
"merge_request"
)
.merge-request-diffs
.diffs.tab-content
=
render
"merge_requests/show/diffs"
if
@diffs
.status
.status
=
render
"notes/per_line_form"
=
render
"notes/per_line_form"
:javascript
var
merge_request
;
$
(
function
(){
MergeRequest
.
ini
t
({
merge_request
=
new
MergeReques
t
({
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
state
==
MergeRequest
::
UNCHECKED
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
...
...
@@ -35,10 +37,5 @@
current_state
:
"
#{
@merge_request
.
human_state
}
"
,
action
:
"
#{
controller
.
action_name
}
"
});
$
(
"
.edit_merge_request
"
).
live
(
"
ajax:beforeSend
"
,
function
()
{
$
(
'
.can_be_merged
'
).
hide
();
$
(
'
.merge_in_progress
'
).
show
();
})
})
});
app/views/merge_requests/automerge.js.haml
View file @
a1566a9c
...
...
@@ -3,5 +3,5 @@
location.reload();
-
else
:plain
MergeRequest.already_cannot_be_m
erged()
merge_request.alreadyOrCannotBeM
erged()
app/views/merge_requests/commits.js.haml
View file @
a1566a9c
:plain
$(".merge-request-
commits").html("
#{
escape_javascript
(
render
(
partial:
"commits"
))
}
");
merge_request.$(".
commits").html("
#{
escape_javascript
(
render
(
partial:
"commits"
))
}
");
app/views/merge_requests/diffs.js.haml
View file @
a1566a9c
:plain
$(".merge-request-
diffs").html("
#{
escape_javascript
(
render
(
partial:
"merge_requests/show/diffs"
))
}
");
merge_request.$(".
diffs").html("
#{
escape_javascript
(
render
(
partial:
"merge_requests/show/diffs"
))
}
");
$(function(){
PerLineNotes.init();
});
app/views/merge_requests/index.html.haml
View file @
a1566a9c
...
...
@@ -43,6 +43,4 @@
%span
.cgray.right
#{
@merge_requests
.
total_count
}
merge requests for this filter
:javascript
$
(
function
()
{
merge_requestsPage
();
})
$
(
merge_requestsPage
);
app/views/merge_requests/show.js.haml
View file @
a1566a9c
:plain
$(".merge-request-notes").html("
#{
escape_javascript
(
render
notes
/
notes_with_form
", tid: @merge_request.id, tt: "
merge_request
")
}
");
merge_request.$(".notes").html("
#{
escape_javascript
(
render
"
notes/notes_with_form"
,
tid:
@merge_request
.
id
,
tt:
"merge_request"
)
}
");
app/views/merge_requests/show/_commits.html.haml
View file @
a1566a9c
...
...
@@ -3,16 +3,16 @@
%h5
.title
%i
.icon-list
Commits (
#{
@commits
.
count
}
)
.
merge-request-
commits
.commits
-
if
@commits
.
count
>
8
%ul
.first
_mr_
commits.well-list
%ul
.first
-
commits.well-list
-
@commits
.
first
(
8
).
each
do
|
commit
|
=
render
"commits/commit"
,
commit:
commit
%li
.bottom
8 of
#{
@commits
.
count
}
commits displayed.
%strong
%a
.
mr_show_all_
commits
Click here to show all
%ul
.all
_mr_
commits.hide.well-list
%a
.
show-all-
commits
Click here to show all
%ul
.all
-
commits.hide.well-list
-
@commits
.
each
do
|
commit
|
=
render
"commits/commit"
,
commit:
commit
...
...
app/views/merge_requests/show/_mr_accept.html.haml
View file @
a1566a9c
...
...
@@ -40,6 +40,6 @@
.alert.alert-info
%strong
This merge request already can not be merged. Try to reload page.
.merge
_in_
progress.hide
.merge
-in-
progress.hide
%span
.cgray
Merge is in progress. Please wait. Page will be automatically reloaded.
=
image_tag
"ajax_loader.gif"
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