Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

left_sidebar: Add Alerts View to the left sidebar. #28858

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Alerts: Add message_view_header and narrow_banner for alert views.
This commit adds the message_view_header to the alert views.

It also adds the narrow banner to display when no message with
matching alert words is found.
  • Loading branch information
roanster007 committed Mar 10, 2024
commit ccc9991bda064216f2594ef1a48a5c6f84833edf
12 changes: 10 additions & 2 deletions web/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@ export class Filter {
if (_.isEqual(term_types, ["is-starred"])) {
return true;
}
if (_.isEqual(term_types, ["is-alerted"])) {
return true;
}
if (_.isEqual(term_types, ["streams-public"])) {
return true;
}
Expand Down Expand Up @@ -876,6 +879,8 @@ export class Filter {
return "/#narrow/is/starred";
case "is-mentioned":
return "/#narrow/is/mentioned";
case "is-alerted":
return "/#narrow/is/alerted";
case "streams-public":
return "/#narrow/streams/public";
case "dm":
Expand Down Expand Up @@ -932,6 +937,9 @@ export class Filter {
case "is-resolved":
icon = "check";
break;
case "is-alerted":
zulip_icon = "preview";
break;
default:
icon = undefined;
break;
Expand Down Expand Up @@ -1013,11 +1021,11 @@ export class Filter {
return $t({defaultMessage: "All direct messages"});
case "is-resolved":
return $t({defaultMessage: "Topics marked as resolved"});
case "is-alerted":
return $t({defaultMessage: "Alerted messages"});
// 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"});
}
Expand Down
15 changes: 15 additions & 0 deletions web/src/narrow_banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ function pick_empty_narrow_banner(): NarrowBannerData {
},
),
};
case "alerted":
return {
title: $t({defaultMessage: "You have no messages with alert words."}),
html: $t_html(
{
defaultMessage: "Learn more about alerts <z-link>here</z-link>.",
},
{
"z-link": (content_html) =>
`<a target="_blank" rel="noopener noreferrer" href="/help/dm-mention-alert-notifications">${content_html.join(
"",
)}</a>`,
},
),
};
case "dm":
// You have no direct messages.
if (
Expand Down
6 changes: 3 additions & 3 deletions web/tests/filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1729,10 +1729,10 @@ test("navbar_helpers", () => {
},
{
terms: is_alerted,
is_common_narrow: false,
icon: undefined,
is_common_narrow: true,
zulip_icon: "preview",
title: "translated: Alerted messages",
redirect_url_with_search: "#",
redirect_url_with_search: "/#narrow/is/alerted",
},
{
terms: is_unread,
Expand Down
10 changes: 10 additions & 0 deletions web/tests/narrow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ run_test("show_empty_narrow_message", ({mock_template}) => {
),
);

set_filter([["is", "alerted"]]);
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have no messages with alert words.",
'translated HTML: Learn more about alerts <a target="_blank" rel="noopener noreferrer" href="/help/dm-mention-alert-notifications">here</a>.',
),
);

// organization has disabled sending direct messages
realm.realm_private_message_policy =
settings_config.private_message_policy_values.disabled.code;
Expand Down