mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
narrow: Remove frontend support for "group-pm-with" operator.
Replaces "group-pm-with" in the web app with "dm-including".
This commit is contained in:
committed by
Tim Abbott
parent
311f436c68
commit
ae41e61520
@@ -161,20 +161,6 @@ function message_matches_search_term(message, operator, operand) {
|
|||||||
case "sender":
|
case "sender":
|
||||||
return people.id_matches_email_operand(message.sender_id, operand);
|
return people.id_matches_email_operand(message.sender_id, operand);
|
||||||
|
|
||||||
case "group-pm-with": {
|
|
||||||
const operand_ids = people.pm_with_operand_ids(operand);
|
|
||||||
if (!operand_ids) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const user_ids = people.group_pm_with_user_ids(message);
|
|
||||||
if (!user_ids) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return user_ids.includes(operand_ids[0]);
|
|
||||||
// We should also check if the current user is in the recipient list (user_ids) of the
|
|
||||||
// message, but it is implicit by the fact that the current user has access to the message.
|
|
||||||
}
|
|
||||||
|
|
||||||
case "dm": {
|
case "dm": {
|
||||||
// TODO: use user_ids, not emails here
|
// TODO: use user_ids, not emails here
|
||||||
if (message.type !== "private") {
|
if (message.type !== "private") {
|
||||||
@@ -229,6 +215,11 @@ export class Filter {
|
|||||||
return "dm";
|
return "dm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (operator === "group-pm-with") {
|
||||||
|
// "group-pm-with:" was replaced with "dm-including:"
|
||||||
|
return "dm-including";
|
||||||
|
}
|
||||||
|
|
||||||
if (operator === "from") {
|
if (operator === "from") {
|
||||||
return "sender";
|
return "sender";
|
||||||
}
|
}
|
||||||
@@ -269,7 +260,6 @@ export class Filter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "dm-including":
|
case "dm-including":
|
||||||
case "group-pm-with":
|
|
||||||
operand = operand.toString().toLowerCase();
|
operand = operand.toString().toLowerCase();
|
||||||
break;
|
break;
|
||||||
case "search":
|
case "search":
|
||||||
@@ -489,8 +479,6 @@ export class Filter {
|
|||||||
"dm",
|
"dm",
|
||||||
"dm-including",
|
"dm-including",
|
||||||
"not-dm-including",
|
"not-dm-including",
|
||||||
"group-pm-with",
|
|
||||||
"not-group-pm-with",
|
|
||||||
"is-dm",
|
"is-dm",
|
||||||
"not-is-dm",
|
"not-is-dm",
|
||||||
"is-resolved",
|
"is-resolved",
|
||||||
@@ -771,8 +759,7 @@ export class Filter {
|
|||||||
return (
|
return (
|
||||||
(this.has_operator("is") && this.operands("is")[0] === "dm") ||
|
(this.has_operator("is") && this.operands("is")[0] === "dm") ||
|
||||||
this.has_operator("dm") ||
|
this.has_operator("dm") ||
|
||||||
this.has_operator("dm-including") ||
|
this.has_operator("dm-including")
|
||||||
this.has_operator("group-pm-with")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,7 +950,6 @@ export class Filter {
|
|||||||
"topic",
|
"topic",
|
||||||
"dm",
|
"dm",
|
||||||
"dm-including",
|
"dm-including",
|
||||||
"group-pm-with",
|
|
||||||
"sender",
|
"sender",
|
||||||
"near",
|
"near",
|
||||||
"id",
|
"id",
|
||||||
@@ -1040,9 +1026,6 @@ export class Filter {
|
|||||||
// Note: We hack around using this in "describe" below.
|
// Note: We hack around using this in "describe" below.
|
||||||
case "is":
|
case "is":
|
||||||
return verb + "messages that are";
|
return verb + "messages that are";
|
||||||
|
|
||||||
case "group-pm-with":
|
|
||||||
return verb + "group direct messages including";
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,42 +425,6 @@ function pick_empty_narrow_banner() {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case "group-pm-with": {
|
|
||||||
const person_in_group_pm = people.get_by_email(first_operand);
|
|
||||||
if (!person_in_group_pm) {
|
|
||||||
return {
|
|
||||||
title: $t({defaultMessage: "This user does not exist!"}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
page_params.realm_private_message_policy ===
|
|
||||||
settings_config.private_message_policy_values.disabled.code
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
title: $t({
|
|
||||||
defaultMessage:
|
|
||||||
"You are not allowed to send group direct messages in this organization.",
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
title: $t(
|
|
||||||
{
|
|
||||||
defaultMessage: "You have no group direct messages with {person} yet.",
|
|
||||||
},
|
|
||||||
{person: person_in_group_pm.full_name},
|
|
||||||
),
|
|
||||||
html: $t_html(
|
|
||||||
{
|
|
||||||
defaultMessage: "Why not <z-link>start the conversation</z-link>?",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"z-link": (content_html) =>
|
|
||||||
`<a href="#" class="empty_feed_compose_private">${content_html}</a>`,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return default_banner;
|
return default_banner;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,27 +497,6 @@ export function pm_with_user_ids(message) {
|
|||||||
return sorted_other_user_ids(user_ids);
|
return sorted_other_user_ids(user_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function group_pm_with_user_ids(message) {
|
|
||||||
if (message.type !== "private") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.display_recipient.length === 0) {
|
|
||||||
blueslip.error("Empty recipient list in message");
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const user_ids = message.display_recipient.map((recip) => recip.id);
|
|
||||||
const is_user_present = user_ids.some((user_id) => is_my_user_id(user_id));
|
|
||||||
if (is_user_present) {
|
|
||||||
user_ids.sort();
|
|
||||||
if (user_ids.length > 2) {
|
|
||||||
return user_ids;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pm_perma_link(message) {
|
export function pm_perma_link(message) {
|
||||||
const user_ids = all_user_ids_in_pm(message);
|
const user_ids = all_user_ids_in_pm(message);
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ function get_stream_suggestions(last, operators) {
|
|||||||
{operator: "is", operand: "dm"},
|
{operator: "is", operand: "dm"},
|
||||||
{operator: "dm"},
|
{operator: "dm"},
|
||||||
{operator: "dm-including"},
|
{operator: "dm-including"},
|
||||||
{operator: "group-pm-with"},
|
|
||||||
];
|
];
|
||||||
if (!check_validity(last, operators, valid, invalid)) {
|
if (!check_validity(last, operators, valid, invalid)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -239,7 +238,7 @@ function make_people_getter(last) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Possible args for autocomplete_operator: dm, pm-with, sender, from, dm-including, group-pm-with
|
// Possible args for autocomplete_operator: dm, pm-with, sender, from, dm-including
|
||||||
function get_person_suggestions(people_getter, last, operators, autocomplete_operator) {
|
function get_person_suggestions(people_getter, last, operators, autocomplete_operator) {
|
||||||
if ((last.operator === "is" && last.operand === "dm") || last.operator === "pm-with") {
|
if ((last.operator === "is" && last.operand === "dm") || last.operator === "pm-with") {
|
||||||
// Interpret "is:dm" or "pm-with:" operator as equivalent to "dm:".
|
// Interpret "is:dm" or "pm-with:" operator as equivalent to "dm:".
|
||||||
@@ -258,7 +257,6 @@ function get_person_suggestions(people_getter, last, operators, autocomplete_ope
|
|||||||
|
|
||||||
switch (autocomplete_operator) {
|
switch (autocomplete_operator) {
|
||||||
case "dm-including":
|
case "dm-including":
|
||||||
case "group-pm-with":
|
|
||||||
invalid = [{operator: "stream"}, {operator: "is", operand: "resolved"}];
|
invalid = [{operator: "stream"}, {operator: "is", operand: "resolved"}];
|
||||||
break;
|
break;
|
||||||
case "dm":
|
case "dm":
|
||||||
@@ -362,7 +360,6 @@ function get_topic_suggestions(last, operators) {
|
|||||||
{operator: "dm"},
|
{operator: "dm"},
|
||||||
{operator: "is", operand: "dm"},
|
{operator: "is", operand: "dm"},
|
||||||
{operator: "dm-including"},
|
{operator: "dm-including"},
|
||||||
{operator: "group-pm-with"},
|
|
||||||
{operator: "topic"},
|
{operator: "topic"},
|
||||||
];
|
];
|
||||||
if (!check_validity(last, operators, ["stream", "topic", "search"], invalid)) {
|
if (!check_validity(last, operators, ["stream", "topic", "search"], invalid)) {
|
||||||
@@ -518,7 +515,6 @@ function get_streams_filter_suggestions(last, operators) {
|
|||||||
invalid: [
|
invalid: [
|
||||||
{operator: "is", operand: "dm"},
|
{operator: "is", operand: "dm"},
|
||||||
{operator: "stream"},
|
{operator: "stream"},
|
||||||
{operator: "group-pm-with"},
|
|
||||||
{operator: "dm-including"},
|
{operator: "dm-including"},
|
||||||
{operator: "dm"},
|
{operator: "dm"},
|
||||||
{operator: "in"},
|
{operator: "in"},
|
||||||
@@ -569,7 +565,6 @@ function get_is_filter_suggestions(last, operators) {
|
|||||||
{operator: "is", operand: "dm"},
|
{operator: "is", operand: "dm"},
|
||||||
{operator: "dm"},
|
{operator: "dm"},
|
||||||
{operator: "dm-including"},
|
{operator: "dm-including"},
|
||||||
{operator: "group-pm-with"},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -659,17 +654,7 @@ function get_operator_suggestions(last) {
|
|||||||
last_operand = last_operand.slice(1);
|
last_operand = last_operand.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let choices = [
|
let choices = ["stream", "topic", "dm", "dm-including", "sender", "near", "from", "pm-with"];
|
||||||
"stream",
|
|
||||||
"topic",
|
|
||||||
"dm",
|
|
||||||
"dm-including",
|
|
||||||
"sender",
|
|
||||||
"near",
|
|
||||||
"from",
|
|
||||||
"group-pm-with",
|
|
||||||
"pm-with",
|
|
||||||
];
|
|
||||||
choices = choices.filter((choice) => common.phrase_match(last_operand, choice));
|
choices = choices.filter((choice) => common.phrase_match(last_operand, choice));
|
||||||
|
|
||||||
return choices.map((choice) => {
|
return choices.map((choice) => {
|
||||||
@@ -746,14 +731,7 @@ export function get_search_result(base_query, query) {
|
|||||||
search_operators.push(last);
|
search_operators.push(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
const person_suggestion_ops = [
|
const person_suggestion_ops = ["sender", "dm", "dm-including", "from", "pm-with"];
|
||||||
"sender",
|
|
||||||
"dm",
|
|
||||||
"dm-including",
|
|
||||||
"from",
|
|
||||||
"group-pm-with",
|
|
||||||
"pm-with",
|
|
||||||
];
|
|
||||||
|
|
||||||
// Handle spaces in person name in new suggestions only. Checks if the last operator is 'search'
|
// Handle spaces in person name in new suggestions only. Checks if the last operator is 'search'
|
||||||
// and the second last operator in search_operators is one out of person_suggestion_ops.
|
// and the second last operator in search_operators is one out of person_suggestion_ops.
|
||||||
@@ -813,7 +791,6 @@ export function get_search_result(base_query, query) {
|
|||||||
get_people("dm"),
|
get_people("dm"),
|
||||||
get_people("dm-including"),
|
get_people("dm-including"),
|
||||||
get_people("from"),
|
get_people("from"),
|
||||||
get_people("group-pm-with"),
|
|
||||||
get_group_suggestions,
|
get_group_suggestions,
|
||||||
get_topic_suggestions,
|
get_topic_suggestions,
|
||||||
get_operator_suggestions,
|
get_operator_suggestions,
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ test("basics", () => {
|
|||||||
assert.ok(filter.has_operator("dm"));
|
assert.ok(filter.has_operator("dm"));
|
||||||
assert.ok(!filter.has_operator(" pm-with"));
|
assert.ok(!filter.has_operator(" pm-with"));
|
||||||
|
|
||||||
operators = [{operator: "group-pm-with", operand: "joe@example.com"}];
|
operators = [{operator: "dm-including", operand: "joe@example.com"}];
|
||||||
filter = new Filter(operators);
|
filter = new Filter(operators);
|
||||||
assert.ok(!filter.is_non_huddle_pm());
|
assert.ok(!filter.is_non_huddle_pm());
|
||||||
assert.ok(filter.contains_only_private_messages());
|
assert.ok(filter.contains_only_private_messages());
|
||||||
@@ -268,6 +268,12 @@ test("basics", () => {
|
|||||||
assert.ok(!filter.is_personal_filter());
|
assert.ok(!filter.is_personal_filter());
|
||||||
assert.ok(!filter.is_conversation_view());
|
assert.ok(!filter.is_conversation_view());
|
||||||
|
|
||||||
|
// "group-pm-with" was replaced with "dm-including"
|
||||||
|
operators = [{operator: "group-pm-with", operand: "joe@example.com"}];
|
||||||
|
filter = new Filter(operators);
|
||||||
|
assert.ok(filter.has_operator("dm-including"));
|
||||||
|
assert.ok(!filter.has_operator("group-pm-with"));
|
||||||
|
|
||||||
operators = [{operator: "is", operand: "resolved"}];
|
operators = [{operator: "is", operand: "resolved"}];
|
||||||
filter = new Filter(operators);
|
filter = new Filter(operators);
|
||||||
assert.ok(!filter.contains_only_private_messages());
|
assert.ok(!filter.contains_only_private_messages());
|
||||||
@@ -638,6 +644,11 @@ test("canonicalization", () => {
|
|||||||
assert.equal(term.operator, "dm");
|
assert.equal(term.operator, "dm");
|
||||||
assert.equal(term.operand, "me@example.com");
|
assert.equal(term.operand, "me@example.com");
|
||||||
|
|
||||||
|
// "group-pm-with" was replaced with "dm-including"
|
||||||
|
term = Filter.canonicalize_term({operator: "group-pm-with", operand: "joe@example.com"});
|
||||||
|
assert.equal(term.operator, "dm-including");
|
||||||
|
assert.equal(term.operand, "joe@example.com");
|
||||||
|
|
||||||
term = Filter.canonicalize_term({operator: "search", operand: "foo"});
|
term = Filter.canonicalize_term({operator: "search", operand: "foo"});
|
||||||
assert.equal(term.operator, "search");
|
assert.equal(term.operator, "search");
|
||||||
assert.equal(term.operand, "foo");
|
assert.equal(term.operand, "foo");
|
||||||
@@ -839,36 +850,6 @@ test("predicate_basics", () => {
|
|||||||
);
|
);
|
||||||
assert.ok(!predicate({type: "stream"}));
|
assert.ok(!predicate({type: "stream"}));
|
||||||
|
|
||||||
predicate = get_predicate([["group-pm-with", "nobody@example.com"]]);
|
|
||||||
assert.ok(
|
|
||||||
!predicate({
|
|
||||||
type: "private",
|
|
||||||
display_recipient: [{id: joe.user_id}],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
predicate = get_predicate([["group-pm-with", "Joe@example.com"]]);
|
|
||||||
assert.ok(
|
|
||||||
predicate({
|
|
||||||
type: "private",
|
|
||||||
display_recipient: [{id: joe.user_id}, {id: steve.user_id}, {id: me.user_id}],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
assert.ok(
|
|
||||||
!predicate({
|
|
||||||
// you must be a part of the group direct message
|
|
||||||
type: "private",
|
|
||||||
display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
assert.ok(
|
|
||||||
!predicate({
|
|
||||||
type: "private",
|
|
||||||
display_recipient: [{id: steve.user_id}, {id: me.user_id}],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
assert.ok(!predicate({type: "stream"}));
|
|
||||||
|
|
||||||
const img_msg = {
|
const img_msg = {
|
||||||
content:
|
content:
|
||||||
'<p><a href="/user_uploads/randompath/test.jpeg">test.jpeg</a></p><div class="message_inline_image"><a href="/user_uploads/randompath/test.jpeg" title="test.jpeg"><img src="/user_uploads/randompath/test.jpeg"></a></div>',
|
'<p><a href="/user_uploads/randompath/test.jpeg">test.jpeg</a></p><div class="message_inline_image"><a href="/user_uploads/randompath/test.jpeg" title="test.jpeg"><img src="/user_uploads/randompath/test.jpeg"></a></div>',
|
||||||
@@ -1815,9 +1796,6 @@ run_test("is_spectator_compatible", () => {
|
|||||||
assert.ok(
|
assert.ok(
|
||||||
!Filter.is_spectator_compatible([{operator: "dm-including", operand: "hamlet@zulip.com"}]),
|
!Filter.is_spectator_compatible([{operator: "dm-including", operand: "hamlet@zulip.com"}]),
|
||||||
);
|
);
|
||||||
assert.ok(
|
|
||||||
!Filter.is_spectator_compatible([{operator: "group-pm-with", operand: "hamlet@zulip.com"}]),
|
|
||||||
);
|
|
||||||
assert.ok(Filter.is_spectator_compatible([{operator: "stream", operand: "Denmark"}]));
|
assert.ok(Filter.is_spectator_compatible([{operator: "stream", operand: "Denmark"}]));
|
||||||
assert.ok(
|
assert.ok(
|
||||||
Filter.is_spectator_compatible([
|
Filter.is_spectator_compatible([
|
||||||
@@ -1838,4 +1816,8 @@ run_test("is_spectator_compatible", () => {
|
|||||||
assert.ok(
|
assert.ok(
|
||||||
!Filter.is_spectator_compatible([{operator: "pm-with", operand: "hamlet@zulip.com"}]),
|
!Filter.is_spectator_compatible([{operator: "pm-with", operand: "hamlet@zulip.com"}]),
|
||||||
);
|
);
|
||||||
|
// "group-pm-with:" was replaced with "dm-including:"
|
||||||
|
assert.ok(
|
||||||
|
!Filter.is_spectator_compatible([{operator: "group-pm-with", operand: "hamlet@zulip.com"}]),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -477,51 +477,6 @@ run_test("show_empty_narrow_message", ({mock_template}) => {
|
|||||||
empty_narrow_html("translated: You don't have any direct message conversations yet."),
|
empty_narrow_html("translated: You don't have any direct message conversations yet."),
|
||||||
);
|
);
|
||||||
|
|
||||||
// organization has disabled sending direct messages
|
|
||||||
page_params.realm_private_message_policy =
|
|
||||||
settings_config.private_message_policy_values.disabled.code;
|
|
||||||
|
|
||||||
// prioritize information about invalid user in narrow/search
|
|
||||||
set_filter([["group-pm-with", ["Yo"]]]);
|
|
||||||
narrow_banner.show_empty_narrow_message();
|
|
||||||
assert.equal(
|
|
||||||
$(".empty_feed_notice_main").html(),
|
|
||||||
empty_narrow_html("translated: This user does not exist!"),
|
|
||||||
);
|
|
||||||
|
|
||||||
set_filter([["group-pm-with", "alice@example.com"]]);
|
|
||||||
narrow_banner.show_empty_narrow_message();
|
|
||||||
assert.equal(
|
|
||||||
$(".empty_feed_notice_main").html(),
|
|
||||||
empty_narrow_html(
|
|
||||||
"translated: You are not allowed to send group direct messages in this organization.",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// group direct messages with bots are not possible when
|
|
||||||
// sending direct messages is disabled
|
|
||||||
set_filter([["group-pm-with", "bot@example.com"]]);
|
|
||||||
narrow_banner.show_empty_narrow_message();
|
|
||||||
assert.equal(
|
|
||||||
$(".empty_feed_notice_main").html(),
|
|
||||||
empty_narrow_html(
|
|
||||||
"translated: You are not allowed to send group direct messages in this organization.",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// sending direct messages enabled
|
|
||||||
page_params.realm_private_message_policy =
|
|
||||||
settings_config.private_message_policy_values.by_anyone.code;
|
|
||||||
set_filter([["group-pm-with", "alice@example.com"]]);
|
|
||||||
narrow_banner.show_empty_narrow_message();
|
|
||||||
assert.equal(
|
|
||||||
$(".empty_feed_notice_main").html(),
|
|
||||||
empty_narrow_html(
|
|
||||||
"translated: You have no group direct messages with Alice Smith yet.",
|
|
||||||
'translated HTML: Why not <a href="#" class="empty_feed_compose_private">start the conversation</a>?',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
set_filter([["sender", "ray@example.com"]]);
|
set_filter([["sender", "ray@example.com"]]);
|
||||||
narrow_banner.show_empty_narrow_message();
|
narrow_banner.show_empty_narrow_message();
|
||||||
assert.equal(
|
assert.equal(
|
||||||
|
|||||||
@@ -75,9 +75,8 @@ run_test("blueslip", () => {
|
|||||||
display_recipient: [],
|
display_recipient: [],
|
||||||
sender_id: me.user_id,
|
sender_id: me.user_id,
|
||||||
};
|
};
|
||||||
blueslip.expect("error", "Empty recipient list in message", 4);
|
blueslip.expect("error", "Empty recipient list in message", 3);
|
||||||
people.pm_with_user_ids(message);
|
people.pm_with_user_ids(message);
|
||||||
people.group_pm_with_user_ids(message);
|
|
||||||
people.all_user_ids_in_pm(message);
|
people.all_user_ids_in_pm(message);
|
||||||
assert.equal(people.pm_perma_link(message), undefined);
|
assert.equal(people.pm_perma_link(message), undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -151,11 +151,11 @@ test("initialize", ({mock_template}) => {
|
|||||||
const search_suggestions = {
|
const search_suggestions = {
|
||||||
lookup_table: new Map([
|
lookup_table: new Map([
|
||||||
[
|
[
|
||||||
"group-pm-with:zo",
|
"dm-including:zo",
|
||||||
{
|
{
|
||||||
description_html: "group direct messages including",
|
description_html: "group direct messages including",
|
||||||
is_person: true,
|
is_person: true,
|
||||||
search_string: "group-pm-with:user7@zulipdev.com",
|
search_string: "dm-including:user7@zulipdev.com",
|
||||||
user_pill_context: {
|
user_pill_context: {
|
||||||
display_value: "<strong>Zo</strong>e",
|
display_value: "<strong>Zo</strong>e",
|
||||||
has_image: true,
|
has_image: true,
|
||||||
@@ -203,7 +203,7 @@ test("initialize", ({mock_template}) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
strings: ["zo", "sender:zo", "dm:zo", "group-pm-with:zo"],
|
strings: ["zo", "sender:zo", "dm:zo", "dm-including:zo"],
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Test source */
|
/* Test source */
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ run_test("initialize", ({mock_template}) => {
|
|||||||
const search_suggestions = {
|
const search_suggestions = {
|
||||||
lookup_table: new Map([
|
lookup_table: new Map([
|
||||||
[
|
[
|
||||||
"group-pm-with:zo",
|
"dm-including:zo",
|
||||||
{
|
{
|
||||||
description_html: "group direct messages including",
|
description_html: "group direct messages including",
|
||||||
is_person: true,
|
is_person: true,
|
||||||
search_string: "group-pm-with:user7@zulipdev.com",
|
search_string: "dm-including:user7@zulipdev.com",
|
||||||
user_pill_context: {
|
user_pill_context: {
|
||||||
display_value: "<strong>Zo</strong>e",
|
display_value: "<strong>Zo</strong>e",
|
||||||
has_image: true,
|
has_image: true,
|
||||||
@@ -185,7 +185,7 @@ run_test("initialize", ({mock_template}) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
strings: ["zo", "sender:zo", "dm:zo", "group-pm-with:zo"],
|
strings: ["zo", "sender:zo", "dm:zo", "dm-including:zo"],
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Test source */
|
/* Test source */
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ test("dm_suggestions", ({override}) => {
|
|||||||
"sender:alice@zulip.com",
|
"sender:alice@zulip.com",
|
||||||
"dm:alice@zulip.com",
|
"dm:alice@zulip.com",
|
||||||
"dm-including:alice@zulip.com",
|
"dm-including:alice@zulip.com",
|
||||||
"group-pm-with:alice@zulip.com",
|
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
@@ -222,7 +221,6 @@ test("dm_suggestions", ({override}) => {
|
|||||||
"sender:alice@zulip.com",
|
"sender:alice@zulip.com",
|
||||||
"dm:alice@zulip.com",
|
"dm:alice@zulip.com",
|
||||||
"dm-including:alice@zulip.com",
|
"dm-including:alice@zulip.com",
|
||||||
"group-pm-with:alice@zulip.com",
|
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
@@ -519,7 +517,6 @@ test("check_is_suggestions", ({override}) => {
|
|||||||
"sender:alice@zulip.com",
|
"sender:alice@zulip.com",
|
||||||
"dm:alice@zulip.com",
|
"dm:alice@zulip.com",
|
||||||
"dm-including:alice@zulip.com",
|
"dm-including:alice@zulip.com",
|
||||||
"group-pm-with:alice@zulip.com",
|
|
||||||
"has:image",
|
"has:image",
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
@@ -710,13 +707,7 @@ test("topic_suggestions", ({override}) => {
|
|||||||
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
||||||
|
|
||||||
suggestions = get_suggestions("", "te");
|
suggestions = get_suggestions("", "te");
|
||||||
expected = [
|
expected = ["te", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
"te",
|
|
||||||
"sender:ted@zulip.com",
|
|
||||||
"dm:ted@zulip.com",
|
|
||||||
"dm-including:ted@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
stream_topic_history.add_message({
|
stream_topic_history.add_message({
|
||||||
@@ -737,7 +728,6 @@ test("topic_suggestions", ({override}) => {
|
|||||||
"sender:ted@zulip.com",
|
"sender:ted@zulip.com",
|
||||||
"dm:ted@zulip.com",
|
"dm:ted@zulip.com",
|
||||||
"dm-including:ted@zulip.com",
|
"dm-including:ted@zulip.com",
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
"stream:office topic:team",
|
"stream:office topic:team",
|
||||||
"stream:office topic:test",
|
"stream:office topic:test",
|
||||||
];
|
];
|
||||||
@@ -894,8 +884,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
"dm:ted@zulip.com",
|
"dm:ted@zulip.com",
|
||||||
"dm-including:bob@zulip.com",
|
"dm-including:bob@zulip.com",
|
||||||
"dm-including:ted@zulip.com",
|
"dm-including:ted@zulip.com",
|
||||||
"group-pm-with:bob@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
@@ -903,19 +891,16 @@ test("people_suggestions", ({override}) => {
|
|||||||
const is_person = (q) => suggestions.lookup_table.get(q).is_person;
|
const is_person = (q) => suggestions.lookup_table.get(q).is_person;
|
||||||
assert.equal(is_person("dm:ted@zulip.com"), true);
|
assert.equal(is_person("dm:ted@zulip.com"), true);
|
||||||
assert.equal(is_person("sender:ted@zulip.com"), true);
|
assert.equal(is_person("sender:ted@zulip.com"), true);
|
||||||
assert.equal(is_person("group-pm-with:ted@zulip.com"), true);
|
|
||||||
assert.equal(is_person("dm-including:ted@zulip.com"), true);
|
assert.equal(is_person("dm-including:ted@zulip.com"), true);
|
||||||
|
|
||||||
const has_image = (q) => suggestions.lookup_table.get(q).user_pill_context.has_image;
|
const has_image = (q) => suggestions.lookup_table.get(q).user_pill_context.has_image;
|
||||||
assert.equal(has_image("dm:bob@zulip.com"), true);
|
assert.equal(has_image("dm:bob@zulip.com"), true);
|
||||||
assert.equal(has_image("sender:bob@zulip.com"), true);
|
assert.equal(has_image("sender:bob@zulip.com"), true);
|
||||||
assert.equal(has_image("group-pm-with:bob@zulip.com"), true);
|
|
||||||
assert.equal(has_image("dm-including:bob@zulip.com"), true);
|
assert.equal(has_image("dm-including:bob@zulip.com"), true);
|
||||||
|
|
||||||
const describe = (q) => suggestions.lookup_table.get(q).description_html;
|
const describe = (q) => suggestions.lookup_table.get(q).description_html;
|
||||||
assert.equal(describe("dm:ted@zulip.com"), "Direct messages with");
|
assert.equal(describe("dm:ted@zulip.com"), "Direct messages with");
|
||||||
assert.equal(describe("sender:ted@zulip.com"), "Sent by");
|
assert.equal(describe("sender:ted@zulip.com"), "Sent by");
|
||||||
assert.equal(describe("group-pm-with:ted@zulip.com"), "Group direct messages including");
|
|
||||||
assert.equal(describe("dm-including:ted@zulip.com"), "Direct messages including");
|
assert.equal(describe("dm-including:ted@zulip.com"), "Direct messages including");
|
||||||
|
|
||||||
let expectedString = "<strong>Te</strong>d Smith";
|
let expectedString = "<strong>Te</strong>d Smith";
|
||||||
@@ -924,7 +909,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
suggestions.lookup_table.get(q).user_pill_context.display_value.string;
|
suggestions.lookup_table.get(q).user_pill_context.display_value.string;
|
||||||
assert.equal(get_full_name("sender:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("sender:ted@zulip.com"), expectedString);
|
||||||
assert.equal(get_full_name("dm:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("dm:ted@zulip.com"), expectedString);
|
||||||
assert.equal(get_full_name("group-pm-with:ted@zulip.com"), expectedString);
|
|
||||||
assert.equal(get_full_name("dm-including:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("dm-including:ted@zulip.com"), expectedString);
|
||||||
|
|
||||||
expectedString = `${example_avatar_url}?s=50`;
|
expectedString = `${example_avatar_url}?s=50`;
|
||||||
@@ -932,17 +916,10 @@ test("people_suggestions", ({override}) => {
|
|||||||
const get_avatar_url = (q) => suggestions.lookup_table.get(q).user_pill_context.img_src;
|
const get_avatar_url = (q) => suggestions.lookup_table.get(q).user_pill_context.img_src;
|
||||||
assert.equal(get_avatar_url("dm:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("dm:bob@zulip.com"), expectedString);
|
||||||
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
||||||
assert.equal(get_avatar_url("group-pm-with:bob@zulip.com"), expectedString);
|
|
||||||
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "Ted "); // note space
|
suggestions = get_suggestions("", "Ted "); // note space
|
||||||
expected = [
|
expected = ["Ted", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
"Ted",
|
|
||||||
"sender:ted@zulip.com",
|
|
||||||
"dm:ted@zulip.com",
|
|
||||||
"dm-including:ted@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
|
||||||
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
@@ -985,11 +962,6 @@ test("operator_suggestions", ({override}) => {
|
|||||||
expected = ["st", "streams:public", "is:starred", "stream:"];
|
expected = ["st", "streams:public", "is:starred", "stream:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "group-";
|
|
||||||
suggestions = get_suggestions("", query);
|
|
||||||
expected = ["group-", "group-pm-with:"];
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
|
||||||
|
|
||||||
query = "-s";
|
query = "-s";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions("", query);
|
||||||
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
||||||
@@ -1037,7 +1009,6 @@ test("multiple_operators_without_pills", () => {
|
|||||||
"is:dm sender:alice@zulip.com",
|
"is:dm sender:alice@zulip.com",
|
||||||
"is:dm dm:alice@zulip.com",
|
"is:dm dm:alice@zulip.com",
|
||||||
"is:dm dm-including:alice@zulip.com",
|
"is:dm dm-including:alice@zulip.com",
|
||||||
"is:dm group-pm-with:alice@zulip.com",
|
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ test("dm_suggestions", ({override}) => {
|
|||||||
"is:dm sender:alice@zulip.com",
|
"is:dm sender:alice@zulip.com",
|
||||||
"is:dm dm:alice@zulip.com",
|
"is:dm dm:alice@zulip.com",
|
||||||
"is:dm dm-including:alice@zulip.com",
|
"is:dm dm-including:alice@zulip.com",
|
||||||
"is:dm group-pm-with:alice@zulip.com",
|
|
||||||
"is:dm",
|
"is:dm",
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
@@ -219,7 +218,6 @@ test("dm_suggestions", ({override}) => {
|
|||||||
"is:starred has:link is:dm sender:alice@zulip.com",
|
"is:starred has:link is:dm sender:alice@zulip.com",
|
||||||
"is:starred has:link is:dm dm:alice@zulip.com",
|
"is:starred has:link is:dm dm:alice@zulip.com",
|
||||||
"is:starred has:link is:dm dm-including:alice@zulip.com",
|
"is:starred has:link is:dm dm-including:alice@zulip.com",
|
||||||
"is:starred has:link is:dm group-pm-with:alice@zulip.com",
|
|
||||||
"is:starred has:link is:dm",
|
"is:starred has:link is:dm",
|
||||||
"is:starred has:link",
|
"is:starred has:link",
|
||||||
"is:starred",
|
"is:starred",
|
||||||
@@ -527,7 +525,6 @@ test("check_is_suggestions", ({override}) => {
|
|||||||
"sender:alice@zulip.com",
|
"sender:alice@zulip.com",
|
||||||
"dm:alice@zulip.com",
|
"dm:alice@zulip.com",
|
||||||
"dm-including:alice@zulip.com",
|
"dm-including:alice@zulip.com",
|
||||||
"group-pm-with:alice@zulip.com",
|
|
||||||
"has:image",
|
"has:image",
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
@@ -677,13 +674,7 @@ test("topic_suggestions", ({override}) => {
|
|||||||
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
||||||
|
|
||||||
suggestions = get_suggestions("", "te");
|
suggestions = get_suggestions("", "te");
|
||||||
expected = [
|
expected = ["te", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
"te",
|
|
||||||
"sender:ted@zulip.com",
|
|
||||||
"dm:ted@zulip.com",
|
|
||||||
"dm-including:ted@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
stream_topic_history.add_message({
|
stream_topic_history.add_message({
|
||||||
@@ -704,7 +695,6 @@ test("topic_suggestions", ({override}) => {
|
|||||||
"sender:ted@zulip.com",
|
"sender:ted@zulip.com",
|
||||||
"dm:ted@zulip.com",
|
"dm:ted@zulip.com",
|
||||||
"dm-including:ted@zulip.com",
|
"dm-including:ted@zulip.com",
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
"stream:office topic:team",
|
"stream:office topic:team",
|
||||||
"stream:office topic:test",
|
"stream:office topic:test",
|
||||||
];
|
];
|
||||||
@@ -866,8 +856,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
"dm:ted@zulip.com",
|
"dm:ted@zulip.com",
|
||||||
"dm-including:bob@zulip.com",
|
"dm-including:bob@zulip.com",
|
||||||
"dm-including:ted@zulip.com",
|
"dm-including:ted@zulip.com",
|
||||||
"group-pm-with:bob@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
@@ -877,7 +865,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
}
|
}
|
||||||
assert.equal(is_person("dm:ted@zulip.com"), true);
|
assert.equal(is_person("dm:ted@zulip.com"), true);
|
||||||
assert.equal(is_person("sender:ted@zulip.com"), true);
|
assert.equal(is_person("sender:ted@zulip.com"), true);
|
||||||
assert.equal(is_person("group-pm-with:ted@zulip.com"), true);
|
|
||||||
assert.equal(is_person("dm-including:ted@zulip.com"), true);
|
assert.equal(is_person("dm-including:ted@zulip.com"), true);
|
||||||
|
|
||||||
function has_image(q) {
|
function has_image(q) {
|
||||||
@@ -885,7 +872,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
}
|
}
|
||||||
assert.equal(has_image("dm:bob@zulip.com"), true);
|
assert.equal(has_image("dm:bob@zulip.com"), true);
|
||||||
assert.equal(has_image("sender:bob@zulip.com"), true);
|
assert.equal(has_image("sender:bob@zulip.com"), true);
|
||||||
assert.equal(has_image("group-pm-with:bob@zulip.com"), true);
|
|
||||||
assert.equal(has_image("dm-including:bob@zulip.com"), true);
|
assert.equal(has_image("dm-including:bob@zulip.com"), true);
|
||||||
|
|
||||||
function describe(q) {
|
function describe(q) {
|
||||||
@@ -893,7 +879,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
}
|
}
|
||||||
assert.equal(describe("dm:ted@zulip.com"), "Direct messages with");
|
assert.equal(describe("dm:ted@zulip.com"), "Direct messages with");
|
||||||
assert.equal(describe("sender:ted@zulip.com"), "Sent by");
|
assert.equal(describe("sender:ted@zulip.com"), "Sent by");
|
||||||
assert.equal(describe("group-pm-with:ted@zulip.com"), "Group direct messages including");
|
|
||||||
assert.equal(describe("dm-including:ted@zulip.com"), "Direct messages including");
|
assert.equal(describe("dm-including:ted@zulip.com"), "Direct messages including");
|
||||||
|
|
||||||
let expectedString = "<strong>Te</strong>d Smith";
|
let expectedString = "<strong>Te</strong>d Smith";
|
||||||
@@ -903,7 +888,6 @@ test("people_suggestions", ({override}) => {
|
|||||||
}
|
}
|
||||||
assert.equal(get_full_name("sender:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("sender:ted@zulip.com"), expectedString);
|
||||||
assert.equal(get_full_name("dm:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("dm:ted@zulip.com"), expectedString);
|
||||||
assert.equal(get_full_name("group-pm-with:ted@zulip.com"), expectedString);
|
|
||||||
assert.equal(get_full_name("dm-including:ted@zulip.com"), expectedString);
|
assert.equal(get_full_name("dm-including:ted@zulip.com"), expectedString);
|
||||||
|
|
||||||
expectedString = example_avatar_url + "?s=50";
|
expectedString = example_avatar_url + "?s=50";
|
||||||
@@ -913,18 +897,11 @@ test("people_suggestions", ({override}) => {
|
|||||||
}
|
}
|
||||||
assert.equal(get_avatar_url("dm:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("dm:bob@zulip.com"), expectedString);
|
||||||
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
||||||
assert.equal(get_avatar_url("group-pm-with:bob@zulip.com"), expectedString);
|
|
||||||
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "Ted "); // note space
|
suggestions = get_suggestions("", "Ted "); // note space
|
||||||
|
|
||||||
expected = [
|
expected = ["Ted", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
"Ted",
|
|
||||||
"sender:ted@zulip.com",
|
|
||||||
"dm:ted@zulip.com",
|
|
||||||
"dm-including:ted@zulip.com",
|
|
||||||
"group-pm-with:ted@zulip.com",
|
|
||||||
];
|
|
||||||
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
@@ -958,11 +935,6 @@ test("operator_suggestions", ({override}) => {
|
|||||||
expected = ["st", "streams:public", "is:starred", "stream:"];
|
expected = ["st", "streams:public", "is:starred", "stream:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "group-";
|
|
||||||
suggestions = get_suggestions("", query);
|
|
||||||
expected = ["group-", "group-pm-with:"];
|
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
|
||||||
|
|
||||||
query = "-s";
|
query = "-s";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions("", query);
|
||||||
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
||||||
|
|||||||
Reference in New Issue
Block a user