-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtable_component.html.erb
75 lines (75 loc) · 2.68 KB
/
table_component.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<% if @bot_accounts.count.positive? %>
<%= viral_data_table(@bot_accounts, id: "bots-table") do |table| %>
<% table.with_column(t("bots.index.table.header.username")) do |row| %>
<%= row.user.email %>
<% end %>
<% table.with_column(t("bots.index.table.header.active_tokens")) do |row| %>
<% if row.user.personal_access_tokens.active.count.positive? %>
<%= link_to row.user.personal_access_tokens.active.count,
bot_tokens_path(row),
data: {
turbo_stream: true,
},
class: "font-semibold text-slate-800 dark:text-slate-300 hover:underline" %>
<% else %>
0
<% end %>
<% end %>
<% table.with_column(t("bots.index.table.header.created")) do |row| %>
<%= helpers.local_time_ago(row.user.created_at) %>
<% end %>
<% table.with_column(t("bots.index.table.header.access_level")) do |row| %>
<% unless row.membership.nil? %>
<%= t(:"bots.index.table.access_level.level_#{row.membership.access_level}") %>
<% end %>
<% end %>
<% table.with_column(t("bots.index.table.header.expiration")) do |row| %>
<% if !row.membership&.expires_at.nil? %>
<%= helpers.local_time(row.membership.expires_at, :full_date) %>
<% else %>
<%= t("bots.index.table.never") %>
<% end %>
<% end %>
<% table.with_column(t("bots.index.table.header.actions"),
sticky_key: :right
) do |row| %>
<% if @abilities[:generate_token] %>
<%= link_to(
t("bots.index.table.actions.generate_new_token"),
new_token_path(row),
data: {
turbo_stream: true,
},
aria: {
label: t("bots.index.table.actions.generate_new_token_aria_label"),
},
class:
"font-medium text-blue-600 underline dark:text-blue-500 hover:no-underline cursor-pointer",
) %>
<% end %>
<% if @abilities[:destroy_bot] %>
<%= link_to(
t("bots.index.table.actions.destroy"),
destroy_path(row),
data: {
"turbo-stream": true,
},
aria: {
label: t("bots.index.table.actions.destroy_aria_label"),
},
class:
"font-medium text-blue-600 underline dark:text-blue-500 hover:no-underline cursor-pointer",
) %>
<% end %>
<% end %>
<% end %>
<%= render Viral::Pagy::FullComponent.new(@pagy, item: t("bots.index.pagy_item")) %>
<% else %>
<div class="empty_state_message">
<%= viral_empty(
title: t("bots.index.table.empty_state.title"),
description: t("bots.index.table.empty_state.description"),
icon_name: :bug_ant,
) %>
</div>
<% end %>