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
57576873
Commit
57576873
authored
Apr 14, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protected tags EE backend refactoring
parent
14bd793c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
24 deletions
+21
-24
app/controllers/projects/protected_branches_controller.rb
app/controllers/projects/protected_branches_controller.rb
+2
-2
app/controllers/projects/protected_refs_controller.rb
app/controllers/projects/protected_refs_controller.rb
+6
-0
app/controllers/projects/protected_tags_controller.rb
app/controllers/projects/protected_tags_controller.rb
+1
-1
app/helpers/branches_helper.rb
app/helpers/branches_helper.rb
+9
-0
app/models/protected_branch.rb
app/models/protected_branch.rb
+0
-18
app/views/projects/protected_branches/_protected_branch_access_summary.html.haml
...ected_branches/_protected_branch_access_summary.html.haml
+2
-2
app/views/projects/protected_tags/_protected_tag_access_summary.html.haml
...ts/protected_tags/_protected_tag_access_summary.html.haml
+1
-1
No files found.
app/controllers/projects/protected_branches_controller.rb
View file @
57576873
...
...
@@ -23,7 +23,7 @@ class Projects::ProtectedBranchesController < Projects::ProtectedRefsController
def
protected_ref_params
params
.
require
(
:protected_branch
).
permit
(
:name
,
merge_access_levels_attributes:
[
:access_level
,
:id
,
:user_id
,
:_destroy
,
:group_id
]
,
push_access_levels_attributes:
[
:access_level
,
:id
,
:user_id
,
:_destroy
,
:group_id
]
)
merge_access_levels_attributes:
access_level_attributes
,
push_access_levels_attributes:
access_level_attributes
)
end
end
app/controllers/projects/protected_refs_controller.rb
View file @
57576873
...
...
@@ -44,4 +44,10 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
format
.
js
{
head
:ok
}
end
end
protected
def
access_level_attributes
[
:access_level
,
:id
,
:user_id
,
:_destroy
,
:group_id
]
end
end
app/controllers/projects/protected_tags_controller.rb
View file @
57576873
...
...
@@ -22,6 +22,6 @@ class Projects::ProtectedTagsController < Projects::ProtectedRefsController
end
def
protected_ref_params
params
.
require
(
:protected_tag
).
permit
(
:name
,
create_access_levels_attributes:
[
:access_level
,
:id
]
)
params
.
require
(
:protected_tag
).
permit
(
:name
,
create_access_levels_attributes:
access_level_attributes
)
end
end
app/helpers/branches_helper.rb
View file @
57576873
...
...
@@ -34,6 +34,15 @@ module BranchesHelper
ProtectedBranch
.
protected?
(
project
,
branch
.
name
)
end
# Returns a hash were keys are types of access levels (user, role), and
# values are the number of access levels of the particular type.
def
access_level_frequencies
(
access_levels
)
access_levels
.
reduce
(
Hash
.
new
(
0
))
do
|
frequencies
,
access_level
|
frequencies
[
access_level
.
type
]
=
frequencies
[
access_level
.
type
]
+
1
frequencies
end
end
def
access_levels_data
(
access_levels
)
access_levels
.
map
do
|
level
|
if
level
.
type
==
:user
...
...
app/models/protected_branch.rb
View file @
57576873
...
...
@@ -4,24 +4,6 @@ class ProtectedBranch < ActiveRecord::Base
protected_ref_access_levels
:merge
,
:push
# Returns a hash were keys are types of push access levels (user, role), and
# values are the number of access levels of the particular type.
def
push_access_level_frequencies
push_access_levels
.
reduce
(
Hash
.
new
(
0
))
do
|
frequencies
,
access_level
|
frequencies
[
access_level
.
type
]
=
frequencies
[
access_level
.
type
]
+
1
frequencies
end
end
# Returns a hash were keys are types of merge access levels (user, role), and
# values are the number of access levels of the particular type.
def
merge_access_level_frequencies
merge_access_levels
.
reduce
(
Hash
.
new
(
0
))
do
|
frequencies
,
access_level
|
frequencies
[
access_level
.
type
]
=
frequencies
[
access_level
.
type
]
+
1
frequencies
end
end
# Check if branch name is marked as protected in the system
def
self
.
protected?
(
project
,
ref_name
)
return
true
if
project
.
empty_repo?
&&
default_branch_protected?
...
...
app/views/projects/protected_branches/_protected_branch_access_summary.html.haml
View file @
57576873
%td
=
render
partial:
'projects/protected_branches/access_level_dropdown'
,
locals:
{
protected_branch:
protected_branch
,
access_levels:
protected_branch
.
merge_access_levels
,
level_frequencies:
protected_branch
.
merge_access_level_frequencies
,
input_basic_name:
'merge_access_levels'
,
toggle_class:
'js-allowed-to-merge'
}
=
render
partial:
'projects/protected_branches/access_level_dropdown'
,
locals:
{
protected_branch:
protected_branch
,
access_levels:
protected_branch
.
merge_access_levels
,
level_frequencies:
access_level_frequencies
(
protected_branch
.
merge_access_levels
)
,
input_basic_name:
'merge_access_levels'
,
toggle_class:
'js-allowed-to-merge'
}
%td
=
render
partial:
'projects/protected_branches/access_level_dropdown'
,
locals:
{
protected_branch:
protected_branch
,
access_levels:
protected_branch
.
push_access_levels
,
level_frequencies:
protected_branch
.
push_access_level_frequencies
,
input_basic_name:
'push_access_levels'
,
toggle_class:
'js-allowed-to-push'
}
=
render
partial:
'projects/protected_branches/access_level_dropdown'
,
locals:
{
protected_branch:
protected_branch
,
access_levels:
protected_branch
.
push_access_levels
,
level_frequencies:
access_level_frequencies
(
protected_branch
.
push_access_levels
)
,
input_basic_name:
'push_access_levels'
,
toggle_class:
'js-allowed-to-push'
}
app/views/projects/protected_tags/_protected_tag_access_summary.html.haml
View file @
57576873
%td
=
render
partial:
'projects/protected_tags/access_level_dropdown'
,
locals:
{
protected_tag:
protected_tag
,
access_levels:
protected_tag
.
create_access_levels
,
level_frequencies:
protected_tag
.
create_access_level_frequencies
,
input_basic_name:
'create_access_levels'
,
toggle_class:
'js-allowed-to-create'
}
=
render
partial:
'projects/protected_tags/access_level_dropdown'
,
locals:
{
protected_tag:
protected_tag
,
access_levels:
protected_tag
.
create_access_levels
,
level_frequencies:
access_level_frequencies
(
protected_tag
.
create_access_levels
)
,
input_basic_name:
'create_access_levels'
,
toggle_class:
'js-allowed-to-create'
}
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