closes #4799
[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 this user. Please input a VM and
15       repository for the user. If you had previously provided any of
16       these items, they are pre-filled for you and you can leave them
17       as is if you would like to reuse them.
18     </p>
19
20     <blockquote>
21       <%= link_to "Setup #{@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'}  %>
22     </blockquote>
23
24     <p>
25       As an admin, you can deactivate and reset this user. This will
26       remove all repository/VM permissions for the user. If you
27       "setup" the user again, the user will have to sign the user
28       agreement again.
29     </p>
30
31     <blockquote>
32       <%= 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}?"} %>
33     </blockquote>
34   </div>
35   <div class="col-md-6">
36     <div class="panel panel-default">
37       <div class="panel-heading">
38         Group memberships
39       </div>
40       <div class="panel-body">
41         <div class="alert alert-info">
42           <b>Tip:</b> in most cases, you want <i>both permissions at once</i> for a given group.
43           <br/>
44           The user&rarr;group permission is can_manage.
45           <br/>
46           The group&rarr;user permission is can_read.
47         </div>
48         <form>
49           <% permitted_group_perms = {}
50              Link.filter([
51              ['tail_uuid', '=', @object.uuid],
52              ['head_uuid', 'is_a', 'arvados#group'],
53              ['link_class', '=', 'permission'],
54              ]).each do |perm|
55                permitted_group_perms[perm.head_uuid] = perm.uuid
56              end %>
57           <% member_group_perms = {}
58              Link.permissions_for(@object).each do |perm|
59                member_group_perms[perm.tail_uuid] = perm.uuid
60              end %>
61           <% Group.order(['name']).where(group_class: 'role').each do |group| %>
62             <div>
63               <label class="checkbox-inline" data-toggle-permission="true" data-permission-tail="<%= @object.uuid %>" data-permission-name="can_manage">
64                 <%= check_box_tag(
65                     'group_uuids[]',
66                     group.uuid,
67                     permitted_group_perms[group.uuid],
68                     disabled: (group.owner_uuid == @object.uuid),
69                     data: {
70                       permission_head: group.uuid,
71                       permission_uuid: permitted_group_perms[group.uuid]}) %>
72                 <small>user&rarr;group</small>
73               </label>
74               <label class="checkbox-inline" data-toggle-permission="true" data-permission-head="<%= @object.uuid %>" data-permission-name="can_read">
75                 <%= check_box_tag(
76                     'group_uuids[]',
77                     group.uuid,
78                     member_group_perms[group.uuid],
79                     disabled: (group.owner_uuid == @object.uuid),
80                     data: {
81                       permission_tail: group.uuid,
82                       permission_uuid: member_group_perms[group.uuid]}) %>
83                 <small>group&rarr;user</small>
84               </label>
85               <label class="checkbox-inline">
86                 <%= group.name || '(unnamed)' %> <span class="deemphasize">(owned by <%= User.find?(group.owner_uuid).andand.full_name %>)</span>
87               </label>
88             </div>
89           <% end.empty? and begin %>
90             <div>
91               (No groups defined.)
92             </div>
93           <% end %>
94         </form>
95       </div>
96       <div class="panel-footer">
97         To manage these groups (roles), use:
98         <ul>
99           <li><code>arv group create \<br/>--group '{"group_class":"role","name":"New group"}'</code></li>
100           <li><code>arv group list \<br/>--filters '[["group_class","=","role"]]' \<br/>--select '["uuid","name"]'</code></li>
101           <li><code>arv edit <i>uuid</i></code></li>
102         </ul>
103       </div>
104     </div>
105   </div>
106 </div>
107
108 <div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>