Commit Graph

5004 Commits

Author SHA1 Message Date
evykassirer 1b0a14bf40 compose banner: Add specific functions to clear warnings and errors.
Instead of removing all compose banners, we now remove only warnings
and errors -- this makes no difference right now, but this change
will allow us to add other compose banners that are cleared at
different times.
2022-12-14 20:36:07 -08:00
N-Shar-ma 38587b79b9 compose: Always preserve cursor position post replacement in a textarea.
Refactored (moved) the code for preserving the cursor's initial logical
position from `quote_and_reply()` in `compose_actions.js` which calls
`replace_syntax()` directly into `replace_syntax()` in `compose_ui.js`.
This ensures that anytime text in a textarea is replaced, the original
cursor position is always restored.

Earlier, this was needed to be done separately, and missing that would
lead to bugs with the cursor unexpectedly jumping on replacement.

Fixes: #23863.
2022-12-14 12:40:51 -08:00
Sahil Batra d0626bbaef message_edit: Remove get_editability function.
This commit removes get_editability function and we can instead
use is_content_editable and is_topic_editable/can_move_message
functions to check the permissions. We can remove get_editability
since there is no longer a sort order to the possibilities and
it is not necessary that if a user has permission to edit content
then they can edit the topics also.

So, this commit adds is_message_editable_ignoring_permissions
check to is_content_editable and also modifies the tests accordingly.
2022-12-13 23:11:50 -08:00
Sahil Batra 939a6edf0f settings: Rename helper function to check who can edit topics.
This commit renames "can_edit_topic_of_any_message" function
in models.py to "can_move_messages_to_another_topic" and
"user_can_edit_topic_of_any_message" function in settings_data.js
to "user_can_move_messages_to_another_topic".

This change is done since topic editing permission does not
depend on message sender now and messages are considered same
irrespective of whether the user who is editing the topic had sent
the message or not. This also makes the naming consistent with
what we use for the label of this setting in webapp and how we
describe this action in help documentation.
2022-12-13 23:11:50 -08:00
Sahil Batra 24a1f7b792 message_edit: Topic editing permission should not depend on message sender.
This commit changes the topic edit permssions in webapp to not depend
whether the user editing the message had sent the message or it was sent
by someone else. Backend changes were done already in previous commits.

Previously, we always allowed topic edits when the user themseleves had
sent the message not considering the edit_topic_policy and the 3-day time
limit. But now we consider all messages as same and editing is allowed only
according to edit_topic_policy setting and the time limit of 3 days in
addition for users who are not admins or moderators.
2022-12-13 23:11:50 -08:00
Sahil Batra e6ec2badb5 message_edit: Make topic editing independent of allow_message_editing.
We now allow editing stream and topic of message even if
allow_message_editing if False using webapp given that is
allowed as per other topic and stream edit specific settings.

Fixes a part of #21739.
2022-12-13 23:11:50 -08:00
Sahil Batra ad9a7d2e06 message_edit: Add "Nobody" option for move_messages_between_streams_policy. 2022-12-13 23:11:50 -08:00
Sahil Batra 02eee3a04f message_edit: Add "Nobody" option for edit_topic_policy setting. 2022-12-13 23:11:50 -08:00
Yuri Sulyma 911b3b5365 ts: Convert util.js to TypeScript; add (Raw)Message type in types.ts.
Co-authored-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:23:29 -08:00
Zixuan James Li b757c1a9b6 util: Move is_pm_recipient to compose_fade_helper.
"is_pm_recipient" is not supposed to be called with an arbitrary
recipient object which might have "to_user_ids" being undefined.
Since this helper is only used with focused_recipient in
compose_fade_helper, we move it there.

Note that the helper is no longer separately tested. It is now covered
by the test case of "compose_fade_helper.would_receive_message".

(See
5e74a8d0cc/static/js/compose.js (L156-L162))

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:20:36 -08:00
Zixuan James Li 55793cb4d5 util: Stringify possibly undefined values.
This avoids "@typescript-eslint/restrict-template-expressions" when we
convert util.js to util.ts.

Note that prettier would otherwise split the first template literal
expression in half if we don't start a newline.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:20:36 -08:00
Zixuan James Li a63d3507ac node_tests: Add missing stream_id to msg.
.msg of a message container should have the "stream_id" property when it
is a stream message.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:20:36 -08:00
Zixuan James Li a3a0103d86 markdown: Calculate linkifier precedence in topics.
This uses the linkifier index among the list of linkifiers in the
replacement as the priority to order the replacement order for
patterns in the topic. This avoids having multiple overlapping matches
that each produce a link.

The linkifier with the lowest id will be prioritized when its pattern
overlaps with another. Linkifiers are prioritized over raw URLs.

Note that the same algorithm is used for local echoing and the
backend markdown processor.

Fixes #23715.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:16:20 -08:00
Zixuan James Li 4602c34108 markdown: Correctly retrieve indices for repeated matches.
The same pattern being matched multiple times in a topic cannot be
properly ordered using topic_name.find(match_text) and etc. when there
are multiple matches of the same pattern in the topic.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-13 15:16:20 -08:00
Tim Abbott af54293ff8 Revert "drafts: Test that sending a drafted message deletes the draft."
This test was failing nondeterministically.

This reverts commit f7c2b90dc2.
This reverts commit a972804de3.
2022-12-13 10:34:55 -08:00
Aman Agrawal 36354f0625 message_list: Remove message_list.narrowed from code. 2022-12-12 18:04:11 -08:00
Tim Abbott 5f4faaf22c message_fetch: Pass msg_list to load_messages_for_narrow.
This tweak makes the code easier to reason about and may also help
generalize the codebase to support maintaining multiple message lists.
2022-12-12 08:45:58 +00:00
evykassirer a972804de3 drafts: Fix flaky test by waiting for compose box to clear.
Fixes flaky test mentioned on CZO here:
https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/main.20failing/near/1478126
Test was introduced here: #23820.

The compose box clear happens after the message is sent,
and the test wasn't consistently waiting for the compose
box to successfully clear. This change forces a wait.
2022-12-11 23:23:33 -08:00
evykassirer f7c2b90dc2 drafts: Test that sending a drafted message deletes the draft. 2022-12-11 17:45:55 -08:00
Riken Shah d0c7252c51 drafts: Rename two functions in puppeteer tests for better clarity.
Soon there will be another way to restore a message draft,
and this rename helps specify which kind of restoring is
happening here.
2022-12-11 17:45:38 -08:00
David Rosa a153e9232e Rename "operators" to "filters" in "Search operators" reference.
Changes all the uses of the word "operators" to "filters" in the
in-app "Search operators" reference to align with the updated help
center documentation.

Fixes #23767.
2022-12-09 13:52:13 -08:00
Lauryn Menard 6b3fbab520 narrow-banner: Update default empty banner text to be more general.
Updates the default empty narrow banner text to be more generally
applicable, particularly in the case when all messages have been
moved to a new topic.
2022-12-08 13:01:33 -08:00
Sahil Batra ee04677d4b settings: Remove ID from discard button in save-discard widget.
This commit removes ID from discard button in save-discard widget.

Generating IDs using variables results in difficulty to grep
the code and we can anyway access the discard button by using
ID of the settings-subsection-parent div. Also, we do not use
ID to access this button, so we can change this safely.
2022-12-07 10:23:47 -08:00
Sahil Batra 821a409c8b settings: Remove ID from save button in save-discard widget.
This commit removes ID from save button in save-discard widget.

Generating IDs using variables results in difficulty to grep
the code and we can anyway access the save button by using
ID of the settings-subsection-parent div.
2022-12-07 10:23:47 -08:00
Sahil Batra 4b46f08b5f settings: Use subection-parent div to get subsction.
We used id of save-button to get subsection parameter
which is passed to get_complete_data_for_subsection.

This commit now changes it to instead get subsection
from settings-subsection-parent div. We also change
the id of settings-subsection-parent div of organization
joining settings in this commit to be a more reasonable
name as per this change.
2022-12-07 10:23:47 -08:00
Anders Kaseorg 8b6bd961e6 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-07 09:55:05 -08:00
evykassirer e9045dcd58 compose: Rename compose_error to compose_banner.
It no longer handles only error messages, but banners of multiple
types.
2022-12-06 15:43:49 -08:00
evykassirer f9c72701c6 compose: Migrate compose_private_stream_alert to use compose_banner.
This is part several updates for #22524.

Notes:

* data-stream_name isn't needed in the template (before or after),
  since there is not even an action button that could use it.
2022-12-06 15:43:34 -08:00
evykassirer 086f02a3ab compose: Migrate compose_not_subscribed to use compose_banner.
This is part several updates for #22524.

This commit also removes `compose_error.hide()` since there is only
one remaining use of it (which has been replaced by the contents of
`hide()`). Eventually `#compose-send-status` should be replaced
fully in a future PR, after we rewrite the upload banner to use
the new banner template.

Testing note: I removed the test test_compose_not_subscribed_clicked
since it heavily relies on the old way of rendering banners and is too
UI-focused (instead of logic focused) for me to feel like it's worth
testing that the banner is removed when clicking the button.
2022-12-06 15:43:34 -08:00
evykassirer 8ced075643 compose: Migrate compose-all-everyone to use compose_banner.
This is part several updates for #22524.

Testing note: I removed the test test_compose_all_everyone_confirm_clicked
since it heavily relies on the old way of rendering banners and is too
UI-focused (instead of logic focused) for me to feel like it's worth
testing that the banner is removed when clicking the button.
2022-12-06 15:43:34 -08:00
evykassirer ab5d088188 compose: Migrate compose_invite_users to use compose_banner.
This is part several updates for #22524.

Testing note: I removed the tests test_compose_invite_users_clicked
and test_compose_invite_close_clicked, since they heavily relied on
the old way of rendering banners and were too UI-focused (instead of
logic focused) for me to feel like it was worth testing that the
banners removed when clicking the buttons.
2022-12-06 15:43:34 -08:00
evykassirer 89230ba554 compose_validate test: Rename mentioned to mentioned_details for clarity. 2022-12-06 15:43:34 -08:00
evykassirer f1c6fc13e7 compose: Migrate generic error to use shared banner template.
Error banners were rendered in a different place than warnings.
Now compose errors and warnings share the same template and styling
in compose_banner.hbs

Testing notes:
* I removed test_message_overflow since it seemed not to test
  anything that test_check_overflow_text wasn't already testing.
* private_message_recipient() can't be called to set emails to non-valid
  emails, so `invalid_recipient` cannot be tested (and is likely very
  difficult to trigger in production, if possible at all).
2022-12-06 15:43:33 -08:00
evykassirer 85cbd324eb compose: Create shared compose banner and use for resolved topic warning.
This is the beginning of a fix for #22524 which converts several
banners to a new style. As a part of that set of changes, this
commit creates the shared template and warning styling. The
resolved topic warning was picked (for no particular reason)
to migrate first. Further commits updating other banners
to follow.
2022-12-06 15:42:07 -08:00
evykassirer 4b175514aa emoji: Remove variation selector when generating emoji.
Fixes #23625.

The U+FE0F character was appearing in the data supplied by
emoji-datasource-google, but isn't in the CLDR data. By
removing that variation selector character, all remaining
emoji (that were previously marked as "not found in custom
emoji name maps, but also not found in CLDR data. Skipping.")
are now supported.
2022-12-06 12:33:59 -08:00
Aman Agrawal eb45925b1a actions_popover: Use tippyjs instead of bootstrap to display popover.
Fixes #23494
Popover now automatically displays on left when there is not
enough space top or bottom of the reference element.
2022-12-06 09:58:40 -08:00
Aman Agrawal 38a4751b7b recent: Sort PM recipients by their last sent message id.
Fixes #23563
2022-11-29 11:29:12 -08:00
Aman Agrawal c0ad0b3b10 recent_senders: Return senders in most recent sender first order.
Since the library is named `recent_senders`, most recent sender
first order is expected from this library.
2022-11-29 11:29:12 -08:00
Aman Agrawal d3b8f6965c recent_senders: Rename process_message_for_senders.
Since it only processes stream messages, change its name to
`process_stream_message`.
2022-11-29 11:29:12 -08:00
Aman Agrawal 77c7fe4699 Revert "compose_ui: Revert changes for replace_syntax done in 1ca4566eb2."
This reverts commit 5c833f0423.
2022-11-27 13:32:02 -08:00
Anders Kaseorg 2cf64b569e people: Fix misleading comments and tests for utcToZonedTime.
The reason utcToZonedTime would return an invalid Date (i.e. ‘new
Date(NaN)’) is because we passed in an invalid timezone.  Fix the
comments and tests to reflect this; remove unnecessary mocking and the
misleading ‘instanceof Date’ check.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-24 09:18:11 -08:00
Aman Agrawal 69d2684126 people: Verify `utcToZonedTime` returns a `Date` before formatting it.
`current_date` being invalid here could result in `user card`
not being displayed to users. So, it is important to verify that
the date is valid so that we don't run into any errors.

This fixes (unverified) an issue where user card was not being
displayed to some users on Zulip Desktop app because `current_date`
was not valid.
2022-11-23 12:03:52 -08:00
Sahil Batra 8241e2d353 settings: Refactor code for realm message retention setting.
This commit refactors the code for realm message retention
setting which will help us in reusing some code when adding
save-discard widget for stream settings in further commits.

Following changes have been done in this commit -

- Renamed the "retain_for_period" option to "custom_period"
and "retain_forever" option to "unlimited" to match with
the stream settings options such that we can reuse the code.

- Updated set_message_retention_setting_dropdown such that
it can be used for stream message retention setting as well.
2022-11-22 17:14:35 -08:00
Sahil Batra 30f4e67aaa settings: Rename "org-subsection-parent" class to "settings-subsection-parent".
This commit renames the "org-subsection-parent" class used for
organization settings subsections to "settings-subsection-parent"
such that we can use same for the stream settings and avoid
duplicating code for handling save-discard widget which will be
added in future.
2022-11-22 17:14:35 -08:00
Sahil Batra e9316499cb settings_org: Pass subsection elem to get_subsection_property_elements.
We passed subsection elem to get_subsection_property_elements function
in all cases except the one when calling from discard button click
handler and we passed the input elem instead in that case.

This commit changes the code to pass subsection element directly
in the discard button click handler as well such that we can use
get_subsection_property_elements function for the stream settings
code and do not find the subsection element inside the function.
2022-11-22 17:14:35 -08:00
Ujjawal Modi 23f2d44c6d settings: Improve success feedback for deleting alert words
We add the alert word that was removed to the banner text, and also
reorder a bit for clearer UI.

Fixes #22813
2022-11-22 16:23:56 -08:00
Tim Abbott 2a3f708e9a gear_menu: Delete unused Bootstrap tabs code.
Before 2017, Zulip's manage streams and settings UIs were tab in the
same pane position as our current message feed and recent topics.

That original implementation was implemented using Bootstrap tabs;
while it hasn't been in use for years, we had a bunch of stale code
related to it leftover in this module.
2022-11-22 13:55:21 -08:00
Tim Abbott f29e748e3b puppeteer: Stop looking for tab-pane elements.
These haven't been a part of Zulip's navigation in several years, so
it's just a reference to a useless extra CSS class.
2022-11-22 13:55:21 -08:00
Lauryn Menard 024932a489 narrow-banner: Fix empty narrow banner titles with user's full name.
Fixes an issue introduced in 6b4ab21 when we started using the
user's full name for empty narrow titles in a single operator
narrow of either "pm-with", "group-pm-with" or "sender".

For these empty narrow titles, any ', & or < characters in the
user's full name are not escaped.
2022-11-22 11:58:21 -08:00
Anders Kaseorg eb2c822d3f eslint: Enable object-shorthand avoidExplicitReturnArrows option.
This is equivalent in the absence of ‘this’ (which ESLint knows to
check for).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-17 16:48:44 -08:00