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
32c663ff
Commit
32c663ff
authored
Sep 20, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use policies to handle with global/project label permissions
parent
701544fb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+0
-10
app/policies/group_label_policy.rb
app/policies/group_label_policy.rb
+5
-0
app/policies/label_policy.rb
app/policies/label_policy.rb
+7
-0
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+2
-2
No files found.
app/helpers/labels_helper.rb
View file @
32c663ff
...
...
@@ -54,16 +54,6 @@ module LabelsHelper
end
end
def
can_admin_label
(
label
)
subject
=
case
label
when
GroupLabel
then
label
.
group
else
label
.
project
end
can?
(
current_user
,
:admin_label
,
subject
)
end
def
edit_label_path
(
label
)
case
label
when
GroupLabel
then
edit_group_label_path
(
label
.
group
,
label
)
...
...
app/policies/group_label_policy.rb
0 → 100644
View file @
32c663ff
class
GroupLabelPolicy
<
BasePolicy
def
rules
can!
:admin_label
if
Ability
.
allowed?
(
@user
,
:admin_label
,
@subject
.
group
)
end
end
app/policies/label_policy.rb
0 → 100644
View file @
32c663ff
class
LabelPolicy
<
BasePolicy
def
rules
return
unless
@user
can!
:admin_label
if
Ability
.
allowed?
(
@user
,
:admin_label
,
@subject
.
project
)
end
end
app/views/shared/_label.html.haml
View file @
32c663ff
...
...
@@ -21,7 +21,7 @@
%li
.label-subscription
{
data:
{
url:
toggle_subscription_label_path
(
label
)
}
}
%a
.js-subscribe-button.label-subscribe-button.subscription-status
{
role:
"button"
,
href:
"#"
,
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
)
-
if
can
_admin_label
(
label
)
-
if
can
?
(
current_user
,
:admin_label
,
label
)
%li
=
link_to
'Edit'
,
edit_label_path
(
label
)
%li
...
...
@@ -40,7 +40,7 @@
=
icon
(
'eye'
,
class:
'label-subscribe-button-icon'
)
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
-
if
can
_admin_label
(
label
)
-
if
can
?
(
current_user
,
:admin_label
,
label
)
=
link_to
edit_label_path
(
label
),
title:
"Edit"
,
class:
'btn btn-transparent btn-action'
,
data:
{
toggle:
"tooltip"
}
do
%span
.sr-only
Edit
=
icon
(
'pencil-square-o'
)
...
...
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