compose: Check posting policy for direct messages.

Prior this commit, changing the message type from a stream (where posting
was not allowed) to a direct message using the compose box dropdown, did not
changed the state of the send button from disabled to enabled even though
direct messages were allowed in the organization.

This was happening because `check_stream_posting_policy_for_compose_box` was
only for streams.

Now, function is updated to check for both streams and direct
messages, as it checks if direct messages are allowed or not, and depending on
that, it updates the send button's state, tooltip and displays a relevant banner.
This commit is contained in:
Brijmohan Siyag
2023-05-13 03:18:00 +05:30
committed by Tim Abbott
parent ee88bb5187
commit cb00fbc42f
5 changed files with 45 additions and 25 deletions

View File

@@ -121,7 +121,7 @@ test("start", ({override, override_rewire, mock_template}) => {
override_rewire(compose_actions, "blur_compose_inputs", () => {});
override_rewire(compose_actions, "clear_textarea", () => {});
override_rewire(compose_recipient, "on_compose_select_recipient_update", () => {});
override_rewire(compose_recipient, "check_stream_posting_policy_for_compose_box", () => {});
override_rewire(compose_recipient, "check_posting_policy_for_compose_box", () => {});
mock_template("inline_decorated_stream_name.hbs", false, () => {});
mock_stream_header_colorblock();
@@ -245,7 +245,7 @@ test("respond_to_message", ({override, override_rewire, mock_template}) => {
override_rewire(compose_actions, "complete_starting_tasks", () => {});
override_rewire(compose_actions, "clear_textarea", () => {});
override_rewire(compose_recipient, "on_compose_select_recipient_update", noop);
override_rewire(compose_recipient, "check_stream_posting_policy_for_compose_box", noop);
override_rewire(compose_recipient, "check_posting_policy_for_compose_box", noop);
override_private_message_recipient({override});
mock_template("inline_decorated_stream_name.hbs", false, () => {});
mock_stream_header_colorblock();
@@ -299,7 +299,7 @@ test("reply_with_mention", ({override, override_rewire, mock_template}) => {
override_rewire(compose_actions, "complete_starting_tasks", () => {});
override_rewire(compose_actions, "clear_textarea", () => {});
override_private_message_recipient({override});
override_rewire(compose_recipient, "check_stream_posting_policy_for_compose_box", noop);
override_rewire(compose_recipient, "check_posting_policy_for_compose_box", noop);
mock_template("inline_decorated_stream_name.hbs", false, () => {});
const denmark = {

View File

@@ -164,6 +164,11 @@ test("basics", () => {
assert.equal(stream_data.slug_to_name("99-whatever"), "99-whatever");
assert.equal(stream_data.slug_to_name("99whatever"), "99whatever");
// sub_store
assert.equal(sub_store.get(-3), undefined);
assert.equal(sub_store.get(undefined), undefined);
assert.equal(sub_store.get(1), denmark);
});
test("get_subscribed_streams_for_user", () => {