filter by username in email digest preview
adds a user prompt on the email digest preview page to generate a preview for a particular user also fixes some broken styling on the page
This commit is contained in:
parent
2f58663dda
commit
fe5264f9e9
|
@ -5,7 +5,7 @@ export default Ember.Controller.extend({
|
|||
const model = this.get('model');
|
||||
|
||||
this.set('loading', true);
|
||||
Discourse.EmailPreview.findDigest(this.get('lastSeen')).then(email => {
|
||||
Discourse.EmailPreview.findDigest(this.get('lastSeen'), this.get('username')).then(email => {
|
||||
model.setProperties(email.getProperties('html_content', 'text_content'));
|
||||
this.set('loading', false);
|
||||
});
|
||||
|
|
|
@ -9,18 +9,20 @@
|
|||
Discourse.EmailPreview = Discourse.Model.extend({});
|
||||
|
||||
Discourse.EmailPreview.reopenClass({
|
||||
findDigest: function(lastSeenAt) {
|
||||
findDigest: function(lastSeenAt, username) {
|
||||
|
||||
if (Em.isEmpty(lastSeenAt)) {
|
||||
lastSeenAt = moment().subtract(7, 'days').format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
if (Em.isEmpty(username)) {
|
||||
username = Discourse.User.current().username;
|
||||
}
|
||||
|
||||
return Discourse.ajax("/admin/email/preview-digest.json", {
|
||||
data: {last_seen_at: lastSeenAt}
|
||||
data: { last_seen_at: lastSeenAt, username: username }
|
||||
}).then(function (result) {
|
||||
return Discourse.EmailPreview.create(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<div class='span7 controls'>
|
||||
<label for='last-seen'>{{i18n 'admin.email.last_seen_user'}}</label>
|
||||
{{input type="date" value=lastSeen id="last-seen"}}
|
||||
<label>{{i18n 'admin.email.user'}}:</label>
|
||||
{{user-selector single="true" usernames=username}}
|
||||
<button class='btn' {{action "refresh"}}>{{i18n 'admin.email.refresh'}}</button>
|
||||
<div class="toggle">
|
||||
<label>{{i18n 'admin.email.format'}}</label>
|
||||
|
|
|
@ -213,6 +213,14 @@ td.flaggers td {
|
|||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
}
|
||||
#last-seen {
|
||||
float: none;
|
||||
}
|
||||
.ac-wrap {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.paste-users {
|
||||
|
|
|
@ -34,7 +34,9 @@ class Admin::EmailController < Admin::AdminController
|
|||
|
||||
def preview_digest
|
||||
params.require(:last_seen_at)
|
||||
renderer = Email::Renderer.new(UserNotifications.digest(current_user, since: params[:last_seen_at]))
|
||||
params.require(:username)
|
||||
user = User.find_by_username(params[:username])
|
||||
renderer = Email::Renderer.new(UserNotifications.digest(user, since: params[:last_seen_at]))
|
||||
render json: MultiJson.dump(html_content: renderer.html, text_content: renderer.text)
|
||||
end
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ describe Admin::EmailController do
|
|||
end
|
||||
|
||||
it "previews the digest" do
|
||||
xhr :get, :preview_digest, last_seen_at: 1.week.ago
|
||||
xhr :get, :preview_digest, last_seen_at: 1.week.ago, username: user.username
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue