Turn @usernames into Discourse user mentions/links

No notifications are sent for appearing in a journal, but profile
popovers etc. all work like mentions anywhere else in a topic.
This commit is contained in:
2026-09-27 13:50:17 +02:00
parent b82fc0fc80
commit 7872a1a0eb
10 changed files with 291 additions and 14 deletions
@@ -49,6 +49,23 @@ const accountsReport = {
{ commodity: "EUR", quantity: "-1000.0", display: "(1000.00 EUR)" },
],
},
{
account: "equity:members:@tony",
label: "@tony",
depth: 2,
root: false,
mention: { username: "tony", text: "@tony" },
amounts: [
{ commodity: "EUR", quantity: "-1000.0", display: "(1000.00 EUR)" },
],
},
{
account: "equity:members:@nobody",
label: "@nobody",
depth: 2,
root: false,
amounts: [{ commodity: "EUR", quantity: "0.0", display: "0.00 EUR" }],
},
],
total: [{ commodity: "EUR", quantity: "1000.0", display: "1000.00 EUR" }],
},
@@ -203,6 +220,17 @@ const transactionsReport = {
{ commodity: "EUR", quantity: "-400.0", display: "-400.00 EUR" },
],
},
{
account: "equity:members:@tony",
account_segments: [
{ text: "equity" },
{ text: "members" },
{ text: "@tony", username: "tony" },
],
amounts: [
{ commodity: "EUR", quantity: "-600.0", display: "-600.00 EUR" },
],
},
],
},
{
@@ -296,6 +324,15 @@ acceptance("Hledger plugin", function (needs) {
assert
.dom('.hledger-dashboard__account[title="assets:bank"]')
.hasText("Bank");
assert
.dom('a.mention[href="/u/tony"][data-user-card="tony"]')
.hasText("@tony", "links a mentioned account to its user");
assert
.dom('.hledger-dashboard__account[title="equity:members:@nobody"] a')
.doesNotExist("leaves an unknown mention as plain text");
assert
.dom('.hledger-dashboard__account[title="equity:members:@nobody"]')
.hasText("@nobody");
const rootAccount = document.querySelector(
".hledger-dashboard__account.--depth-0"
@@ -437,5 +474,11 @@ acceptance("Hledger plugin", function (needs) {
.dom(".hledger-dashboard__table")
.includesText("assets:bank:checking");
assert.dom(".hledger-dashboard__table").includesText("1000.00 EUR");
assert
.dom(".hledger-dashboard__table")
.includesText("equity:members:@tony", "keeps path separators");
assert
.dom('a.mention[href="/u/tony"][data-user-card="tony"]')
.hasText("@tony", "links a mentioned account in the journal");
});
});