15803: Adjust workbench1 user panel to promote setup/unsetup buttons
[arvados.git] / apps / workbench / app / views / users / _show_admin.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <div class="row">
6   <div class="col-md-6">
7
8     <p>
9       This button sets up an inactive user.  After setup, they will be able to log in.
10       This dialog bog also allows you to optionally setup a shell account for this user.
11       The login name is automatically generated from the user's e-mail address.
12     </p>
13
14     <%= link_to "Setup 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'}  %>
15
16     <p style="margin-top: 3em">
17       As an admin, you can deactivate and reset this user. This will
18       remove all repository/VM permissions for the user. If you
19       "setup" the user again, the user will have to sign the user
20       agreement again.
21     </p>
22
23     <%= 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}?"} %>
24
25     <p style="margin-top: 3em">
26       As an admin, you can log in as this user. When you&rsquo;ve
27       finished, you will need to log out and log in again with your
28       own account.
29     </p>
30
31     <%= button_to "Log in as #{@object.full_name}", sudo_user_url(id: @object.uuid), class: 'btn btn-primary' %>
32   </div>
33   <div class="col-md-6">
34     <div class="panel panel-default">
35       <div class="panel-heading">
36         Group memberships
37
38         <div class="pull-right">
39           <%= link_to raw('<i class="fa fa-plus"></i> Add new group'), "#",
40                        {class: 'btn btn-xs btn-primary', 'data-toggle' => "modal",
41                         'data-target' => '#add-group-modal'}  %>
42         </div>
43       </div>
44       <div class="panel-body">
45         <div class="alert alert-info">
46           <b>Tip:</b> in most cases, you want <i>both permissions at once</i> for a given group.
47           <br/>
48           The user&rarr;group permission is can_manage.
49           <br/>
50           The group&rarr;user permission is can_read.
51         </div>
52         <form>
53           <% permitted_group_perms = {}
54              Link.filter([
55              ['tail_uuid', '=', @object.uuid],
56              ['head_uuid', 'is_a', 'arvados#group'],
57              ['link_class', '=', 'permission'],
58              ]).each do |perm|
59                permitted_group_perms[perm.head_uuid] = perm.uuid
60              end %>
61           <% member_group_perms = {}
62              Link.permissions_for(@object).each do |perm|
63                member_group_perms[perm.tail_uuid] = perm.uuid
64              end %>
65           <% Group.order(['name']).where(group_class: 'role').each do |group| %>
66             <div>
67               <label class="checkbox-inline" data-toggle-permission="true" data-permission-tail="<%= @object.uuid %>" data-permission-name="can_manage">
68                 <%= check_box_tag(
69                     'group_uuids[]',
70                     group.uuid,
71                     permitted_group_perms[group.uuid],
72                     disabled: (group.owner_uuid == @object.uuid),
73                     data: {
74                       permission_head: group.uuid,
75                       permission_uuid: permitted_group_perms[group.uuid] || 'x'}) %>
76                 <small>user&rarr;group</small>
77               </label>
78               <label class="checkbox-inline" data-toggle-permission="true" data-permission-head="<%= @object.uuid %>" data-permission-name="can_read">
79                 <%= check_box_tag(
80                     'group_uuids[]',
81                     group.uuid,
82                     member_group_perms[group.uuid],
83                     disabled: (group.owner_uuid == @object.uuid),
84                     data: {
85                       permission_tail: group.uuid,
86                       permission_uuid: member_group_perms[group.uuid] || 'x'}) %>
87                 <small>group&rarr;user</small>
88               </label>
89               <label class="checkbox-inline">
90                 <%= group.name || '(unnamed)' %> <span class="deemphasize">(owned by <%= User.find?(group.owner_uuid).andand.full_name %>)</span>
91               </label>
92             </div>
93           <% end.empty? and begin %>
94             <div>
95               (No groups defined.)
96             </div>
97           <% end %>
98         </form>
99       </div>
100       <div class="panel-footer">
101         These groups (roles) can also be managed from the command line. For example:
102         <ul>
103           <li><code>arv group create \<br/>--group '{"group_class":"role","name":"New group"}'</code></li>
104           <li><code>arv group list \<br/>--filters '[["group_class","=","role"]]' \<br/>--select '["uuid","name"]'</code></li>
105           <li><code>arv edit <i>uuid</i></code></li>
106         </ul>
107       </div>
108     </div>
109   </div>
110 </div>
111
112 <div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
113 <%= render partial: "add_group_modal" %>