Commit c5f56ee8a06e305265d78cdb847f3dc87bd7e6f2

Authored by Dmitriy Zaporozhets
1 parent 251945e2

Restyle admin:group:show. Remove .all calls fro users, projects here

app/assets/javascripts/admin.js.coffee
@@ -19,11 +19,13 @@ class Admin @@ -19,11 +19,13 @@ class Admin
19 19
20 modal = $('.change-owner-holder') 20 modal = $('.change-owner-holder')
21 21
22 - $('.change-owner-link').bind "click", -> 22 + $('.change-owner-link').bind "click", (e) ->
  23 + e.preventDefault()
23 $(this).hide() 24 $(this).hide()
24 modal.show() 25 modal.show()
25 26
26 - $('.change-owner-cancel-link').bind "click", -> 27 + $('.change-owner-cancel-link').bind "click", (e) ->
  28 + e.preventDefault()
27 modal.hide() 29 modal.hide()
28 $('.change-owner-link').show() 30 $('.change-owner-link').show()
29 31
app/assets/javascripts/users_select.js.coffee
@@ -14,23 +14,24 @@ $ -> @@ -14,23 +14,24 @@ $ ->
14 userFormatSelection = (user) -> 14 userFormatSelection = (user) ->
15 user.name 15 user.name
16 16
17 - $('.ajax-users-select').select2  
18 - placeholder: "Search for a user"  
19 - multiple: $('.ajax-users-select').hasClass('multiselect')  
20 - minimumInputLength: 0  
21 - query: (query) ->  
22 - Api.users query.term, (users) ->  
23 - data = { results: users }  
24 - query.callback(data) 17 + $('.ajax-users-select').each (i, select) ->
  18 + $(select).select2
  19 + placeholder: "Search for a user"
  20 + multiple: $(select).hasClass('multiselect')
  21 + minimumInputLength: 0
  22 + query: (query) ->
  23 + Api.users query.term, (users) ->
  24 + data = { results: users }
  25 + query.callback(data)
25 26
26 - initSelection: (element, callback) ->  
27 - id = $(element).val()  
28 - if id isnt ""  
29 - Api.user(id, callback) 27 + initSelection: (element, callback) ->
  28 + id = $(element).val()
  29 + if id isnt ""
  30 + Api.user(id, callback)
30 31
31 32
32 - formatResult: userFormatResult  
33 - formatSelection: userFormatSelection  
34 - dropdownCssClass: "ajax-users-dropdown"  
35 - escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results  
36 - m 33 + formatResult: userFormatResult
  34 + formatSelection: userFormatSelection
  35 + dropdownCssClass: "ajax-users-dropdown"
  36 + escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results
  37 + m
app/controllers/admin/groups_controller.rb
@@ -12,8 +12,6 @@ class Admin::GroupsController < Admin::ApplicationController @@ -12,8 +12,6 @@ class Admin::GroupsController < Admin::ApplicationController
12 @projects = @projects.not_in_group(@group) if @group.projects.present? 12 @projects = @projects.not_in_group(@group) if @group.projects.present?
13 @projects = @projects.all 13 @projects = @projects.all
14 @projects.reject!(&:empty_repo?) 14 @projects.reject!(&:empty_repo?)
15 -  
16 - @users = User.active  
17 end 15 end
18 16
19 def new 17 def new
@@ -68,7 +66,8 @@ class Admin::GroupsController < Admin::ApplicationController @@ -68,7 +66,8 @@ class Admin::GroupsController < Admin::ApplicationController
68 end 66 end
69 67
70 def project_teams_update 68 def project_teams_update
71 - @group.add_users_to_project_teams(params[:user_ids], params[:project_access]) 69 + @group.add_users_to_project_teams(params[:user_ids].split(','), params[:project_access])
  70 +
72 redirect_to [:admin, @group], notice: 'Users were successfully added.' 71 redirect_to [:admin, @group], notice: 'Users were successfully added.'
73 end 72 end
74 73
app/controllers/admin/projects_controller.rb
@@ -14,9 +14,6 @@ class Admin::ProjectsController < Admin::ApplicationController @@ -14,9 +14,6 @@ class Admin::ProjectsController < Admin::ApplicationController
14 14
15 def show 15 def show
16 @repository = @project.repository 16 @repository = @project.repository
17 - @users = User.active  
18 - @users = @users.not_in_project(@project) if @project.users.present?  
19 - @users = @users.all  
20 end 17 end
21 18
22 protected 19 protected
app/views/admin/groups/show.html.haml
1 %h3.page_title 1 %h3.page_title
2 Group: #{@group.name} 2 Group: #{@group.name}
3 3
4 -%br  
5 -%table.zebra-striped  
6 - %thead  
7 - %tr  
8 - %th Group  
9 - %th  
10 - %tr  
11 - %td  
12 - %b  
13 - Name:  
14 - %td  
15 - = @group.name  
16 -    
17 - = link_to edit_admin_group_path(@group), class: "btn btn-small pull-right" do  
18 - %i.icon-edit  
19 - Edit  
20 - %tr  
21 - %td  
22 - %b  
23 - Description:  
24 - %td  
25 - = @group.description  
26 - %tr  
27 - %td  
28 - %b  
29 - Path:  
30 - %td  
31 - %span.monospace= File.join(Gitlab.config.gitlab_shell.repos_path, @group.path)  
32 - %tr  
33 - %td  
34 - %b  
35 - Owner:  
36 - %td  
37 - = @group.owner_name  
38 - .pull-right  
39 - = link_to "#", class: "btn btn-small change-owner-link" do  
40 - %i.icon-edit  
41 - Change owner 4 + = link_to edit_admin_group_path(@group), class: "btn btn-small pull-right" do
  5 + %i.icon-edit
  6 + Edit
  7 +%hr
  8 +.row
  9 + .span6
  10 + .ui-box
  11 + %h5.title
  12 + Group info:
  13 + %ul.well-list
  14 + %li
  15 + %span.light Name:
  16 + %strong= @group.name
  17 + %li
  18 + %span.light Path:
  19 + %strong
  20 + = @group.path
42 21
43 - %tr.change-owner-holder.hide  
44 - %td.bgred  
45 - %b.cred  
46 - New Owner:  
47 - %td.bgred  
48 - = form_for [:admin, @group] do |f|  
49 - = f.select :owner_id, User.all.map { |user| [user.name, user.id] }, {}, {class: 'chosen'}  
50 - %div  
51 - = f.submit 'Change Owner', class: "btn btn-remove"  
52 - = link_to "Cancel", "#", class: "btn change-owner-cancel-link" 22 + %li
  23 + %span.light Description:
  24 + %strong
  25 + = @group.description
53 26
54 -- if @group.projects.any?  
55 - %fieldset  
56 - %legend Projects (#{@group.projects.count})  
57 - %table  
58 - %thead  
59 - %tr  
60 - %th Project name  
61 - %th Path  
62 - %th Users  
63 - %th.cred Danger Zone!  
64 - - @group.projects.each do |project|  
65 - %tr  
66 - %td  
67 - = link_to project.name_with_namespace, [:admin, project]  
68 - %td  
69 - %span.monospace= project.path_with_namespace + ".git"  
70 - %td= project.users.count  
71 - %td.bgred  
72 - = link_to 'Transfer project to global namespace', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Remove project from group and move to global namespace. Are you sure?', method: :delete, class: "btn btn-remove small" 27 + %li
  28 + %span.light Owned by:
  29 + %strong
  30 + - if @group.owner
  31 + = link_to @group.owner_name, admin_user_path(@group.owner)
  32 + - else
  33 + (deleted)
  34 + .pull-right
  35 + = link_to "#", class: "btn btn-small change-owner-link" do
  36 + %i.icon-edit
  37 + Change owner
  38 + %li.change-owner-holder.hide.bgred
  39 + .form-holder
  40 + %strong.cred New Owner:
  41 + = form_for [:admin, @group] do |f|
  42 + = users_select_tag(:"group[owner_id]")
  43 + .prepend-top-10
  44 + = f.submit 'Change Owner', class: "btn btn-remove"
  45 + = link_to "Cancel", "#", class: "btn change-owner-cancel-link"
73 46
74 - = form_tag project_teams_update_admin_group_path(@group), id: "new_team_member", class: "bulk_import", method: :put do  
75 - %table.zebra-striped  
76 - %thead  
77 - %tr  
78 - %th Users  
79 - %th Project Access: 47 + %li
  48 + %span.light Created at:
  49 + %strong
  50 + = @group.created_at.stamp("March 1, 1999")
80 51
81 - - @group.users.each do |user|  
82 - - next unless user  
83 - %tr{class: "user_#{user.id}"}  
84 - %td.name= link_to user.name, admin_user_path(user)  
85 - %td.projects_access  
86 - - user.authorized_projects.in_namespace(@group).each do |project|  
87 - - u_p = user.users_projects.in_project(project).first  
88 - - next unless u_p  
89 - %span  
90 - = project.name_with_namespace  
91 - = link_to "(#{ u_p.project_access_human })", edit_admin_project_member_path(project, user)  
92 - %tr  
93 - %td.input= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), multiple: true, data: {placeholder: 'Select users'}, class: 'chosen span5'  
94 - %td= select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3"}  
95 52
96 - %tr  
97 - %td= submit_tag 'Add user to projects in group', class: "btn btn-create"  
98 - %td 53 + .ui-box
  54 + %h5.title
  55 + Add user to Group projects:
  56 + .ui-box-body.form-holder
  57 + %p.light
99 Read more about project permissions 58 Read more about project permissions
100 %strong= link_to "here", help_permissions_path, class: "vlink" 59 %strong= link_to "here", help_permissions_path, class: "vlink"
101 60
102 -- else  
103 - %fieldset  
104 - %legend Group is empty 61 + = form_tag project_teams_update_admin_group_path(@group), id: "new_team_member", class: "bulk_import", method: :put do
  62 + %div
  63 + = users_select_tag(:user_ids, multiple: true)
  64 + %div.prepend-top-10
  65 + = select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span2"}
  66 + %hr
  67 + = submit_tag 'Add user to projects in group', class: "btn btn-create"
105 68
106 -= form_tag project_update_admin_group_path(@group), class: "bulk_import", method: :put do  
107 - %fieldset  
108 - %legend Move projects to group  
109 - .alert  
110 - You can move only projects with existing repos  
111 - %br  
112 - Group projects will be moved in group directory and will not be accessible by old path  
113 - .clearfix  
114 - = label_tag :project_ids do 69 + .span6
  70 + .ui-box
  71 + %h5.title
115 Projects 72 Projects
116 - .input  
117 - = select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'  
118 - .form-actions  
119 - = submit_tag 'Move projects', class: "btn btn-create"  
120 - 73 + %small
  74 + (#{@group.projects.count})
  75 + %ul.well-list
  76 + - @group.projects.each do |project|
  77 + %li
  78 + %strong
  79 + = link_to project.name_with_namespace, [:admin, project]
  80 + %span.pull-right.light
  81 + %span.monospace= project.path_with_namespace + ".git"