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
33416a7e
Commit
33416a7e
authored
Oct 10, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show all available groups in approvers groups dropdown
parent
e8b6300c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
40 additions
and
23 deletions
+40
-23
app/assets/javascripts/admin_email_select.js
app/assets/javascripts/admin_email_select.js
+1
-1
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+5
-7
app/assets/javascripts/groups_select.js
app/assets/javascripts/groups_select.js
+4
-2
app/assets/javascripts/project_select.js
app/assets/javascripts/project_select.js
+2
-2
app/assets/javascripts/search.js
app/assets/javascripts/search.js
+1
-1
app/helpers/selects_helper.rb
app/helpers/selects_helper.rb
+1
-3
app/views/projects/_merge_request_settings.html.haml
app/views/projects/_merge_request_settings.html.haml
+2
-2
app/views/shared/issuable/_approvals.html.haml
app/views/shared/issuable/_approvals.html.haml
+2
-2
doc/api/groups.md
doc/api/groups.md
+7
-2
lib/api/groups.rb
lib/api/groups.rb
+3
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+12
-1
No files found.
app/assets/javascripts/admin_email_select.js
View file @
33416a7e
...
...
@@ -13,7 +13,7 @@
minimumInputLength
:
0
,
query
:
function
(
query
)
{
var
group_result
,
project_result
;
group_result
=
Api
.
groups
(
query
.
term
,
skip_ldap
,
function
(
groups
)
{
group_result
=
Api
.
groups
(
query
.
term
,
{
skip_ldap
:
skip_ldap
}
,
function
(
groups
)
{
return
groups
;
});
project_result
=
Api
.
projects
(
query
.
term
,
'
id
'
,
function
(
projects
)
{
...
...
app/assets/javascripts/api.js
View file @
33416a7e
...
...
@@ -23,16 +23,14 @@
});
},
// Return groups list. Filtered by query
// Only active groups retrieved
groups
:
function
(
query
,
skip_ldap
,
skip_groups
,
callback
)
{
groups
:
function
(
query
,
options
,
callback
)
{
var
url
=
Api
.
buildUrl
(
Api
.
groupsPath
);
return
$
.
ajax
({
url
:
url
,
data
:
{
search
:
query
,
skip_groups
:
skip_groups
,
per_page
:
20
},
data
:
$
.
extend
({
search
:
query
,
per_page
:
20
},
options
),
dataType
:
"
json
"
}).
done
(
function
(
groups
)
{
return
callback
(
groups
);
...
...
app/assets/javascripts/groups_select.js
View file @
33416a7e
...
...
@@ -5,15 +5,17 @@
function
GroupsSelect
()
{
$
(
'
.ajax-groups-select
'
).
each
((
function
(
_this
)
{
return
function
(
i
,
select
)
{
var
skip_ldap
,
skip_groups
;
var
skip_ldap
,
all_available
,
skip_groups
;
skip_ldap
=
$
(
select
).
hasClass
(
'
skip_ldap
'
);
all_available
=
$
(
select
).
data
(
'
all-available
'
);
skip_groups
=
$
(
select
).
data
(
'
skip-groups
'
)
||
[];
return
$
(
select
).
select2
({
placeholder
:
"
Search for a group
"
,
multiple
:
$
(
select
).
hasClass
(
'
multiselect
'
),
minimumInputLength
:
0
,
query
:
function
(
query
)
{
return
Api
.
groups
(
query
.
term
,
skip_ldap
,
skip_groups
,
function
(
groups
)
{
options
=
{
all_available
:
all_available
,
skip_groups
:
skip_groups
}
return
Api
.
groups
(
query
.
term
,
options
,
function
(
groups
)
{
var
data
;
data
=
{
results
:
groups
...
...
app/assets/javascripts/project_select.js
View file @
33416a7e
...
...
@@ -23,7 +23,7 @@
data
=
groups
.
concat
(
projects
);
return
finalCallback
(
data
);
};
return
Api
.
groups
(
term
,
false
,
false
,
groupsCallback
);
return
Api
.
groups
(
term
,
{}
,
groupsCallback
);
};
}
else
{
projectsCallback
=
finalCallback
;
...
...
@@ -72,7 +72,7 @@
data
=
groups
.
concat
(
projects
);
return
finalCallback
(
data
);
};
return
Api
.
groups
(
query
.
term
,
false
,
false
,
groupsCallback
);
return
Api
.
groups
(
query
.
term
,
{}
,
groupsCallback
);
};
}
else
{
projectsCallback
=
finalCallback
;
...
...
app/assets/javascripts/search.js
View file @
33416a7e
...
...
@@ -10,7 +10,7 @@
filterable
:
true
,
fieldName
:
'
group_id
'
,
data
:
function
(
term
,
callback
)
{
return
Api
.
groups
(
term
,
false
,
false
,
function
(
data
)
{
return
Api
.
groups
(
term
,
{}
,
function
(
data
)
{
data
.
unshift
({
name
:
'
Any
'
});
...
...
app/helpers/selects_helper.rb
View file @
33416a7e
...
...
@@ -60,9 +60,7 @@ module SelectsHelper
def
select2_tag
(
id
,
opts
=
{})
opts
[
:class
]
<<
' multiselect'
if
opts
[
:multiple
]
value
=
opts
[
:selected
]
||
''
css_class
=
opts
[
:class
]
hidden_field_tag
(
id
,
value
,
class:
css_class
,
data:
{
skip_groups:
opts
[
:skip_groups
],
url:
autocomplete_groups_path
})
hidden_field_tag
(
id
,
value
,
opts
)
end
def
admin_email_select_tag
(
id
,
opts
=
{})
...
...
app/views/projects/_merge_request_settings.html.haml
View file @
33416a7e
...
...
@@ -63,8 +63,8 @@
Add an approver suggestion for each merge request
=
f
.
label
:approver_group_ids
,
class:
'label-light'
do
Approver groups
-
project_approver_group_paths
=
@project
.
approver_groups
.
includes
(
:group
).
map
{
|
ag
|
ag
.
group
.
path
}
=
groups_select_tag
(
'project[approver_group_ids]'
,
multiple:
true
,
skip_groups:
project_approver_group_paths
,
class:
'input-large'
)
-
skip_groups
=
@project
.
approver_groups
.
includes
(
:group
).
map
{
|
ag
|
ag
.
group
.
id
}
=
groups_select_tag
(
'project[approver_group_ids]'
,
multiple:
true
,
data:
{
skip_groups:
skip_groups
,
all_available:
true
}
,
class:
'input-large'
)
.help-block
Add a group as an approver suggestion for each merge request
...
...
app/views/shared/issuable/_approvals.html.haml
View file @
33416a7e
...
...
@@ -21,8 +21,8 @@
This merge request must be approved by these users.
You can override the project settings by setting your own list of approvers.
-
approver_group_id
s
=
issuable
.
overall_approver_groups
.
includes
(
:group
).
map
{
|
ag
|
ag
.
group
.
id
}
=
groups_select_tag
(
'merge_request[approver_group_ids]'
,
multiple:
true
,
skip_groups:
approver_group_ids
,
class:
'input-large'
)
-
skip_group
s
=
issuable
.
overall_approver_groups
.
includes
(
:group
).
map
{
|
ag
|
ag
.
group
.
id
}
=
groups_select_tag
(
'merge_request[approver_group_ids]'
,
multiple:
true
,
data:
{
skip_groups:
skip_groups
,
all_available:
true
}
,
class:
'input-large'
)
.help-block
This merge request must be approved by members of these groups.
You can override the project settings by setting your own list of approvers.
...
...
doc/api/groups.md
View file @
33416a7e
...
...
@@ -2,7 +2,12 @@
## List groups
Get a list of groups. (As user: my groups, as admin: all groups)
Get a list of groups. (As user: my groups or all available, as admin: all groups).
Parameters:
-
`all_available`
(optional) - if passed, show all groups you have access to
-
`skip_groups`
(optional)(array of group paths) - if passed, skip groups
```
GET /groups
...
...
@@ -459,7 +464,7 @@ Parameters:
-
`id`
(required) - The ID of a group
-
`cn`
(required) - The CN of a LDAP group
-
`group_access`
(required) - Minimum access level for members of the LDAP group
-
`provider`
(required) - LDAP provider for the LDAP group (when using several providers)
-
`provider`
(required) - LDAP provider for the LDAP group (when using several providers)
### Delete LDAP group link
...
...
lib/api/groups.rb
View file @
33416a7e
...
...
@@ -8,11 +8,14 @@ module API
#
# Parameters:
# skip_groups (optional) - Array of group ids to exclude from list
# all_available (optional, boolean) - Show all group that you have access to
# Example Request:
# GET /groups
get
do
@groups
=
if
current_user
.
admin
Group
.
all
elsif
params
[
:all_available
]
GroupsFinder
.
new
.
execute
(
current_user
)
else
current_user
.
groups
end
...
...
spec/requests/api/groups_spec.rb
View file @
33416a7e
...
...
@@ -47,7 +47,7 @@ describe API::API, api: true do
end
end
context
"when authenticated as
admin"
do
context
"when authenticated as admin"
do
it
"admin: returns an array of all groups"
do
get
api
(
"/groups"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
...
...
@@ -65,6 +65,17 @@ describe API::API, api: true do
expect
(
json_response
.
length
).
to
eq
(
1
)
end
end
context
"when using all_available in request"
do
it
"returns all groups you have access to"
do
public_group
=
create
:group
,
:public
get
api
(
"/groups"
,
user1
),
all_available:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
public_group
.
name
)
end
end
end
describe
"GET /groups/:id"
do
...
...
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