mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
search: Update description string for channel terms.
This commit is contained in:
@@ -45,6 +45,11 @@ type Part =
|
||||
topic_display_name: string;
|
||||
is_empty_string_topic: boolean;
|
||||
}
|
||||
| {
|
||||
type: "channel";
|
||||
prefix_for_operator: string;
|
||||
operand: string;
|
||||
}
|
||||
| {
|
||||
type: "is_operator";
|
||||
verb: string;
|
||||
@@ -694,7 +699,7 @@ export class Filter {
|
||||
|
||||
switch (operator) {
|
||||
case "channel":
|
||||
return verb + "channel";
|
||||
return verb + "messages in #";
|
||||
case "channels":
|
||||
return verb + "channels";
|
||||
case "near":
|
||||
@@ -839,7 +844,7 @@ export class Filter {
|
||||
const stream = stream_data.get_sub_by_id_string(operand);
|
||||
if (stream) {
|
||||
return {
|
||||
type: "prefix_for_operator",
|
||||
type: "channel",
|
||||
prefix_for_operator,
|
||||
operand: stream.name,
|
||||
};
|
||||
|
@@ -157,10 +157,9 @@ function get_channel_suggestions(last: NarrowTerm, terms: NarrowTerm[]): Suggest
|
||||
channels = typeahead_helper.sorter(query, channels, (x) => x);
|
||||
|
||||
return channels.map((channel_name) => {
|
||||
const prefix = "channel";
|
||||
const prefix = "messages in #";
|
||||
const verb = last.negated ? "exclude " : "";
|
||||
const description_html =
|
||||
verb + prefix + " " + Handlebars.Utils.escapeExpression(channel_name);
|
||||
const description_html = verb + prefix + Handlebars.Utils.escapeExpression(channel_name);
|
||||
const channel = stream_data.get_sub_by_name(channel_name);
|
||||
assert(channel !== undefined);
|
||||
const term = {
|
||||
|
@@ -4,10 +4,14 @@
|
||||
{{~this.content~}}
|
||||
{{else if (eq this.type "channel_topic")}}
|
||||
{{~#if is_empty_string_topic~}}
|
||||
channel {{this.channel}} > <span class="empty-topic-display">{{this.topic_display_name}}</span>
|
||||
messages in #{{this.channel}} > <span class="empty-topic-display">{{this.topic_display_name}}</span>
|
||||
{{~else~}}
|
||||
channel {{this.channel}} > {{this.topic_display_name}}
|
||||
messages in #{{this.channel}} > {{this.topic_display_name}}
|
||||
{{~/if~}}
|
||||
{{else if (eq this.type "channel")}}
|
||||
{{~!-- squash whitespace --~}}
|
||||
{{this.prefix_for_operator}}{{this.operand}}
|
||||
{{~!-- squash whitespace --~}}
|
||||
{{else if (eq this.type "invalid_has")}}
|
||||
{{~!-- squash whitespace --~}}
|
||||
invalid {{this.operand}} operand for has operator
|
||||
|
@@ -1682,7 +1682,7 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "is", operand: "starred"},
|
||||
];
|
||||
string = "channel devel, starred messages";
|
||||
string = "messages in #devel, starred messages";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
const river_id = new_stream_id();
|
||||
@@ -1691,14 +1691,14 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "channel", operand: river_id.toString()},
|
||||
{operator: "is", operand: "unread"},
|
||||
];
|
||||
string = "channel river, unread messages";
|
||||
string = "messages in #river, unread messages";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "topic", operand: "JS"},
|
||||
];
|
||||
string = "channel devel > JS";
|
||||
string = "messages in #devel > JS";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
@@ -1754,7 +1754,7 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "topic", operand: "JS", negated: true},
|
||||
];
|
||||
string = "channel devel, exclude topic JS";
|
||||
string = "messages in #devel, exclude topic JS";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
@@ -1768,28 +1768,28 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "is", operand: "starred", negated: true},
|
||||
];
|
||||
string = "channel devel, exclude starred messages";
|
||||
string = "messages in #devel, exclude starred messages";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "has", operand: "image", negated: true},
|
||||
];
|
||||
string = "channel devel, exclude messages with images";
|
||||
string = "messages in #devel, exclude messages with images";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
{operator: "has", operand: "abc", negated: true},
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
];
|
||||
string = "invalid abc operand for has operator, channel devel";
|
||||
string = "invalid abc operand for has operator, messages in #devel";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
{operator: "has", operand: "image", negated: true},
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
];
|
||||
string = "exclude messages with images, channel devel";
|
||||
string = "exclude messages with images, messages in #devel";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [];
|
||||
@@ -1801,7 +1801,7 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "stream", operand: devel_id.toString()},
|
||||
{operator: "subject", operand: "JS", negated: true},
|
||||
];
|
||||
string = "channel devel, exclude topic JS";
|
||||
string = "messages in #devel, exclude topic JS";
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
// Empty string topic involved.
|
||||
@@ -1810,7 +1810,8 @@ test("describe", ({mock_template, override}) => {
|
||||
{operator: "channel", operand: devel_id.toString()},
|
||||
{operator: "topic", operand: ""},
|
||||
];
|
||||
string = 'channel devel > <span class="empty-topic-display">translated: general chat</span>';
|
||||
string =
|
||||
'messages in #devel > <span class="empty-topic-display">translated: general chat</span>';
|
||||
assert.equal(Filter.search_description_as_html(narrow, false), string);
|
||||
|
||||
narrow = [
|
||||
|
@@ -706,7 +706,7 @@ test("topic_suggestions", ({override, mock_template}) => {
|
||||
return suggestions.lookup_table.get(q).description_html;
|
||||
}
|
||||
assert.equal(describe("te"), "Search for te");
|
||||
assert.equal(describe(`channel:${office_id} topic:team`), "Channel office > team");
|
||||
assert.equal(describe(`channel:${office_id} topic:team`), "Messages in #office > team");
|
||||
|
||||
suggestions = get_suggestions(`topic:staplers channel:${office_id}`);
|
||||
expected = [`topic:staplers channel:${office_id}`, "topic:staplers"];
|
||||
@@ -826,7 +826,7 @@ test("xss_channel_name", () => {
|
||||
const suggestions = get_suggestions(query);
|
||||
assert.deepEqual(
|
||||
suggestions.lookup_table.get(`channel:${stream_id}`).description_html,
|
||||
"Channel <em> Italics </em>",
|
||||
"Messages in #<em> Italics </em>",
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user