mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 16:53:49 +08:00
37942cb8bb
- 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">
27 lines
762 B
JavaScript
27 lines
762 B
JavaScript
import { action } from "@ember/object";
|
|
import AdminEmailLogs from "admin/routes/admin-email-logs";
|
|
import IncomingEmail from "admin/models/incoming-email";
|
|
import IncomingEmailModal from "../components/modal/incoming-email";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import { inject as service } from "@ember/service";
|
|
|
|
export default class AdminEmailBouncedRoute extends AdminEmailLogs {
|
|
@service modal;
|
|
status = "bounced";
|
|
|
|
@action
|
|
async showIncomingEmail(id) {
|
|
const model = await this.loadFromBounced(id);
|
|
this.modal.show(IncomingEmailModal, { model });
|
|
}
|
|
|
|
@action
|
|
async loadFromBounced(id) {
|
|
try {
|
|
return await IncomingEmail.findByBounced(id);
|
|
} catch (error) {
|
|
popupAjaxError(error);
|
|
}
|
|
}
|
|
}
|