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
70ed87ba
Commit
70ed87ba
authored
Dec 26, 2018
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use proper finder helper to get existing labels
parent
6383a986
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
lib/api/group_labels.rb
lib/api/group_labels.rb
+13
-11
No files found.
lib/api/group_labels.rb
View file @
70ed87ba
...
@@ -11,7 +11,7 @@ module API
...
@@ -11,7 +11,7 @@ module API
end
end
resource
:groups
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
resource
:groups
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get all labels of the group'
do
desc
'Get all labels of the group'
do
detail
'This feature was added in GitLab 11.
3
'
detail
'This feature was added in GitLab 11.
7
'
success
Entities
::
Label
success
Entities
::
Label
end
end
params
do
params
do
...
@@ -24,7 +24,7 @@ module API
...
@@ -24,7 +24,7 @@ module API
end
end
desc
'Create a new label'
do
desc
'Create a new label'
do
detail
'This feature was added in GitLab 11.
3
'
detail
'This feature was added in GitLab 11.
7
'
success
Entities
::
Label
success
Entities
::
Label
end
end
params
do
params
do
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
post
':id/labels'
do
post
':id/labels'
do
authorize!
:admin_label
,
user_group
authorize!
:admin_label
,
user_group
label
=
available_labels_for
(
user_group
,
{
title:
params
[
:name
]
}
)
label
=
available_labels_for
(
user_group
).
find_by_title
(
params
[
:name
]
)
conflict!
(
'Label already exists'
)
if
label
conflict!
(
'Label already exists'
)
if
label
label
=
::
Labels
::
CreateService
.
new
(
declared_params
(
include_missing:
false
)).
execute
(
group:
user_group
)
label
=
::
Labels
::
CreateService
.
new
(
declared_params
(
include_missing:
false
)).
execute
(
group:
user_group
)
...
@@ -48,7 +48,7 @@ module API
...
@@ -48,7 +48,7 @@ module API
end
end
desc
'Delete an existing label'
do
desc
'Delete an existing label'
do
detail
'This feature was added in GitLab 11.
3
'
detail
'This feature was added in GitLab 11.
7
'
success
Entities
::
Label
success
Entities
::
Label
end
end
params
do
params
do
...
@@ -57,14 +57,13 @@ module API
...
@@ -57,14 +57,13 @@ module API
delete
':id/labels'
do
delete
':id/labels'
do
authorize!
:admin_label
,
user_group
authorize!
:admin_label
,
user_group
label
=
available_labels_for
(
user_group
,
{
title:
params
[
:name
]
})
label
=
find_label
(
user_group
,
params
[
:name
])
not_found!
(
'Label'
)
unless
label
destroy_conditionally!
(
label
)
destroy_conditionally!
(
label
)
end
end
desc
'Update an existing label. At least one optional parameter is required.'
do
desc
'Update an existing label. At least one optional parameter is required.'
do
detail
'This feature was added in GitLab 11.
3
'
detail
'This feature was added in GitLab 11.
7
'
success
Entities
::
Label
success
Entities
::
Label
end
end
params
do
params
do
...
@@ -77,11 +76,14 @@ module API
...
@@ -77,11 +76,14 @@ module API
put
':id/labels'
do
put
':id/labels'
do
authorize!
:admin_label
,
user_group
authorize!
:admin_label
,
user_group
label
=
available_labels_for
(
user_group
,
{
title:
params
[
:name
]
})
label
=
find_label
(
user_group
,
params
[
:name
])
not_found!
(
'Label not found'
)
unless
label
label
=
::
Labels
::
UpdateService
.
new
(
declared_params
(
include_missing:
false
)).
execute
(
label
)
label_params
=
declared_params
(
include_missing:
false
)
render_validation_error!
(
label
)
if
label
.
changed?
# Rename new name to the actual label attribute name
label_params
[
:name
]
=
label_params
.
delete
(
:new_name
)
if
label_params
.
key?
(
:new_name
)
label
=
::
Labels
::
UpdateService
.
new
(
label_params
).
execute
(
label
)
render_validation_error!
(
label
)
unless
label
.
valid?
present
label
,
with:
Entities
::
Label
,
current_user:
current_user
,
parent:
user_group
present
label
,
with:
Entities
::
Label
,
current_user:
current_user
,
parent:
user_group
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