Commit ed3f44085e01f50864ce840f007a50d2154df6f5
1 parent
6b24c375
Exists in
master
and in
4 other branches
Redesign Admin -> user -> show page
Showing
6 changed files
with
99 additions
and
135 deletions
Show diff stats
app/controllers/admin/users_controller.rb
| @@ -9,8 +9,12 @@ class Admin::UsersController < Admin::ApplicationController | @@ -9,8 +9,12 @@ class Admin::UsersController < Admin::ApplicationController | ||
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | def show | 11 | def show |
| 12 | - @projects = Project.scoped | ||
| 13 | - @projects = @projects.without_user(admin_user) if admin_user.authorized_projects.present? | 12 | + # Projects user can be added to |
| 13 | + @not_in_projects = Project.scoped | ||
| 14 | + @not_in_projects = @not_in_projects.without_user(admin_user) if admin_user.authorized_projects.present? | ||
| 15 | + | ||
| 16 | + # Projects he already own or joined | ||
| 17 | + @projects = admin_user.authorized_projects.where('projects.id in (?)', admin_user.authorized_projects.map(&:id)) | ||
| 14 | end | 18 | end |
| 15 | 19 | ||
| 16 | def team_update | 20 | def team_update |
app/models/user.rb
app/views/admin/users/show.html.haml
| 1 | -%h3.page_title | ||
| 2 | - User: #{@admin_user.name} | ||
| 3 | - - if @admin_user.blocked | ||
| 4 | - %small Blocked | ||
| 5 | - - if @admin_user.admin | ||
| 6 | - %small Administrator | ||
| 7 | - = link_to edit_admin_user_path(@admin_user), class: "btn pull-right" do | ||
| 8 | - %i.icon-edit | ||
| 9 | - Edit | ||
| 10 | - | ||
| 11 | -%br | ||
| 12 | - | ||
| 13 | -%table.zebra-striped | ||
| 14 | - %thead | ||
| 15 | - %tr | ||
| 16 | - %th Profile | ||
| 17 | - %th | ||
| 18 | - %tr | ||
| 19 | - %td | ||
| 20 | - %b | ||
| 21 | - Email: | ||
| 22 | - %td | ||
| 23 | - = @admin_user.email | ||
| 24 | - %tr | ||
| 25 | - %td | ||
| 26 | - %b | ||
| 27 | - Username: | ||
| 28 | - %td | ||
| 29 | - = @admin_user.username | ||
| 30 | - %tr | ||
| 31 | - %td | ||
| 32 | - %b | ||
| 33 | - Admin: | ||
| 34 | - %td= check_box_tag "admin", 1, @admin_user.admin, disabled: :disabled | ||
| 35 | - %tr | ||
| 36 | - %td | ||
| 37 | - %b | ||
| 38 | - Blocked: | ||
| 39 | - %td= check_box_tag "blocked", 1, @admin_user.blocked, disabled: :disabled | ||
| 40 | - %tr | ||
| 41 | - %td | ||
| 42 | - %b | ||
| 43 | - Created at: | ||
| 44 | - %td | ||
| 45 | - = @admin_user.created_at.stamp("March 1, 1999") | ||
| 46 | - %tr | ||
| 47 | - %td | ||
| 48 | - %b | ||
| 49 | - Projects limit: | ||
| 50 | - %td | ||
| 51 | - = @admin_user.projects_limit | ||
| 52 | - - unless @admin_user.skype.empty? | ||
| 53 | - %tr | ||
| 54 | - %td | ||
| 55 | - %b | ||
| 56 | - Skype: | ||
| 57 | - %td | ||
| 58 | - = @admin_user.skype | ||
| 59 | - - unless @admin_user.linkedin.empty? | ||
| 60 | - %tr | ||
| 61 | - %td | ||
| 62 | - %b | ||
| 63 | - Linkedin: | ||
| 64 | - %td | ||
| 65 | - = @admin_user.linkedin | ||
| 66 | - - unless @admin_user.twitter.empty? | ||
| 67 | - %tr | ||
| 68 | - %td | ||
| 69 | - %b | ||
| 70 | - Twitter: | ||
| 71 | - %td | ||
| 72 | - = @admin_user.twitter | ||
| 73 | - | ||
| 74 | -%br | ||
| 75 | -%h5 Add User to Projects | ||
| 76 | -%br | ||
| 77 | -= form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do | ||
| 78 | - %table | ||
| 79 | - %thead | ||
| 80 | - %tr | ||
| 81 | - %th Projects | ||
| 82 | - %th Project Access: | ||
| 83 | - | ||
| 84 | - %tr | ||
| 85 | - %td= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' | ||
| 86 | - %td= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3" | ||
| 87 | - | ||
| 88 | - %tr | ||
| 89 | - %td= submit_tag 'Add', class: "btn btn-primary" | ||
| 90 | - %td | 1 | +.row |
| 2 | + .span6 | ||
| 3 | + %h3.page_title | ||
| 4 | + = image_tag gravatar_icon(@admin_user.email, 90), class: "avatar s90" | ||
| 5 | + = @admin_user.name | ||
| 6 | + - if @admin_user.blocked | ||
| 7 | + %span.cred (Blocked) | ||
| 8 | + - if @admin_user.admin | ||
| 9 | + %span.cred (Admin) | ||
| 10 | + .pull-right | ||
| 11 | + = link_to edit_admin_user_path(@admin_user), class: "btn pull-right" do | ||
| 12 | + %i.icon-edit | ||
| 13 | + Edit | ||
| 14 | + %br | ||
| 15 | + %small @#{@admin_user.username} | ||
| 16 | + %br | ||
| 17 | + %small member since #{@admin_user.created_at.stamp("Nov 12, 2031")} | ||
| 18 | + .clearfix | ||
| 19 | + %hr | ||
| 20 | + %h5 | ||
| 21 | + Add User to Projects | ||
| 22 | + %small | ||
| 91 | Read more about project permissions | 23 | Read more about project permissions |
| 92 | %strong= link_to "here", help_permissions_path, class: "vlink" | 24 | %strong= link_to "here", help_permissions_path, class: "vlink" |
| 93 | -%br | ||
| 94 | - | ||
| 95 | -- if @admin_user.groups.present? | ||
| 96 | - %h5 Owner of groups: | ||
| 97 | - %br | ||
| 98 | - | ||
| 99 | - %table.zebra-striped | ||
| 100 | - %thead | ||
| 101 | - %tr | ||
| 102 | - %th Name | 25 | + %br |
| 26 | + = form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do | ||
| 27 | + .control-group | ||
| 28 | + = label_tag :project_ids, "Projects", class: 'control-label' | ||
| 29 | + .controls | ||
| 30 | + = select_tag :project_ids, options_from_collection_for_select(@not_in_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span3' | ||
| 31 | + .control-group | ||
| 32 | + = label_tag :project_access, "Project Access", class: 'control-label' | ||
| 33 | + .controls | ||
| 34 | + = select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3" | ||
| 103 | 35 | ||
| 104 | - - @admin_user.groups.each do |group| | ||
| 105 | - %tr | ||
| 106 | - %td= link_to group.name, admin_group_path(group) | 36 | + .form-actions |
| 37 | + = submit_tag 'Add', class: "btn btn-create" | ||
| 38 | + .pull-right | ||
| 39 | + %br | ||
| 107 | 40 | ||
| 41 | + - if @admin_user.owned_groups.present? | ||
| 42 | + .ui-box | ||
| 43 | + %h5.title Owned groups: | ||
| 44 | + %ul.well-list | ||
| 45 | + - @admin_user.groups.each do |group| | ||
| 46 | + %li | ||
| 47 | + %strong= link_to group.name, admin_group_path(group) | ||
| 108 | 48 | ||
| 109 | -- if @admin_user.authorized_projects.present? | ||
| 110 | - %h5 Authorized Projects: | ||
| 111 | - %br | 49 | + - if @admin_user.owned_teams.present? |
| 50 | + .ui-box | ||
| 51 | + %h5.title Owned teams: | ||
| 52 | + %ul.well-list | ||
| 53 | + - @admin_user.owned_teams.each do |team| | ||
| 54 | + %li | ||
| 55 | + %strong= link_to team.name, admin_team_path(team) | ||
| 112 | 56 | ||
| 113 | - %table.zebra-striped | ||
| 114 | - %thead | ||
| 115 | - %tr | ||
| 116 | - %th Name | ||
| 117 | - %th Project Access | ||
| 118 | - %th | ||
| 119 | - %th | ||
| 120 | 57 | ||
| 121 | - - @admin_user.tm_in_authorized_projects.each do |tm| | ||
| 122 | - - project = tm.project | ||
| 123 | - %tr | ||
| 124 | - %td= link_to project.name_with_namespace, admin_project_path(project) | ||
| 125 | - %td= tm.project_access_human | ||
| 126 | - %td= link_to 'Edit Access', edit_admin_project_member_path(project, tm.user), class: "btn btn-small" | ||
| 127 | - %td= link_to 'Remove from team', admin_project_member_path(project, tm.user), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove" | 58 | + .span6 |
| 59 | + = render 'users/profile', user: @admin_user | ||
| 60 | + .ui-box | ||
| 61 | + %h5.title Projects (#{@projects.count}) | ||
| 62 | + %ul.well-list | ||
| 63 | + - @projects.each do |project| | ||
| 64 | + %li | ||
| 65 | + = link_to admin_project_path(project), class: dom_class(project) do | ||
| 66 | + - if project.namespace | ||
| 67 | + = project.namespace.human_name | ||
| 68 | + \/ | ||
| 69 | + %strong.well-title | ||
| 70 | + = truncate(project.name, length: 45) | ||
| 71 | + %span.pull-right.light | ||
| 72 | + - if project.owner == @admin_user | ||
| 73 | + %i.icon-wrench | ||
| 74 | + - tm = project.team.get_tm(@admin_user.id) | ||
| 75 | + - if tm | ||
| 76 | + = tm.project_access_human | ||
| 77 | + = link_to edit_admin_project_member_path(project, tm.user), class: "btn btn-small" do | ||
| 78 | + %i.icon-edit | ||
| 79 | + = link_to admin_project_member_path(project, tm.user), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove" do | ||
| 80 | + %i.icon-remove | ||
| 81 | + %p.light | ||
| 82 | + %i.icon-wrench | ||
| 83 | + – user is a project owner |
app/views/users/_profile.html.haml
| @@ -4,20 +4,20 @@ | @@ -4,20 +4,20 @@ | ||
| 4 | %ul.well-list | 4 | %ul.well-list |
| 5 | %li | 5 | %li |
| 6 | %strong Email | 6 | %strong Email |
| 7 | - %span.pull-right= mail_to @user.email | ||
| 8 | - - unless @user.skype.blank? | 7 | + %span.pull-right= mail_to user.email |
| 8 | + - unless user.skype.blank? | ||
| 9 | %li | 9 | %li |
| 10 | %strong Skype | 10 | %strong Skype |
| 11 | - %span.pull-right= @user.skype | ||
| 12 | - - unless @user.linkedin.blank? | 11 | + %span.pull-right= user.skype |
| 12 | + - unless user.linkedin.blank? | ||
| 13 | %li | 13 | %li |
| 14 | %strong LinkedIn | 14 | %strong LinkedIn |
| 15 | - %span.pull-right= @user.linkedin | ||
| 16 | - - unless @user.twitter.blank? | 15 | + %span.pull-right= user.linkedin |
| 16 | + - unless user.twitter.blank? | ||
| 17 | %li | 17 | %li |
| 18 | %strong Twitter | 18 | %strong Twitter |
| 19 | - %span.pull-right= @user.twitter | ||
| 20 | - - unless @user.bio.blank? | 19 | + %span.pull-right= user.twitter |
| 20 | + - unless user.bio.blank? | ||
| 21 | %li | 21 | %li |
| 22 | %strong Bio | 22 | %strong Bio |
| 23 | - %span.pull-right= @user.bio | 23 | + %span.pull-right= user.bio |
app/views/users/_projects.html.haml
| @@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
| 10 | %strong.well-title | 10 | %strong.well-title |
| 11 | = truncate(project.name, length: 45) | 11 | = truncate(project.name, length: 45) |
| 12 | %span.pull-right.light | 12 | %span.pull-right.light |
| 13 | - - if project.owner == @user | 13 | + - if project.owner == user |
| 14 | %i.icon-wrench | 14 | %i.icon-wrench |
| 15 | - - tm = project.team.get_tm(@user.id) | 15 | + - tm = project.team.get_tm(user.id) |
| 16 | - if tm | 16 | - if tm |
| 17 | = tm.project_access_human | 17 | = tm.project_access_human |
| 18 | %p.light | 18 | %p.light |
app/views/users/show.html.haml