Skip to content

Commit f2e4cfa

Browse files
committed
feat(panel): add a button to download a ticket from ticket page on the panel
1 parent ca3a778 commit f2e4cfa

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

  • crates/rustmail_panel/src/components

crates/rustmail_panel/src/components/ticket.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,29 @@ pub fn ticket_details(props: &TicketDetailsProps) -> Html {
635635
}
636636
}
637637
</div>
638+
<div>
639+
<a
640+
href={
641+
let mut content = format!("Ticket #{}\nUser: {}\nCategory: {}\n\n", ticket.id, ticket.user_name, ticket.category_name.as_deref().unwrap_or("Unknown"));
642+
for msg in &ticket.messages {
643+
let prefix = match msg.message_type() {
644+
MessageType::User => "[User]",
645+
MessageType::Staff => "[Staff]",
646+
MessageType::System => "[System]",
647+
MessageType::Internal => "[Internal]",
648+
};
649+
content.push_str(&format!("{} {} ({}):\n{}\n\n", prefix, msg.user_name, msg.created_at, msg.content));
650+
}
651+
let encoded_content = urlencoding::encode(&content);
652+
format!("data:text/plain;charset=utf-8,{}", encoded_content)
653+
}
654+
download={format!("ticket-{}.txt", ticket.id)}
655+
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded-lg inline-flex items-center justify-center gap-2 transition"
656+
>
657+
<i class="bi bi-download"></i>
658+
{i18n.t("panel.tickets.download")}
659+
</a>
660+
</div>
638661
</div>
639662

640663
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">

0 commit comments

Comments
 (0)