BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bcd58069
Commit
bcd58069
authored
Mar 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add access-level filter support for projects select
This also refactores ProjectSelect adding some decorator-like functions.
parent
a91101b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
22 deletions
+43
-22
project_select.js.coffee
app/assets/javascripts/project_select.js.coffee
+38
-18
user.rb
app/models/user.rb
+1
-1
move_service.rb
app/services/issues/move_service.rb
+2
-2
_form.html.haml
app/views/shared/issuable/_form.html.haml
+2
-1
No files found.
app/assets/javascripts/project_select.js.coffee
View file @
bcd58069
class
@
ProjectSelect
constructor
:
->
$
(
'.ajax-project-select'
).
each
(
i
,
select
)
-
>
$
(
'.ajax-project-select'
).
each
(
i
,
select
)
=
>
@
groupId
=
$
(
select
).
data
(
'group-id'
)
@
includeGroups
=
$
(
select
).
data
(
'include-groups'
)
@
orderBy
=
$
(
select
).
data
(
'order-by'
)
||
'id'
@
selectId
=
$
(
select
).
data
(
'select-id'
)
||
'web_url'
@
accessLevel
=
$
(
select
).
data
(
'access-level'
)
placeholder
=
"Search for project"
placeholder
+=
" or group"
if
@
includeGroups
...
...
@@ -12,25 +13,11 @@ class @ProjectSelect
$
(
select
).
select2
placeholder
:
placeholder
minimumInputLength
:
0
query
:
(
query
)
=>
finalCallback
=
(
projects
)
->
data
=
{
results
:
projects
}
query
.
callback
(
data
)
if
@
includeGroups
projectsCallback
=
(
projects
)
->
groupsCallback
=
(
groups
)
->
data
=
groups
.
concat
(
projects
)
finalCallback
(
data
)
Api
.
groups
query
.
term
,
false
,
groupsCallback
else
projectsCallback
=
finalCallback
query
:
(
options
)
=>
if
@
groupId
Api
.
groupProjects
@
groupId
,
query
.
term
,
projectsCallback
Api
.
groupProjects
@
groupId
,
options
.
term
,
@
createCallback
(
options
)
else
Api
.
projects
query
.
term
,
@
orderBy
,
projectsCallback
Api
.
projects
options
.
term
,
@
orderBy
,
@
createCallback
(
options
)
id
:
(
project
)
=>
project
[
@
selectId
]
...
...
@@ -39,3 +26,36 @@ class @ProjectSelect
project
.
name_with_namespace
||
project
.
name
dropdownCssClass
:
"ajax-project-dropdown"
createCallback
:
(
options
)
=>
finalCallback
=
(
projects
)
->
options
.
callback
({
results
:
projects
})
@
accessLevelCallbackDecorator
(
@
groupsCallbackDecorator
(
finalCallback
)
)
groupsCallbackDecorator
:
(
callback
)
=>
return
callback
unless
@
includeGroups
(
projects
)
=>
Api
.
groups
options
.
term
,
false
,
(
groups
)
=>
data
=
groups
.
concat
(
projects
)
callback
(
data
)
accessLevelCallbackDecorator
:
(
callback
)
=>
return
callback
unless
@
accessLevel
##
# Requires ECMAScript >= 5
#
(
projects
)
=>
data
=
projects
.
filter
(
i
)
=>
max
=
Math
.
max
(
i
.
permissions
.
group_access
?
.
access_level
?
0
,
i
.
permissions
.
project_access
?
.
access_level
?
0
)
max
>=
@
accessLevel
callback
(
data
)
app/models/user.rb
View file @
bcd58069
...
...
@@ -429,7 +429,7 @@ class User < ActiveRecord::Base
Group
.
where
(
"namespaces.id IN (
#{
union
.
to_sql
}
)"
)
end
# Returns
the groups a
user is authorized to access.
# Returns
projects
user is authorized to access.
def
authorized_projects
Project
.
where
(
"projects.id IN (
#{
projects_union
.
to_sql
}
)"
)
end
...
...
app/services/issues/move_service.rb
View file @
bcd58069
...
...
@@ -15,7 +15,7 @@ module Issues
ActiveRecord
::
Base
.
transaction
do
# New issue tasks
#
open
_new_issue
create
_new_issue
rewrite_notes
add_moved_from_note
...
...
@@ -43,7 +43,7 @@ module Issues
can?
(
@current_user
,
:admin_issue
,
@project_new
)
end
def
open
_new_issue
def
create
_new_issue
@issue_new
.
iid
=
nil
@issue_new
.
project
=
@project_new
@issue_new
.
labels
=
[]
...
...
app/views/shared/issuable/_form.html.haml
View file @
bcd58069
...
...
@@ -73,7 +73,8 @@
=
f
.
label
:move_to_project_id
,
'Move'
,
class:
'control-label'
.col-sm-10
=
project_select_tag
(
"
#{
issuable
.
class
.
model_name
.
param_key
}
[move_to_project_id]"
,
placeholder:
'Select project'
,
class:
'custom-form-control'
,
data:
{
'select-id'
=>
'id'
})
placeholder:
'Select project'
,
class:
'custom-form-control'
,
data:
{
'select-id'
=>
'id'
,
'access-level'
=>
Gitlab
::
Access
::
REPORTER
})
-
if
issuable
.
is_a?
(
MergeRequest
)
%hr
...
...
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