gear_menu: Delete unused Bootstrap tabs code.

Before 2017, Zulip's manage streams and settings UIs were tab in the
same pane position as our current message feed and recent topics.

That original implementation was implemented using Bootstrap tabs;
while it hasn't been in use for years, we had a bunch of stale code
related to it leftover in this module.
This commit is contained in:
Tim Abbott 2022-11-20 18:52:18 -08:00
parent f29e748e3b
commit 2a3f708e9a
12 changed files with 6 additions and 76 deletions

View File

@ -137,10 +137,6 @@ function test_helper({override, change_tab}) {
stub(ui_report, "error"); stub(ui_report, "error");
if (change_tab) { if (change_tab) {
override(ui_util, "change_tab_to", (hash) => {
events.push("change_tab_to " + hash);
});
override(narrow, "activate", (terms) => { override(narrow, "activate", (terms) => {
narrow_terms = terms; narrow_terms = terms;
events.push("narrow.activate"); events.push("narrow.activate");
@ -190,7 +186,6 @@ run_test("hash_interactions", ({override}) => {
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],
"change_tab_to #message_feed_container",
[narrow, "deactivate"], [narrow, "deactivate"],
[floating_recipient_bar, "update"], [floating_recipient_bar, "update"],
]); ]);
@ -200,7 +195,6 @@ run_test("hash_interactions", ({override}) => {
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],
"change_tab_to #message_feed_container",
[narrow, "deactivate"], [narrow, "deactivate"],
[floating_recipient_bar, "update"], [floating_recipient_bar, "update"],
]); ]);
@ -225,7 +219,6 @@ run_test("hash_interactions", ({override}) => {
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],
"change_tab_to #message_feed_container",
"narrow.activate", "narrow.activate",
[floating_recipient_bar, "update"], [floating_recipient_bar, "update"],
]); ]);
@ -239,7 +232,6 @@ run_test("hash_interactions", ({override}) => {
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],
"change_tab_to #message_feed_container",
"narrow.activate", "narrow.activate",
[floating_recipient_bar, "update"], [floating_recipient_bar, "update"],
]); ]);
@ -254,7 +246,6 @@ run_test("hash_interactions", ({override}) => {
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],
"change_tab_to #message_feed_container",
[ui_report, "error"], [ui_report, "error"],
]); ]);

View File

@ -35,7 +35,6 @@ const search = mock_esm("../../static/js/search");
const stream_list = mock_esm("../../static/js/stream_list"); const stream_list = mock_esm("../../static/js/stream_list");
const top_left_corner = mock_esm("../../static/js/top_left_corner"); const top_left_corner = mock_esm("../../static/js/top_left_corner");
const typing_events = mock_esm("../../static/js/typing_events"); const typing_events = mock_esm("../../static/js/typing_events");
const ui_util = mock_esm("../../static/js/ui_util");
const unread_ops = mock_esm("../../static/js/unread_ops"); const unread_ops = mock_esm("../../static/js/unread_ops");
mock_esm("../../static/js/recent_topics_util", { mock_esm("../../static/js/recent_topics_util", {
is_visible() {}, is_visible() {},
@ -90,7 +89,6 @@ function test_helper() {
stub(top_left_corner, "handle_narrow_activated"); stub(top_left_corner, "handle_narrow_activated");
stub(typing_events, "render_notifications_for_narrow"); stub(typing_events, "render_notifications_for_narrow");
stub(compose_actions, "update_narrow_to_recipient_visibility"); stub(compose_actions, "update_narrow_to_recipient_visibility");
stub(ui_util, "change_tab_to");
stub(unread_ops, "process_visible"); stub(unread_ops, "process_visible");
stub(compose_closed_ui, "update_buttons_for_stream"); stub(compose_closed_ui, "update_buttons_for_stream");
stub(compose_closed_ui, "update_buttons_for_private"); stub(compose_closed_ui, "update_buttons_for_private");
@ -192,7 +190,6 @@ run_test("basics", () => {
[message_scroll, "hide_indicators"], [message_scroll, "hide_indicators"],
[notifications, "clear_compose_notifications"], [notifications, "clear_compose_notifications"],
[notifications, "redraw_title"], [notifications, "redraw_title"],
[ui_util, "change_tab_to"],
[unread_ops, "process_visible"], [unread_ops, "process_visible"],
[hashchange, "save_narrow"], [hashchange, "save_narrow"],
[compose_closed_ui, "update_buttons_for_stream"], [compose_closed_ui, "update_buttons_for_stream"],

View File

@ -21,7 +21,6 @@ mock_esm("../../static/js/search_pill_widget", {
}, },
}); });
mock_esm("../../static/js/ui_util", { mock_esm("../../static/js/ui_util", {
change_tab_to: noop,
place_caret_at_end: noop, place_caret_at_end: noop,
}); });

View File

@ -9,14 +9,9 @@ const {page_params} = require("../zjsunit/zpage_params");
page_params.search_pills_enabled = false; page_params.search_pills_enabled = false;
const noop = () => {};
const narrow = mock_esm("../../static/js/narrow"); const narrow = mock_esm("../../static/js/narrow");
const narrow_state = mock_esm("../../static/js/narrow_state"); const narrow_state = mock_esm("../../static/js/narrow_state");
const search_suggestion = mock_esm("../../static/js/search_suggestion"); const search_suggestion = mock_esm("../../static/js/search_suggestion");
mock_esm("../../static/js/ui_util", {
change_tab_to: noop,
});
const Filter = {}; const Filter = {};

View File

@ -2,10 +2,7 @@ import $ from "jquery";
import render_gear_menu from "../templates/gear_menu.hbs"; import render_gear_menu from "../templates/gear_menu.hbs";
import * as hashchange from "./hashchange";
import {$t} from "./i18n"; import {$t} from "./i18n";
import * as message_viewport from "./message_viewport";
import * as navigate from "./navigate";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as settings_data from "./settings_data"; import * as settings_data from "./settings_data";
@ -80,15 +77,8 @@ in static/js/info_overlay.js. They are dispatched
using a click handler in static/js/click_handlers.js. using a click handler in static/js/click_handlers.js.
The click handler uses "[data-overlay-trigger]" as The click handler uses "[data-overlay-trigger]" as
the selector and then calls browser_history.go_to_location. the selector and then calls browser_history.go_to_location.
*/ */
// We want to remember how far we were scrolled on each 'tab'.
// To do so, we need to save away the old position of the
// scrollbar when we switch to a new tab (and restore it
// when we switch back.)
const scroll_positions = new Map();
export function update_org_settings_menu_item() { export function update_org_settings_menu_item() {
const $item = $(".admin-menu-item").expectOne(); const $item = $(".admin-menu-item").expectOne();
if (page_params.is_admin) { if (page_params.is_admin) {
@ -156,38 +146,6 @@ export function initialize() {
}); });
$("#navbar-buttons").html(rendered_gear_menu); $("#navbar-buttons").html(rendered_gear_menu);
update_org_settings_menu_item(); update_org_settings_menu_item();
$('#gear-menu a[data-toggle="tab"]').on("show", (e) => {
// Save the position of our old tab away, before we switch
const old_tab = $(e.relatedTarget).attr("href");
scroll_positions.set(old_tab, message_viewport.scrollTop());
});
$('#gear-menu a[data-toggle="tab"]').on("shown", (e) => {
const target_tab = $(e.target).attr("href");
// Hide all our error messages when switching tabs
$(".alert").removeClass("show");
// Set the URL bar title to show the sub-page you're currently on.
let browser_url = target_tab;
if (browser_url === "#message_feed_container") {
browser_url = "";
}
hashchange.changehash(browser_url);
// After we show the new tab, restore its old scroll position
// (we apparently have to do this after setting the hash,
// because otherwise that action may scroll us somewhere.)
if (target_tab === "#message_feed_container") {
if (scroll_positions.has(target_tab)) {
message_viewport.scrollTop(scroll_positions.get(target_tab));
} else {
navigate.scroll_to_selected();
}
}
});
// The admin and settings pages are generated client-side through
// templates.
} }
export function open() { export function open() {

View File

@ -26,7 +26,6 @@ import * as spectators from "./spectators";
import * as stream_settings_ui from "./stream_settings_ui"; import * as stream_settings_ui from "./stream_settings_ui";
import * as top_left_corner from "./top_left_corner"; import * as top_left_corner from "./top_left_corner";
import * as ui_report from "./ui_report"; import * as ui_report from "./ui_report";
import * as ui_util from "./ui_util";
import * as user_groups_settings_ui from "./user_groups_settings_ui"; import * as user_groups_settings_ui from "./user_groups_settings_ui";
import {user_settings} from "./user_settings"; import {user_settings} from "./user_settings";
@ -91,7 +90,6 @@ export function save_narrow(operators) {
function show_all_message_view() { function show_all_message_view() {
const coming_from_recent_topics = maybe_hide_recent_topics(); const coming_from_recent_topics = maybe_hide_recent_topics();
ui_util.change_tab_to("#message_feed_container");
narrow.deactivate(coming_from_recent_topics); narrow.deactivate(coming_from_recent_topics);
top_left_corner.handle_narrow_deactivated(); top_left_corner.handle_narrow_deactivated();
floating_recipient_bar.update(); floating_recipient_bar.update();
@ -138,7 +136,6 @@ function do_hashchange_normal(from_reload) {
switch (hash[0]) { switch (hash[0]) {
case "#narrow": { case "#narrow": {
maybe_hide_recent_topics(); maybe_hide_recent_topics();
ui_util.change_tab_to("#message_feed_container");
let operators; let operators;
try { try {
// TODO: Show possible valid URLs to the user. // TODO: Show possible valid URLs to the user.

View File

@ -39,7 +39,6 @@ import * as stream_list from "./stream_list";
import * as top_left_corner from "./top_left_corner"; import * as top_left_corner from "./top_left_corner";
import * as topic_generator from "./topic_generator"; import * as topic_generator from "./topic_generator";
import * as typing_events from "./typing_events"; import * as typing_events from "./typing_events";
import * as ui_util from "./ui_util";
import * as unread from "./unread"; import * as unread from "./unread";
import * as unread_ops from "./unread_ops"; import * as unread_ops from "./unread_ops";
import * as unread_ui from "./unread_ui"; import * as unread_ui from "./unread_ui";
@ -489,7 +488,6 @@ export function activate(raw_operators, opts) {
$("#zfilt").addClass("focused_table"); $("#zfilt").addClass("focused_table");
$("#zhome").removeClass("focused_table"); $("#zhome").removeClass("focused_table");
ui_util.change_tab_to("#message_feed_container");
message_list.set_narrowed(msg_list); message_list.set_narrowed(msg_list);
message_lists.set_current(message_list.narrowed); message_lists.set_current(message_list.narrowed);

View File

@ -24,7 +24,6 @@ export function narrow_or_search_for_term(search_string) {
// while using input tool // while using input tool
return $search_query_box.val(); return $search_query_box.val();
} }
ui_util.change_tab_to("#message_feed_container");
let operators; let operators;
if (page_params.search_pills_enabled) { if (page_params.search_pills_enabled) {

View File

@ -5,10 +5,6 @@ import * as keydown_util from "./keydown_util";
// Add functions to this that have no non-trivial // Add functions to this that have no non-trivial
// dependencies other than jQuery. // dependencies other than jQuery.
export function change_tab_to(tabname: string): void {
$(`#gear-menu a[href="${CSS.escape(tabname)}"]`).tab("show");
}
// https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser // https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
export function place_caret_at_end(el: HTMLElement): void { export function place_caret_at_end(el: HTMLElement): void {
el.focus(); el.focus();

View File

@ -546,6 +546,10 @@ p.n-margin {
.column-middle { .column-middle {
min-height: 100%; min-height: 100%;
.column-middle-inner {
overflow: auto;
}
} }
} }

View File

@ -4,10 +4,6 @@
<i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i> <i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i>
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown"> <ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
{{!-- It is quite ingrained in our frontend code that your Home
view is a Bootstrap nav tab, even though we don't show the tab
anymore --}}
<li class="invisible" style="display:none;" role="presentation"><a href="#message_feed_container" data-toggle="tab"></a></li>
<li class="org-info org-name">{{realm_name}}</li> <li class="org-info org-name">{{realm_name}}</li>
<li class="org-info org-url">{{realm_uri}}</li> <li class="org-info org-url">{{realm_uri}}</li>
{{#if is_self_hosted }} {{#if is_self_hosted }}

View File

@ -151,7 +151,7 @@
<div class="column-left" id="left-sidebar-container"> <div class="column-left" id="left-sidebar-container">
</div> </div>
<div class="column-middle"> <div class="column-middle">
<div class="column-middle-inner tab-content"> <div class="column-middle-inner">
<div id="recent_topics_view"> <div id="recent_topics_view">
<div class="recent_topics_container"> <div class="recent_topics_container">
<div id="recent_topics_table"></div> <div id="recent_topics_table"></div>
@ -166,7 +166,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane" id="message_feed_container"> <div id="message_feed_container">
<div class="fixed-app" id="floating_recipient_bar"> <div class="fixed-app" id="floating_recipient_bar">
<div class="app-main recipient_bar_content"> <div class="app-main recipient_bar_content">
<div class="column-middle column-overlay recipient-bar-main"> <div class="column-middle column-overlay recipient-bar-main">