Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

group-settings: Show bots in group setting typeahead.

Sahil Batrabd3771d332b0
diff --git a/web/src/pill_typeahead.ts b/web/src/pill_typeahead.ts
index 23ce41acc5f..cec74d94c71 100644
--- a/web/src/pill_typeahead.ts
+++ b/web/src/pill_typeahead.ts
@@ -189,7 +189,7 @@ export function set_up_group_setting_typeahead(
source = user_group_pill.typeahead_source(pills, opts.setting_name, opts.setting_type);
source = [
...source,
- ...user_pill.typeahead_source(pills, true, opts.setting_name, opts.setting_type),
+ ...user_pill.typeahead_source(pills, false, opts.setting_name, opts.setting_type),
];
return source;
diff --git a/web/src/typeahead_helper.ts b/web/src/typeahead_helper.ts
index 921e3158539..f130217088d 100644
--- a/web/src/typeahead_helper.ts
+++ b/web/src/typeahead_helper.ts
@@ -707,6 +707,14 @@ export function compare_group_setting_options(
assert(option_a.type === "user");
assert(option_b.type === "user");
+ if (option_a.user.is_bot && !option_b.user.is_bot) {
+ return 1;
+ }
+
+ if (!option_a.user.is_bot && option_b.user.is_bot) {
+ return -1;
+ }
+
if (target_group !== undefined) {
if (
!target_group.members.has(option_a.user.user_id) &&
diff --git a/web/tests/typeahead_helper.test.cjs b/web/tests/typeahead_helper.test.cjs
index 53bd8467acd..cfdfbe391c0 100644
--- a/web/tests/typeahead_helper.test.cjs
+++ b/web/tests/typeahead_helper.test.cjs
@@ -1280,6 +1280,10 @@ test("compare_group_setting_options", () => {
-1,
);
+ // A user always has a higher priority than a bot.
+ assert.equal(th.compare_group_setting_options(b_bot_item, b_user_1_item, bob_group), 1);
+ assert.equal(th.compare_group_setting_options(b_user_1_item, b_bot_item, bob_group), -1);
+
// A user who is a member of the group being changed has higher priority.
// If both the users are not members of the group being changed, alphabetical order
// is used to decide priority.