refs #6588
[arvados.git] / apps / workbench / app / views / users / _show_admin.html.erb
1 <div class="row">
2   <div class="col-md-6">
3     <p>
4       As an admin, you can log in as this user. When you&rsquo;ve
5       finished, you will need to log out and log in again with your
6       own account.
7     </p>
8
9     <blockquote>
10       <%= button_to "Log in as #{@object.full_name}", sudo_user_url(id: @object.uuid), class: 'btn btn-primary' %>
11     </blockquote>
12
13     <p>
14       As an admin, you can setup a shell account for this user.
15       The login name is automatically generated from the user's e-mail address.
16     </p>
17
18     <blockquote>
19       <%= link_to "Setup shell account #{'for ' if @object.full_name.present?} #{@object.full_name}", setup_popup_user_url(id: @object.uuid),  {class: 'btn btn-primary', :remote => true, 'data-toggle' =>  "modal", 'data-target' => '#user-setup-modal-window'}  %>
20     </blockquote>
21
22     <p>
23       As an admin, you can deactivate and reset this user. This will
24       remove all repository/VM permissions for the user. If you
25       "setup" the user again, the user will have to sign the user
26       agreement again.
27     </p>
28
29     <blockquote>
30       <%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', data: {confirm: "Are you sure you want to deactivate #{@object.full_name}?"} %>
31     </blockquote>
32   </div>
33   <div class="col-md-6">
34     <div class="panel panel-default">
35       <div class="panel-heading">
36         Group memberships
37       </div>
38       <div class="panel-body">
39         <div class="alert alert-info">
40           <b>Tip:</b> in most cases, you want <i>both permissions at once</i> for a given group.
41           <br/>
42           The user&rarr;group permission is can_manage.
43           <br/>
44           The group&rarr;user permission is can_read.
45         </div>
46         <form>
47           <% permitted_group_perms = {}
48              Link.filter([
49              ['tail_uuid', '=', @object.uuid],
50              ['head_uuid', 'is_a', 'arvados#group'],
51              ['link_class', '=', 'permission'],
52              ]).each do |perm|
53                permitted_group_perms[perm.head_uuid] = perm.uuid
54              end %>
55           <% member_group_perms = {}
56              Link.permissions_for(@object).each do |perm|
57                member_group_perms[perm.tail_uuid] = perm.uuid
58              end %>
59           <% Group.order(['name']).where(group_class: 'role').each do |group| %>
60             <div>
61               <label class="checkbox-inline" data-toggle-permission="true" data-permission-tail="<%= @object.uuid %>" data-permission-name="can_manage">
62                 <%= check_box_tag(
63                     'group_uuids[]',
64                     group.uuid,
65                     permitted_group_perms[group.uuid],
66                     disabled: (group.owner_uuid == @object.uuid),
67                     data: {
68                       permission_head: group.uuid,
69                       permission_uuid: permitted_group_perms[group.uuid]}) %>
70                 <small>user&rarr;group</small>
71               </label>
72               <label class="checkbox-inline" data-toggle-permission="true" data-permission-head="<%= @object.uuid %>" data-permission-name="can_read">
73                 <%= check_box_tag(
74                     'group_uuids[]',
75                     group.uuid,
76                     member_group_perms[group.uuid],
77                     disabled: (group.owner_uuid == @object.uuid),
78                     data: {
79                       permission_tail: group.uuid,
80                       permission_uuid: member_group_perms[group.uuid]}) %>
81                 <small>group&rarr;user</small>
82               </label>
83               <label class="checkbox-inline">
84                 <%= group.name || '(unnamed)' %> <span class="deemphasize">(owned by <%= User.find?(group.owner_uuid).andand.full_name %>)</span>
85               </label>
86             </div>
87           <% end.empty? and begin %>
88             <div>
89               (No groups defined.)
90             </div>
91           <% end %>
92         </form>
93       </div>
94       <div class="panel-footer">
95         To manage these groups (roles), use:
96         <ul>
97           <li><code>arv group create \<br/>--group '{"group_class":"role","name":"New group"}'</code></li>
98           <li><code>arv group list \<br/>--filters '[["group_class","=","role"]]' \<br/>--select '["uuid","name"]'</code></li>
99           <li><code>arv edit <i>uuid</i></code></li>
100         </ul>
101       </div>
102     </div>
103   </div>
104 </div>
105
106 <div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>