recent-topics: Update hash for view to be "#recent".

Updates the hash used for the recent conversations view to be
"#recent" instead of "#recent_topics".

We will need to keep the logic for handling "#recent_topics"
permanently because users potentially have messages from
Welcome Bot with links to that hash.

Including "recent_topics" as a web_public_allowed_hash in
hash_util.js can be changed once self-hosted servers cannot
upgrade directly to Zulip 5.x from the current version.

Fixes #23132.
This commit is contained in:
Lauryn Menard 2022-10-24 12:18:09 +02:00 committed by Tim Abbott
parent 530406e2ef
commit e66f125ee6
8 changed files with 35 additions and 6 deletions

View File

@ -205,6 +205,19 @@ run_test("hash_interactions", ({override}) => {
[floating_recipient_bar, "update"],
]);
// Test old "#recent_topics" hash redirects to "#recent".
recent_topics_ui_shown = false;
window.location.hash = "#recent_topics";
helper.clear_events();
$window_stub.trigger("hashchange");
assert.equal(recent_topics_ui_shown, true);
helper.assert_events([
[overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"],
]);
assert.equal(window.location.hash, "#recent");
window.location.hash = "#narrow/stream/Denmark";
helper.clear_events();

View File

@ -272,8 +272,13 @@ export function is_spectator_compatible(hash) {
// This implementation should agree with the similar function in zerver/lib/narrow.py.
const web_public_allowed_hashes = [
"",
"narrow", // full #narrow hash handled in narrow.is_spectator_compatible
// full #narrow hash handled in narrow.is_spectator_compatible
"narrow",
// TODO/compatibility: #recent_topics was renamed to #recent
// in 2022. We should support the old URL fragment at least
// until one cannot directly upgrade from Zulip 5.x.
"recent_topics",
"recent",
"keyboard-shortcuts",
"message-formatting",
"search-operators",

View File

@ -181,6 +181,17 @@ function do_hashchange_normal(from_reload) {
show_default_view();
break;
case "#recent_topics":
// The URL for Recent Conversations was changed from
// #recent_topics to #recent in 2022. Because pre-change
// Welcome Bot messages included links to this URL, we
// need to support the "#recent_topics" hash as an alias
// for #recent permanently. We show the view and then
// replace the current URL hash in a way designed to hide
// this detail in the browser's forward/back session history.
recent_topics_ui.show();
window.location.replace("#recent");
break;
case "#recent":
recent_topics_ui.show();
break;
case "#all_messages":

View File

@ -819,7 +819,7 @@ export function process_hotkey(e, hotkey) {
narrow.narrow_to_next_pm_string();
return true;
case "open_recent_topics":
browser_history.go_to_location("#recent_topics");
browser_history.go_to_location("#recent");
return true;
case "all_messages":
browser_history.go_to_location("#all_messages");

View File

@ -2,7 +2,7 @@
<div class="{{#if is_trailing_bookend}}trailing_bookend {{/if}}bookend sub-unsub-message">
{{#if is_spectator}}
<span class="recent-topics-link">
<a href="#recent_topics">{{t "Browse recent conversations" }}</a>
<a href="#recent">{{t "Browse recent conversations" }}</a>
</span>
{{else}}
<span class="stream-status">

View File

@ -14,7 +14,7 @@
<span class="arrow all-messages-sidebar-menu-icon hidden-for-spectators"><i class="zulip-icon zulip-icon-ellipsis-v-solid" aria-hidden="true"></i></span>
</li>
<li class="top_left_recent_topics top_left_row" title="{{t 'Recent conversations' }} (t)">
<a href="#recent_topics">
<a href="#recent">
<span class="filter-icon">
<i class="fa fa-clock-o" aria-hidden="true"></i>
</span>

View File

@ -154,7 +154,7 @@ def select_welcome_bot_response(human_response_lower: str) -> str:
)
+ "\n\n",
_(
"Check out [Recent conversations](#recent_topics) to see what's happening! "
"Check out [Recent conversations](#recent) to see what's happening! "
'You can return to this conversation by clicking "Private messages" in the upper left.'
),
]

View File

@ -98,7 +98,7 @@ class TutorialTests(ZulipTestCase):
expected_response = (
"In Zulip, topics [tell you what a message is about](/help/streams-and-topics). "
"They are light-weight subjects, very similar to the subject line of an email.\n\n"
"Check out [Recent conversations](#recent_topics) to see what's happening! "
"Check out [Recent conversations](#recent) to see what's happening! "
'You can return to this conversation by clicking "Private messages" in the upper left.'
)
self.assertEqual(most_recent_message(user).content, expected_response)