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