Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose: Add typeahead for user group silent mentions.
akshatdaltonb636a9199bb5
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.jsindex d88ed781d8f..4f359eb5446 100644--- a/frontend_tests/node_tests/composebox_typeahead.js+++ b/frontend_tests/node_tests/composebox_typeahead.js@@ -421,6 +421,20 @@ test("content_typeahead_selected", (override) => {expected_value = "@**Othello, the Moor of Venice** ";assert.equal(actual_value, expected_value);+ fake_this.query = "@back";+ fake_this.token = "back";+ with_field(compose, "warn_if_mentioning_unsubscribed_user", unexpected_warn, () => {+ actual_value = ct.content_typeahead_selected.call(fake_this, backend);+ });+ expected_value = "@*Backend* ";+ assert.equal(actual_value, expected_value);++ fake_this.query = "@*back";+ fake_this.token = "back";+ actual_value = ct.content_typeahead_selected.call(fake_this, backend);+ expected_value = "@*Backend* ";+ assert.equal(actual_value, expected_value);+// silent mentionfake_this.completing = "silent_mention";function unexpected_warn() {@@ -454,18 +468,18 @@ test("content_typeahead_selected", (override) => {expected_value = "@_**King Hamlet** ";assert.equal(actual_value, expected_value);- fake_this.query = "@back";+ fake_this.query = "@_back";fake_this.token = "back";with_field(compose, "warn_if_mentioning_unsubscribed_user", unexpected_warn, () => {actual_value = ct.content_typeahead_selected.call(fake_this, backend);});- expected_value = "@*Backend* ";+ expected_value = "@_*Backend* ";assert.equal(actual_value, expected_value);- fake_this.query = "@*back";+ fake_this.query = "@_*back";fake_this.token = "back";actual_value = ct.content_typeahead_selected.call(fake_this, backend);- expected_value = "@*Backend* ";+ expected_value = "@_*Backend* ";assert.equal(actual_value, expected_value);fake_this.query = "/m";@@ -1431,7 +1445,7 @@ test("filter_and_sort_mentions (silent)", () => {const suggestions = ct.filter_and_sort_mentions(is_silent, "al");- assert.deepEqual(suggestions, [alice, hal]);+ assert.deepEqual(suggestions, [alice, hal, call_center]);});test("typeahead_results", () => {@@ -1561,7 +1575,6 @@ test("muted users excluded from results", () => {// mentions typeaheads, so we need only test once.let results;const opts = {- want_groups: false,want_broadcast: true,};@@ -1574,7 +1587,8 @@ test("muted users excluded from results", () => {results = ct.get_person_suggestions("corde", opts);assert.deepEqual(results, []);- // Make sure our muting logic doesn't break wildcard mentions.+ // Make sure our muting logic doesn't break wildcard mentions+ // or user group mentions.results = ct.get_person_suggestions("all", opts);- assert.deepEqual(results, [mention_all]);+ assert.deepEqual(results, [mention_all, call_center]);});diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.jsindex a8072ff42b2..41f6a1e6d68 100644--- a/static/js/composebox_typeahead.js+++ b/static/js/composebox_typeahead.js@@ -423,7 +423,6 @@ export const slash_commands = [export function filter_and_sort_mentions(is_silent, query, opts) {opts = {want_broadcast: !is_silent,- want_groups: !is_silent,filter_pills: false,...opts,};@@ -433,7 +432,6 @@ export function filter_and_sort_mentions(is_silent, query, opts) {export function get_pm_people(query) {const opts = {want_broadcast: false,- want_groups: true,filter_pills: true,};return get_person_suggestions(query, opts);@@ -460,13 +458,7 @@ export function get_person_suggestions(query, opts) {return persons.filter((item) => query_matches_person(query, item));}- let groups;-- if (opts.want_groups) {- groups = user_groups.get_realm_user_groups();- } else {- groups = [];- }+ const groups = user_groups.get_realm_user_groups();const filtered_groups = groups.filter((item) => query_matches_name_description(query, item));@@ -827,7 +819,9 @@ export function content_typeahead_selected(item, event) {beginning = beginning.slice(0, -1);}if (user_groups.is_user_group(item)) {- beginning += "@*" + item.name + "* ";+ let user_group_mention_text = is_silent ? "@_*" : "@*";+ user_group_mention_text += item.name + "* ";+ beginning += user_group_mention_text;// We could theoretically warn folks if they are// mentioning a user group that literally has zero// members where we are posting to, but we don't have@@ -1005,7 +999,7 @@ function get_header_html() {tip_text = $t({defaultMessage: "Press > for list of topics"});break;case "silent_mention":- tip_text = $t({defaultMessage: "User will not be notified"});+ tip_text = $t({defaultMessage: "Silent mentions do not trigger notifications."});break;case "syntax":if (page_params.realm_default_code_block_language !== null) {