Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Do not use bootstrap tabs in bots panel.
Sahil Batraa6370fda6867
diff --git a/web/src/settings_bots.js b/web/src/settings_bots.jsindex 829b1ff5ddc..bc895048376 100644--- a/web/src/settings_bots.js+++ b/web/src/settings_bots.js@@ -8,6 +8,7 @@ import render_bot_settings_tip from "../templates/settings/bot_settings_tip.hbs"import * as avatar from "./avatar";import * as bot_data from "./bot_data";import * as channel from "./channel";+import * as components from "./components";import {show_copied_confirmation} from "./copied_tooltip";import {csrf_token} from "./csrf";import * as dialog_widget from "./dialog_widget";@@ -25,21 +26,6 @@ const INCOMING_WEBHOOK_BOT_TYPE = 2;const OUTGOING_WEBHOOK_BOT_TYPE = "3";const EMBEDDED_BOT_TYPE = "4";-const focus_tab = {- active_bots_tab() {- $("#bots_lists_navbar .active").removeClass("active");- $("#bots_lists_navbar .active-bots-tab").addClass("active");- $("#active_bots_list").show();- $("#inactive_bots_list").hide();- },- inactive_bots_tab() {- $("#bots_lists_navbar .active").removeClass("active");- $("#bots_lists_navbar .inactive-bots-tab").addClass("active");- $("#active_bots_list").hide();- $("#inactive_bots_list").show();- },-};-function add_bot_row(info) {const $row = $(render_bot_avatar_row(info));if (info.is_active) {@@ -346,9 +332,21 @@ export function set_up() {);});- // This needs to come before render_bots() in case the user- // has no active bots- focus_tab.active_bots_tab();+ const toggler = components.toggle({+ child_wants_focus: true,+ values: [+ {label: $t({defaultMessage: "Active bots"}), key: "active-bots"},+ {label: $t({defaultMessage: "Inactive bots"}), key: "inactive-bots"},+ ],+ callback(_name, key) {+ $(".bots_list").hide();+ $(`[data-bot-settings-section="${CSS.escape(key)}"]`).show();+ },+ });++ $("#bot-settings .tab-container").prepend(toggler.get());+ toggler.goto("active-bots");+render_bots();$("#active_bots_list").on("click", "button.deactivate_bot", (e) => {@@ -453,18 +451,6 @@ export function set_up() {show_copied_confirmation(e.trigger);});- $("#bots_lists_navbar .active-bots-tab").on("click", (e) => {- e.preventDefault();- e.stopPropagation();- focus_tab.active_bots_tab();- });-- $("#bots_lists_navbar .inactive-bots-tab").on("click", (e) => {- e.preventDefault();- e.stopPropagation();- focus_tab.inactive_bots_tab();- });-$("#bot-settings .add-a-new-bot").on("click", (e) => {e.preventDefault();e.stopPropagation();diff --git a/web/styles/dark_theme.css b/web/styles/dark_theme.cssindex cba6d71c48d..55994f1245c 100644--- a/web/styles/dark_theme.css+++ b/web/styles/dark_theme.css@@ -1095,13 +1095,6 @@border-bottom: 1px solid hsl(0deg 0% 100%);}- #bots_lists_navbar .active a {- color: hsl(0deg 0% 87%);- background-color: var(--color-background);- border-color: hsl(0deg 0% 87%);- border-bottom-color: transparent;- }-.searching-for-more-topics img {filter: invert(100%);}diff --git a/web/styles/settings.css b/web/styles/settings.cssindex c07049f800d..d867d195db5 100644--- a/web/styles/settings.css+++ b/web/styles/settings.css@@ -835,8 +835,15 @@ input[type="checkbox"] {max-height: calc(95vh - 280px);}-#bot-settings .add-a-new-bot {- margin-bottom: 2px;+#bot-settings {+ .add-a-new-bot {+ margin-bottom: 2px;+ }++ hr {+ margin: 10px 0;+ border-color: hsl(0deg 0% 85%);+ }}.bots_list {@@ -972,10 +979,6 @@ input[type="checkbox"] {}}-#bots_lists_navbar .active a {- background-color: hsl(0deg 0% 98%);-}-#inactive_bots_list .bot_info .reactivate_bot {margin-top: 5px;}diff --git a/web/templates/settings/bot_settings.hbs b/web/templates/settings/bot_settings.hbsindex 85579c9fb16..3c6440b54ed 100644--- a/web/templates/settings/bot_settings.hbs+++ b/web/templates/settings/bot_settings.hbs@@ -21,15 +21,14 @@</div>{{/unless}}- <ul class="nav nav-tabs nav-justified" id="bots_lists_navbar">- <li class="active active-bots-tab"><a>{{t "Active bots" }}</a></li>- <li class="inactive-bots-tab"><a>{{t "Inactive bots" }}</a></li>- </ul>+ <hr/>- <ol class="bots_list" id="active_bots_list" data-empty="{{t 'You have no active bots.' }}">+ <div class="tab-container"></div>++ <ol id="active_bots_list" class="bots_list" data-bot-settings-section="active-bots" data-empty="{{t 'You have no active bots.' }}"></ol>- <ol class="bots_list" id="inactive_bots_list" data-empty="{{t 'You have no inactive bots.' }}">+ <ol id="inactive_bots_list" class="bots_list" data-bot-settings-section="inactive-bots" data-empty="{{t 'You have no inactive bots.' }}"></ol></div>diff --git a/web/tests/settings_bots.test.js b/web/tests/settings_bots.test.jsindex c723961360b..3251a68f704 100644--- a/web/tests/settings_bots.test.js+++ b/web/tests/settings_bots.test.js@@ -2,9 +2,8 @@const {strict: assert} = require("assert");-const {mock_cjs, zrequire} = require("./lib/namespace");+const {zrequire} = require("./lib/namespace");const {run_test} = require("./lib/test");-const $ = require("./lib/zjquery");const {page_params} = require("./lib/zpage_params");const bot_data_params = {@@ -28,16 +27,6 @@ const bot_data_params = {],};-class ClipboardJS {- constructor(sel) {- assert.equal(sel, "#copy_zuliprc");- }- on() {- // do nothing.- }-}-mock_cjs("clipboard", ClipboardJS);-const bot_data = zrequire("bot_data");const settings_bots = zrequire("settings_bots");@@ -102,45 +91,6 @@ test("generate_botserverrc_content", () => {assert.equal(content, expected);});-test("test tab clicks", () => {- settings_bots.set_up();-- function click_on_tab($tab_elem) {- $tab_elem.trigger("click");- }-- const tabs = {- $active: $("#bots_lists_navbar .active-bots-tab"),- $inactive: $("#bots_lists_navbar .inactive-bots-tab"),- };-- $("#bots_lists_navbar .active").removeClass = (cls) => {- assert.equal(cls, "active");- for (const $tab of Object.values(tabs)) {- $tab.removeClass("active");- }- };-- const forms = {- $active: $("#active_bots_list"),- $inactive: $("#inactive_bots_list"),- };-- click_on_tab(tabs.$active);- assert.ok(tabs.$active.hasClass("active"));- assert.ok(!tabs.$inactive.hasClass("active"));-- assert.ok(forms.$active.visible());- assert.ok(!forms.$inactive.visible());-- click_on_tab(tabs.$inactive);- assert.ok(!tabs.$active.hasClass("active"));- assert.ok(tabs.$inactive.hasClass("active"));-- assert.ok(!forms.$active.visible());- assert.ok(forms.$inactive.visible());-});-test("can_create_new_bots", () => {page_params.is_admin = true;assert.ok(settings_bots.can_create_new_bots());