mirror of https://github.com/zulip/zulip.git
compose: Rename compose_error to compose_banner.
It no longer handles only error messages, but banners of multiple types.
This commit is contained in:
parent
f9c72701c6
commit
e9045dcd58
|
@ -1,26 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {$t} = require("../zjsunit/i18n");
|
||||
const {zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
|
||||
const compose_error = zrequire("compose_error");
|
||||
|
||||
run_test("compose_error_test", () => {
|
||||
compose_error.show($t({defaultMessage: "You have nothing to send!"}), $("#compose-textarea"));
|
||||
|
||||
assert.ok($("#compose-send-status").hasClass("alert-error"));
|
||||
assert.equal($("#compose-error-msg").html(), $t({defaultMessage: "You have nothing to send!"}));
|
||||
assert.ok(!$("#compose-send-button .loader").visible());
|
||||
assert.ok($("#compose-textarea").is_focused());
|
||||
|
||||
$("#compose-send-status").fadeOut = (prop) => {
|
||||
assert.equal(prop, 500);
|
||||
return "none";
|
||||
};
|
||||
|
||||
$("#compose-send-status").stop(true).fadeOut(500);
|
||||
});
|
|
@ -14,7 +14,7 @@ const {mock_banners} = require("./lib/compose_banner");
|
|||
const channel = mock_esm("../../static/js/channel");
|
||||
const compose_actions = mock_esm("../../static/js/compose_actions");
|
||||
|
||||
const compose_error = zrequire("compose_error");
|
||||
const compose_banner = zrequire("compose_banner");
|
||||
const compose_pm_pill = zrequire("compose_pm_pill");
|
||||
const compose_state = zrequire("compose_state");
|
||||
const compose_validate = zrequire("compose_validate");
|
||||
|
@ -83,7 +83,7 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
|
|||
$("#compose_banners .user_not_subscribed").length = 0;
|
||||
let user_not_subscribed_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", true, (data, html) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.user_not_subscribed);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.user_not_subscribed);
|
||||
user_not_subscribed_rendered = true;
|
||||
return html;
|
||||
});
|
||||
|
@ -112,7 +112,7 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
|
|||
|
||||
let stream_does_not_exist_rendered = false;
|
||||
mock_template("compose_banner/stream_does_not_exist_error.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.stream_does_not_exist);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.stream_does_not_exist);
|
||||
assert.equal(data.stream_name, "Frontend");
|
||||
stream_does_not_exist_rendered = true;
|
||||
});
|
||||
|
@ -174,7 +174,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
compose_state.private_message_recipient("");
|
||||
let pm_recipient_error_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.missing_private_message_recipient);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.missing_private_message_recipient);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({defaultMessage: "Please specify at least one valid recipient."}),
|
||||
|
@ -194,7 +194,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
people.deactivate(bob);
|
||||
let deactivated_user_error_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.deactivated_user);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.deactivated_user);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({defaultMessage: "You cannot send messages to deactivated users."}),
|
||||
|
@ -216,7 +216,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
let zephyr_error_rendered = false;
|
||||
let empty_message_error_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
if (data.classname === compose_error.CLASSNAMES.zephyr_not_running) {
|
||||
if (data.classname === compose_banner.CLASSNAMES.zephyr_not_running) {
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -225,7 +225,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
}),
|
||||
);
|
||||
zephyr_error_rendered = true;
|
||||
} else if (data.classname === compose_error.CLASSNAMES.empty_message) {
|
||||
} else if (data.classname === compose_banner.CLASSNAMES.empty_message) {
|
||||
assert.equal(data.banner_text, $t({defaultMessage: "You have nothing to send!"}));
|
||||
empty_message_error_rendered = true;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
compose_state.stream_name("");
|
||||
let empty_stream_error_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.missing_stream);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.missing_stream);
|
||||
assert.equal(data.banner_text, $t({defaultMessage: "Please specify a stream."}));
|
||||
empty_stream_error_rendered = true;
|
||||
});
|
||||
|
@ -269,7 +269,7 @@ test_ui("validate", ({override, mock_template}) => {
|
|||
compose_state.topic("");
|
||||
let missing_topic_error_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.topic_missing);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.topic_missing);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({defaultMessage: "Topics are required in this organization."}),
|
||||
|
@ -397,7 +397,7 @@ test_ui("validate_stream_message", ({override_rewire, mock_template}) => {
|
|||
|
||||
let wildcards_not_allowed_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.wildcards_not_allowed);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.wildcards_not_allowed);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -432,7 +432,7 @@ test_ui("test_validate_stream_message_post_policy_admin_only", ({mock_template})
|
|||
|
||||
let banner_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -475,7 +475,7 @@ test_ui("test_validate_stream_message_post_policy_moderators_only", ({mock_templ
|
|||
stream_data.add_sub(sub);
|
||||
let banner_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -510,7 +510,7 @@ test_ui("test_validate_stream_message_post_policy_full_members_only", ({mock_tem
|
|||
stream_data.add_sub(sub);
|
||||
let banner_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.no_post_permissions);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -532,7 +532,7 @@ test_ui("test_check_overflow_text", ({mock_template}) => {
|
|||
const $send_button = $("#compose-send-button");
|
||||
let banner_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.message_too_long);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.message_too_long);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
@ -624,7 +624,7 @@ test_ui("warn_if_private_stream_is_linked", ({mock_template}) => {
|
|||
|
||||
let banner_rendered = false;
|
||||
mock_template("compose_banner/private_stream_warning.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.private_stream_warning);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.private_stream_warning);
|
||||
assert.equal(data.stream_name, "Denmark");
|
||||
banner_rendered = true;
|
||||
return "private_stream_warning_stub";
|
||||
|
@ -666,7 +666,7 @@ test_ui("warn_if_mentioning_unsubscribed_user", ({override, mock_template}) => {
|
|||
|
||||
let new_banner_rendered = false;
|
||||
mock_template("compose_banner/not_subscribed_warning.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.recipient_not_subscribed);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.recipient_not_subscribed);
|
||||
assert.equal(data.user_id, 34);
|
||||
assert.equal(data.stream_id, 111);
|
||||
assert.equal(data.name, "Foo Barson");
|
||||
|
@ -746,7 +746,7 @@ test_ui("test warn_if_topic_resolved", ({override, mock_template}) => {
|
|||
|
||||
let error_shown = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
|
||||
assert.equal(data.classname, compose_error.CLASSNAMES.topic_resolved);
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.topic_resolved);
|
||||
assert.equal(
|
||||
data.banner_text,
|
||||
$t({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
const compose_banner = require("../../../static/js/compose_error");
|
||||
const compose_banner = require("../../../static/js/compose_banner");
|
||||
const $ = require("../../zjsunit/zjquery");
|
||||
|
||||
exports.mock_banners = () => {
|
||||
|
|
|
@ -5,8 +5,8 @@ import _ from "lodash";
|
|||
import * as blueslip from "./blueslip";
|
||||
import * as channel from "./channel";
|
||||
import * as compose_actions from "./compose_actions";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
import {get_recipient_label} from "./compose_closed_ui";
|
||||
import * as compose_error from "./compose_error";
|
||||
import * as compose_fade from "./compose_fade";
|
||||
import * as compose_state from "./compose_state";
|
||||
import * as compose_ui from "./compose_ui";
|
||||
|
@ -74,11 +74,11 @@ export function update_video_chat_button_display() {
|
|||
}
|
||||
|
||||
export function clear_invites() {
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.recipient_not_subscribed}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.recipient_not_subscribed}`).remove();
|
||||
}
|
||||
|
||||
export function clear_private_stream_alert() {
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.private_stream_warning}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.private_stream_warning}`).remove();
|
||||
}
|
||||
|
||||
export function clear_preview_area() {
|
||||
|
@ -251,9 +251,9 @@ export function send_message(request = create_message_object()) {
|
|||
// If we're not local echo'ing messages, or if this message was not
|
||||
// locally echoed, show error in compose box
|
||||
if (!locally_echoed) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
response,
|
||||
compose_error.CLASSNAMES.generic_compose_error,
|
||||
compose_banner.CLASSNAMES.generic_compose_error,
|
||||
$("#compose-textarea"),
|
||||
);
|
||||
return;
|
||||
|
@ -451,7 +451,7 @@ export function initialize() {
|
|||
|
||||
$("#compose_banners").on(
|
||||
"click",
|
||||
`.${compose_error.CLASSNAMES.wildcard_warning} .compose_banner_action_button`,
|
||||
`.${compose_banner.CLASSNAMES.wildcard_warning} .compose_banner_action_button`,
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
compose_validate.clear_wildcard_warnings();
|
||||
|
@ -460,7 +460,7 @@ export function initialize() {
|
|||
},
|
||||
);
|
||||
|
||||
const user_not_subscribed_classname = `.${compose_error.CLASSNAMES.user_not_subscribed}`;
|
||||
const user_not_subscribed_classname = `.${compose_banner.CLASSNAMES.user_not_subscribed}`;
|
||||
$("#compose_banners").on(
|
||||
"click",
|
||||
`${user_not_subscribed_classname} .compose_banner_action_button`,
|
||||
|
@ -479,7 +479,7 @@ export function initialize() {
|
|||
|
||||
$("#compose_banners").on(
|
||||
"click",
|
||||
`.${compose_error.CLASSNAMES.topic_resolved} .compose_banner_action_button`,
|
||||
`.${compose_banner.CLASSNAMES.topic_resolved} .compose_banner_action_button`,
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -496,7 +496,7 @@ export function initialize() {
|
|||
|
||||
$("#compose_banners").on(
|
||||
"click",
|
||||
`.${compose_error.CLASSNAMES.recipient_not_subscribed} .compose_banner_action_button`,
|
||||
`.${compose_banner.CLASSNAMES.recipient_not_subscribed} .compose_banner_action_button`,
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -511,9 +511,9 @@ export function initialize() {
|
|||
|
||||
function failure(error_msg) {
|
||||
clear_invites();
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
error_msg,
|
||||
compose_error.CLASSNAMES.generic_compose_error,
|
||||
compose_banner.CLASSNAMES.generic_compose_error,
|
||||
$("#compose-textarea"),
|
||||
);
|
||||
$(event.target).prop("disabled", true);
|
||||
|
@ -530,7 +530,7 @@ export function initialize() {
|
|||
},
|
||||
);
|
||||
|
||||
for (const classname of Object.values(compose_error.CLASSNAMES)) {
|
||||
for (const classname of Object.values(compose_banner.CLASSNAMES)) {
|
||||
const classname_selector = `.${classname}`;
|
||||
$("#compose_banners").on(
|
||||
"click",
|
||||
|
|
|
@ -7,7 +7,7 @@ import render_private_stream_warning from "../templates/compose_banner/private_s
|
|||
import render_wildcard_warning from "../templates/compose_banner/wildcard_warning.hbs";
|
||||
|
||||
import * as channel from "./channel";
|
||||
import * as compose_error from "./compose_error";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
import * as compose_pm_pill from "./compose_pm_pill";
|
||||
import * as compose_state from "./compose_state";
|
||||
import * as compose_ui from "./compose_ui";
|
||||
|
@ -101,9 +101,9 @@ export function warn_if_private_stream_is_linked(linked_stream) {
|
|||
}
|
||||
|
||||
const new_row = render_private_stream_warning({
|
||||
banner_type: compose_error.WARNING,
|
||||
banner_type: compose_banner.WARNING,
|
||||
stream_name: linked_stream.name,
|
||||
classname: compose_error.CLASSNAMES.private_stream_warning,
|
||||
classname: compose_banner.CLASSNAMES.private_stream_warning,
|
||||
});
|
||||
|
||||
$("#compose_banners").append(new_row);
|
||||
|
@ -139,7 +139,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) {
|
|||
|
||||
if (needs_subscribe_warning(user_id, sub.stream_id)) {
|
||||
const $existing_invites_area = $(
|
||||
`#compose_banners .${compose_error.CLASSNAMES.recipient_not_subscribed}`,
|
||||
`#compose_banners .${compose_banner.CLASSNAMES.recipient_not_subscribed}`,
|
||||
);
|
||||
|
||||
const existing_invites = Array.from($existing_invites_area, (user_row) =>
|
||||
|
@ -152,13 +152,13 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) {
|
|||
const context = {
|
||||
user_id,
|
||||
stream_id: sub.stream_id,
|
||||
banner_type: compose_error.WARNING,
|
||||
banner_type: compose_banner.WARNING,
|
||||
button_text: can_subscribe_other_users
|
||||
? $t({defaultMessage: "Subscribe them"})
|
||||
: null,
|
||||
can_subscribe_other_users,
|
||||
name: mentioned.full_name,
|
||||
classname: compose_error.CLASSNAMES.recipient_not_subscribed,
|
||||
classname: compose_banner.CLASSNAMES.recipient_not_subscribed,
|
||||
};
|
||||
|
||||
const new_row = render_not_subscribed_warning(context);
|
||||
|
@ -168,7 +168,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) {
|
|||
}
|
||||
|
||||
export function clear_topic_resolved_warning() {
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.topic_resolved}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.topic_resolved}`).remove();
|
||||
}
|
||||
|
||||
export function warn_if_topic_resolved(topic_changed) {
|
||||
|
@ -196,7 +196,7 @@ export function warn_if_topic_resolved(topic_changed) {
|
|||
const $compose_banner_area = $("#compose_banners");
|
||||
|
||||
if (sub && message_content !== "" && resolved_topic.is_resolved(topic_name)) {
|
||||
if ($(`#compose_banners .${compose_error.CLASSNAMES.topic_resolved}`).length) {
|
||||
if ($(`#compose_banners .${compose_banner.CLASSNAMES.topic_resolved}`).length) {
|
||||
// Error is already displayed; no action required.
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ export function warn_if_topic_resolved(topic_changed) {
|
|||
: null;
|
||||
|
||||
const context = {
|
||||
banner_type: compose_error.WARNING,
|
||||
banner_type: compose_banner.WARNING,
|
||||
stream_id: sub.stream_id,
|
||||
topic_name,
|
||||
banner_text: $t({
|
||||
|
@ -214,7 +214,7 @@ export function warn_if_topic_resolved(topic_changed) {
|
|||
"You are sending a message to a resolved topic. You can send as-is or unresolve the topic first.",
|
||||
}),
|
||||
button_text,
|
||||
classname: compose_error.CLASSNAMES.topic_resolved,
|
||||
classname: compose_banner.CLASSNAMES.topic_resolved,
|
||||
};
|
||||
|
||||
const new_row = render_compose_banner(context);
|
||||
|
@ -228,9 +228,9 @@ function show_wildcard_warnings(stream_id) {
|
|||
const subscriber_count = peer_data.get_subscriber_count(stream_id) || 0;
|
||||
|
||||
const $compose_banner_area = $("#compose_banners");
|
||||
const classname = compose_error.CLASSNAMES.wildcard_warning;
|
||||
const classname = compose_banner.CLASSNAMES.wildcard_warning;
|
||||
const $wildcard_template = render_wildcard_warning({
|
||||
banner_type: compose_error.WARNING,
|
||||
banner_type: compose_banner.WARNING,
|
||||
subscriber_count,
|
||||
stream_name: compose_state.stream_name(),
|
||||
wildcard_mention,
|
||||
|
@ -248,7 +248,7 @@ function show_wildcard_warnings(stream_id) {
|
|||
}
|
||||
|
||||
export function clear_wildcard_warnings() {
|
||||
const classname = compose_error.CLASSNAMES.wildcard_warning;
|
||||
const classname = compose_banner.CLASSNAMES.wildcard_warning;
|
||||
$(`#compose_banners .${classname}`).remove();
|
||||
}
|
||||
|
||||
|
@ -354,12 +354,12 @@ function validate_stream_message_mentions(stream_id) {
|
|||
// stream, check if they permission to do so.
|
||||
if (wildcard_mention !== null && subscriber_count > wildcard_mention_large_stream_threshold) {
|
||||
if (!wildcard_mention_allowed()) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({
|
||||
defaultMessage:
|
||||
"You do not have permission to use wildcard mentions in this stream.",
|
||||
}),
|
||||
compose_error.CLASSNAMES.wildcards_not_allowed,
|
||||
compose_banner.CLASSNAMES.wildcards_not_allowed,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -385,22 +385,22 @@ function validate_stream_message_mentions(stream_id) {
|
|||
export function validation_error(error_type, stream_name) {
|
||||
switch (error_type) {
|
||||
case "does-not-exist":
|
||||
compose_error.show_stream_does_not_exist_error(stream_name);
|
||||
compose_banner.show_stream_does_not_exist_error(stream_name);
|
||||
return false;
|
||||
case "error":
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "Error checking subscription."}),
|
||||
compose_error.CLASSNAMES.subscription_error,
|
||||
compose_banner.CLASSNAMES.subscription_error,
|
||||
$("#stream_message_recipient_stream"),
|
||||
);
|
||||
return false;
|
||||
case "not-subscribed": {
|
||||
if ($(`#compose_banners .${compose_error.CLASSNAMES.user_not_subscribed}`).length) {
|
||||
if ($(`#compose_banners .${compose_banner.CLASSNAMES.user_not_subscribed}`).length) {
|
||||
return false;
|
||||
}
|
||||
const sub = stream_data.get_sub(stream_name);
|
||||
const new_row = render_compose_banner({
|
||||
banner_type: compose_error.ERROR,
|
||||
banner_type: compose_banner.ERROR,
|
||||
banner_text: $t({
|
||||
defaultMessage:
|
||||
"You're not subscribed to this stream. You will not be notified if other users reply to your message.",
|
||||
|
@ -408,7 +408,7 @@ export function validation_error(error_type, stream_name) {
|
|||
button_text: stream_data.can_toggle_subscription(sub)
|
||||
? $t({defaultMessage: "Subscribe"})
|
||||
: null,
|
||||
classname: compose_error.CLASSNAMES.user_not_subscribed,
|
||||
classname: compose_banner.CLASSNAMES.user_not_subscribed,
|
||||
// The message cannot be sent until the user subscribes to the stream, so
|
||||
// closing the banner would be more confusing than helpful.
|
||||
hide_close_button: true,
|
||||
|
@ -432,9 +432,9 @@ export function validate_stream_message_address_info(stream_name) {
|
|||
function validate_stream_message() {
|
||||
const stream_name = compose_state.stream_name();
|
||||
if (stream_name === "") {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "Please specify a stream."}),
|
||||
compose_error.CLASSNAMES.missing_stream,
|
||||
compose_banner.CLASSNAMES.missing_stream,
|
||||
$("#stream_message_recipient_stream"),
|
||||
);
|
||||
return false;
|
||||
|
@ -445,9 +445,9 @@ function validate_stream_message() {
|
|||
// TODO: We plan to migrate the empty topic to only using the
|
||||
// `""` representation for i18n reasons, but have not yet done so.
|
||||
if (topic === "" || topic === "(no topic)") {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "Topics are required in this organization."}),
|
||||
compose_error.CLASSNAMES.topic_missing,
|
||||
compose_banner.CLASSNAMES.topic_missing,
|
||||
$("#stream_message_recipient_topic"),
|
||||
);
|
||||
return false;
|
||||
|
@ -460,11 +460,11 @@ function validate_stream_message() {
|
|||
}
|
||||
|
||||
if (!stream_data.can_post_messages_in_stream(sub)) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({
|
||||
defaultMessage: "You do not have permission to post in this stream.",
|
||||
}),
|
||||
compose_error.CLASSNAMES.no_post_permissions,
|
||||
compose_banner.CLASSNAMES.no_post_permissions,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -495,18 +495,18 @@ function validate_private_message() {
|
|||
(user_ids.length !== 1 || !people.get_by_user_id(user_ids[0]).is_bot)
|
||||
) {
|
||||
// Unless we're composing to a bot
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "Private messages are disabled in this organization."}),
|
||||
compose_error.CLASSNAMES.private_messages_disabled,
|
||||
compose_banner.CLASSNAMES.private_messages_disabled,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (compose_state.private_message_recipient().length === 0) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "Please specify at least one valid recipient."}),
|
||||
compose_error.CLASSNAMES.missing_private_message_recipient,
|
||||
compose_banner.CLASSNAMES.missing_private_message_recipient,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
return false;
|
||||
|
@ -520,17 +520,17 @@ function validate_private_message() {
|
|||
let context = {};
|
||||
if (invalid_recipients.length === 1) {
|
||||
context = {recipient: invalid_recipients.join(",")};
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "The recipient {recipient} is not valid."}, context),
|
||||
compose_error.CLASSNAMES.invalid_recipient,
|
||||
compose_banner.CLASSNAMES.invalid_recipient,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
return false;
|
||||
} else if (invalid_recipients.length > 1) {
|
||||
context = {recipients: invalid_recipients.join(",")};
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "The recipients {recipients} are not valid."}, context),
|
||||
compose_error.CLASSNAMES.invalid_recipients,
|
||||
compose_banner.CLASSNAMES.invalid_recipients,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
return false;
|
||||
|
@ -539,9 +539,9 @@ function validate_private_message() {
|
|||
for (const user_id of user_ids) {
|
||||
if (!people.is_person_active(user_id)) {
|
||||
context = {full_name: people.get_by_user_id(user_id).full_name};
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "You cannot send messages to deactivated users."}, context),
|
||||
compose_error.CLASSNAMES.deactivated_user,
|
||||
compose_banner.CLASSNAMES.deactivated_user,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
|
||||
|
@ -564,7 +564,7 @@ export function check_overflow_text() {
|
|||
$indicator.addClass("over_limit");
|
||||
$("#compose-textarea").addClass("over_limit");
|
||||
$indicator.text(text.length + "/" + max_length);
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t(
|
||||
{
|
||||
defaultMessage:
|
||||
|
@ -572,7 +572,7 @@ export function check_overflow_text() {
|
|||
},
|
||||
{max_length},
|
||||
),
|
||||
compose_error.CLASSNAMES.message_too_long,
|
||||
compose_banner.CLASSNAMES.message_too_long,
|
||||
);
|
||||
$("#compose-send-button").prop("disabled", true);
|
||||
} else if (text.length > 0.9 * max_length) {
|
||||
|
@ -581,13 +581,13 @@ export function check_overflow_text() {
|
|||
$indicator.text(text.length + "/" + max_length);
|
||||
|
||||
$("#compose-send-button").prop("disabled", false);
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.message_too_long}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.message_too_long}`).remove();
|
||||
} else {
|
||||
$indicator.text("");
|
||||
$("#compose-textarea").removeClass("over_limit");
|
||||
|
||||
$("#compose-send-button").prop("disabled", false);
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.message_too_long}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.message_too_long}`).remove();
|
||||
}
|
||||
|
||||
return text.length;
|
||||
|
@ -608,23 +608,23 @@ export function validate() {
|
|||
// Avoid showing an error message when "enter sends" is enabled,
|
||||
// as it is more likely that the user has hit "Enter" accidentally.
|
||||
if (!user_settings.enter_sends) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({defaultMessage: "You have nothing to send!"}),
|
||||
compose_error.CLASSNAMES.empty_message,
|
||||
compose_banner.CLASSNAMES.empty_message,
|
||||
$("#compose-textarea"),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$(`#compose_banners .${compose_error.CLASSNAMES.empty_message}`).remove();
|
||||
$(`#compose_banners .${compose_banner.CLASSNAMES.empty_message}`).remove();
|
||||
|
||||
if ($("#zephyr-mirror-error").is(":visible")) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
$t({
|
||||
defaultMessage:
|
||||
"You need to be running Zephyr mirroring in order to send messages!",
|
||||
}),
|
||||
compose_error.CLASSNAMES.zephyr_not_running,
|
||||
compose_banner.CLASSNAMES.zephyr_not_running,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import $ from "jquery";
|
|||
|
||||
import * as channel from "./channel";
|
||||
import * as compose from "./compose";
|
||||
import * as compose_error from "./compose_error";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
import * as hash_util from "./hash_util";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
import * as message_lists from "./message_lists";
|
||||
|
@ -71,9 +71,9 @@ export function schedule_message(request = compose.create_message_object()) {
|
|||
}
|
||||
|
||||
if (error_message) {
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
error_message,
|
||||
compose_error.CLASSNAMES.generic_compose_error,
|
||||
compose_banner.CLASSNAMES.generic_compose_error,
|
||||
$("#compose-textarea"),
|
||||
);
|
||||
$("#compose-textarea").prop("disabled", false);
|
||||
|
@ -99,9 +99,9 @@ export function schedule_message(request = compose.create_message_object()) {
|
|||
};
|
||||
const error = function (response) {
|
||||
$("#compose-textarea").prop("disabled", false);
|
||||
compose_error.show_error_message(
|
||||
compose_banner.show_error_message(
|
||||
response,
|
||||
compose_error.CLASSNAMES.generic_compose_error,
|
||||
compose_banner.CLASSNAMES.generic_compose_error,
|
||||
$("#compose-textarea"),
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as channel from "./channel";
|
||||
import * as compose_error from "./compose_error";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
import * as dark_theme from "./dark_theme";
|
||||
import * as feedback_widget from "./feedback_widget";
|
||||
import {$t} from "./i18n";
|
||||
|
@ -48,7 +48,7 @@ export function send(opts) {
|
|||
export function tell_user(msg) {
|
||||
// This is a bit hacky, but we don't have a super easy API now
|
||||
// for just telling users stuff.
|
||||
compose_error.show_error_message(msg, compose_error.CLASSNAMES.generic_compose_error);
|
||||
compose_banner.show_error_message(msg, compose_banner.CLASSNAMES.generic_compose_error);
|
||||
}
|
||||
|
||||
export function switch_to_light_theme() {
|
||||
|
|
Loading…
Reference in New Issue