discourse/app/assets/javascripts/admin/addon/controllers/admin-email-sent.js
Kelv b4a89ea610
FEAT: add cc addresses and post_id to sent email logs (#25014)
* add cc addresses and post_id to sent email logs
* sort cc addresses by email address filter value and collapse additional addreses into tooltip
* add slice helper for use in ember tempaltes
2024-01-03 09:27:25 +08:00

34 lines
998 B
JavaScript

import { observes } from "@ember-decorators/object";
import { INPUT_DELAY } from "discourse-common/config/environment";
import discourseDebounce from "discourse-common/lib/debounce";
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
export default class AdminEmailSentController extends AdminEmailLogsController {
ccAddressDisplayThreshold = 2;
sortWithAddressFilter = (addresses) => {
if (!Array.isArray(addresses) || addresses.length === 0) {
return [];
}
const targetEmail = this.filter.address;
if (!targetEmail) {
return addresses;
}
return addresses.sort((a, b) => {
if (a.includes(targetEmail) && !b.includes(targetEmail)) {
return -1;
}
if (!a.includes(targetEmail) && b.includes(targetEmail)) {
return 1;
}
return 0;
});
};
@observes("filter.{status,user,address,type,reply_key}")
filterEmailLogs() {
discourseDebounce(this, this.loadLogs, INPUT_DELAY);
}
}