Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
34558315
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
34558315
编写于
6月 10, 2016
作者:
Z
Z.J. van de Weg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sort API endpoints and implement feedback
上级
3f88221c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
35 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
34558315
module
API
# Issues API
class
Issues
<
Grape
::
API
class
Issues
<
Grape
::
API
before
{
authenticate!
}
helpers
::
Gitlab
::
AkismetHelper
...
...
lib/api/notes.rb
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录