mirror of https://github.com/zulip/zulip.git
settings_bots: Move type_id_to_string to settings_data.js.
This commit is contained in:
parent
71e297efb4
commit
46ab3031a3
|
@ -4,6 +4,11 @@ const t1 = performance.now();
|
||||||
export const page_params: {
|
export const page_params: {
|
||||||
apps_page_url: string;
|
apps_page_url: string;
|
||||||
avatar_source: string;
|
avatar_source: string;
|
||||||
|
bot_types: {
|
||||||
|
type_id: number;
|
||||||
|
name: string;
|
||||||
|
allowed: boolean;
|
||||||
|
}[];
|
||||||
corporate_enabled: boolean;
|
corporate_enabled: boolean;
|
||||||
development_environment: boolean;
|
development_environment: boolean;
|
||||||
language_list: {
|
language_list: {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {$t, $t_html} from "./i18n";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
|
import * as settings_data from "./settings_data";
|
||||||
import * as settings_users from "./settings_users";
|
import * as settings_users from "./settings_users";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as ui_report from "./ui_report";
|
import * as ui_report from "./ui_report";
|
||||||
|
@ -60,10 +61,6 @@ function is_local_part(value) {
|
||||||
return /^[\w!#$%&'*+/=?^`{|}~-]+(\.[\w!#$%&'*+/=?^`{|}~-]+)*$/i.test(value);
|
return /^[\w!#$%&'*+/=?^`{|}~-]+(\.[\w!#$%&'*+/=?^`{|}~-]+)*$/i.test(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function type_id_to_string(type_id) {
|
|
||||||
return page_params.bot_types.find((bot_type) => bot_type.type_id === type_id).name;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function render_bots() {
|
export function render_bots() {
|
||||||
$("#active_bots_list").empty();
|
$("#active_bots_list").empty();
|
||||||
$("#inactive_bots_list").empty();
|
$("#inactive_bots_list").empty();
|
||||||
|
@ -76,7 +73,7 @@ export function render_bots() {
|
||||||
name: elem.full_name,
|
name: elem.full_name,
|
||||||
email: elem.email,
|
email: elem.email,
|
||||||
user_id: elem.user_id,
|
user_id: elem.user_id,
|
||||||
type: type_id_to_string(elem.bot_type),
|
type: settings_data.type_id_to_string(elem.bot_type),
|
||||||
avatar_url: elem.avatar_url,
|
avatar_url: elem.avatar_url,
|
||||||
api_key: elem.api_key,
|
api_key: elem.api_key,
|
||||||
is_active: elem.is_active,
|
is_active: elem.is_active,
|
||||||
|
|
|
@ -253,3 +253,13 @@ export function user_email_not_configured(): boolean {
|
||||||
// page_params.demo_organization_scheduled_deletion_date
|
// page_params.demo_organization_scheduled_deletion_date
|
||||||
return page_params.is_owner && page_params.delivery_email === "";
|
return page_params.is_owner && page_params.delivery_email === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function type_id_to_string(type_id: number): string | undefined {
|
||||||
|
const bot_type = page_params.bot_types.find((bot_type) => bot_type.type_id === type_id);
|
||||||
|
|
||||||
|
if (bot_type === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bot_type.name;
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import * as scroll_util from "./scroll_util";
|
||||||
import * as settings_account from "./settings_account";
|
import * as settings_account from "./settings_account";
|
||||||
import * as settings_bots from "./settings_bots";
|
import * as settings_bots from "./settings_bots";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
|
import * as settings_data from "./settings_data";
|
||||||
import * as settings_panel_menu from "./settings_panel_menu";
|
import * as settings_panel_menu from "./settings_panel_menu";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
import * as ui_report from "./ui_report";
|
import * as ui_report from "./ui_report";
|
||||||
|
@ -241,7 +242,7 @@ function bot_info(bot_user_id) {
|
||||||
info.user_role_text = people.get_user_type(bot_user_id);
|
info.user_role_text = people.get_user_type(bot_user_id);
|
||||||
|
|
||||||
// Convert bot type id to string for viewing to the users.
|
// Convert bot type id to string for viewing to the users.
|
||||||
info.bot_type = settings_bots.type_id_to_string(bot_user.bot_type);
|
info.bot_type = settings_data.type_id_to_string(bot_user.bot_type);
|
||||||
|
|
||||||
info.bot_owner_full_name = bot_owner_full_name(owner_id);
|
info.bot_owner_full_name = bot_owner_full_name(owner_id);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import * as people from "./people";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
import * as settings_account from "./settings_account";
|
import * as settings_account from "./settings_account";
|
||||||
import * as settings_bots from "./settings_bots";
|
import * as settings_bots from "./settings_bots";
|
||||||
|
import * as settings_data from "./settings_data";
|
||||||
import * as settings_profile_fields from "./settings_profile_fields";
|
import * as settings_profile_fields from "./settings_profile_fields";
|
||||||
import * as settings_users from "./settings_users";
|
import * as settings_users from "./settings_users";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
@ -335,7 +336,7 @@ export function show_user_profile(user, default_tab_key = "profile-tab") {
|
||||||
const bot_owner = people.get_by_user_id(bot_owner_id);
|
const bot_owner = people.get_by_user_id(bot_owner_id);
|
||||||
args.bot_owner = bot_owner;
|
args.bot_owner = bot_owner;
|
||||||
}
|
}
|
||||||
args.bot_type = settings_bots.type_id_to_string(user.bot_type);
|
args.bot_type = settings_data.type_id_to_string(user.bot_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#user-profile-modal-holder").html(render_user_profile_modal(args));
|
$("#user-profile-modal-holder").html(render_user_profile_modal(args));
|
||||||
|
|
|
@ -404,3 +404,22 @@ run_test("can_edit_user_group", () => {
|
||||||
page_params.realm_waiting_period_threshold = 0;
|
page_params.realm_waiting_period_threshold = 0;
|
||||||
assert.ok(settings_data.can_edit_user_group(students.id));
|
assert.ok(settings_data.can_edit_user_group(students.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
run_test("type_id_to_string", () => {
|
||||||
|
page_params.bot_types = [
|
||||||
|
{
|
||||||
|
type_id: 1,
|
||||||
|
name: "Generic bot",
|
||||||
|
allowed: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type_id: 2,
|
||||||
|
name: "Incoming webhook",
|
||||||
|
allowed: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
assert.equal(settings_data.type_id_to_string(1), "Generic bot");
|
||||||
|
assert.equal(settings_data.type_id_to_string(2), "Incoming webhook");
|
||||||
|
assert.equal(settings_data.type_id_to_string(5), undefined);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue