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 <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2023-01-24 16:33:40 -05:00
committed by Tim Abbott
parent 5df5f6c125
commit a4963df6ad
2 changed files with 15 additions and 1 deletions

View File

@@ -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") {

View File

@@ -3,7 +3,19 @@
</div>
<div class="clear-float"></div>
<div>
<button class="button rounded sea-green add-a-new-bot {{#unless can_create_new_bots}}hide{{/unless}}">{{t "Add a new bot" }}</button>
{{t "You are viewing all the bots in this organization." }}
{{#if can_create_new_bots}}
{{#tr}}
You can <z-link-new-bot>add a new bot</z-link-new-bot> or <z-link-manage-bot>manage</z-link-manage-bot> your own bots.
{{#*inline "z-link-new-bot"}}<a class="add-a-new-bot">{{> @partial-block}}</a>{{/inline}}
{{#*inline "z-link-manage-bot"}}<a href="/#settings/your-bots">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{else if has_bots}}
{{#tr}}
You can <z-link>manage</z-link> your own bots.
{{#*inline "z-link"}}<a href="/#settings/your-bots">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{/if}}
</div>
<div class="settings_panel_list_header">
<h3>{{t "Bots"}}</h3>