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.

compose_validate: Extract banner text to be re-used.

Aman Agrawal0463f3ab1eba
diff --git a/web/src/compose_banner.ts b/web/src/compose_banner.ts
index e9e8371eb67..f18c2bd2497 100644
--- a/web/src/compose_banner.ts
+++ b/web/src/compose_banner.ts
@@ -238,17 +238,17 @@ export function show_stream_does_not_exist_error(stream_name: string): void {
$("#compose_select_recipient_widget").trigger("click");
}
-export function show_stream_not_subscribed_error(sub: StreamSubscription): void {
+export function show_stream_not_subscribed_error(
+ sub: StreamSubscription,
+ banner_text: string,
+): void {
const $banner_container = $("#compose_banners");
if ($(`#compose_banners .${CSS.escape(CLASSNAMES.user_not_subscribed)}`).length > 0) {
return;
}
const new_row_html = render_compose_banner({
banner_type: ERROR,
- banner_text: $t({
- defaultMessage:
- "You're not subscribed to this channel. You will not be notified if other users reply to your message.",
- }),
+ banner_text,
button_text: stream_data.can_toggle_subscription(sub)
? $t({defaultMessage: "Subscribe"})
: null,
diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.ts
index 682334cc438..56a2c367e2f 100644
--- a/web/src/compose_validate.ts
+++ b/web/src/compose_validate.ts
@@ -60,6 +60,10 @@ export const get_message_too_long_for_compose_error = (): string =>
{max_length: realm.max_message_length},
);
export const NO_MESSAGE_CONTENT_ERROR_MESSAGE = $t({defaultMessage: "Compose a message."});
+export const UNSUBSCRIBED_CHANNEL_ERROR_MESSAGE = $t({
+ defaultMessage:
+ "You're not subscribed to this channel. You will not be notified if other users reply to your message.",
+});
type StreamWildcardOptions = {
stream_id: number;
$banner_container: JQuery;
@@ -738,7 +742,7 @@ export function validate_stream_message_address_info(sub: StreamSubscription): b
if (sub.subscribed) {
return true;
}
- compose_banner.show_stream_not_subscribed_error(sub);
+ compose_banner.show_stream_not_subscribed_error(sub, UNSUBSCRIBED_CHANNEL_ERROR_MESSAGE);
return false;
}