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.

filter: Use decorated channel icon in search description.

sandeepf3607d1b8cc7
diff --git a/web/e2e-tests/message-basics.test.ts b/web/e2e-tests/message-basics.test.ts
index 9da7e6b900a..0f18d62ee98 100644
--- a/web/e2e-tests/message-basics.test.ts
+++ b/web/e2e-tests/message-basics.test.ts
@@ -209,7 +209,7 @@ async function search_tests(page: Page): Promise<void> {
await search_and_check(
page,
"Verona",
- "#Verona",
+ "channel: Verona",
expect_verona_stream,
"#Verona - Zulip Dev - Zulip",
);
diff --git a/web/src/filter.ts b/web/src/filter.ts
index d1d81da7df5..d40c6295ee9 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -17,6 +17,7 @@ import * as resolved_topic from "./resolved_topic.ts";
import {current_user, narrow_canonical_term_schema, narrow_operator_schema} from "./state_data.ts";
import type {NarrowCanonicalTerm, NarrowTerm, NarrowTermSuggestion} from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
+import type {StreamSubscription} from "./sub_store.ts";
import * as sub_store from "./sub_store.ts";
import * as user_topics from "./user_topics.ts";
import * as util from "./util.ts";
@@ -41,14 +42,14 @@ type Part =
}
| {
type: "channel_topic";
- channel: string;
+ stream: StreamSubscription;
topic_display_name: string;
is_empty_string_topic: boolean;
}
| {
type: "channel";
prefix_for_operator: string;
- operand: string;
+ stream: StreamSubscription;
}
| {
type: "is_operator";
@@ -859,13 +860,13 @@ export class Filter {
term_1.operator === "topic" &&
!term_1.negated
) {
- // `channel` might be undefined if it's coming from a text query
- const channel = stream_data.get_sub_by_id_string(term_0.operand)?.name;
- if (channel) {
+ // `sub` might be undefined if it's coming from a text query.
+ const sub = stream_data.get_sub_by_id_string(term_0.operand);
+ if (sub) {
const topic = term_1.operand;
parts.push({
type: "channel_topic",
- channel,
+ stream: sub,
topic_display_name: util.get_final_topic_display_name(topic),
is_empty_string_topic: topic === "",
});
@@ -931,8 +932,8 @@ export class Filter {
if (stream) {
return {
type: "channel",
- prefix_for_operator: verb + "messages in #",
- operand: stream.name,
+ prefix_for_operator: verb + "messages in ",
+ stream,
};
}
// Assume the operand is a partially formed name and return
diff --git a/web/templates/search_description.hbs b/web/templates/search_description.hbs
index 6ba3fe7f471..00f7a5e033f 100644
--- a/web/templates/search_description.hbs
+++ b/web/templates/search_description.hbs
@@ -4,13 +4,13 @@
{{~this.content~}}
{{else if (eq this.type "channel_topic")}}
{{~#if is_empty_string_topic~}}
- messages in #{{this.channel}} > <span class="empty-topic-display">{{this.topic_display_name}}</span>
+ messages in {{> decorated_channel_name stream=this.stream inline_with_text=true show_colored_icon=false}} > <span class="empty-topic-display">{{this.topic_display_name}}</span>
{{~else~}}
- messages in #{{this.channel}} > {{this.topic_display_name}}
+ messages in {{> decorated_channel_name stream=this.stream inline_with_text=true show_colored_icon=false}} > {{this.topic_display_name}}
{{~/if~}}
{{else if (eq this.type "channel")}}
{{~!-- squash whitespace --~}}
- {{this.prefix_for_operator}}{{this.operand}}
+ {{this.prefix_for_operator}}{{> decorated_channel_name stream=this.stream inline_with_text=true show_colored_icon=false}}
{{~!-- squash whitespace --~}}
{{else if (eq this.type "invalid_has")}}
{{~!-- squash whitespace --~}}
diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjs
index 63f4a8672ea..758efebbb88 100644
--- a/web/tests/filter.test.cjs
+++ b/web/tests/filter.test.cjs
@@ -1907,6 +1907,8 @@ test("describe", ({mock_template, override}) => {
assert.equal(Filter.search_description_as_html(narrow, false), string);
page_params.is_spectator = false;
+ const devel_decorated = `<span class="decorated-channel-name-wrapper inline-decorated-channel-name"><span class="channel-privacy-type-icon"><i class="zulip-icon zulip-icon-hashtag" aria-hidden="true"></i></span><span class="decorated-channel-name">devel</span></span>`;
+ const river_decorated = `<span class="decorated-channel-name-wrapper inline-decorated-channel-name"><span class="channel-privacy-type-icon"><i class="zulip-icon zulip-icon-hashtag" aria-hidden="true"></i></span><span class="decorated-channel-name">river</span></span>`;
const devel_id = new_stream_id();
make_sub("devel", devel_id);
@@ -1914,7 +1916,7 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: devel_id.toString()},
{operator: "is", operand: "starred"},
];
- string = "messages in #devel, starred messages";
+ string = `messages in ${devel_decorated}, starred messages`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
const river_id = new_stream_id();
@@ -1923,14 +1925,14 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: river_id.toString()},
{operator: "is", operand: "unread"},
];
- string = "messages in #river, unread messages";
+ string = `messages in ${river_decorated}, unread messages`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
narrow = [
{operator: "channel", operand: devel_id.toString()},
{operator: "topic", operand: "JS"},
];
- string = "messages in #devel > JS";
+ string = `messages in ${devel_decorated} > JS`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
narrow = [
@@ -1989,7 +1991,7 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: devel_id.toString()},
{operator: "topic", operand: "JS", negated: true},
];
- string = "messages in #devel, exclude topic JS";
+ string = `messages in ${devel_decorated}, exclude topic JS`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
narrow = [
@@ -2003,28 +2005,28 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: devel_id.toString()},
{operator: "is", operand: "starred", negated: true},
];
- string = "messages in #devel, exclude starred messages";
+ string = `messages in ${devel_decorated}, 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 = "messages in #devel, exclude messages with images";
+ string = `messages in ${devel_decorated}, 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, messages in #devel";
+ string = `invalid abc operand for has operator, messages in ${devel_decorated}`;
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, messages in #devel";
+ string = `exclude messages with images, messages in ${devel_decorated}`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
narrow = [];
@@ -2035,7 +2037,7 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: devel_id.toString()},
{operator: "subject", operand: "JS", negated: true},
];
- string = "messages in #devel, exclude topic JS";
+ string = `messages in ${devel_decorated}, exclude topic JS`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
// Empty string topic involved.
@@ -2044,8 +2046,7 @@ test("describe", ({mock_template, override}) => {
{operator: "channel", operand: devel_id.toString()},
{operator: "topic", operand: ""},
];
- string =
- 'messages in #devel > <span class="empty-topic-display">translated: general chat</span>';
+ string = `messages in ${devel_decorated} > <span class="empty-topic-display">translated: general chat</span>`;
assert.equal(Filter.search_description_as_html(narrow, false), string);
narrow = [