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
55526227
Commit
55526227
authored
Oct 10, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt frontend to LdapGroupLink with provider
parent
83a3facb
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
10 deletions
+60
-10
app/assets/javascripts/api.js.coffee
app/assets/javascripts/api.js.coffee
+3
-2
app/assets/javascripts/ldap_groups_select.js.coffee
app/assets/javascripts/ldap_groups_select.js.coffee
+4
-1
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+1
-1
app/helpers/selects_helper.rb
app/helpers/selects_helper.rb
+8
-0
app/models/ldap_group_link.rb
app/models/ldap_group_link.rb
+1
-1
app/views/ldap_group_links/_form.html.haml
app/views/ldap_group_links/_form.html.haml
+1
-5
spec/factories.rb
spec/factories.rb
+6
-0
spec/models/ldap_group_link_spec.rb
spec/models/ldap_group_link_spec.rb
+36
-0
No files found.
app/assets/javascripts/api.js.coffee
View file @
55526227
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
users_path
:
"/api/:version/users.json"
users_path
:
"/api/:version/users.json"
user_path
:
"/api/:version/users/:id.json"
user_path
:
"/api/:version/users/:id.json"
notes_path
:
"/api/:version/projects/:id/notes.json"
notes_path
:
"/api/:version/projects/:id/notes.json"
ldap_groups_path
:
"/api/:version/ldap/groups.json"
ldap_groups_path
:
"/api/:version/ldap/
:provider/
groups.json"
namespaces_path
:
"/api/:version/namespaces.json"
namespaces_path
:
"/api/:version/namespaces.json"
project_users_path
:
"/api/:version/projects/:id/users.json"
project_users_path
:
"/api/:version/projects/:id/users.json"
...
@@ -89,8 +89,9 @@
...
@@ -89,8 +89,9 @@
return
url
.
replace
(
':version'
,
gon
.
api_version
)
return
url
.
replace
(
':version'
,
gon
.
api_version
)
# Return LDAP groups list. Filtered by query
# Return LDAP groups list. Filtered by query
ldap_groups
:
(
query
,
callback
)
->
ldap_groups
:
(
query
,
provider
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
ldap_groups_path
)
url
=
Api
.
buildUrl
(
Api
.
ldap_groups_path
)
url
=
url
.
replace
(
':provider'
,
provider
);
$
.
ajax
(
$
.
ajax
(
url
:
url
url
:
url
...
...
app/assets/javascripts/ldap_groups_select.js.coffee
View file @
55526227
...
@@ -12,7 +12,8 @@ $ ->
...
@@ -12,7 +12,8 @@ $ ->
placeholder
:
"Search for a LDAP group"
placeholder
:
"Search for a LDAP group"
minimumInputLength
:
1
minimumInputLength
:
1
query
:
(
query
)
->
query
:
(
query
)
->
Api
.
ldap_groups
query
.
term
,
(
groups
)
->
provider
=
$
(
'#ldap_group_link_provider'
).
val
();
Api
.
ldap_groups
query
.
term
,
provider
,
(
groups
)
->
data
=
{
results
:
groups
}
data
=
{
results
:
groups
}
query
.
callback
(
data
)
query
.
callback
(
data
)
...
@@ -26,3 +27,5 @@ $ ->
...
@@ -26,3 +27,5 @@ $ ->
dropdownCssClass
:
"ajax-groups-dropdown"
dropdownCssClass
:
"ajax-groups-dropdown"
formatNoMatches
:
(
nomatch
)
->
formatNoMatches
:
(
nomatch
)
->
"Match not found; try refining your search query."
"Match not found; try refining your search query."
$
(
'#ldap_group_link_provider'
).
on
'change'
,
->
$
(
'.ajax-ldap-groups-select'
).
select2
(
'data'
,
null
)
\ No newline at end of file
app/helpers/groups_helper.rb
View file @
55526227
app/helpers/selects_helper.rb
View file @
55526227
...
@@ -18,4 +18,12 @@ module SelectsHelper
...
@@ -18,4 +18,12 @@ module SelectsHelper
project_id
=
opts
[
:project_id
]
||
@project
.
id
project_id
=
opts
[
:project_id
]
||
@project
.
id
hidden_field_tag
(
id
,
value
,
class:
css_class
,
'data-placeholder'
=>
placeholder
,
'data-project-id'
=>
project_id
)
hidden_field_tag
(
id
,
value
,
class:
css_class
,
'data-placeholder'
=>
placeholder
,
'data-project-id'
=>
project_id
)
end
end
def
ldap_server_select_options
options_from_collection_for_select
(
Gitlab
::
LDAP
::
Config
.
servers
,
'provider_name'
,
'label'
)
end
end
end
app/models/ldap_group_link.rb
View file @
55526227
...
@@ -3,7 +3,7 @@ class LdapGroupLink < ActiveRecord::Base
...
@@ -3,7 +3,7 @@ class LdapGroupLink < ActiveRecord::Base
belongs_to
:group
belongs_to
:group
validates
:cn
,
:group_access
,
:group_id
,
presence:
true
validates
:cn
,
:group_access
,
:group_id
,
presence:
true
validates
:cn
,
uniqueness:
{
scope:
:group_id
}
validates
:cn
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
}
validates
:group_access
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
validates
:group_access
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
def
access_field
def
access_field
...
...
app/views/ldap_group_links/_form.html.haml
View file @
55526227
...
@@ -7,11 +7,7 @@
...
@@ -7,11 +7,7 @@
=
f
.
label
:cn
,
class:
'control-label'
do
=
f
.
label
:cn
,
class:
'control-label'
do
LDAP Server
LDAP Server
.col-sm-10
.col-sm-10
-
Gitlab
::
LDAP
::
Config
.
servers
.
each
do
|
server
|
=
f
.
select
:provider
,
ldap_server_select_options
.radio-inline
=
f
.
radio_button
:provider
,
server
.
provider_name
=
server
.
label
.form-group.clearfix
.form-group.clearfix
=
f
.
label
:cn
,
class:
'control-label'
do
=
f
.
label
:cn
,
class:
'control-label'
do
LDAP Group cn
LDAP Group cn
...
...
spec/factories.rb
View file @
55526227
...
@@ -182,4 +182,10 @@ FactoryGirl.define do
...
@@ -182,4 +182,10 @@ FactoryGirl.define do
deploy_key
deploy_key
project
project
end
end
factory
:ldap_group_link
do
cn
'group1'
group_access
Gitlab
::
Access
::
GUEST
provider
'ldapmain'
end
end
end
spec/models/ldap_group_link_spec.rb
0 → 100644
View file @
55526227
require
'spec_helper'
describe
LdapGroupLink
do
let
(
:klass
)
{
LdapGroupLink
}
let
(
:ldap_group_link
)
{
build
:ldap_group_link
}
describe
"validation"
do
describe
"cn"
do
it
"validates uniquiness based on group_id and provider"
do
create
(
:ldap_group_link
,
cn:
'group1'
,
group_id:
1
,
provider:
'ldapmain'
)
group_link
=
build
(
:ldap_group_link
,
cn:
'group1'
,
group_id:
1
,
provider:
'ldapmain'
)
expect
(
group_link
).
to_not
be_valid
group_link
.
group_id
=
2
expect
(
group_link
).
to
be_valid
group_link
.
group_id
=
1
group_link
.
provider
=
'ldapalt'
expect
(
group_link
).
to
be_valid
end
end
describe
:provider
do
it
"shows the set value"
do
ldap_group_link
.
provider
=
'1235'
expect
(
ldap_group_link
.
provider
).
to
eql
'1235'
end
it
"defaults to the first ldap server if empty"
do
expect
(
klass
.
new
.
provider
).
to
eql
Gitlab
::
LDAP
::
Config
.
providers
.
first
end
end
end
end
\ No newline at end of file
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