discourse/app/assets/javascripts/admin/addon/templates/admin-email-logs/received.gjs
Alan Guo Xiang Tan 109212127a
FIX: Clicking on subject in admin email logs broken (#35030)
This was a regression introduced in
f0069a4fab where clicking on an email
log's subject link did not open a modal that displays the details of the
incoming email.

In this commit, the following changes were also made:

1. Make all `admin-email-logs/*` routes inherit from the same parent
route.
   Having two different parent routes doing the same thing was probably
   something that was missed in the refactor previously.
2025-10-01 10:04:27 +08:00

63 lines
1.8 KiB
Text
Vendored

import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import RouteTemplate from "ember-route-template";
import formatDate from "discourse/helpers/format-date";
import routeAction from "discourse/helpers/route-action";
import EmailLogsList from "admin/components/email-logs-list";
import IncomingEmail from "admin/models/incoming-email";
const RECEIVED_HEADERS = [
{ key: "admin.email.incoming_emails.from_address" },
{ key: "admin.email.incoming_emails.to_addresses" },
{ key: "admin.email.incoming_emails.subject" },
];
const RECEIVED_FILTERS = [
{
property: "filterFrom",
name: "from",
placeholder: "admin.email.incoming_emails.filters.from_placeholder",
},
{
property: "filterTo",
name: "to",
placeholder: "admin.email.incoming_emails.filters.to_placeholder",
},
{
property: "filterSubject",
name: "subject",
placeholder: "admin.email.incoming_emails.filters.subject_placeholder",
},
];
export default RouteTemplate(
<template>
<EmailLogsList
@status="received"
@logType="received"
@sourceModel={{IncomingEmail}}
@headers={{RECEIVED_HEADERS}}
@filters={{RECEIVED_FILTERS}}
@onShowEmail={{routeAction "showIncomingEmail"}}
>
<:default
as |emailLog ccThreshold sortWithAddressFilter handleShowIncomingEmail|
>
<tr data-test-email-log-row-id={{emailLog.id}}>
<td>{{formatDate emailLog.created_at}}</td>
<td>{{emailLog.from_address}}</td>
<td>{{emailLog.to_addresses}}</td>
<td>
<a
href
{{on "click" (fn handleShowIncomingEmail emailLog.id)}}
class="incoming-email-link"
>
{{emailLog.subject}}
</a>
</td>
</tr>
</:default>
</EmailLogsList>
</template>
);