Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose: Check posting policy for direct messages. #25572

Merged
merged 2 commits into from May 16, 2023

Conversation

brijsiyag
Copy link
Member

@brijsiyag brijsiyag commented May 12, 2023

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 submit button from disabled to enabled even though direct messages were allowed in the organization. Now, 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.

Screenshots and screen captures:

Screenshot 2023-05-16 at 5 58 23 AM Screenshot 2023-05-16 at 5 58 07 AM Screenshot 2023-05-13 at 3 06 03 AM
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@brijsiyag brijsiyag force-pushed the dm_send_disabled branch 3 times, most recently from 8e9d2d0 to 7516b71 Compare May 12, 2023 19:39
@alya
Copy link
Contributor

alya commented May 12, 2023

Looks good to me, other than the banner text change, which should be reverted.

@alya alya added the release goal We'd like to resolve this for the current major release label May 12, 2023
@brijsiyag
Copy link
Member Author

brijsiyag commented May 12, 2023

I have updated it, @alya, can you take look at updated screen capture(2nd one)? I think tooltip looks odd in this case. Should we increase width a little bit ?

@alya
Copy link
Contributor

alya commented May 12, 2023

Can you please post just a screenshot with the corrected banner? In general, always use a screenshot, as the PR template notes.

Screenshots are easier for me to review than videos, which can be nice additions, but aren't a replacement.

@alya
Copy link
Contributor

alya commented May 12, 2023

Similarly, a screenshot would help review the tooltip question.

}
return $t({
defaultMessage: "You do not have permission to post in this stream.",
});
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to avoid the code duplication that we have for these strings. One idea would be to extract a compose_recipient.get_posting_policy_error_message function that returns "" or the error string depending on whether you're allowed to send messages, and use that both here and in check_posting_policy_for_compose_box.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay what I commented earlier was pending for 10 hours and now got deleted.

I was saying that one thing to notice is I have created a new function in stream_data which is get_sub_by_id, to avoid 3 calls to get can_post_messages_in_stream as "get stream name", "get stream" and "get can_post_messages_in_stream", Now it is using 2 calls.

Should I do this in a separate commit?

@brijsiyag
Copy link
Member Author

brijsiyag commented May 12, 2023

@alya , I have updated Screenshots. I was talking about tooltip in first Screenshot, as there is too empty space at end which gives some odd look.

@alya
Copy link
Contributor

alya commented May 12, 2023

Got it. Sure, giving the tooltips a bit more space so that the text fits in English seems helpful (in a separate commit). Thanks!

@brijsiyag
Copy link
Member Author

Sure, So I am doing maxWidth to 350, which works on most of the zoom-ins and zoom-outs.

@brijsiyag brijsiyag force-pushed the dm_send_disabled branch 4 times, most recently from 0055e2b to 085e2a5 Compare May 15, 2023 17:33
@alya
Copy link
Contributor

alya commented May 15, 2023

Sure, So I am doing maxWidth to 350, which works on most of the zoom-ins and zoom-outs.

Thanks! You should post updated screenshots. :)

@timabbott
Copy link
Sponsor Member

This mostly lgtm but I'm going to defer merging until screenshots are posted. Thanks @brijsiyag!

@brijsiyag
Copy link
Member Author

brijsiyag commented May 16, 2023

Sure, So I am doing maxWidth to 350, which works on most of the zoom-ins and zoom-outs.

Thanks! You should post updated screenshots. :)

Ooh yes I should have, an another bug caught my attention and I forgot to do so.
Updated now !!

@brijsiyag
Copy link
Member Author

@timabbott , I have updated the code, PTAL.

@alya
Copy link
Contributor

alya commented May 16, 2023

The updated screenshots look good to me. @timabbott let me know if you'd like me to retest this PR.

@alya alya added the integration review Added by maintainers when a PR may be ready for integration. label May 16, 2023
@timabbott
Copy link
Sponsor Member

I got rid of get_sub_by_id in favor of directly calling sub_store.get(), which seems to have the same output; otherwise lgtm, marked to merge once CI passes. Thanks @brijsiyag!

(Please comment if you see any problem with my changes).

@timabbott timabbott enabled auto-merge (rebase) May 16, 2023 17:21
@brijsiyag
Copy link
Member Author

brijsiyag commented May 16, 2023

@timabbott , why I'm not able to see the changes in compose_recipient.js ?
Seems like you missed that, Should I push with updates ?

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.
Changes the tooltip max-width on the disabled send button
from 300px to 350px to remove the weird looking padding at
the end.
@timabbott
Copy link
Sponsor Member

Fixed.

@timabbott timabbott merged commit 17ec4f1 into zulip:main May 16, 2023
6 checks passed
Joelute added a commit to Joelute/zulip that referenced this pull request Sep 6, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
Joelute added a commit to Joelute/zulip that referenced this pull request Sep 7, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
Joelute added a commit to Joelute/zulip that referenced this pull request Sep 7, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
Joelute added a commit to Joelute/zulip that referenced this pull request Sep 7, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
timabbott pushed a commit that referenced this pull request Sep 21, 2023
After the changes in #25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: #21896.
Vector73 pushed a commit to Vector73/zulip that referenced this pull request Sep 27, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
ToBadForYou pushed a commit to ToBadForYou/zulip that referenced this pull request Oct 7, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
macieksarnowicz pushed a commit to macieksarnowicz/zulip that referenced this pull request Oct 16, 2023
After the changes in zulip#25572, users were no longer able to start a direct
message with bots if the organization disabled direct messages. However,
we should allow direct messages to bots regardless of the policy because
it's a useful interface for users to interact with various classes of
bots.

user_ids_string_to_ids_array was also modified to prevent cases where
the split function returned an array of [0] rather than [] when dealing
with a empty id string of "".

Fixes: zulip#21896.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when a PR may be ready for integration. release goal We'd like to resolve this for the current major release size: L
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants