DEV: Convert admin-incoming-email modal to component-based API (#22701)

- Convert `admin-incoming-email` modal to component-based API
- Testing that the modal was working in local development was extremely challenging due to the need for `rejected` and `bounced` emails. Something that is not easy to stub in a local dev environment. To make this process more smooth for future developers I have added a new rake task:

```
desc "Creates sample email logs"
task "email_logs:populate" => ["db:load_config"] do |_, args|
  DiscourseDev::EmailLog.populate!
end
```

That will generate fully functional email logs in development to be toyed with.

<img width="787" alt="Screenshot 2023-07-20 at 3 27 04 PM" src="https://github.com/discourse/discourse/assets/50783505/47b3fe34-cd7e-49a5-8fe6-768c0fbd1aa2">
This commit is contained in:
Isaac Janzen
2023-07-20 16:31:20 -05:00
committed by GitHub
parent 9ff56ef474
commit 37942cb8bb
9 changed files with 162 additions and 87 deletions

View File

@@ -1,28 +0,0 @@
import Controller from "@ember/controller";
import IncomingEmail from "admin/models/incoming-email";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import discourseComputed from "discourse-common/utils/decorators";
import { longDate } from "discourse/lib/formatter";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default class AdminIncomingEmailController extends Controller.extend(
ModalFunctionality
) {
@discourseComputed("model.date")
date(d) {
return longDate(d);
}
load(id) {
return IncomingEmail.find(id).then((result) => this.set("model", result));
}
loadFromBounced(id) {
return IncomingEmail.findByBounced(id)
.then((result) => this.set("model", result))
.catch((error) => {
this.send("closeModal");
popupAjaxError(error);
});
}
}