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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
eeb41c75
Commit
eeb41c75
authored
Jul 25, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoints to resolve diff notes and discussions
parent
ed6c8238
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
12 deletions
+71
-12
app/controllers/projects/discussions_controller.rb
app/controllers/projects/discussions_controller.rb
+40
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+2
-5
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+14
-3
app/models/merge_request.rb
app/models/merge_request.rb
+7
-0
config/routes.rb
config/routes.rb
+8
-4
No files found.
app/controllers/projects/discussions_controller.rb
0 → 100644
View file @
eeb41c75
class
Projects::DiscussionsController
<
Projects
::
ApplicationController
before_action
:module_enabled
before_action
:merge_request
before_action
:discussion
before_action
:authorize_resolve_discussion!
def
resolve
return
render_404
unless
discussion
.
resolvable?
discussion
.
resolve!
(
current_user
)
head
:ok
end
def
unresolve
return
render_404
unless
discussion
.
resolvable?
discussion
.
unresolve!
head
:ok
end
private
def
merge_request
@merge_request
||=
@project
.
merge_requests
.
find_by!
(
iid:
params
[
:merge_request_id
])
end
def
discussion
@discussion
||=
@merge_request
.
discussions
.
find
{
|
d
|
d
.
id
==
params
[
:id
]
}
||
render_404
end
def
authorize_resolve_discussion!
access_denied!
unless
discussion
.
can_resolve?
(
current_user
)
end
def
module_enabled
render_404
unless
@project
.
merge_requests_enabled
end
end
app/controllers/projects/merge_requests_controller.rb
View file @
eeb41c75
...
@@ -369,12 +369,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -369,12 +369,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
# :show, :diff, :commits, :builds. but not when request the data through AJAX
# :show, :diff, :commits, :builds. but not when request the data through AJAX
def
define_discussion_vars
def
define_discussion_vars
# Build a note object for comment form
# Build a note object for comment form
@note
=
@project
.
notes
.
new
(
noteable:
@
noteable
)
@note
=
@project
.
notes
.
new
(
noteable:
@
merge_request
)
@discussions
=
@noteable
.
mr_and_commit_notes
.
@discussions
=
@merge_request
.
discussions
inc_author_project_award_emoji
.
fresh
.
discussions
# This is not executed lazily
# This is not executed lazily
@notes
=
Banzai
::
NoteRenderer
.
render
(
@notes
=
Banzai
::
NoteRenderer
.
render
(
...
...
app/controllers/projects/notes_controller.rb
View file @
eeb41c75
...
@@ -5,6 +5,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -5,6 +5,7 @@ class Projects::NotesController < Projects::ApplicationController
before_action
:authorize_read_note!
before_action
:authorize_read_note!
before_action
:authorize_create_note!
,
only:
[
:create
]
before_action
:authorize_create_note!
,
only:
[
:create
]
before_action
:authorize_admin_note!
,
only:
[
:update
,
:destroy
]
before_action
:authorize_admin_note!
,
only:
[
:update
,
:destroy
]
before_action
:authorize_resolve_note!
,
only:
[
:resolve
]
before_action
:find_current_user_notes
,
only:
[
:index
]
before_action
:find_current_user_notes
,
only:
[
:index
]
def
index
def
index
...
@@ -67,12 +68,18 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -67,12 +68,18 @@ class Projects::NotesController < Projects::ApplicationController
end
end
def
resolve
def
resolve
sleep
2
return
render_404
unless
note
.
resolvable?
note
.
resolve!
(
current_user
)
head
:ok
head
:ok
end
end
def
resolve_all
def
unresolve
sleep
2
return
render_404
unless
note
.
resolvable?
note
.
unresolve!
head
:ok
head
:ok
end
end
...
@@ -185,6 +192,10 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -185,6 +192,10 @@ class Projects::NotesController < Projects::ApplicationController
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
note
)
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
note
)
end
end
def
authorize_resolve_note!
return
access_denied!
unless
can?
(
current_user
,
:resolve_note
,
note
)
end
def
note_params
def
note_params
params
.
require
(
:note
).
permit
(
params
.
require
(
:note
).
permit
(
:note
,
:noteable
,
:noteable_id
,
:noteable_type
,
:project_id
,
:note
,
:noteable
,
:noteable_id
,
:noteable_type
,
:project_id
,
...
...
app/models/merge_request.rb
View file @
eeb41c75
...
@@ -394,6 +394,13 @@ class MergeRequest < ActiveRecord::Base
...
@@ -394,6 +394,13 @@ class MergeRequest < ActiveRecord::Base
)
)
end
end
def
discussions
self
.
mr_and_commit_notes
.
inc_author_project_award_emoji
.
fresh
.
discussions
end
def
hook_attrs
def
hook_attrs
attrs
=
{
attrs
=
{
source:
source_project
.
try
(
:hook_attrs
),
source:
source_project
.
try
(
:hook_attrs
),
...
...
config/routes.rb
View file @
eeb41c75
...
@@ -720,6 +720,13 @@ Rails.application.routes.draw do
...
@@ -720,6 +720,13 @@ Rails.application.routes.draw do
get
:update_branches
get
:update_branches
get
:diff_for_path
get
:diff_for_path
end
end
resources
:discussions
,
only:
[],
constraints:
{
id:
/\h{40}/
}
do
member
do
post
:resolve
delete
:resolve
,
action: :unresolve
end
end
end
end
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
...
@@ -825,14 +832,11 @@ Rails.application.routes.draw do
...
@@ -825,14 +832,11 @@ Rails.application.routes.draw do
resources
:group_links
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
resources
:group_links
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
constraints:
{
id:
/\d+/
}
do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
constraints:
{
id:
/\d+/
}
do
collection
do
post
:resolve_all
end
member
do
member
do
post
:toggle_award_emoji
post
:toggle_award_emoji
delete
:delete_attachment
delete
:delete_attachment
post
:resolve
post
:resolve
delete
:resolve
,
action: :unresolve
end
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