filter: Add titles for messages with alerts and unread messages.

In `filter.get_title`, add cases for the two missing "is" operators,
"alerted" and "unread".

Prep commit for rewriting `update_narrow_title` to use
`filter.get_title` as a helper for setting browser title text.
This commit is contained in:
Lauryn Menard 2022-10-12 19:03:33 +02:00 committed by Tim Abbott
parent abec99fe0c
commit c1b430d602
2 changed files with 24 additions and 0 deletions

View File

@ -1478,6 +1478,9 @@ test("navbar_helpers", () => {
const group_pm_including_missing_person = [
{operator: "pm-with", operand: "joe@example.com,STEVE@foo.com,sally@doesnotexist.com"},
];
// not common narrows, but used for browser title updates
const is_alerted = [{operator: "is", operand: "alerted"}];
const is_unread = [{operator: "is", operand: "unread"}];
const test_cases = [
{
@ -1598,6 +1601,20 @@ test("navbar_helpers", () => {
]),
redirect_url_with_search: "/#narrow/pm-with/undefined",
},
{
operator: is_alerted,
is_common_narrow: false,
icon: undefined,
title: "translated: Alerted messages",
redirect_url_with_search: "#",
},
{
operator: is_unread,
is_common_narrow: false,
icon: undefined,
title: "translated: Unread messages",
redirect_url_with_search: "#",
},
];
for (const test_case of test_cases) {

View File

@ -706,6 +706,13 @@ export class Filter {
}
case "is-resolved":
return $t({defaultMessage: "Topics marked as resolved"});
// These cases return false for is_common_narrow, and therefore are not
// formatted in the message view header. They are used in narrow.js to
// update the browser title.
case "is-alerted":
return $t({defaultMessage: "Alerted messages"});
case "is-unread":
return $t({defaultMessage: "Unread messages"});
}
}
/* istanbul ignore next */