mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 12:54:25 +08:00
Started off attempting to fix filters, but was frustrated working with the old patterns and template duplication so I've updated everything and tried to consolidate into a `email-logs-list.gjs` component. The primary issue was that the filters only worked once, and if you needed to change them or remove them... you couldn't and had to refresh the page. Before: https://github.com/user-attachments/assets/9cfa0328-41d4-4178-ab87-ba2ff495d932 After: https://github.com/user-attachments/assets/febcff8f-3dfa-4b86-9be1-f333e6502648
53 lines
1.4 KiB
JavaScript
Vendored
53 lines
1.4 KiB
JavaScript
Vendored
import { tracked } from "@glimmer/tracking";
|
|
import { action } from "@ember/object";
|
|
import discourseDebounce from "discourse/lib/debounce";
|
|
import { INPUT_DELAY } from "discourse/lib/environment";
|
|
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
|
import IncomingEmail from "admin/models/incoming-email";
|
|
|
|
export default class AdminEmailLogsRejectedController extends AdminEmailLogsController {
|
|
@tracked filterFrom = "";
|
|
@tracked filterTo = "";
|
|
@tracked filterSubject = "";
|
|
@tracked filterError = "";
|
|
|
|
filters = [
|
|
{ property: "filterFrom", name: "from" },
|
|
{ property: "filterTo", name: "to" },
|
|
{ property: "filterSubject", name: "subject" },
|
|
{ property: "filterError", name: "error" },
|
|
];
|
|
|
|
@action
|
|
updateFilter(filterType, event) {
|
|
const value = event.target.value;
|
|
|
|
switch (filterType) {
|
|
case "from":
|
|
this.filterFrom = value;
|
|
break;
|
|
case "to":
|
|
this.filterTo = value;
|
|
break;
|
|
case "subject":
|
|
this.filterSubject = value;
|
|
break;
|
|
case "error":
|
|
this.filterError = value;
|
|
break;
|
|
}
|
|
|
|
discourseDebounce(this, this.loadLogs, IncomingEmail, INPUT_DELAY);
|
|
}
|
|
|
|
@action
|
|
handleShowIncomingEmail(id, event) {
|
|
event?.preventDefault();
|
|
this.send("showIncomingEmail", id);
|
|
}
|
|
|
|
@action
|
|
loadMore() {
|
|
this.loadLogs(IncomingEmail, true);
|
|
}
|
|
}
|