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
73cbd727
Commit
73cbd727
authored
Jan 25, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added headers to protected branches access dropdown
parent
d28f0594
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
25 deletions
+29
-25
app/assets/javascripts/protected_branches/protected_branch_access_dropdown.js
...ts/protected_branches/protected_branch_access_dropdown.js
+13
-23
app/controllers/projects/protected_branches_controller.rb
app/controllers/projects/protected_branches_controller.rb
+8
-2
changelogs/unreleased-ee/protected-branches-dropdown-headers.yml
...ogs/unreleased-ee/protected-branches-dropdown-headers.yml
+4
-0
spec/features/protected_branches/access_control_ee_spec.rb
spec/features/protected_branches/access_control_ee_spec.rb
+4
-0
No files found.
app/assets/javascripts/protected_branches/protected_branch_access_dropdown.js
View file @
73cbd727
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
this
.
isAllowedToPushDropdown
=
false
;
this
.
isAllowedToPushDropdown
=
false
;
this
.
groups
=
[];
this
.
groups
=
[];
this
.
accessLevel
=
accessLevel
;
this
.
accessLevel
=
accessLevel
;
this
.
accessLevelsData
=
accessLevelsData
;
this
.
accessLevelsData
=
accessLevelsData
.
Roles
;
this
.
$dropdown
=
$dropdown
;
this
.
$dropdown
=
$dropdown
;
this
.
$wrap
=
this
.
$dropdown
.
closest
(
`.
${
this
.
accessLevel
}
-container`
);
this
.
$wrap
=
this
.
$dropdown
.
closest
(
`.
${
this
.
accessLevel
}
-container`
);
this
.
usersPath
=
'
/autocomplete/users.json
'
;
this
.
usersPath
=
'
/autocomplete/users.json
'
;
...
@@ -275,8 +275,7 @@
...
@@ -275,8 +275,7 @@
let
consolidatedData
=
[];
let
consolidatedData
=
[];
const
map
=
[];
const
map
=
[];
let
roles
=
[];
let
roles
=
[];
const
selectedUsers
=
[];
const
users
=
[];
const
unselectedUsers
=
[];
let
groups
=
[];
let
groups
=
[];
const
selectedItems
=
this
.
getSelectedItems
();
const
selectedItems
=
this
.
getSelectedItems
();
...
@@ -319,12 +318,12 @@
...
@@ -319,12 +318,12 @@
if
(
current
.
type
!==
LEVEL_TYPES
.
USER
)
{
continue
;
}
if
(
current
.
type
!==
LEVEL_TYPES
.
USER
)
{
continue
;
}
// Collect selected users
// Collect selected users
selectedU
sers
.
push
({
u
sers
.
push
({
id
:
current
.
user_id
,
id
:
current
.
user_id
,
name
:
current
.
name
,
name
:
current
.
name
,
username
:
current
.
username
,
username
:
current
.
username
,
avatar_url
:
current
.
avatar_url
,
avatar_url
:
current
.
avatar_url
,
type
:
LEVEL_TYPES
.
USER
type
:
LEVEL_TYPES
.
USER
,
});
});
// Save identifiers for easy-checking more later
// Save identifiers for easy-checking more later
...
@@ -339,32 +338,24 @@
...
@@ -339,32 +338,24 @@
// Add is it has not been added
// Add is it has not been added
if
(
map
.
indexOf
(
LEVEL_TYPES
.
USER
+
u
.
id
)
===
-
1
)
{
if
(
map
.
indexOf
(
LEVEL_TYPES
.
USER
+
u
.
id
)
===
-
1
)
{
u
.
type
=
LEVEL_TYPES
.
USER
;
u
.
type
=
LEVEL_TYPES
.
USER
;
u
nselectedU
sers
.
push
(
u
);
users
.
push
(
u
);
}
}
}
}
if
(
group
s
.
length
)
{
if
(
role
s
.
length
)
{
consolidatedData
=
consolidatedData
.
concat
(
group
s
);
consolidatedData
=
consolidatedData
.
concat
(
[{
header
:
'
Roles
'
,
}],
role
s
);
}
}
if
(
roles
.
length
)
{
if
(
groups
.
length
)
{
if
(
groups
.
length
)
{
if
(
roles
.
length
)
{
consolidatedData
=
consolidatedData
.
concat
([
'
divider
'
]);
consolidatedData
=
consolidatedData
.
concat
([
'
divider
'
]);
}
}
consolidatedData
=
consolidatedData
.
concat
(
roles
);
consolidatedData
=
consolidatedData
.
concat
([{
header
:
'
Groups
'
,
}],
groups
);
}
if
(
selectedUsers
.
length
)
{
consolidatedData
=
consolidatedData
.
concat
([
'
divider
'
],
selectedUsers
);
}
if
(
unselectedUsers
.
length
)
{
if
(
!
selectedUsers
.
length
)
{
consolidatedData
=
consolidatedData
.
concat
([
'
divider
'
]);
}
}
consolidatedData
=
consolidatedData
.
concat
(
unselectedUsers
);
if
(
users
.
length
)
{
consolidatedData
=
consolidatedData
.
concat
([
'
divider
'
],
[{
header
:
'
Users
'
,
}],
users
);
}
}
return
consolidatedData
;
return
consolidatedData
;
...
@@ -434,9 +425,8 @@
...
@@ -434,9 +425,8 @@
groupRowHtml
(
group
,
isActive
)
{
groupRowHtml
(
group
,
isActive
)
{
const
avatarHtml
=
group
.
avatar_url
?
`<img src='
${
group
.
avatar_url
}
' class='avatar avatar-inline' width='30'>`
:
''
;
const
avatarHtml
=
group
.
avatar_url
?
`<img src='
${
group
.
avatar_url
}
' class='avatar avatar-inline' width='30'>`
:
''
;
const
nameHtml
=
`<strong class='dropdown-menu-group-full-name'>
${
group
.
name
}
</strong>`
;
const
groupnameHtml
=
`<span class='dropdown-menu-group-groupname'>
${
group
.
name
}
</span>`
;
const
groupnameHtml
=
`<span class='dropdown-menu-group-groupname'>
${
group
.
name
}
</span>`
;
return
`<li><a href='#' class='
${
isActive
?
'
is-active
'
:
''
}
'>
${
avatarHtml
}
${
nameHtml
}
${
groupnameHtml
}
</a></li>`
;
return
`<li><a href='#' class='
${
isActive
?
'
is-active
'
:
''
}
'>
${
avatarHtml
}
${
groupnameHtml
}
</a></li>`
;
}
}
roleRowHtml
(
role
,
isActive
)
{
roleRowHtml
(
role
,
isActive
)
{
...
...
app/controllers/projects/protected_branches_controller.rb
View file @
73cbd727
...
@@ -69,8 +69,14 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
...
@@ -69,8 +69,14 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
def
access_levels_options
def
access_levels_options
{
{
push_access_levels:
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
push_access_levels:
{
merge_access_levels:
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
}
"Roles"
=>
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
merge_access_levels:
{
"Roles"
=>
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
selected_merge_access_levels:
@protected_branch
.
merge_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
},
selected_push_access_levels:
@protected_branch
.
push_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
}
}
}
end
end
...
...
changelogs/unreleased-ee/protected-branches-dropdown-headers.yml
0 → 100644
View file @
73cbd727
---
title
:
Added headers to protected branches access dropdowns
merge_request
:
author
:
spec/features/protected_branches/access_control_ee_spec.rb
View file @
73cbd727
...
@@ -92,6 +92,10 @@ RSpec.shared_examples "protected branches > access control > EE" do
...
@@ -92,6 +92,10 @@ RSpec.shared_examples "protected branches > access control > EE" do
within
(
".protected-branches-list"
)
do
within
(
".protected-branches-list"
)
do
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
find
(
".dropdown-input-field"
).
set
(
users
.
last
.
name
)
# Find a user that is not loaded
find
(
".dropdown-input-field"
).
set
(
users
.
last
.
name
)
# Find a user that is not loaded
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
count:
3
)
%w{Roles Groups Users}
.
each_with_index
do
|
header
,
index
|
expect
(
all
(
'.dropdown-header'
)[
index
]).
to
have_content
(
header
)
end
wait_for_ajax
wait_for_ajax
click_on
users
.
last
.
name
click_on
users
.
last
.
name
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
# close
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
# close
...
...
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