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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
875728b1
Commit
875728b1
authored
Nov 15, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/admin_project_transfer' of /home/git/repositories/gitlab/gitlabhq
parents
77e3fab8
27ad8826
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
187 additions
and
23 deletions
+187
-23
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/api.js.coffee
app/assets/javascripts/api.js.coffee
+15
-0
app/assets/javascripts/namespace_select.js.coffee
app/assets/javascripts/namespace_select.js.coffee
+24
-0
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+30
-0
app/assets/stylesheets/selects.scss
app/assets/stylesheets/selects.scss
+0
-19
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+21
-3
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+9
-0
app/models/namespace.rb
app/models/namespace.rb
+4
-0
app/views/admin/projects/show.html.haml
app/views/admin/projects/show.html.haml
+17
-0
config/routes.rb
config/routes.rb
+7
-1
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/namespaces.rb
lib/api/namespaces.rb
+23
-0
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+31
-0
No files found.
CHANGELOG
View file @
875728b1
...
...
@@ -17,6 +17,7 @@ v 6.3.0
- Fix 500 error for repos with newline in file name
- Extended html titles
- API: create/update repo files
- Admin can transfer project to any namespace
v 6.2.0
- Public project pages are now visible to everyone (files, issues, wik, etc.)
...
...
app/assets/javascripts/api.js.coffee
View file @
875728b1
...
...
@@ -2,6 +2,7 @@
users_path
:
"/api/:version/users.json"
user_path
:
"/api/:version/users/:id.json"
notes_path
:
"/api/:version/projects/:id/notes.json"
namespaces_path
:
"/api/:version/namespaces.json"
# Get 20 (depends on api) recent notes
# and sort the ascending from oldest to newest
...
...
@@ -49,6 +50,20 @@
).
done
(
users
)
->
callback
(
users
)
# Return namespaces list. Filtered by query
namespaces
:
(
query
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
namespaces_path
)
$
.
ajax
(
url
:
url
data
:
private_token
:
gon
.
api_token
search
:
query
per_page
:
20
dataType
:
"json"
).
done
(
namespaces
)
->
callback
(
namespaces
)
buildUrl
:
(
url
)
->
url
=
gon
.
relative_url_root
+
url
if
gon
.
relative_url_root
?
return
url
.
replace
(
':version'
,
gon
.
api_version
)
app/assets/javascripts/namespace_select.js.coffee
0 → 100644
View file @
875728b1
$
->
namespaceFormatResult
=
(
namespace
)
->
markup
=
"<div class='namespace-result'>"
markup
+=
"<span class='namespace-kind'>"
+
namespace
.
kind
+
"</span>"
markup
+=
"<span class='namespace-path'>"
+
namespace
.
path
+
"</span>"
markup
+=
"</div>"
markup
formatSelection
=
(
namespace
)
->
namespace
.
kind
+
": "
+
namespace
.
path
$
(
'.ajax-namespace-select'
).
each
(
i
,
select
)
->
$
(
select
).
select2
placeholder
:
"Search for namespace"
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
minimumInputLength
:
0
query
:
(
query
)
->
Api
.
namespaces
query
.
term
,
(
namespaces
)
->
data
=
{
results
:
namespaces
}
query
.
callback
(
data
)
dropdownCssClass
:
"ajax-namespace-dropdown"
formatResult
:
namespaceFormatResult
formatSelection
:
formatSelection
app/assets/stylesheets/common.scss
View file @
875728b1
...
...
@@ -358,3 +358,33 @@ table {
background
:
#555
;
color
:
#BBB
;
}
.ajax-users-select
{
width
:
400px
;
&
.input-large
{
width
:
210px
;
}
}
.user-result
{
.user-image
{
float
:
left
;
}
.user-name
{
}
.user-username
{
color
:
#999
;
}
}
.namespace-result
{
.namespace-kind
{
color
:
#AAA
;
font-weight
:
normal
;
}
.namespace-path
{
margin-left
:
10px
;
font-weight
:
bolder
;
}
}
app/assets/stylesheets/selects.scss
View file @
875728b1
.ajax-users-select
{
width
:
400px
;
&
.input-large
{
width
:
210px
;
}
}
.user-result
{
.user-image
{
float
:
left
;
}
.user-name
{
}
.user-username
{
color
:
#999
;
}
}
/** Chosen.js selectbox style override **/
.chosen-container
{
min-width
:
100px
;
...
...
app/controllers/admin/projects_controller.rb
View file @
875728b1
class
Admin::ProjectsController
<
Admin
::
ApplicationController
before_filter
:project
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:team_update
]
before_filter
:project
,
only:
[
:show
,
:transfer
]
before_filter
:group
,
only:
[
:show
,
:transfer
]
before_filter
:repository
,
only:
[
:show
,
:transfer
]
def
index
owner_id
=
params
[
:owner_id
]
...
...
@@ -14,8 +16,16 @@ class Admin::ProjectsController < Admin::ApplicationController
end
def
show
@repository
=
@project
.
repository
@group
=
@project
.
group
end
def
transfer
result
=
::
Projects
::
TransferContext
.
new
(
@project
,
current_user
,
project:
params
).
execute
(
:admin
)
if
result
redirect_to
[
:admin
,
@project
]
else
render
:show
end
end
protected
...
...
@@ -26,4 +36,12 @@ class Admin::ProjectsController < Admin::ApplicationController
@project
=
Project
.
find_with_namespace
(
id
)
@project
||
render_404
end
def
group
@group
||=
project
.
group
end
def
repository
@repository
||=
project
.
repository
end
end
app/helpers/namespaces_helper.rb
View file @
875728b1
...
...
@@ -16,4 +16,13 @@ module NamespacesHelper
grouped_options_for_select
(
options
,
selected
)
end
def
namespace_select_tag
(
id
,
opts
=
{})
css_class
=
"ajax-namespace-select "
css_class
<<
"multiselect "
if
opts
[
:multiple
]
css_class
<<
(
opts
[
:class
]
||
''
)
value
=
opts
[
:selected
]
||
''
hidden_field_tag
(
id
,
value
,
class:
css_class
)
end
end
app/models/namespace.rb
View file @
875728b1
...
...
@@ -87,4 +87,8 @@ class Namespace < ActiveRecord::Base
def
send_update_instructions
projects
.
each
(
&
:send_move_instructions
)
end
def
kind
type
==
'Group'
?
'group'
:
'user'
end
end
app/views/admin/projects/show.html.haml
View file @
875728b1
...
...
@@ -74,6 +74,23 @@
%span
.cgreen
%i
.icon-lock
Private
.ui-box
.title
Transfer project
.ui-box-body
=
form_for
@project
,
url:
transfer_admin_project_path
(
@project
),
method: :put
do
|
f
|
.control-group
=
f
.
label
:namespace_id
,
"Namespace"
.controls
=
namespace_select_tag
:namespace_id
,
selected:
params
[
:namespace_id
],
class:
'input-large'
.control-group
.controls
=
f
.
submit
'Transfer'
,
class:
'btn btn-primary'
.span6
-
if
@group
.ui-box
...
...
config/routes.rb
View file @
875728b1
...
...
@@ -89,7 +89,13 @@ Gitlab::Application.routes.draw do
resources
:broadcast_messages
,
only:
[
:index
,
:create
,
:destroy
]
resource
:logs
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
},
only:
[
:index
,
:show
]
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
},
only:
[
:index
,
:show
]
do
member
do
put
:transfer
end
end
root
to:
"dashboard#index"
end
...
...
lib/api/api.rb
View file @
875728b1
...
...
@@ -40,5 +40,6 @@ module API
mount
ProjectHooks
mount
Services
mount
Files
mount
Namespaces
end
end
lib/api/entities.rb
View file @
875728b1
...
...
@@ -136,5 +136,9 @@ module API
expose
:target_id
,
:target_type
,
:author_id
expose
:data
,
:target_title
end
class
Namespace
<
Grape
::
Entity
expose
:id
,
:path
,
:kind
end
end
end
lib/api/namespaces.rb
0 → 100644
View file @
875728b1
module
API
# namespaces API
class
Namespaces
<
Grape
::
API
before
{
authenticate!
authenticated_as_admin!
}
resource
:namespaces
do
# Get a namespaces list
#
# Example Request:
# GET /namespaces
get
do
@namespaces
=
Namespace
.
scoped
@namespaces
=
@namespaces
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@namespaces
=
paginate
@namespaces
present
@namespaces
,
with:
Entities
::
Namespace
end
end
end
end
spec/requests/api/namespaces_spec.rb
0 → 100644
View file @
875728b1
require
'spec_helper'
describe
API
::
API
do
include
ApiHelpers
before
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
}
after
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
disable
(
:user_observer
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let!
(
:group1
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
)
}
describe
"GET /namespaces"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
get
api
(
"/namespaces"
)
response
.
status
.
should
==
401
end
end
context
"when authenticated as admin"
do
it
"admin: should return an array of all namespaces"
do
get
api
(
"/namespaces"
,
admin
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
# Admin namespace + 2 group namespaces
json_response
.
length
.
should
==
3
end
end
end
end
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