Commit 0815098d3af16444645d161cde3ef5150b2fd75d
1 parent
dcea1913
Exists in
master
and in
4 other branches
Admin can transfer project to any namespace
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
6 changed files
with
79 additions
and
23 deletions
Show diff stats
app/assets/stylesheets/common.scss
| @@ -358,3 +358,33 @@ table { | @@ -358,3 +358,33 @@ table { | ||
| 358 | background: #555; | 358 | background: #555; |
| 359 | color: #BBB; | 359 | color: #BBB; |
| 360 | } | 360 | } |
| 361 | + | ||
| 362 | +.ajax-users-select { | ||
| 363 | + width: 400px; | ||
| 364 | + | ||
| 365 | + &.input-large { | ||
| 366 | + width: 210px; | ||
| 367 | + } | ||
| 368 | +} | ||
| 369 | + | ||
| 370 | +.user-result { | ||
| 371 | + .user-image { | ||
| 372 | + float: left; | ||
| 373 | + } | ||
| 374 | + .user-name { | ||
| 375 | + } | ||
| 376 | + .user-username { | ||
| 377 | + color: #999; | ||
| 378 | + } | ||
| 379 | +} | ||
| 380 | + | ||
| 381 | +.namespace-result { | ||
| 382 | + .namespace-kind { | ||
| 383 | + color: #AAA; | ||
| 384 | + font-weight: normal; | ||
| 385 | + } | ||
| 386 | + .namespace-path { | ||
| 387 | + margin-left: 10px; | ||
| 388 | + font-weight: bolder; | ||
| 389 | + } | ||
| 390 | +} |
app/assets/stylesheets/selects.scss
| 1 | -.ajax-users-select { | ||
| 2 | - width: 400px; | ||
| 3 | - | ||
| 4 | - &.input-large { | ||
| 5 | - width: 210px; | ||
| 6 | - } | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -.user-result { | ||
| 10 | - .user-image { | ||
| 11 | - float: left; | ||
| 12 | - } | ||
| 13 | - .user-name { | ||
| 14 | - } | ||
| 15 | - .user-username { | ||
| 16 | - color: #999; | ||
| 17 | - } | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | /** Chosen.js selectbox style override **/ | 1 | /** Chosen.js selectbox style override **/ |
| 21 | .chosen-container { | 2 | .chosen-container { |
| 22 | min-width: 100px; | 3 | min-width: 100px; |
app/controllers/admin/projects_controller.rb
| 1 | class Admin::ProjectsController < Admin::ApplicationController | 1 | class Admin::ProjectsController < Admin::ApplicationController |
| 2 | - before_filter :project, only: [:edit, :show, :update, :destroy, :team_update] | 2 | + before_filter :project, only: [:show, :transfer] |
| 3 | + before_filter :group, only: [:show, :transfer] | ||
| 4 | + before_filter :repository, only: [:show, :transfer] | ||
| 3 | 5 | ||
| 4 | def index | 6 | def index |
| 5 | owner_id = params[:owner_id] | 7 | owner_id = params[:owner_id] |
| @@ -14,8 +16,16 @@ class Admin::ProjectsController < Admin::ApplicationController | @@ -14,8 +16,16 @@ class Admin::ProjectsController < Admin::ApplicationController | ||
| 14 | end | 16 | end |
| 15 | 17 | ||
| 16 | def show | 18 | def show |
| 17 | - @repository = @project.repository | ||
| 18 | - @group = @project.group | 19 | + end |
| 20 | + | ||
| 21 | + def transfer | ||
| 22 | + result = ::Projects::TransferContext.new(@project, current_user, project: params).execute(:admin) | ||
| 23 | + | ||
| 24 | + if result | ||
| 25 | + redirect_to [:admin, @project] | ||
| 26 | + else | ||
| 27 | + render :show | ||
| 28 | + end | ||
| 19 | end | 29 | end |
| 20 | 30 | ||
| 21 | protected | 31 | protected |
| @@ -26,4 +36,12 @@ class Admin::ProjectsController < Admin::ApplicationController | @@ -26,4 +36,12 @@ class Admin::ProjectsController < Admin::ApplicationController | ||
| 26 | @project = Project.find_with_namespace(id) | 36 | @project = Project.find_with_namespace(id) |
| 27 | @project || render_404 | 37 | @project || render_404 |
| 28 | end | 38 | end |
| 39 | + | ||
| 40 | + def group | ||
| 41 | + @group ||= project.group | ||
| 42 | + end | ||
| 43 | + | ||
| 44 | + def repository | ||
| 45 | + @repository ||= project.repository | ||
| 46 | + end | ||
| 29 | end | 47 | end |
app/models/namespace.rb
| @@ -87,4 +87,8 @@ class Namespace < ActiveRecord::Base | @@ -87,4 +87,8 @@ class Namespace < ActiveRecord::Base | ||
| 87 | def send_update_instructions | 87 | def send_update_instructions |
| 88 | projects.each(&:send_move_instructions) | 88 | projects.each(&:send_move_instructions) |
| 89 | end | 89 | end |
| 90 | + | ||
| 91 | + def kind | ||
| 92 | + type == 'Group' ? 'group' : 'user' | ||
| 93 | + end | ||
| 90 | end | 94 | end |
app/views/admin/projects/show.html.haml
| @@ -74,6 +74,23 @@ | @@ -74,6 +74,23 @@ | ||
| 74 | %span.cgreen | 74 | %span.cgreen |
| 75 | %i.icon-lock | 75 | %i.icon-lock |
| 76 | Private | 76 | Private |
| 77 | + .ui-box | ||
| 78 | + .title | ||
| 79 | + Transfer project | ||
| 80 | + .ui-box-body | ||
| 81 | + = form_for @project, url: transfer_admin_project_path(@project), method: :put do |f| | ||
| 82 | + .control-group | ||
| 83 | + = f.label :namespace_id, "Namespace" | ||
| 84 | + .controls | ||
| 85 | + = namespace_select_tag :namespace_id, selected: params[:namespace_id], class: 'input-large' | ||
| 86 | + | ||
| 87 | + .control-group | ||
| 88 | + .controls | ||
| 89 | + = f.submit 'Transfer', class: 'btn btn-primary' | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + | ||
| 77 | .span6 | 94 | .span6 |
| 78 | - if @group | 95 | - if @group |
| 79 | .ui-box | 96 | .ui-box |
config/routes.rb
| @@ -89,7 +89,13 @@ Gitlab::Application.routes.draw do | @@ -89,7 +89,13 @@ Gitlab::Application.routes.draw do | ||
| 89 | resources :broadcast_messages, only: [:index, :create, :destroy] | 89 | resources :broadcast_messages, only: [:index, :create, :destroy] |
| 90 | resource :logs, only: [:show] | 90 | resource :logs, only: [:show] |
| 91 | resource :background_jobs, controller: 'background_jobs', only: [:show] | 91 | resource :background_jobs, controller: 'background_jobs', only: [:show] |
| 92 | - resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] | 92 | + |
| 93 | + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do | ||
| 94 | + member do | ||
| 95 | + put :transfer | ||
| 96 | + end | ||
| 97 | + end | ||
| 98 | + | ||
| 93 | root to: "dashboard#index" | 99 | root to: "dashboard#index" |
| 94 | end | 100 | end |
| 95 | 101 |