Commit 6e78a1d7c8d8fe433a120f403d40379919d958db
Exists in
master
and in
4 other branches
Merge branch 'improve/project_transfer'
Showing
21 changed files
with
154 additions
and
356 deletions
Show diff stats
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +module Projects | ||
| 2 | + class TransferContext < BaseContext | ||
| 3 | + def execute(role = :default) | ||
| 4 | + namespace_id = params[:project].delete(:namespace_id) | ||
| 5 | + allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin | ||
| 6 | + | ||
| 7 | + if allowed_transfer && namespace_id.present? | ||
| 8 | + if namespace_id == Namespace.global_id | ||
| 9 | + if project.namespace.present? | ||
| 10 | + # Transfer to global namespace from anyone | ||
| 11 | + project.transfer(nil) | ||
| 12 | + end | ||
| 13 | + elsif namespace_id.to_i != project.namespace_id | ||
| 14 | + # Transfer to someone namespace | ||
| 15 | + namespace = Namespace.find(namespace_id) | ||
| 16 | + project.transfer(namespace) | ||
| 17 | + end | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + rescue ProjectTransferService::TransferError => ex | ||
| 21 | + project.reload | ||
| 22 | + project.errors.add(:namespace_id, ex.message) | ||
| 23 | + false | ||
| 24 | + end | ||
| 25 | + end | ||
| 26 | +end | ||
| 27 | + |
app/contexts/projects/update_context.rb
| 1 | module Projects | 1 | module Projects |
| 2 | class UpdateContext < BaseContext | 2 | class UpdateContext < BaseContext |
| 3 | def execute(role = :default) | 3 | def execute(role = :default) |
| 4 | - namespace_id = params[:project].delete(:namespace_id) | 4 | + params[:project].delete(:namespace_id) |
| 5 | params[:project].delete(:public) unless can?(current_user, :change_public_mode, project) | 5 | params[:project].delete(:public) unless can?(current_user, :change_public_mode, project) |
| 6 | - | ||
| 7 | - allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin | ||
| 8 | - | ||
| 9 | - if allowed_transfer && namespace_id.present? | ||
| 10 | - if namespace_id == Namespace.global_id | ||
| 11 | - if project.namespace.present? | ||
| 12 | - # Transfer to global namespace from anyone | ||
| 13 | - project.transfer(nil) | ||
| 14 | - end | ||
| 15 | - elsif namespace_id.to_i != project.namespace_id | ||
| 16 | - # Transfer to someone namespace | ||
| 17 | - namespace = Namespace.find(namespace_id) | ||
| 18 | - project.transfer(namespace) | ||
| 19 | - end | ||
| 20 | - end | ||
| 21 | - | ||
| 22 | project.update_attributes(params[:project], as: role) | 6 | project.update_attributes(params[:project], as: role) |
| 23 | end | 7 | end |
| 24 | end | 8 | end |
app/controllers/admin/projects_controller.rb
| @@ -19,34 +19,6 @@ class Admin::ProjectsController < Admin::ApplicationController | @@ -19,34 +19,6 @@ class Admin::ProjectsController < Admin::ApplicationController | ||
| 19 | @users = @users.all | 19 | @users = @users.all |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | - def edit | ||
| 23 | - end | ||
| 24 | - | ||
| 25 | - def team_update | ||
| 26 | - @project.team.add_users_ids(params[:user_ids], params[:project_access]) | ||
| 27 | - | ||
| 28 | - redirect_to [:admin, @project], notice: 'Project was successfully updated.' | ||
| 29 | - end | ||
| 30 | - | ||
| 31 | - def update | ||
| 32 | - project.creator = current_user unless project.creator | ||
| 33 | - | ||
| 34 | - status = ::Projects::UpdateContext.new(project, current_user, params).execute(:admin) | ||
| 35 | - | ||
| 36 | - if status | ||
| 37 | - redirect_to [:admin, @project], notice: 'Project was successfully updated.' | ||
| 38 | - else | ||
| 39 | - render action: "edit" | ||
| 40 | - end | ||
| 41 | - end | ||
| 42 | - | ||
| 43 | - def destroy | ||
| 44 | - @project.team.truncate | ||
| 45 | - @project.destroy | ||
| 46 | - | ||
| 47 | - redirect_to admin_projects_path, notice: 'Project was successfully deleted.' | ||
| 48 | - end | ||
| 49 | - | ||
| 50 | protected | 22 | protected |
| 51 | 23 | ||
| 52 | def project | 24 | def project |
app/controllers/projects_controller.rb
| @@ -4,7 +4,7 @@ class ProjectsController < ProjectResourceController | @@ -4,7 +4,7 @@ class ProjectsController < ProjectResourceController | ||
| 4 | 4 | ||
| 5 | # Authorize | 5 | # Authorize |
| 6 | before_filter :authorize_read_project!, except: [:index, :new, :create] | 6 | before_filter :authorize_read_project!, except: [:index, :new, :create] |
| 7 | - before_filter :authorize_admin_project!, only: [:edit, :update, :destroy] | 7 | + before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer] |
| 8 | before_filter :require_non_empty_project, only: [:blob, :tree, :graph] | 8 | before_filter :require_non_empty_project, only: [:blob, :tree, :graph] |
| 9 | 9 | ||
| 10 | layout 'application', only: [:new, :create] | 10 | layout 'application', only: [:new, :create] |
| @@ -45,10 +45,10 @@ class ProjectsController < ProjectResourceController | @@ -45,10 +45,10 @@ class ProjectsController < ProjectResourceController | ||
| 45 | format.js | 45 | format.js |
| 46 | end | 46 | end |
| 47 | end | 47 | end |
| 48 | + end | ||
| 48 | 49 | ||
| 49 | - rescue Project::TransferError => ex | ||
| 50 | - @error = ex | ||
| 51 | - render :update_failed | 50 | + def transfer |
| 51 | + ::Projects::TransferContext.new(project, current_user, params).execute | ||
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | def show | 54 | def show |
app/models/ability.rb
| @@ -41,7 +41,7 @@ class Ability | @@ -41,7 +41,7 @@ class Ability | ||
| 41 | rules << project_guest_rules | 41 | rules << project_guest_rules |
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | - if project.owner == user | 44 | + if project.owner == user || user.admin? |
| 45 | rules << project_admin_rules | 45 | rules << project_admin_rules |
| 46 | end | 46 | end |
| 47 | 47 |
app/models/project.rb
| @@ -26,8 +26,6 @@ class Project < ActiveRecord::Base | @@ -26,8 +26,6 @@ class Project < ActiveRecord::Base | ||
| 26 | include Gitlab::ShellAdapter | 26 | include Gitlab::ShellAdapter |
| 27 | extend Enumerize | 27 | extend Enumerize |
| 28 | 28 | ||
| 29 | - class TransferError < StandardError; end | ||
| 30 | - | ||
| 31 | attr_accessible :name, :path, :description, :default_branch, :issues_tracker, | 29 | attr_accessible :name, :path, :description, :default_branch, :issues_tracker, |
| 32 | :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, | 30 | :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, |
| 33 | :wiki_enabled, :public, :import_url, as: [:default, :admin] | 31 | :wiki_enabled, :public, :import_url, as: [:default, :admin] |
app/services/project_transfer_service.rb
| @@ -5,6 +5,8 @@ | @@ -5,6 +5,8 @@ | ||
| 5 | class ProjectTransferService | 5 | class ProjectTransferService |
| 6 | include Gitlab::ShellAdapter | 6 | include Gitlab::ShellAdapter |
| 7 | 7 | ||
| 8 | + class TransferError < StandardError; end | ||
| 9 | + | ||
| 8 | attr_accessor :project | 10 | attr_accessor :project |
| 9 | 11 | ||
| 10 | def transfer(project, new_namespace) | 12 | def transfer(project, new_namespace) |
| @@ -19,14 +21,18 @@ class ProjectTransferService | @@ -19,14 +21,18 @@ class ProjectTransferService | ||
| 19 | project.namespace = new_namespace | 21 | project.namespace = new_namespace |
| 20 | project.save! | 22 | project.save! |
| 21 | 23 | ||
| 24 | + # Move main repository | ||
| 22 | unless gitlab_shell.mv_repository(old_path, new_path) | 25 | unless gitlab_shell.mv_repository(old_path, new_path) |
| 23 | raise TransferError.new('Cannot move project') | 26 | raise TransferError.new('Cannot move project') |
| 24 | end | 27 | end |
| 25 | 28 | ||
| 29 | + # Move wiki repo also if present | ||
| 30 | + if project.wikis.any? | ||
| 31 | + gitlab_shell.mv_repository("#{old_path}.wiki", "#{new_path}.wiki") | ||
| 32 | + end | ||
| 33 | + | ||
| 26 | true | 34 | true |
| 27 | end | 35 | end |
| 28 | - rescue => ex | ||
| 29 | - raise Project::TransferError.new(ex.message) | ||
| 30 | end | 36 | end |
| 31 | end | 37 | end |
| 32 | 38 |
app/views/admin/projects/_form.html.haml
| @@ -1,86 +0,0 @@ | @@ -1,86 +0,0 @@ | ||
| 1 | -= form_for [:admin, project] do |f| | ||
| 2 | - -if project.errors.any? | ||
| 3 | - .alert.alert-error | ||
| 4 | - %ul | ||
| 5 | - - project.errors.full_messages.each do |msg| | ||
| 6 | - %li= msg | ||
| 7 | - | ||
| 8 | - .clearfix.project_name_holder | ||
| 9 | - = f.label :name do | ||
| 10 | - Project name is | ||
| 11 | - .input | ||
| 12 | - = f.text_field :name, placeholder: "Example Project", class: "xxlarge" | ||
| 13 | - | ||
| 14 | - - if project.repo_exists? | ||
| 15 | - %fieldset.adv_settings | ||
| 16 | - %legend Advanced settings: | ||
| 17 | - .clearfix | ||
| 18 | - = f.label :path do | ||
| 19 | - Path | ||
| 20 | - .input | ||
| 21 | - = text_field_tag :ppath, @project.repository.path_to_repo, class: "xlarge", disabled: true | ||
| 22 | - | ||
| 23 | - .clearfix | ||
| 24 | - = f.label :default_branch, "Default Branch" | ||
| 25 | - .input= f.select(:default_branch, @project.repository.heads.map(&:name), {}, style: "width:210px;") | ||
| 26 | - | ||
| 27 | - %fieldset.adv_settings | ||
| 28 | - %legend Features: | ||
| 29 | - | ||
| 30 | - .clearfix | ||
| 31 | - = f.label :issues_enabled, "Issues" | ||
| 32 | - .input= f.check_box :issues_enabled | ||
| 33 | - | ||
| 34 | - - if Project.issues_tracker.values.count > 1 | ||
| 35 | - .clearfix | ||
| 36 | - = f.label :issues_tracker, "Issues tracker", class: 'control-label' | ||
| 37 | - .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled }) | ||
| 38 | - | ||
| 39 | - .clearfix | ||
| 40 | - = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label' | ||
| 41 | - .input= f.text_field :issues_tracker_id, class: "xxlarge", disabled: !@project.can_have_issues_tracker_id? | ||
| 42 | - | ||
| 43 | - .clearfix | ||
| 44 | - = f.label :merge_requests_enabled, "Merge Requests" | ||
| 45 | - .input= f.check_box :merge_requests_enabled | ||
| 46 | - | ||
| 47 | - .clearfix | ||
| 48 | - = f.label :wall_enabled, "Wall" | ||
| 49 | - .input= f.check_box :wall_enabled | ||
| 50 | - | ||
| 51 | - .clearfix | ||
| 52 | - = f.label :wiki_enabled, "Wiki" | ||
| 53 | - .input= f.check_box :wiki_enabled | ||
| 54 | - | ||
| 55 | - %fieldset.features | ||
| 56 | - %legend Public mode: | ||
| 57 | - .clearfix | ||
| 58 | - = f.label :public do | ||
| 59 | - %span Allow public http clone | ||
| 60 | - .input= f.check_box :public | ||
| 61 | - | ||
| 62 | - %fieldset.features | ||
| 63 | - %legend Transfer: | ||
| 64 | - .control-group | ||
| 65 | - = f.label :namespace_id do | ||
| 66 | - %span Namespace | ||
| 67 | - .controls | ||
| 68 | - = f.select :namespace_id, namespaces_options(@project.namespace_id, :all), {}, {class: 'chosen'} | ||
| 69 | - %br | ||
| 70 | - %ul.prepend-top-10.cred | ||
| 71 | - %li Be careful. Changing project namespace can have unintended side effects | ||
| 72 | - %li You can transfer project only to namespaces you can manage | ||
| 73 | - %li You will need to update your local repositories to point to the new location. | ||
| 74 | - | ||
| 75 | - | ||
| 76 | - .actions | ||
| 77 | - = f.submit 'Save Project', class: "btn btn-save" | ||
| 78 | - = link_to 'Cancel', admin_projects_path, class: "btn btn-cancel" | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - | ||
| 82 | -:javascript | ||
| 83 | - $(function(){ | ||
| 84 | - new Projects(); | ||
| 85 | - }) | ||
| 86 | - |
app/views/admin/projects/edit.html.haml
app/views/admin/projects/index.html.haml
| @@ -52,8 +52,8 @@ | @@ -52,8 +52,8 @@ | ||
| 52 | %i.icon-lock.cgreen | 52 | %i.icon-lock.cgreen |
| 53 | = link_to project.name_with_namespace, [:admin, project] | 53 | = link_to project.name_with_namespace, [:admin, project] |
| 54 | .pull-right | 54 | .pull-right |
| 55 | - = link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" | ||
| 56 | - = link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" | 55 | + = link_to 'Edit', edit_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" |
| 56 | + = link_to 'Destroy', [project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" | ||
| 57 | - if @projects.blank? | 57 | - if @projects.blank? |
| 58 | %p.nothing_here_message 0 projects matches | 58 | %p.nothing_here_message 0 projects matches |
| 59 | - else | 59 | - else |
app/views/admin/projects/show.html.haml
| 1 | %h3.page_title | 1 | %h3.page_title |
| 2 | Project: #{@project.name_with_namespace} | 2 | Project: #{@project.name_with_namespace} |
| 3 | - = link_to edit_admin_project_path(@project), class: "btn pull-right" do | 3 | + = link_to edit_project_path(@project), class: "btn pull-right" do |
| 4 | %i.icon-edit | 4 | %i.icon-edit |
| 5 | Edit | 5 | Edit |
| 6 | +%hr | ||
| 7 | +.row | ||
| 8 | + .span6 | ||
| 9 | + .ui-box | ||
| 10 | + %h5.title | ||
| 11 | + Project info: | ||
| 12 | + %ul.well-list | ||
| 13 | + %li | ||
| 14 | + %span.light Name: | ||
| 15 | + %strong= @project.name | ||
| 16 | + %li | ||
| 17 | + %span.light Namespace: | ||
| 18 | + %strong | ||
| 19 | + - if @project.namespace | ||
| 20 | + = link_to @project.namespace.human_name, [:admin, @project.group || @project.owner] | ||
| 21 | + - else | ||
| 22 | + Global | ||
| 23 | + %li | ||
| 24 | + %span.light Owned by: | ||
| 25 | + %strong | ||
| 26 | + - if @project.owner | ||
| 27 | + = link_to @project.owner_name, admin_user_path(@project.owner) | ||
| 28 | + - else | ||
| 29 | + (deleted) | ||
| 6 | 30 | ||
| 31 | + %li | ||
| 32 | + %span.light Created by: | ||
| 33 | + %strong | ||
| 34 | + = @project.creator.try(:name) || '(deleted)' | ||
| 7 | 35 | ||
| 8 | -%br | ||
| 9 | -%table.zebra-striped | ||
| 10 | - %thead | ||
| 11 | - %tr | ||
| 12 | - %th Project | ||
| 13 | - %th | ||
| 14 | - %tr | ||
| 15 | - %td | ||
| 16 | - %b | ||
| 17 | - Name: | ||
| 18 | - %td | ||
| 19 | - = @project.name | ||
| 20 | - %tr | ||
| 21 | - %td | ||
| 22 | - %b | ||
| 23 | - Namespace: | ||
| 24 | - %td | ||
| 25 | - - if @project.namespace | ||
| 26 | - = @project.namespace.human_name | ||
| 27 | - - else | ||
| 28 | - Global | ||
| 29 | - %tr | ||
| 30 | - %td | ||
| 31 | - %b | ||
| 32 | - Owned by: | ||
| 33 | - %td | ||
| 34 | - - if @project.owner | ||
| 35 | - = link_to @project.owner_name, admin_user_path(@project.owner) | ||
| 36 | - - else | ||
| 37 | - (deleted) | ||
| 38 | - %tr | ||
| 39 | - %td | ||
| 40 | - %b | ||
| 41 | - Created by: | ||
| 42 | - %td | ||
| 43 | - = @project.creator.try(:name) || '(deleted)' | ||
| 44 | - %tr | ||
| 45 | - %td | ||
| 46 | - %b | ||
| 47 | - Created at: | ||
| 48 | - %td | ||
| 49 | - = @project.created_at.stamp("March 1, 1999") | ||
| 50 | - %tr | ||
| 51 | - %td | ||
| 52 | - %b | ||
| 53 | - Smart HTTP: | ||
| 54 | - %td | ||
| 55 | - = link_to @project.http_url_to_repo | ||
| 56 | - %tr | ||
| 57 | - %td | ||
| 58 | - %b | ||
| 59 | - SSH: | ||
| 60 | - %td | ||
| 61 | - = link_to @project.ssh_url_to_repo | ||
| 62 | - - if @project.public | ||
| 63 | - %tr.bgred | ||
| 64 | - %td | ||
| 65 | - %b | ||
| 66 | - Public Read-Only Code access: | ||
| 67 | - %td | ||
| 68 | - = check_box_tag 'public', nil, @project.public | 36 | + %li |
| 37 | + %span.light Created at: | ||
| 38 | + %strong | ||
| 39 | + = @project.created_at.stamp("March 1, 1999") | ||
| 69 | 40 | ||
| 70 | -- if @repository | ||
| 71 | - %table.zebra-striped | ||
| 72 | - %thead | ||
| 73 | - %tr | ||
| 74 | - %th Repository | ||
| 75 | - %th | ||
| 76 | - %tr | ||
| 77 | - %td | ||
| 78 | - %b | ||
| 79 | - FS Path: | ||
| 80 | - %td | ||
| 81 | - %code= @repository.path_to_repo | ||
| 82 | - %tr | ||
| 83 | - %td | ||
| 84 | - %b | ||
| 85 | - Last commit at: | ||
| 86 | - %td | ||
| 87 | - = last_commit(@project) | 41 | + %li |
| 42 | + %span.light http: | ||
| 43 | + %strong | ||
| 44 | + = link_to @project.http_url_to_repo | ||
| 45 | + %li | ||
| 46 | + %span.light ssh: | ||
| 47 | + %strong | ||
| 48 | + = link_to @project.ssh_url_to_repo | ||
| 49 | + %li | ||
| 50 | + %span.light fs: | ||
| 51 | + %strong | ||
| 52 | + = @repository.path_to_repo | ||
| 88 | 53 | ||
| 89 | -%br | ||
| 90 | -%h5 | ||
| 91 | - Team | ||
| 92 | - %small | ||
| 93 | - (#{@project.users.count}) | ||
| 94 | -%br | ||
| 95 | -%table.zebra-striped.team_members | ||
| 96 | - %thead | ||
| 97 | - %tr | ||
| 98 | - %th Name | ||
| 99 | - %th Project Access | ||
| 100 | - %th Repository Access | ||
| 101 | - %th | 54 | + %li |
| 55 | + %span.light last commit: | ||
| 56 | + %strong | ||
| 57 | + - if @repository | ||
| 58 | + = last_commit(@project) | ||
| 59 | + - else | ||
| 60 | + never | ||
| 102 | 61 | ||
| 103 | - - @project.users.each do |tm| | ||
| 104 | - %tr | ||
| 105 | - %td | ||
| 106 | - = link_to tm.name, admin_user_path(tm) | ||
| 107 | - %td= @project.project_access_human(tm) | ||
| 108 | - %td= link_to 'Edit Access', edit_admin_project_member_path(@project, tm), class: "btn btn-small" | ||
| 109 | - %td= link_to 'Remove from team', admin_project_member_path(@project, tm), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove small" | ||
| 110 | - | ||
| 111 | -%br | ||
| 112 | -%h5 Add new team member | ||
| 113 | -%br | ||
| 114 | -= form_tag team_update_admin_project_path(@project), class: "bulk_import", method: :put do | ||
| 115 | - %table.zebra-striped | ||
| 116 | - %thead | ||
| 117 | - %tr | ||
| 118 | - %th Users | ||
| 119 | - %th Project Access: | ||
| 120 | - | ||
| 121 | - %tr | ||
| 122 | - %td= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), multiple: true, data: {placeholder: 'Select users'}, class: 'chosen span5' | ||
| 123 | - %td= select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3"} | ||
| 124 | - | ||
| 125 | - %tr | ||
| 126 | - %td= submit_tag 'Add', class: "btn btn-primary" | ||
| 127 | - %td | ||
| 128 | - Read more about project permissions | ||
| 129 | - %strong= link_to "here", help_permissions_path, class: "vlink" | 62 | + %li |
| 63 | + %span.light access: | ||
| 64 | + %strong | ||
| 65 | + - if @project.public | ||
| 66 | + %span.cblue | ||
| 67 | + %i.icon-share | ||
| 68 | + Public | ||
| 69 | + - else | ||
| 70 | + %span.cgreen | ||
| 71 | + %i.icon-lock | ||
| 72 | + Private | ||
| 73 | + .span6 | ||
| 74 | + .ui-box | ||
| 75 | + %h5.title | ||
| 76 | + Team | ||
| 77 | + %small | ||
| 78 | + (#{@project.users.count}) | ||
| 79 | + = link_to project_team_index_path(@project), class: "btn btn-tiny" do | ||
| 80 | + %i.icon-edit | ||
| 81 | + Edit Team | ||
| 82 | + %ul.well-list.team_members | ||
| 83 | + - @project.users.each do |tm| | ||
| 84 | + %li | ||
| 85 | + %strong | ||
| 86 | + = link_to tm.name, admin_user_path(tm) | ||
| 87 | + %span.pull-right.light= @project.project_access_human(tm) |
app/views/admin/projects/team.html.haml
app/views/projects/_form.html.haml
| @@ -107,8 +107,9 @@ | @@ -107,8 +107,9 @@ | ||
| 107 | - if can?(current_user, :change_namespace, @project) | 107 | - if can?(current_user, :change_namespace, @project) |
| 108 | .ui-box.ui-box-danger | 108 | .ui-box.ui-box-danger |
| 109 | %h5.title Transfer project | 109 | %h5.title Transfer project |
| 110 | + .errors-holder | ||
| 110 | .form-holder | 111 | .form-holder |
| 111 | - = form_for(@project, remote: true, html: { class: 'transfer-project' }) do |f| | 112 | + = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f| |
| 112 | .control-group | 113 | .control-group |
| 113 | = f.label :namespace_id do | 114 | = f.label :namespace_id do |
| 114 | %span Namespace | 115 | %span Namespace |
| @@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
| 1 | +- if @project.errors[:namespace_id].present? | ||
| 2 | + :plain | ||
| 3 | + $("#tab-transfer .errors-holder").replaceWith(errorMessage('#{escape_javascript(@project.errors[:namespace_id].first)}')); | ||
| 4 | + $("#tab-transfer .form-actions input").removeAttr('disabled').removeClass('disabled'); | ||
| 5 | +- else | ||
| 6 | + :plain | ||
| 7 | + location.href = "#{edit_project_path(@project)}"; |
app/views/projects/update_failed.js.haml
config/routes.rb
| @@ -85,11 +85,7 @@ Gitlab::Application.routes.draw do | @@ -85,11 +85,7 @@ Gitlab::Application.routes.draw do | ||
| 85 | resource :logs, only: [:show] | 85 | resource :logs, only: [:show] |
| 86 | resource :resque, controller: 'resque', only: [:show] | 86 | resource :resque, controller: 'resque', only: [:show] |
| 87 | 87 | ||
| 88 | - resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do | ||
| 89 | - member do | ||
| 90 | - get :team | ||
| 91 | - put :team_update | ||
| 92 | - end | 88 | + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do |
| 93 | scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do | 89 | scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do |
| 94 | resources :members, only: [:edit, :update, :destroy] | 90 | resources :members, only: [:edit, :update, :destroy] |
| 95 | end | 91 | end |
| @@ -167,6 +163,10 @@ Gitlab::Application.routes.draw do | @@ -167,6 +163,10 @@ Gitlab::Application.routes.draw do | ||
| 167 | # Project Area | 163 | # Project Area |
| 168 | # | 164 | # |
| 169 | resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do | 165 | resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do |
| 166 | + member do | ||
| 167 | + put :transfer | ||
| 168 | + end | ||
| 169 | + | ||
| 170 | resources :blob, only: [:show], constraints: {id: /.+/} | 170 | resources :blob, only: [:show], constraints: {id: /.+/} |
| 171 | resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } | 171 | resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } |
| 172 | resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit' | 172 | resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit' |
features/steps/admin/admin_projects.rb
| @@ -16,9 +16,7 @@ class AdminProjects < Spinach::FeatureSteps | @@ -16,9 +16,7 @@ class AdminProjects < Spinach::FeatureSteps | ||
| 16 | Then 'I should see project details' do | 16 | Then 'I should see project details' do |
| 17 | project = Project.first | 17 | project = Project.first |
| 18 | current_path.should == admin_project_path(project) | 18 | current_path.should == admin_project_path(project) |
| 19 | - | ||
| 20 | page.should have_content(project.name_with_namespace) | 19 | page.should have_content(project.name_with_namespace) |
| 21 | page.should have_content(project.creator.name) | 20 | page.should have_content(project.creator.name) |
| 22 | - page.should have_content('Add new team member') | ||
| 23 | end | 21 | end |
| 24 | end | 22 | end |
lib/tasks/gitlab/check.rake
| @@ -637,8 +637,8 @@ namespace :gitlab do | @@ -637,8 +637,8 @@ namespace :gitlab do | ||
| 637 | 637 | ||
| 638 | def check_gitlab_shell | 638 | def check_gitlab_shell |
| 639 | print "GitLab Shell version? ... " | 639 | print "GitLab Shell version? ... " |
| 640 | - if gitlab_shell_version.strip == '1.1.0' | ||
| 641 | - puts 'OK (1.1.0)'.green | 640 | + if gitlab_shell_version.strip == '1.2.0' |
| 641 | + puts 'OK (1.2.0)'.green | ||
| 642 | else | 642 | else |
| 643 | puts 'FAIL. Please update gitlab-shell to v1.1.0'.red | 643 | puts 'FAIL. Please update gitlab-shell to v1.1.0'.red |
| 644 | end | 644 | end |
spec/features/admin/admin_projects_spec.rb
| @@ -31,46 +31,4 @@ describe "Admin::Projects" do | @@ -31,46 +31,4 @@ describe "Admin::Projects" do | ||
| 31 | page.should have_content(@project.name) | 31 | page.should have_content(@project.name) |
| 32 | end | 32 | end |
| 33 | end | 33 | end |
| 34 | - | ||
| 35 | - describe "GET /admin/projects/:id/edit" do | ||
| 36 | - before do | ||
| 37 | - visit admin_projects_path | ||
| 38 | - click_link "edit_project_#{@project.id}" | ||
| 39 | - end | ||
| 40 | - | ||
| 41 | - it "should have project edit page" do | ||
| 42 | - page.should have_content("Edit project") | ||
| 43 | - page.should have_button("Save Project") | ||
| 44 | - end | ||
| 45 | - | ||
| 46 | - describe "Update project" do | ||
| 47 | - before do | ||
| 48 | - fill_in "project_name", with: "Big Bang" | ||
| 49 | - click_button "Save Project" | ||
| 50 | - @project.reload | ||
| 51 | - end | ||
| 52 | - | ||
| 53 | - it "should show page with new data" do | ||
| 54 | - page.should have_content("Big Bang") | ||
| 55 | - end | ||
| 56 | - | ||
| 57 | - it "should change project entry" do | ||
| 58 | - @project.name.should == "Big Bang" | ||
| 59 | - end | ||
| 60 | - end | ||
| 61 | - end | ||
| 62 | - | ||
| 63 | - describe "Add new team member" do | ||
| 64 | - before do | ||
| 65 | - @new_user = create(:user) | ||
| 66 | - visit admin_project_path(@project) | ||
| 67 | - end | ||
| 68 | - | ||
| 69 | - it "should create new user" do | ||
| 70 | - select @new_user.name, from: "user_ids" | ||
| 71 | - expect { click_button "Add" }.to change { UsersProject.count }.by(1) | ||
| 72 | - page.should have_content @new_user.name | ||
| 73 | - current_path.should == admin_project_path(@project) | ||
| 74 | - end | ||
| 75 | - end | ||
| 76 | end | 34 | end |
spec/features/security/project_access_spec.rb
| @@ -33,7 +33,7 @@ describe "Application access" do | @@ -33,7 +33,7 @@ describe "Application access" do | ||
| 33 | 33 | ||
| 34 | it { should be_allowed_for master } | 34 | it { should be_allowed_for master } |
| 35 | it { should be_allowed_for reporter } | 35 | it { should be_allowed_for reporter } |
| 36 | - it { should be_denied_for :admin } | 36 | + it { should be_allowed_for :admin } |
| 37 | it { should be_denied_for guest } | 37 | it { should be_denied_for guest } |
| 38 | it { should be_denied_for :user } | 38 | it { should be_denied_for :user } |
| 39 | it { should be_denied_for :visitor } | 39 | it { should be_denied_for :visitor } |
| @@ -44,7 +44,7 @@ describe "Application access" do | @@ -44,7 +44,7 @@ describe "Application access" do | ||
| 44 | 44 | ||
| 45 | it { should be_allowed_for master } | 45 | it { should be_allowed_for master } |
| 46 | it { should be_allowed_for reporter } | 46 | it { should be_allowed_for reporter } |
| 47 | - it { should be_denied_for :admin } | 47 | + it { should be_allowed_for :admin } |
| 48 | it { should be_denied_for guest } | 48 | it { should be_denied_for guest } |
| 49 | it { should be_denied_for :user } | 49 | it { should be_denied_for :user } |
| 50 | it { should be_denied_for :visitor } | 50 | it { should be_denied_for :visitor } |
| @@ -55,7 +55,7 @@ describe "Application access" do | @@ -55,7 +55,7 @@ describe "Application access" do | ||
| 55 | 55 | ||
| 56 | it { should be_allowed_for master } | 56 | it { should be_allowed_for master } |
| 57 | it { should be_allowed_for reporter } | 57 | it { should be_allowed_for reporter } |
| 58 | - it { should be_denied_for :admin } | 58 | + it { should be_allowed_for :admin } |
| 59 | it { should be_denied_for guest } | 59 | it { should be_denied_for guest } |
| 60 | it { should be_denied_for :user } | 60 | it { should be_denied_for :user } |
| 61 | it { should be_denied_for :visitor } | 61 | it { should be_denied_for :visitor } |
| @@ -66,7 +66,7 @@ describe "Application access" do | @@ -66,7 +66,7 @@ describe "Application access" do | ||
| 66 | 66 | ||
| 67 | it { should be_allowed_for master } | 67 | it { should be_allowed_for master } |
| 68 | it { should be_allowed_for reporter } | 68 | it { should be_allowed_for reporter } |
| 69 | - it { should be_denied_for :admin } | 69 | + it { should be_allowed_for :admin } |
| 70 | it { should be_denied_for guest } | 70 | it { should be_denied_for guest } |
| 71 | it { should be_denied_for :user } | 71 | it { should be_denied_for :user } |
| 72 | it { should be_denied_for :visitor } | 72 | it { should be_denied_for :visitor } |
| @@ -77,7 +77,7 @@ describe "Application access" do | @@ -77,7 +77,7 @@ describe "Application access" do | ||
| 77 | 77 | ||
| 78 | it { should be_allowed_for master } | 78 | it { should be_allowed_for master } |
| 79 | it { should be_allowed_for reporter } | 79 | it { should be_allowed_for reporter } |
| 80 | - it { should be_denied_for :admin } | 80 | + it { should be_allowed_for :admin } |
| 81 | it { should be_denied_for guest } | 81 | it { should be_denied_for guest } |
| 82 | it { should be_denied_for :user } | 82 | it { should be_denied_for :user } |
| 83 | it { should be_denied_for :visitor } | 83 | it { should be_denied_for :visitor } |
| @@ -88,7 +88,7 @@ describe "Application access" do | @@ -88,7 +88,7 @@ describe "Application access" do | ||
| 88 | 88 | ||
| 89 | it { should be_allowed_for master } | 89 | it { should be_allowed_for master } |
| 90 | it { should be_allowed_for reporter } | 90 | it { should be_allowed_for reporter } |
| 91 | - it { should be_denied_for :admin } | 91 | + it { should be_allowed_for :admin } |
| 92 | it { should be_denied_for guest } | 92 | it { should be_denied_for guest } |
| 93 | it { should be_denied_for :user } | 93 | it { should be_denied_for :user } |
| 94 | it { should be_denied_for :visitor } | 94 | it { should be_denied_for :visitor } |
| @@ -99,7 +99,7 @@ describe "Application access" do | @@ -99,7 +99,7 @@ describe "Application access" do | ||
| 99 | 99 | ||
| 100 | it { should be_allowed_for master } | 100 | it { should be_allowed_for master } |
| 101 | it { should be_allowed_for reporter } | 101 | it { should be_allowed_for reporter } |
| 102 | - it { should be_denied_for :admin } | 102 | + it { should be_allowed_for :admin } |
| 103 | it { should be_denied_for guest } | 103 | it { should be_denied_for guest } |
| 104 | it { should be_denied_for :user } | 104 | it { should be_denied_for :user } |
| 105 | it { should be_denied_for :visitor } | 105 | it { should be_denied_for :visitor } |
| @@ -114,7 +114,7 @@ describe "Application access" do | @@ -114,7 +114,7 @@ describe "Application access" do | ||
| 114 | 114 | ||
| 115 | it { @blob_path.should be_allowed_for master } | 115 | it { @blob_path.should be_allowed_for master } |
| 116 | it { @blob_path.should be_allowed_for reporter } | 116 | it { @blob_path.should be_allowed_for reporter } |
| 117 | - it { @blob_path.should be_denied_for :admin } | 117 | + it { @blob_path.should be_allowed_for :admin } |
| 118 | it { @blob_path.should be_denied_for guest } | 118 | it { @blob_path.should be_denied_for guest } |
| 119 | it { @blob_path.should be_denied_for :user } | 119 | it { @blob_path.should be_denied_for :user } |
| 120 | it { @blob_path.should be_denied_for :visitor } | 120 | it { @blob_path.should be_denied_for :visitor } |
| @@ -125,7 +125,7 @@ describe "Application access" do | @@ -125,7 +125,7 @@ describe "Application access" do | ||
| 125 | 125 | ||
| 126 | it { should be_allowed_for master } | 126 | it { should be_allowed_for master } |
| 127 | it { should be_denied_for reporter } | 127 | it { should be_denied_for reporter } |
| 128 | - it { should be_denied_for :admin } | 128 | + it { should be_allowed_for :admin } |
| 129 | it { should be_denied_for guest } | 129 | it { should be_denied_for guest } |
| 130 | it { should be_denied_for :user } | 130 | it { should be_denied_for :user } |
| 131 | it { should be_denied_for :visitor } | 131 | it { should be_denied_for :visitor } |
| @@ -136,7 +136,7 @@ describe "Application access" do | @@ -136,7 +136,7 @@ describe "Application access" do | ||
| 136 | 136 | ||
| 137 | it { should be_allowed_for master } | 137 | it { should be_allowed_for master } |
| 138 | it { should be_denied_for reporter } | 138 | it { should be_denied_for reporter } |
| 139 | - it { should be_denied_for :admin } | 139 | + it { should be_allowed_for :admin } |
| 140 | it { should be_denied_for guest } | 140 | it { should be_denied_for guest } |
| 141 | it { should be_denied_for :user } | 141 | it { should be_denied_for :user } |
| 142 | it { should be_denied_for :visitor } | 142 | it { should be_denied_for :visitor } |
| @@ -147,7 +147,7 @@ describe "Application access" do | @@ -147,7 +147,7 @@ describe "Application access" do | ||
| 147 | 147 | ||
| 148 | it { should be_allowed_for master } | 148 | it { should be_allowed_for master } |
| 149 | it { should be_allowed_for reporter } | 149 | it { should be_allowed_for reporter } |
| 150 | - it { should be_denied_for :admin } | 150 | + it { should be_allowed_for :admin } |
| 151 | it { should be_denied_for guest } | 151 | it { should be_denied_for guest } |
| 152 | it { should be_denied_for :user } | 152 | it { should be_denied_for :user } |
| 153 | it { should be_denied_for :visitor } | 153 | it { should be_denied_for :visitor } |
| @@ -158,7 +158,7 @@ describe "Application access" do | @@ -158,7 +158,7 @@ describe "Application access" do | ||
| 158 | 158 | ||
| 159 | it { should be_allowed_for master } | 159 | it { should be_allowed_for master } |
| 160 | it { should be_allowed_for reporter } | 160 | it { should be_allowed_for reporter } |
| 161 | - it { should be_denied_for :admin } | 161 | + it { should be_allowed_for :admin } |
| 162 | it { should be_denied_for guest } | 162 | it { should be_denied_for guest } |
| 163 | it { should be_denied_for :user } | 163 | it { should be_denied_for :user } |
| 164 | it { should be_denied_for :visitor } | 164 | it { should be_denied_for :visitor } |
| @@ -169,7 +169,7 @@ describe "Application access" do | @@ -169,7 +169,7 @@ describe "Application access" do | ||
| 169 | 169 | ||
| 170 | it { should be_allowed_for master } | 170 | it { should be_allowed_for master } |
| 171 | it { should be_allowed_for reporter } | 171 | it { should be_allowed_for reporter } |
| 172 | - it { should be_denied_for :admin } | 172 | + it { should be_allowed_for :admin } |
| 173 | it { should be_denied_for guest } | 173 | it { should be_denied_for guest } |
| 174 | it { should be_denied_for :user } | 174 | it { should be_denied_for :user } |
| 175 | it { should be_denied_for :visitor } | 175 | it { should be_denied_for :visitor } |
| @@ -180,7 +180,7 @@ describe "Application access" do | @@ -180,7 +180,7 @@ describe "Application access" do | ||
| 180 | 180 | ||
| 181 | it { should be_allowed_for master } | 181 | it { should be_allowed_for master } |
| 182 | it { should be_allowed_for reporter } | 182 | it { should be_allowed_for reporter } |
| 183 | - it { should be_denied_for :admin } | 183 | + it { should be_allowed_for :admin } |
| 184 | it { should be_denied_for guest } | 184 | it { should be_denied_for guest } |
| 185 | it { should be_denied_for :user } | 185 | it { should be_denied_for :user } |
| 186 | it { should be_denied_for :visitor } | 186 | it { should be_denied_for :visitor } |
| @@ -196,7 +196,7 @@ describe "Application access" do | @@ -196,7 +196,7 @@ describe "Application access" do | ||
| 196 | 196 | ||
| 197 | it { should be_allowed_for master } | 197 | it { should be_allowed_for master } |
| 198 | it { should be_allowed_for reporter } | 198 | it { should be_allowed_for reporter } |
| 199 | - it { should be_denied_for :admin } | 199 | + it { should be_allowed_for :admin } |
| 200 | it { should be_denied_for guest } | 200 | it { should be_denied_for guest } |
| 201 | it { should be_denied_for :user } | 201 | it { should be_denied_for :user } |
| 202 | it { should be_denied_for :visitor } | 202 | it { should be_denied_for :visitor } |
| @@ -212,7 +212,7 @@ describe "Application access" do | @@ -212,7 +212,7 @@ describe "Application access" do | ||
| 212 | 212 | ||
| 213 | it { should be_allowed_for master } | 213 | it { should be_allowed_for master } |
| 214 | it { should be_allowed_for reporter } | 214 | it { should be_allowed_for reporter } |
| 215 | - it { should be_denied_for :admin } | 215 | + it { should be_allowed_for :admin } |
| 216 | it { should be_denied_for guest } | 216 | it { should be_denied_for guest } |
| 217 | it { should be_denied_for :user } | 217 | it { should be_denied_for :user } |
| 218 | it { should be_denied_for :visitor } | 218 | it { should be_denied_for :visitor } |
| @@ -223,7 +223,7 @@ describe "Application access" do | @@ -223,7 +223,7 @@ describe "Application access" do | ||
| 223 | 223 | ||
| 224 | it { should be_allowed_for master } | 224 | it { should be_allowed_for master } |
| 225 | it { should be_allowed_for reporter } | 225 | it { should be_allowed_for reporter } |
| 226 | - it { should be_denied_for :admin } | 226 | + it { should be_allowed_for :admin } |
| 227 | it { should be_denied_for guest } | 227 | it { should be_denied_for guest } |
| 228 | it { should be_denied_for :user } | 228 | it { should be_denied_for :user } |
| 229 | it { should be_denied_for :visitor } | 229 | it { should be_denied_for :visitor } |
spec/routing/admin_routing_spec.rb
| @@ -66,33 +66,13 @@ end | @@ -66,33 +66,13 @@ end | ||
| 66 | # PUT /admin/projects/:id(.:format) admin/projects#update {:id=>/[^\/]+/} | 66 | # PUT /admin/projects/:id(.:format) admin/projects#update {:id=>/[^\/]+/} |
| 67 | # DELETE /admin/projects/:id(.:format) admin/projects#destroy {:id=>/[^\/]+/} | 67 | # DELETE /admin/projects/:id(.:format) admin/projects#destroy {:id=>/[^\/]+/} |
| 68 | describe Admin::ProjectsController, "routing" do | 68 | describe Admin::ProjectsController, "routing" do |
| 69 | - it "to #team" do | ||
| 70 | - get("/admin/projects/gitlab/team").should route_to('admin/projects#team', id: 'gitlab') | ||
| 71 | - end | ||
| 72 | - | ||
| 73 | - it "to #team_update" do | ||
| 74 | - put("/admin/projects/gitlab/team_update").should route_to('admin/projects#team_update', id: 'gitlab') | ||
| 75 | - end | ||
| 76 | - | ||
| 77 | it "to #index" do | 69 | it "to #index" do |
| 78 | get("/admin/projects").should route_to('admin/projects#index') | 70 | get("/admin/projects").should route_to('admin/projects#index') |
| 79 | end | 71 | end |
| 80 | 72 | ||
| 81 | - it "to #edit" do | ||
| 82 | - get("/admin/projects/gitlab/edit").should route_to('admin/projects#edit', id: 'gitlab') | ||
| 83 | - end | ||
| 84 | - | ||
| 85 | it "to #show" do | 73 | it "to #show" do |
| 86 | get("/admin/projects/gitlab").should route_to('admin/projects#show', id: 'gitlab') | 74 | get("/admin/projects/gitlab").should route_to('admin/projects#show', id: 'gitlab') |
| 87 | end | 75 | end |
| 88 | - | ||
| 89 | - it "to #update" do | ||
| 90 | - put("/admin/projects/gitlab").should route_to('admin/projects#update', id: 'gitlab') | ||
| 91 | - end | ||
| 92 | - | ||
| 93 | - it "to #destroy" do | ||
| 94 | - delete("/admin/projects/gitlab").should route_to('admin/projects#destroy', id: 'gitlab') | ||
| 95 | - end | ||
| 96 | end | 76 | end |
| 97 | 77 | ||
| 98 | # edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {:id=>/[^\/]+/, :project_id=>/[^\/]+/} | 78 | # edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {:id=>/[^\/]+/, :project_id=>/[^\/]+/} |