Commit 643a6e5824cc8ffb6b58288b7822f42d13476c8f
1 parent
24e26d8b
Exists in
master
and in
4 other branches
Improve admin user show page
Show permissions for all project. Add ability to remove user from group if not an owner Remove unnecessary admin controller
Showing
6 changed files
with
30 additions
and
20 deletions
Show diff stats
app/assets/javascripts/admin.js.coffee
| ... | ... | @@ -23,10 +23,16 @@ class Admin |
| 23 | 23 | e.preventDefault() |
| 24 | 24 | $(this).hide() |
| 25 | 25 | modal.show() |
| 26 | - | |
| 26 | + | |
| 27 | 27 | $('.change-owner-cancel-link').bind "click", (e) -> |
| 28 | 28 | e.preventDefault() |
| 29 | 29 | modal.hide() |
| 30 | 30 | $('.change-owner-link').show() |
| 31 | 31 | |
| 32 | + $('li.users_project').bind 'ajax:success', -> | |
| 33 | + Turbolinks.visit(location.href) | |
| 34 | + | |
| 35 | + $('li.users_group').bind 'ajax:success', -> | |
| 36 | + Turbolinks.visit(location.href) | |
| 37 | + | |
| 32 | 38 | @Admin = Admin | ... | ... |
app/controllers/admin/members_controller.rb
| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | -class Admin::MembersController < Admin::ApplicationController | |
| 2 | - def destroy | |
| 3 | - user = User.find_by_username(params[:id]) | |
| 4 | - project = Project.find_with_namespace(params[:project_id]) | |
| 5 | - project.users_projects.where(user_id: user).first.destroy | |
| 6 | - | |
| 7 | - redirect_to :back | |
| 8 | - end | |
| 9 | -end |
app/models/project_team.rb
| ... | ... | @@ -32,7 +32,15 @@ class ProjectTeam |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | def find_tm(user_id) |
| 35 | - project.users_projects.find_by_user_id(user_id) | |
| 35 | + tm = project.users_projects.find_by_user_id(user_id) | |
| 36 | + | |
| 37 | + # If user is not in project members | |
| 38 | + # we should check for group membership | |
| 39 | + if group && !tm | |
| 40 | + tm = group.users_groups.find_by_user_id(user_id) | |
| 41 | + end | |
| 42 | + | |
| 43 | + tm | |
| 36 | 44 | end |
| 37 | 45 | |
| 38 | 46 | def add_user(user, access) | ... | ... |
app/views/admin/users/show.html.haml
| ... | ... | @@ -95,17 +95,20 @@ |
| 95 | 95 | %ul.well-list |
| 96 | 96 | - @user.users_groups.each do |user_group| |
| 97 | 97 | - group = user_group.group |
| 98 | - %li | |
| 98 | + %li.users_group | |
| 99 | 99 | %strong= link_to group.name, admin_group_path(group) |
| 100 | 100 | .pull-right |
| 101 | 101 | %span.light= user_group.human_access |
| 102 | + - unless user_group.owner? | |
| 103 | + = link_to group_users_group_path(group, user_group), confirm: remove_user_from_group_message(group, @user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do | |
| 104 | + %i.icon-remove.icon-white | |
| 102 | 105 | |
| 103 | 106 | .ui-box |
| 104 | 107 | .title Projects (#{@projects.count}) |
| 105 | 108 | %ul.well-list |
| 106 | 109 | - @projects.sort_by(&:name_with_namespace).each do |project| |
| 107 | 110 | - tm = project.team.find_tm(@user.id) |
| 108 | - %li | |
| 111 | + %li.users_project | |
| 109 | 112 | = link_to admin_project_path(project), class: dom_class(project) do |
| 110 | 113 | - if project.namespace |
| 111 | 114 | = project.namespace.human_name |
| ... | ... | @@ -119,7 +122,9 @@ |
| 119 | 122 | %span.light Owner |
| 120 | 123 | - else |
| 121 | 124 | %span.light= tm.human_access |
| 122 | - = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @user), method: :delete, class: "btn btn-small btn-remove" do | |
| 123 | - %i.icon-remove | |
| 125 | + | |
| 126 | + - if tm.respond_to? :project | |
| 127 | + = link_to project_team_member_path(project, @user), confirm: remove_from_project_team_message(project, @user), remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from project' do | |
| 128 | + %i.icon-remove | |
| 124 | 129 | |
| 125 | 130 | ... | ... |
config/routes.rb
| ... | ... | @@ -89,11 +89,7 @@ Gitlab::Application.routes.draw do |
| 89 | 89 | |
| 90 | 90 | resource :logs, only: [:show] |
| 91 | 91 | resource :background_jobs, controller: 'background_jobs', only: [:show] |
| 92 | - | |
| 93 | - resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do | |
| 94 | - resources :members, only: [:destroy] | |
| 95 | - end | |
| 96 | - | |
| 92 | + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] | |
| 97 | 93 | root to: "dashboard#index" |
| 98 | 94 | end |
| 99 | 95 | ... | ... |