Skip to content

Commit eefbe79

Browse files
committed
Use Ember.ListView for blocked emails list
1 parent 1e730cc commit eefbe79

8 files changed

Lines changed: 1252 additions & 23 deletions

File tree

app/assets/javascripts/admin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
//= require list_view.js
12
//= require_tree ./admin

app/assets/javascripts/admin/controllers/admin_logs_blocked_emails_controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
**/
99
Discourse.AdminLogsBlockedEmailsController = Ember.ArrayController.extend(Discourse.Presence, {
1010
loading: false,
11+
content: [],
1112

1213
show: function() {
1314
var self = this;

app/assets/javascripts/admin/templates/logs/blocked_emails.js.handlebars

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,20 @@
22
<div class='admin-loading'>{{i18n loading}}</div>
33
{{else}}
44
{{#if model.length}}
5-
<table class='table blocked-emails'>
6-
<thead>
7-
<th class="email">{{i18n admin.logs.blocked_emails.email}}</th>
8-
<th class="action">{{i18n admin.logs.action}}</th>
9-
<th class="match_count">{{i18n admin.logs.blocked_emails.match_count}}</th>
10-
<th class="last_match_at">{{i18n admin.logs.blocked_emails.last_match_at}}</th>
11-
<th class="created_at">{{i18n admin.logs.created_at}}</th>
12-
</thead>
135

14-
<tbody>
15-
{{#each model}}
16-
<tr>
17-
<td class="email">{{email}}</td>
18-
<td class="action">{{actionName}}</td>
19-
<td class="match_count">{{match_count}}</td>
20-
<td class="last_match_at">{{unboundAgeWithTooltip last_match_at}}</td>
21-
<td class="created_at">{{unboundAgeWithTooltip created_at}}</td>
22-
</tr>
23-
{{/each}}
24-
</tbody>
25-
</table>
6+
<div class='table blocked-emails'>
7+
<div class="heading-container">
8+
<div class="col heading email">{{i18n admin.logs.blocked_emails.email}}</div>
9+
<div class="col heading action">{{i18n admin.logs.action}}</div>
10+
<div class="col heading match_count">{{i18n admin.logs.blocked_emails.match_count}}</div>
11+
<div class="col heading last_match_at">{{i18n admin.logs.blocked_emails.last_match_at}}</div>
12+
<div class="col heading created_at">{{i18n admin.logs.created_at}}</div>
13+
<div class="clearfix"></div>
14+
</div>
15+
16+
{{view Discourse.BlockedEmailsListView contentBinding="controller"}}
17+
</div>
18+
2619
{{else}}
2720
{{i18n search.no_results}}
2821
{{/if}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="col email">{{email}}</div>
2+
<div class="col action">{{actionName}}</div>
3+
<div class="col match_count">{{match_count}}</div>
4+
<div class="col last_match_at">{{unboundAgeWithTooltip last_match_at}}</div>
5+
<div class="col created_at">{{unboundAgeWithTooltip created_at}}</div>
6+
<div class="clearfix"></div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Discourse.BlockedEmailsListView = Ember.ListView.extend({
2+
height: 500,
3+
rowHeight: 32,
4+
itemViewClass: Ember.ListItemView.extend({templateName: "admin/templates/logs/blocked_emails_list_item"})
5+
});

app/assets/stylesheets/admin/admin_base.scss

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,12 +694,35 @@ table {
694694
}
695695
}
696696

697-
/* Logs */
697+
// Logs
698698

699699
.blocked-emails {
700-
.match_count, .last_match_at, .created_at {
700+
width: 900px;
701+
margin-left: 5px;
702+
border-bottom: dotted 1px #ddd;
703+
.heading-container {
704+
width: 100%;
705+
background-color: #e4e4e4;
706+
}
707+
.heading {
708+
font-weight: bold;
709+
}
710+
.col {
711+
display: inline-block;
712+
padding-top: 6px;
713+
}
714+
.email {
715+
width: 400px;
716+
margin-left: 5px;
717+
}
718+
.action, .match_count, .last_match_at, .created_at {
719+
width: 110px;
701720
text-align: center;
702721
}
722+
.ember-list-item-view {
723+
width: 100%;
724+
border-top: solid 1px #ddd;
725+
}
703726
}
704727

705728
.staff-actions {
@@ -719,3 +742,14 @@ table {
719742
}
720743
}
721744
}
745+
746+
// Ember.ListView
747+
748+
.ember-list-view {
749+
overflow-y: auto;
750+
overflow-x: hidden;
751+
position: relative;
752+
}
753+
.ember-list-item-view {
754+
position: absolute;
755+
}

app/controllers/admin/blocked_emails_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Admin::BlockedEmailsController < Admin::AdminController
22

33
def index
4-
blocked_emails = BlockedEmail.limit(50).order('last_match_at desc').to_a
4+
blocked_emails = BlockedEmail.limit(200).order('last_match_at desc').to_a
55
render_serialized(blocked_emails, BlockedEmailSerializer)
66
end
77

0 commit comments

Comments
 (0)