Commit cc04c5b8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor admin user page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent b2139093
class Admin::UsersController < Admin::ApplicationController class Admin::UsersController < Admin::ApplicationController
before_action :user, only: [:show, :edit, :update, :destroy] before_action :user, except: [:index, :new, :create]
def index def index
@users = User.order_name_asc.filter(params[:filter]) @users = User.order_name_asc.filter(params[:filter])
...@@ -9,8 +9,17 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -9,8 +9,17 @@ class Admin::UsersController < Admin::ApplicationController
end end
def show def show
end
def projects
@personal_projects = user.personal_projects @personal_projects = user.personal_projects
@joined_projects = user.projects.joined(@user) @joined_projects = user.projects.joined(@user)
end
def groups
end
def keys
@keys = user.keys @keys = user.keys
end end
......
%h3.page-title - page_title "Identities", @user.name, "Users"
Identities for = render 'admin/users/head'
= link_to @user.name, [:admin, @user]
%hr
- if @identities.present? - if @identities.present?
%table.table %table.table
%thead %thead
......
%h3.page-title
= @user.name
- if @user.blocked?
%span.cred (Blocked)
- if @user.admin
%span.cred (Admin)
.pull-right
= link_to edit_admin_user_path(@user), class: "btn btn-grouped" do
%i.fa.fa-pencil-square-o
Edit
%ul.nav.nav-tabs
= nav_link(path: 'users#show') do
= link_to "Account", admin_user_path(@user)
= nav_link(path: 'users#groups') do
= link_to "Groups", groups_admin_user_path(@user)
= nav_link(path: 'users#projects') do
= link_to "Projects", projects_admin_user_path(@user)
= nav_link(path: 'users#keys') do
= link_to "SSH keys", keys_admin_user_path(@user)
= nav_link(controller: :identities) do
= link_to "Identities", admin_user_identities_path(@user)
- page_title "Groups", @user.name, "Users"
= render 'admin/users/head'
- if @user.group_members.present?
.panel.panel-default
.panel-heading Groups:
%ul.well-list
- @user.group_members.each do |group_member|
- group = group_member.group
%li.group_member
%span{class: ("list-item-name" unless group_member.owner?)}
%strong= link_to group.name, admin_group_path(group)
.pull-right
%span.light= group_member.human_access
- unless group_member.owner?
= link_to group_group_member_path(group, group_member), data: { confirm: remove_user_from_group_message(group, group_member) }, method: :delete, remote: true, class: "btn-xs btn btn-remove", title: 'Remove user from group' do
%i.fa.fa-times.fa-inverse
- else
.nothing-here-block This user has no groups.
- page_title "Keys", @user.name, "Users"
= render 'admin/users/head'
= render 'profiles/keys/key_table', admin: true
- page_title "Projects", @user.name, "Users"
= render 'admin/users/head'
- if @user.groups.any?
.panel.panel-default
.panel-heading Group projects
%ul.well-list
- @user.groups.each do |group|
%li
%strong= group.name
&ndash; access to
#{pluralize(group.projects.count, 'project')}
.row
.col-md-6
- if @personal_projects.present?
= render 'users/projects', projects: @personal_projects
- else
.nothing-here-block This user has no personal projects.
.col-md-6
.panel.panel-default
.panel-heading Joined projects (#{@joined_projects.count})
%ul.well-list
- @joined_projects.sort_by(&:name_with_namespace).each do |project|
- member = project.team.find_member(@user.id)
%li.project_member
.list-item-name
= link_to admin_namespace_project_path(project.namespace, project), class: dom_class(project) do
= project.name_with_namespace
- if member
.pull-right
- if member.owner?
%span.light Owner
- else
%span.light= member.human_access
- if member.respond_to? :project
= link_to namespace_project_project_member_path(project.namespace, project, member), data: { confirm: remove_from_project_team_message(project, member) }, remote: true, method: :delete, class: "btn-xs btn btn-remove", title: 'Remove user from project' do
%i.fa.fa-times
- page_title @user.name, "Users" - page_title @user.name, "Users"
%h3.page-title = render 'admin/users/head', page_name: 'Account'
User:
= @user.name
- if @user.blocked?
%span.cred (Blocked)
- if @user.admin
%span.cred (Admin)
.pull-right .row
= link_to edit_admin_user_path(@user), class: "btn btn-grouped" do .col-md-6
%i.fa.fa-pencil-square-o .panel.panel-default
Edit .panel-heading
%hr = @user.name
%ul.nav.nav-tabs %ul.well-list
%li.active
%a{"data-toggle" => "tab", href: "#account"} Account
%li
%a{"data-toggle" => "tab", href: "#profile"} Profile
%li
%a{"data-toggle" => "tab", href: "#groups"} Groups
%li
%a{"data-toggle" => "tab", href: "#projects"} Projects
%li %li
%a{"data-toggle" => "tab", href: "#ssh-keys"} SSH keys = image_tag avatar_icon(@user.email, 60), class: "avatar s60"
%li %li
= link_to "Identities", admin_user_identities_path(@user) %span.light Profile page:
%strong
= link_to user_path(@user) do
= @user.username
= render 'users/profile', user: @user
.tab-content
#account.tab-pane.active
.row
.col-md-6
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
Account: Account:
...@@ -158,77 +144,3 @@ ...@@ -158,77 +144,3 @@
%strong #{@user.solo_owned_groups.map(&:name).join(', ')} %strong #{@user.solo_owned_groups.map(&:name).join(', ')}
%p %p
You must transfer ownership or delete these groups before you can delete this user. You must transfer ownership or delete these groups before you can delete this user.
#profile.tab-pane
.row
.col-md-6
.panel.panel-default
.panel-heading
= @user.name
%ul.well-list
%li
= image_tag avatar_icon(@user.email, 60), class: "avatar s60"
%li
%span.light Profile page:
%strong
= link_to user_path(@user) do
= @user.username
.col-md-6
= render 'users/profile', user: @user
#groups.tab-pane
- if @user.group_members.present?
.panel.panel-default
.panel-heading Groups:
%ul.well-list
- @user.group_members.each do |group_member|
- group = group_member.group
%li.group_member
%span{class: ("list-item-name" unless group_member.owner?)}
%strong= link_to group.name, admin_group_path(group)
.pull-right
%span.light= group_member.human_access
- unless group_member.owner?
= link_to group_group_member_path(group, group_member), data: { confirm: remove_user_from_group_message(group, group_member) }, method: :delete, remote: true, class: "btn-xs btn btn-remove", title: 'Remove user from group' do
%i.fa.fa-times.fa-inverse
- else
.nothing-here-block This user has no groups.
#projects.tab-pane
- if @user.groups.any?
.panel.panel-default
.panel-heading Group projects
%ul.well-list
- @user.groups.each do |group|
%li
%strong= group.name
&ndash; access to
#{pluralize(group.projects.count, 'project')}
.row
.col-md-6
= render 'users/projects', projects: @personal_projects
.col-md-6
.panel.panel-default
.panel-heading Joined projects (#{@joined_projects.count})
%ul.well-list
- @joined_projects.sort_by(&:name_with_namespace).each do |project|
- member = project.team.find_member(@user.id)
%li.project_member
.list-item-name
= link_to admin_namespace_project_path(project.namespace, project), class: dom_class(project) do
= project.name_with_namespace
- if member
.pull-right
- if member.owner?
%span.light Owner
- else
%span.light= member.human_access
- if member.respond_to? :project
= link_to namespace_project_project_member_path(project.namespace, project, member), data: { confirm: remove_from_project_team_message(project, member) }, remote: true, method: :delete, class: "btn-xs btn btn-remove", title: 'Remove user from project' do
%i.fa.fa-times
#ssh-keys.tab-pane
= render 'profiles/keys/key_table', admin: true
...@@ -152,6 +152,9 @@ Gitlab::Application.routes.draw do ...@@ -152,6 +152,9 @@ Gitlab::Application.routes.draw do
resources :identities, only: [:index, :edit, :update, :destroy] resources :identities, only: [:index, :edit, :update, :destroy]
member do member do
get :projects
get :keys
get :groups
put :team_update put :team_update
put :block put :block
put :unblock put :unblock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment