mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 20:41:46 +00:00
compose_banner: Show realm_empty_topic_display_name for topic="".
This commit adds support to display `realm_empty_topic_display_name` value in the compose banners for topics having the actual value of empty string. Fixes part of #32996.
This commit is contained in:
committed by
Tim Abbott
parent
8379f0cffb
commit
5bb53ec091
@@ -19,6 +19,7 @@ import * as people from "./people.ts";
|
|||||||
import * as stream_data from "./stream_data.ts";
|
import * as stream_data from "./stream_data.ts";
|
||||||
import {user_settings} from "./user_settings.ts";
|
import {user_settings} from "./user_settings.ts";
|
||||||
import * as user_topics from "./user_topics.ts";
|
import * as user_topics from "./user_topics.ts";
|
||||||
|
import * as util from "./util.ts";
|
||||||
|
|
||||||
export function notify_unmute(muted_narrow: string, stream_id: number, topic_name: string): void {
|
export function notify_unmute(muted_narrow: string, stream_id: number, topic_name: string): void {
|
||||||
const $unmute_notification = $(
|
const $unmute_notification = $(
|
||||||
@@ -38,12 +39,25 @@ export function notify_unmute(muted_narrow: string, stream_id: number, topic_nam
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MessageRecipient =
|
||||||
|
| {
|
||||||
|
message_type: "channel";
|
||||||
|
channel_name: string;
|
||||||
|
topic_display_name: string;
|
||||||
|
is_empty_string_topic: boolean;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
message_type: "direct";
|
||||||
|
recipient_text: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function notify_above_composebox(
|
export function notify_above_composebox(
|
||||||
banner_text: string,
|
banner_text: string,
|
||||||
classname: string,
|
classname: string,
|
||||||
above_composebox_narrow_url: string | null,
|
above_composebox_narrow_url: string | null,
|
||||||
link_msg_id: number,
|
link_msg_id: number,
|
||||||
link_text: string,
|
message_recipient: MessageRecipient | null,
|
||||||
|
link_text: string | null,
|
||||||
): void {
|
): void {
|
||||||
const $notification = $(
|
const $notification = $(
|
||||||
render_message_sent_banner({
|
render_message_sent_banner({
|
||||||
@@ -51,6 +65,7 @@ export function notify_above_composebox(
|
|||||||
classname,
|
classname,
|
||||||
above_composebox_narrow_url,
|
above_composebox_narrow_url,
|
||||||
link_msg_id,
|
link_msg_id,
|
||||||
|
message_recipient,
|
||||||
link_text,
|
link_text,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -66,14 +81,17 @@ export function notify_automatic_new_visibility_policy(
|
|||||||
): void {
|
): void {
|
||||||
const followed =
|
const followed =
|
||||||
data.automatic_new_visibility_policy === user_topics.all_visibility_policies.FOLLOWED;
|
data.automatic_new_visibility_policy === user_topics.all_visibility_policies.FOLLOWED;
|
||||||
const stream_topic = get_message_header(message);
|
|
||||||
const narrow_url = get_above_composebox_narrow_url(message);
|
const narrow_url = get_above_composebox_narrow_url(message);
|
||||||
|
const message_recipient = get_message_recipient(message);
|
||||||
|
assert(message_recipient.message_type === "channel");
|
||||||
const $notification = $(
|
const $notification = $(
|
||||||
render_automatic_new_visibility_policy_banner({
|
render_automatic_new_visibility_policy_banner({
|
||||||
banner_type: compose_banner.SUCCESS,
|
banner_type: compose_banner.SUCCESS,
|
||||||
classname: compose_banner.CLASSNAMES.automatic_new_visibility_policy,
|
classname: compose_banner.CLASSNAMES.automatic_new_visibility_policy,
|
||||||
link_msg_id: data.id,
|
link_msg_id: data.id,
|
||||||
channel_topic: stream_topic,
|
channel_name: message_recipient.channel_name,
|
||||||
|
topic_display_name: message_recipient.topic_display_name,
|
||||||
|
is_empty_string_topic: message_recipient.is_empty_string_topic,
|
||||||
narrow_url,
|
narrow_url,
|
||||||
followed,
|
followed,
|
||||||
button_text: $t({defaultMessage: "Change setting"}),
|
button_text: $t({defaultMessage: "Change setting"}),
|
||||||
@@ -86,24 +104,38 @@ export function notify_automatic_new_visibility_policy(
|
|||||||
|
|
||||||
// Note that this returns values that are not HTML-escaped, for use in
|
// Note that this returns values that are not HTML-escaped, for use in
|
||||||
// Handlebars templates that will do further escaping.
|
// Handlebars templates that will do further escaping.
|
||||||
function get_message_header(message: Message): string {
|
function get_message_recipient(message: Message): MessageRecipient {
|
||||||
if (message.type === "stream") {
|
if (message.type === "stream") {
|
||||||
const stream_name = stream_data.get_stream_name_from_id(message.stream_id);
|
const channel_message_recipient: MessageRecipient = {
|
||||||
return `#${stream_name} > ${message.topic}`;
|
message_type: "channel",
|
||||||
|
channel_name: stream_data.get_stream_name_from_id(message.stream_id),
|
||||||
|
topic_display_name: util.get_final_topic_display_name(message.topic),
|
||||||
|
is_empty_string_topic: message.topic === "",
|
||||||
|
};
|
||||||
|
return channel_message_recipient;
|
||||||
}
|
}
|
||||||
|
const direct_message_recipient: MessageRecipient = {
|
||||||
|
message_type: "direct",
|
||||||
|
recipient_text: "",
|
||||||
|
};
|
||||||
if (message.display_recipient.length > 2) {
|
if (message.display_recipient.length > 2) {
|
||||||
return $t(
|
direct_message_recipient.recipient_text = $t(
|
||||||
{defaultMessage: "group direct messages with {recipient}"},
|
{defaultMessage: "group direct messages with {recipient}"},
|
||||||
{recipient: message.display_reply_to},
|
{recipient: message.display_reply_to},
|
||||||
);
|
);
|
||||||
|
return direct_message_recipient;
|
||||||
}
|
}
|
||||||
if (people.is_current_user(message.reply_to)) {
|
if (people.is_current_user(message.reply_to)) {
|
||||||
return $t({defaultMessage: "direct messages with yourself"});
|
direct_message_recipient.recipient_text = $t({
|
||||||
|
defaultMessage: "direct messages with yourself",
|
||||||
|
});
|
||||||
|
return direct_message_recipient;
|
||||||
}
|
}
|
||||||
return $t(
|
direct_message_recipient.recipient_text = $t(
|
||||||
{defaultMessage: "direct messages with {recipient}"},
|
{defaultMessage: "direct messages with {recipient}"},
|
||||||
{recipient: message.display_reply_to},
|
{recipient: message.display_reply_to},
|
||||||
);
|
);
|
||||||
|
return direct_message_recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_muted_narrow(message: Message): string | undefined {
|
export function get_muted_narrow(message: Message): string | undefined {
|
||||||
@@ -225,6 +257,7 @@ export function notify_local_mixes(
|
|||||||
// Don't display a URL on hover for the "Scroll to bottom" link.
|
// Don't display a URL on hover for the "Scroll to bottom" link.
|
||||||
null,
|
null,
|
||||||
link_msg_id,
|
link_msg_id,
|
||||||
|
null,
|
||||||
link_text,
|
link_text,
|
||||||
);
|
);
|
||||||
compose_banner.set_scroll_to_message_banner_message_id(link_msg_id);
|
compose_banner.set_scroll_to_message_banner_message_id(link_msg_id);
|
||||||
@@ -239,16 +272,13 @@ export function notify_local_mixes(
|
|||||||
const banner_text = $t({
|
const banner_text = $t({
|
||||||
defaultMessage: "Sent! Your message is outside your current view.",
|
defaultMessage: "Sent! Your message is outside your current view.",
|
||||||
});
|
});
|
||||||
const link_text = $t(
|
|
||||||
{defaultMessage: "Go to {message_recipient}"},
|
|
||||||
{message_recipient: get_message_header(message)},
|
|
||||||
);
|
|
||||||
notify_above_composebox(
|
notify_above_composebox(
|
||||||
banner_text,
|
banner_text,
|
||||||
compose_banner.CLASSNAMES.narrow_to_recipient,
|
compose_banner.CLASSNAMES.narrow_to_recipient,
|
||||||
get_above_composebox_narrow_url(message),
|
get_above_composebox_narrow_url(message),
|
||||||
link_msg_id,
|
link_msg_id,
|
||||||
link_text,
|
get_message_recipient(message),
|
||||||
|
null,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -291,16 +321,13 @@ export function notify_messages_outside_current_search(messages: Message[]): voi
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const above_composebox_narrow_url = get_above_composebox_narrow_url(message);
|
const above_composebox_narrow_url = get_above_composebox_narrow_url(message);
|
||||||
const link_text = $t(
|
|
||||||
{defaultMessage: "Narrow to {message_recipient}"},
|
|
||||||
{message_recipient: get_message_header(message)},
|
|
||||||
);
|
|
||||||
notify_above_composebox(
|
notify_above_composebox(
|
||||||
$t({defaultMessage: "Sent! Your message is outside your current view."}),
|
$t({defaultMessage: "Sent! Your message is outside your current view."}),
|
||||||
compose_banner.CLASSNAMES.narrow_to_recipient,
|
compose_banner.CLASSNAMES.narrow_to_recipient,
|
||||||
above_composebox_narrow_url,
|
above_composebox_narrow_url,
|
||||||
message.id,
|
message.id,
|
||||||
link_text,
|
get_message_recipient(message),
|
||||||
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,25 @@
|
|||||||
<p class="banner_message">
|
<p class="banner_message">
|
||||||
{{#if followed}}
|
{{#if followed}}
|
||||||
{{#tr}}
|
{{#tr}}
|
||||||
Now following <z-link>{channel_topic}</z-link>.
|
Now following <z-link></z-link>.
|
||||||
{{#*inline "z-link"}}<a class="above_compose_banner_action_link white-space-preserve-wrap" href="{{narrow_url}}" data-message-id="{{link_msg_id}}">{{> @partial-block}}</a>{{/inline}}
|
{{#*inline "z-link"~}}
|
||||||
|
<a class="above_compose_banner_action_link white-space-preserve-wrap" href="{{narrow_url}}" data-message-id="{{link_msg_id}}">
|
||||||
|
{{~!-- squash whitespace --~}}
|
||||||
|
#{{channel_name}} > <span {{#if is_empty_string_topic}}class="empty-topic-display"{{/if}}>{{topic_display_name}}</span>
|
||||||
|
{{~!-- squash whitespace --~}}
|
||||||
|
</a>
|
||||||
|
{{~/inline}}
|
||||||
{{/tr}}
|
{{/tr}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#tr}}
|
{{#tr}}
|
||||||
Unmuted <z-link>{channel_topic}</z-link>.
|
Unmuted <z-link></z-link>.
|
||||||
{{#*inline "z-link"}}<a class="above_compose_banner_action_link white-space-preserve-wrap" href="{{narrow_url}}" data-message-id="{{link_msg_id}}">{{> @partial-block}}</a>{{/inline}}
|
{{#*inline "z-link"~}}
|
||||||
|
<a class="above_compose_banner_action_link white-space-preserve-wrap" href="{{narrow_url}}" data-message-id="{{link_msg_id}}">
|
||||||
|
{{~!-- squash whitespace --~}}
|
||||||
|
#{{channel_name}} > <span {{#if is_empty_string_topic}}class="empty-topic-display"{{/if}}>{{topic_display_name}}</span>
|
||||||
|
{{~!-- squash whitespace --~}}
|
||||||
|
</a>
|
||||||
|
{{~/inline}}
|
||||||
{{/tr}}
|
{{/tr}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,7 +1,22 @@
|
|||||||
<div class="above_compose_banner main-view-banner success {{classname}}">
|
<div class="above_compose_banner main-view-banner success {{classname}}">
|
||||||
<p class="banner_content">
|
<p class="banner_content">
|
||||||
{{banner_text}}
|
{{banner_text}}
|
||||||
{{#if link_text}} <a class="above_compose_banner_action_link" {{#if above_composebox_narrow_url}}href="{{above_composebox_narrow_url}}"{{/if}} data-message-id="{{link_msg_id}}">{{link_text}}</a>{{/if}}
|
<a class="above_compose_banner_action_link" {{#if above_composebox_narrow_url}}href="{{above_composebox_narrow_url}}"{{/if}} data-message-id="{{link_msg_id}}">
|
||||||
|
{{#if message_recipient}}
|
||||||
|
{{#with message_recipient}}
|
||||||
|
{{#if (eq message_type "channel")}}
|
||||||
|
{{#tr}}
|
||||||
|
Go to #{channel_name} > <z-topic-display-name></z-topic-display-name>
|
||||||
|
{{#*inline "z-topic-display-name"}}<span {{#if is_empty_string_topic}}class="empty-topic-display"{{/if}}>{{topic_display_name}}</span>{{/inline}}
|
||||||
|
{{/tr}}
|
||||||
|
{{else}}
|
||||||
|
{{t 'Go to {recipient_text}' }}
|
||||||
|
{{/if}}
|
||||||
|
{{/with}}
|
||||||
|
{{else}}
|
||||||
|
{{link_text}}
|
||||||
|
{{/if}}
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<a role="button" class="zulip-icon zulip-icon-close main-view-banner-close-button"></a>
|
<a role="button" class="zulip-icon zulip-icon-close main-view-banner-close-button"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user