Skip to content

Commit c4ef714

Browse files
authored
Improve invites list with click-to-copy inputs (mastodon#10259)
1 parent 1c6dca9 commit c4ef714

5 files changed

Lines changed: 46 additions & 25 deletions

File tree

app/javascript/styles/mastodon/tables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
}
8383
}
8484
}
85+
86+
&--invites tbody td {
87+
vertical-align: middle;
88+
}
8589
}
8690

8791
.table-wrapper {
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
%tr
2+
%td
3+
.input-copy
4+
.input-copy__wrapper
5+
%input{ type: :text, maxlength: '999', spellcheck: 'false', readonly: 'true', value: public_invite_url(invite_code: invite.code) }
6+
%button{ type: :button }= t('generic.copy')
7+
28
%td
39
.name-tag
410
= image_tag invite.user.account.avatar.url(:original), alt: '', width: 16, height: 16, class: 'avatar'
511
%span.username= invite.user.account.username
6-
%td
7-
= invite.uses
8-
= " / #{invite.max_uses}" unless invite.max_uses.nil?
9-
%td
10-
- if invite.expired?
12+
13+
- if invite.expired?
14+
%td{ colspan: 2 }
1115
= t('invites.expired')
12-
- else
16+
- else
17+
%td
18+
= fa_icon 'user fw'
19+
= invite.uses
20+
= " / #{invite.max_uses}" unless invite.max_uses.nil?
21+
%td
1322
- if invite.expires_at.nil?
1423
1524
- else
1625
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
1726
= l invite.expires_at
18-
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
1927
%td
2028
- if !invite.expired? && policy(invite).destroy?
2129
= table_link_to 'times', t('invites.delete'), admin_invite_path(invite), method: :delete

app/views/admin/invites/index.html.haml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
%hr.spacer/
2020

21-
.table-wrapper
22-
%table.table
21+
.table-wrapper.simple_form
22+
%table.table.table--invites
2323
%thead
2424
%tr
25+
%th
2526
%th
2627
%th= t('invites.table.uses')
2728
%th= t('invites.table.expires_at')
2829
%th
29-
%th
3030
%tbody
3131
= render @invites
3232

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
%tr
22
%td
3-
= invite.uses
4-
= " / #{invite.max_uses}" unless invite.max_uses.nil?
5-
%td
6-
- if invite.expired?
3+
.input-copy
4+
.input-copy__wrapper
5+
%input{ type: :text, maxlength: '999', spellcheck: 'false', readonly: 'true', value: public_invite_url(invite_code: invite.code) }
6+
%button{ type: :button }= t('generic.copy')
7+
8+
- if invite.expired?
9+
%td{ colspan: 2 }
710
= t('invites.expired')
8-
- else
11+
- else
12+
%td
13+
= fa_icon 'user fw'
14+
= invite.uses
15+
= " / #{invite.max_uses}" unless invite.max_uses.nil?
16+
%td
917
- if invite.expires_at.nil?
1018
1119
- else
1220
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
1321
= l invite.expires_at
14-
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
22+
1523
%td
1624
- if !invite.expired? && policy(invite).destroy?
1725
= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete

app/views/invites/index.html.haml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
%hr.spacer/
1010

11-
%table.table
12-
%thead
13-
%tr
14-
%th= t('invites.table.uses')
15-
%th= t('invites.table.expires_at')
16-
%th
17-
%th
18-
%tbody
19-
= render @invites
11+
.simple_form
12+
%table.table.table--invites
13+
%thead
14+
%tr
15+
%th
16+
%th= t('invites.table.uses')
17+
%th= t('invites.table.expires_at')
18+
%th
19+
%tbody
20+
= render @invites

0 commit comments

Comments
 (0)