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.

composebox_typeahead: Add info field to slash command as secondary text.

Pratik Chandac84ff59dc9a9
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts
index 426c1e53aaf..042d8962856 100644
--- a/web/src/composebox_typeahead.ts
+++ b/web/src/composebox_typeahead.ts
@@ -68,6 +68,7 @@ import * as util from "./util";
type SlashCommand = {
text: string;
name: string;
+ info: string;
aliases: NamedCurve;
placeholder?: string;
};
@@ -527,35 +528,40 @@ function should_show_custom_query(query: string, items: string[]): boolean {
export const dev_only_slash_commands = [
{
- text: $t({defaultMessage: "/dark (Switch to the dark theme)"}),
+ text: $t({defaultMessage: "/dark"}),
name: "dark",
aliases: "night",
+ info: $t({defaultMessage: "Switch to the dark theme"}),
},
{
- text: $t({defaultMessage: "/light (Switch to light theme)"}),
+ text: $t({defaultMessage: "/light"}),
name: "light",
aliases: "day",
+ info: $t({defaultMessage: "Switch to light theme"}),
},
];
export const slash_commands = [
{
- text: $t({defaultMessage: "/me (Action message)"}),
+ text: $t({defaultMessage: "/me"}),
name: "me",
aliases: "",
placeholder: $t({defaultMessage: "is …"}),
+ info: $t({defaultMessage: "Action message"}),
},
{
- text: $t({defaultMessage: "/poll (Create a poll)"}),
+ text: $t({defaultMessage: "/poll"}),
name: "poll",
aliases: "",
placeholder: $t({defaultMessage: "Question"}),
+ info: $t({defaultMessage: "Create a poll"}),
},
{
- text: $t({defaultMessage: "/todo (Create a collaborative to-do list)"}),
+ text: $t({defaultMessage: "/todo"}),
name: "todo",
aliases: "",
placeholder: $t({defaultMessage: "Task list"}),
+ info: $t({defaultMessage: "Create a collaborative to-do list"}),
},
];
@@ -974,6 +980,7 @@ export function content_highlighter_html(item: TypeaheadSuggestion): string | un
case "slash":
return typeahead_helper.render_typeahead_item({
primary: item.text,
+ secondary: item.info,
});
case "stream":
return typeahead_helper.render_stream(item);
diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js
index 9881aa05d33..921dd793bec 100644
--- a/web/tests/composebox_typeahead.test.js
+++ b/web/tests/composebox_typeahead.test.js
@@ -225,8 +225,9 @@ const emojis_by_name = new Map(
const me_command = {
name: "me",
aliases: "",
- text: "translated: /me (Action message)",
+ text: "translated: /me",
placeholder: "translated: is …",
+ info: "translated: Action message",
};
const me_command_item = slash_item(me_command);
@@ -239,14 +240,16 @@ const my_command_item = slash_item({
const dark_command = {
name: "dark",
aliases: "night",
- text: "translated: /dark (Switch to the dark theme)",
+ text: "translated: /dark",
+ info: "translated: Switch to the dark theme",
};
const dark_command_item = slash_item(dark_command);
const light_command = {
name: "light",
aliases: "day",
- text: "translated: /light (Switch to light theme)",
+ text: "translated: /light",
+ info: "translated: Switch to light theme",
};
const light_command_item = slash_item(light_command);
@@ -1710,15 +1713,17 @@ test("begins_typeahead", ({override, override_rewire}) => {
assert_typeahead_equals("test no#o", []);
const poll_command = {
- text: "translated: /poll (Create a poll)",
+ text: "translated: /poll",
name: "poll",
+ info: "translated: Create a poll",
aliases: "",
placeholder: "translated: Question",
type: "slash",
};
const todo_command = {
- text: "translated: /todo (Create a collaborative to-do list)",
+ text: "translated: /todo",
name: "todo",
+ info: "translated: Create a collaborative to-do list",
aliases: "",
placeholder: "translated: Task list",
type: "slash",
@@ -1905,12 +1910,14 @@ test("content_highlighter_html", ({override_rewire}) => {
ct.get_or_set_completing_for_tests("slash");
let th_render_slash_command_called = false;
const me_slash = {
- text: "/me (Action message)",
+ text: "/me",
type: "slash",
+ info: "translated: Action message",
};
override_rewire(typeahead_helper, "render_typeahead_item", (item) => {
assert.deepEqual(item, {
- primary: "/me (Action message)",
+ primary: "/me",
+ secondary: "translated: Action message",
});
th_render_slash_command_called = true;
});