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
iv
gitlab-ce
Commits
34558315
Commit
34558315
authored
Jun 10, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort API endpoints and implement feedback
parent
3f88221c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
35 deletions
+41
-35
CHANGELOG
CHANGELOG
+1
-0
lib/api/api.rb
lib/api/api.rb
+26
-25
lib/api/award_emoji.rb
lib/api/award_emoji.rb
+12
-8
lib/api/issues.rb
lib/api/issues.rb
+1
-1
lib/api/notes.rb
lib/api/notes.rb
+1
-1
No files found.
CHANGELOG
View file @
34558315
...
...
@@ -48,6 +48,7 @@ v 8.9.0 (unreleased)
- Upgrade to jQuery 2
- Adds selected branch name to the dropdown toggle
- Add API endpoint for Sidekiq Metrics !4653
- Refactoring Award Emoji with API support for Issues and MergeRequests
- Use Knapsack to evenly distribute tests across multiple nodes
- Add `sha` parameter to MR merge API, to ensure only reviewed changes are merged
- Don't allow MRs to be merged when commits were added since the last review / page load
...
...
lib/api/api.rb
View file @
34558315
...
...
@@ -26,40 +26,41 @@ module API
# Ensure the namespace is right, otherwise we might load Grape::API::Helpers
helpers
::
API
::
Helpers
mount
::
API
::
Groups
# Sort these alphabetically
mount
::
API
::
AwardEmoji
mount
::
API
::
Branches
mount
::
API
::
Builds
mount
::
API
::
CommitStatuses
mount
::
API
::
Commits
mount
::
API
::
DeployKeys
mount
::
API
::
Files
mount
::
API
::
Gitignores
mount
::
API
::
GroupMembers
mount
::
API
::
Users
mount
::
API
::
Projects
mount
::
API
::
Repositories
mount
::
API
::
Groups
mount
::
API
::
Internal
mount
::
API
::
Issues
mount
::
API
::
Milestones
mount
::
API
::
Session
mount
::
API
::
Keys
mount
::
API
::
Labels
mount
::
API
::
Licenses
mount
::
API
::
MergeRequests
mount
::
API
::
Milestones
mount
::
API
::
Namespaces
mount
::
API
::
Notes
mount
::
API
::
AwardEmoji
mount
::
API
::
Internal
mount
::
API
::
SystemHooks
mount
::
API
::
ProjectSnippets
mount
::
API
::
ProjectMembers
mount
::
API
::
DeployKeys
mount
::
API
::
ProjectHooks
mount
::
API
::
ProjectMembers
mount
::
API
::
ProjectSnippets
mount
::
API
::
Projects
mount
::
API
::
Repositories
mount
::
API
::
Runners
mount
::
API
::
Services
mount
::
API
::
Files
mount
::
API
::
Commits
mount
::
API
::
CommitStatuses
mount
::
API
::
Namespaces
mount
::
API
::
Branches
mount
::
API
::
Labels
mount
::
API
::
Session
mount
::
API
::
Settings
mount
::
API
::
Keys
mount
::
API
::
SidekiqMetrics
mount
::
API
::
Subscriptions
mount
::
API
::
SystemHooks
mount
::
API
::
Tags
mount
::
API
::
Triggers
mount
::
API
::
Build
s
mount
::
API
::
User
s
mount
::
API
::
Variables
mount
::
API
::
Runners
mount
::
API
::
Licenses
mount
::
API
::
Subscriptions
mount
::
API
::
Gitignores
mount
::
API
::
SidekiqMetrics
end
end
lib/api/award_emoji.rb
View file @
34558315
...
...
@@ -17,9 +17,9 @@ module API
# Example Request:
# GET /projects/:id/issues/:awardable_id/award_emoji
get
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
do
awardable
=
user_project
.
send
(
awardable_string
.
to_sym
).
find
(
params
[
awardable_id_string
.
to_sym
])
awardable
=
user_project
.
send
(
awardable_string
.
to_sym
).
find
(
params
[
awardable_id_string
])
if
can
?
(
current_user
,
awardable_read_ability_name
(
awardable
),
awardable
)
if
can
_read_awardable?
(
awardable
)
awards
=
paginate
(
awardable
.
award_emoji
)
present
awards
,
with:
Entities
::
AwardEmoji
else
...
...
@@ -38,7 +38,7 @@ module API
get
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji/:award_id"
do
awardable
=
user_project
.
send
(
awardable_string
.
to_sym
).
find
(
params
[
awardable_id_string
.
to_sym
])
if
can
?
(
current_user
,
awardable_read_ability_name
(
awardable
),
awardable
)
if
can
_read_awardable?
(
awardable
)
present
awardable
.
award_emoji
.
find
(
params
[
:award_id
]),
with:
Entities
::
AwardEmoji
else
not_found!
(
"Award Emoji"
)
...
...
@@ -49,16 +49,15 @@ module API
#
# Parameters:
# id (required) - The ID of a project
#
noteable_id (required) - The ID of an issue or snippet
#
awardable_id (required) - The ID of an issue or mr
# name (required) - The name of a award_emoji (without colons)
# Example Request:
# POST /projects/:id/issues/:noteable_id/notes
# POST /projects/:id/snippets/:noteable_id/notes
# POST /projects/:id/issues/:awardable_id/notes
post
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
do
required_attributes!
[
:name
]
awardable
=
user_project
.
send
(
awardable_string
.
to_sym
).
find
(
params
[
awardable_id_string
.
to_sym
])
not_found!
(
'Award Emoji'
)
unless
can
?
(
current_user
,
awardable_read_ability_name
(
awardable
),
awardable
)
not_found!
(
'Award Emoji'
)
unless
can
_read_awardable?
(
awardable
)
award
=
awardable
.
award_emoji
.
new
(
name:
params
[
:name
],
user:
current_user
)
...
...
@@ -90,7 +89,12 @@ module API
end
helpers
do
def
awardable_read_ability_name
(
awardable
)
"read_
#{
awardable
.
class
.
to_s
.
underscore
.
downcase
}
"
.
to_sym
end
def
can_read_awardable?
(
awardable
)
ability
=
"read_
#{
awardable
.
class
.
to_s
.
underscore
}
"
.
to_sym
can?
(
current_user
,
ability
,
awardable
)
end
end
end
...
...
lib/api/issues.rb
View file @
34558315
lib/api/notes.rb
View file @
34558315
...
...
@@ -144,7 +144,7 @@ module API
helpers
do
def
noteable_read_ability_name
(
noteable
)
"read_
#{
noteable
.
class
.
to_s
.
underscore
.
downcase
}
"
.
to_sym
"read_
#{
noteable
.
class
.
to_s
.
underscore
}
"
.
to_sym
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