Files
chatwoot/app/views/super_admin/users/show.html.erb
2025-12-19 12:14:23 -08:00

169 lines
7.8 KiB
ERB

<%#
# Show
This view is the template for the show page.
It renders the attributes of a resource,
as well as a link to its edit page.
## Local variables:
- `page`:
An instance of [Administrate::Page::Show][1].
Contains methods for accessing the resource to be displayed on the page,
as well as helpers for describing how each attribute of the resource
should be displayed.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
%>
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<section class="flex flex-col w-full h-full">
<header class="sticky top-0 z-10 bg-n-background border-b border-n-weak" role="banner">
<div class="flex items-center justify-between w-full h-16 mx-auto max-w-[60rem]">
<div class="flex items-center gap-3">
<div class="border border-n-weak p-2 rounded-full text-n-slate-11">
<svg width="24" height="24"><use xlink:href="#icon-users" /></svg>
</div>
<div class="flex flex-col justify-center">
<h1 class="text-base font-medium tracking-tight text-n-slate-12">
<%= content_for(:title) %>
</h1>
<p class="text-xs text-n-slate-11 m-0">Profile, accounts, and access control</p>
</div>
</div>
<div class="flex items-center gap-2">
<% if authorized_action?(page.resource, :edit) %>
<%= link_to(
t("administrate.actions.edit"),
[:edit, namespace, page.resource.becomes(User)],
class: "inline-flex items-center justify-center h-8 px-3 text-sm font-medium text-white bg-woot-500 rounded-lg hover:bg-woot-600 transition-colors"
) %>
<% end %>
</div>
</div>
</header>
<main class="flex-1 px-6 overflow-y-auto">
<div class="w-full mx-auto max-w-[60rem] py-6 space-y-6">
<%# User Information Card %>
<div class="rounded-xl bg-n-solid-2 shadow outline-1 outline outline-n-container overflow-hidden">
<div class="px-6 py-4 border-b border-n-weak">
<h2 class="text-base font-medium text-n-slate-12">User Information</h2>
</div>
<div class="divide-y divide-n-weak">
<% page.attributes.each do |title, attributes| %>
<% next if title.present? %>
<% attributes.each do |attribute| %>
<% next if ['account_users', 'custom_attributes'].include?(attribute.name.to_s) %>
<div class="grid grid-cols-[180px,1fr] items-center min-h-12 px-6">
<span class="text-sm text-n-slate-11">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</span>
<span class="text-sm text-n-slate-12 py-3">
<%= render_field attribute, page: page %>
</span>
</div>
<% end %>
<% end %>
</div>
</div>
<%# Account Users Card %>
<% page.attributes.each do |title, attributes| %>
<% next if title.present? %>
<% attributes.each do |attribute| %>
<% if attribute.name.to_s == 'account_users' && page.resource.account_users.any? %>
<div class="rounded-xl bg-n-solid-2 shadow outline-1 outline outline-n-container overflow-hidden">
<div class="px-6 py-4 border-b border-n-weak">
<h2 class="text-base font-medium text-n-slate-12">Account Users</h2>
</div>
<div class="overflow-x-auto">
<table class="w-full">
<thead class="border-b border-n-weak">
<tr>
<th class="text-left py-3 !pl-6 pr-4 text-sm text-n-slate-11">Account</th>
<th class="text-left py-3 px-4 text-sm text-n-slate-11">User</th>
<th class="text-left py-3 px-4 text-sm text-n-slate-11">Inviter</th>
<th class="text-left py-3 px-4 text-sm text-n-slate-11">Role</th>
<th class="text-left py-3 pl-4 !pr-6 text-sm text-n-slate-11"></th>
</tr>
</thead>
<tbody class="divide-y divide-n-weak">
<% page.resource.account_users.each do |account_user| %>
<tr class="hover:bg-n-alpha-1">
<td class="py-4 !pl-6 pr-4 text-sm text-n-slate-12">
<%= link_to "##{account_user.account_id} #{account_user.account.name}", super_admin_account_path(account_user.account), class: "text-n-slate-12 hover:underline" %>
</td>
<td class="py-4 px-4 text-sm text-n-slate-12">
<%= link_to "##{account_user.user_id} #{account_user.user.name}", super_admin_user_path(account_user.user), class: "text-n-slate-12 hover:underline" %>
</td>
<td class="py-4 px-4 text-sm text-n-slate-11">
<% if account_user.inviter.present? %>
<%= link_to account_user.inviter.name, super_admin_user_path(account_user.inviter), class: "text-n-slate-12 hover:underline" %>
<% else %>
<span class="text-n-slate-10">---</span>
<% end %>
</td>
<td class="py-4 px-4">
<span class="inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-n-alpha-2 text-n-slate-12 capitalize">
<%= account_user.role %>
</span>
</td>
<td class="py-4 pl-4 !pr-6 text-right">
<%= link_to "Destroy", super_admin_account_user_path(account_user), method: :delete, data: { confirm: "Are you sure?" }, class: "text-sm font-medium text-n-ruby-11 hover:underline" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% end %>
<% end %>
<% end %>
<%# Custom Attributes Card %>
<% if page.resource.try(:custom_attributes).present? %>
<div class="rounded-xl bg-n-solid-2 shadow outline-1 outline outline-n-container overflow-hidden">
<div class="px-6 py-4 border-b border-n-weak">
<h2 class="text-base font-medium text-n-slate-12">Custom Attributes</h2>
</div>
<div class="divide-y divide-n-weak">
<% page.resource.custom_attributes.each do |key, value| %>
<div class="grid grid-cols-[180px,1fr] items-start min-h-12 px-6">
<span class="text-sm text-n-slate-11 py-3">
<%= key.to_s.titleize %>
</span>
<span class="text-sm text-n-slate-12 py-3 break-all font-mono">
<%= value %>
</span>
</div>
<% end %>
</div>
</div>
<% end %>
<%# Actions Card %>
<div class="rounded-xl bg-n-solid-2 shadow outline-1 outline outline-n-container overflow-hidden">
<div class="px-6 py-4 border-b border-n-weak">
<h2 class="text-base font-medium text-n-slate-12">Actions</h2>
</div>
<div class="divide-y divide-n-weak">
<div class="px-6 py-4">
<h3 class="text-sm font-medium text-n-slate-12 mb-3">Add User to Account</h3>
<%= render 'super_admin/shared/account_user_form', page: page, namespace: namespace, resource_type: 'user' %>
</div>
<%= render partial: "impersonate", locals: {page: page} %>
</div>
</div>
</div>
</main>
</section>