From a4963df6ad1b1f0eea882016a3fce273818ca42c Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Tue, 24 Jan 2023 16:33:40 -0500 Subject: [PATCH] settings: Remove "add a new bot button" from admin page. Instead, we show a message with links that either opens a modal for creating a new bot or navigates to the bot settings page. The "add a new bot" link only show up when the user has enough permission to create new bots, and the "manage your bots" link only shows up when the user has at least one bot if they don't have the permission to create one. Otherwise, the message does not show up at all. Signed-off-by: Zixuan James Li --- web/src/admin.js | 2 ++ web/templates/settings/bot_list_admin.hbs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/web/src/admin.js b/web/src/admin.js index f37401d187..08e7e10e02 100644 --- a/web/src/admin.js +++ b/web/src/admin.js @@ -3,6 +3,7 @@ import $ from "jquery"; import render_admin_tab from "../templates/settings/admin_tab.hbs"; import render_settings_organization_settings_tip from "../templates/settings/organization_settings_tip.hbs"; +import * as bot_data from "./bot_data"; import {$t, get_language_name, language_list} from "./i18n"; import {page_params} from "./page_params"; import {realm_user_settings_defaults} from "./realm_user_settings_defaults"; @@ -201,6 +202,7 @@ export function build_page() { realm_enable_read_receipts: page_params.realm_enable_read_receipts, allow_sorting_deactivated_users_list_by_email: settings_users.allow_sorting_deactivated_users_list_by_email(), + has_bots: bot_data.get_all_bots_for_current_user().length > 0, }; if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") { diff --git a/web/templates/settings/bot_list_admin.hbs b/web/templates/settings/bot_list_admin.hbs index 4dab5591e4..46a07ccd0e 100644 --- a/web/templates/settings/bot_list_admin.hbs +++ b/web/templates/settings/bot_list_admin.hbs @@ -3,7 +3,19 @@
- + {{t "You are viewing all the bots in this organization." }} + {{#if can_create_new_bots}} + {{#tr}} + You can add a new bot or manage your own bots. + {{#*inline "z-link-new-bot"}}{{> @partial-block}}{{/inline}} + {{#*inline "z-link-manage-bot"}}{{> @partial-block}}{{/inline}} + {{/tr}} + {{else if has_bots}} + {{#tr}} + You can manage your own bots. + {{#*inline "z-link"}}{{> @partial-block}}{{/inline}} + {{/tr}} + {{/if}}

{{t "Bots"}}