Commit Graph

5074 Commits

Author SHA1 Message Date
N-Shar-ma 963e1412b5 typeahead: Add message view context to PM recipient suggestions.
Uptil now when composing PMs, only for @-mentions was the stream / topic
being viewed taken into consideration. The PM recipient suggestions were
unaffected by the current view.

Now this context has been added to the PM recipient suggestions as well,
ensuring consistent sorting of options across both typeahead menus, with
subscribers and recent posters to that stream / view getting priority.

When the view is not narrowed to a stream / topic, the PM suggestions
are sorted the same as before.

This PR has the same code changes discussed and made in #22630, with an
added test suite.

Fixes: #21645.
2023-01-18 15:50:04 -08:00
Lauryn Menard 1e96c6e9a2 settings-profile: Move tooltip for name change disabled to field.
Moves the tooltip when name changes are disabled to be shown on
hovering over the full name input field. Removes the question icon
that previously showed the tooltip on hover.
2023-01-18 13:39:16 -08:00
Lauryn Menard 578af48632 settings-modal: Only update display if overlay loaded in DOM.
If the personal / organization settings overlay has not been
loaded to the DOM in the user's session, then there's no need
to update the overlay display for changes to the user's
permissions to update their name, email or avatar.

So we check for the relevant element ids before updating the
overlay display when the user's role or these organization
settings change, and return early if they are not present in
the DOM.
2023-01-18 13:38:09 -08:00
N-Shar-ma 25eff08324 typeahead: Show the time typeahead irrespective of text before syntax.
Uptil now, on typing "<time" after some other autocompleteable token
like a mention or emoji, the timezone aware time typeahead would not
get triggered since the time syntax was checked after the earlier syntax
had been mistakenly used to (wrongly) tokenize the precursor text.

Now the code has been fixed to detect the time syntax the same way as
the rest: checking each character in the precursor text from end to
start, and tokenize it correctly.

Fixes: #23998.
2023-01-17 17:10:14 -08:00
Aman Agrawal 1f3367abfb message_list_view: Remove dead next_is_same_sender code.
The `next_is_same_sender` has no effect on the CSS of the message
displayed and the JS changes seem to have no effect too.

See cc8021a742 for more details.
2023-01-14 14:49:28 -08:00
Lauryn Menard 1a3b0edf4b account-settings: Disable deactivate account button when only owner.
Disables the deactivate account button in the user's account and
privacy settings tab if they are the only active organization owner.

Adds a tooltip when hovering on the deactivated button to let the
user know why the button is disabled.

The backend already returns an error for self account deactivation
requests if the user is the only organization owner.
2023-01-11 13:30:31 -08:00
Lauryn Menard eef22e4e04 settings-account: Make live update for avatar changes consistent.
The `settings-info-icon` with the tooltip for the user avatar
section was removed in commit 103db2afaf. This removes the changes
to that tooltip in `settings_account.update_avatar_change_display`.

Instead of hiding or showing the `image_upload_button` in that same
live update function, we now add or remove the `hide` class, which
in the previous commit has a specific CSS hover rule for the image
upload widget.

Also adds test coverage for the `is_admin` case for this setting
because administrators can always change their own avatar even if
the organization has disabled avatar changes.
2023-01-11 13:12:59 -08:00
N-Shar-ma 95b77c0c1a util: Add function `get_string_diff`.
The new function specifies the single minimal diff between 2 strings.
It takes in 2 string parameters and returns an array with 3 integers
where the 1st is the index where the difference starts and the 2nd and
3rd are the indices of the end of the diff in the 2 strings.
2023-01-06 16:53:57 -08:00
Lauryn Menard e7c6f35482 user-events: Update account settings display if `is_admin` is changed.
There are a few account settings that are possibly deactivated if
a user is not an administrator (email, name and avatar changes),
depending on the organization's policy for changing those settings.

When a user's role is updated to become (or no longer be) an admin,
the display for these account settings may need to be updated.

Adds `settings_account.update_account_settings_display` to the
functions called in `user_events.update_person` if the active
user's role is changed to or from an administrator role.
2023-01-04 16:26:21 -08:00
Anders Kaseorg bd884c88ed Fix typos caught by typos.
https://github.com/crate-ci/typos

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 11:09:50 -08:00
Lauryn Menard c50de056c9 settings-account: Move disable change email logic out of template.
Moves the complicated logic in `account_settings.hbs` for whether
to disable the change email button (and show the tooltip) to
`settings_data.ts`.

This update mirrors how similar realm settings are handled,
such as `realm_name_changes_disabled`, and means that the
`realm_email_changes_disabled` bool is added to `page_params.ts`.

Prep commit for moving the email changes disabled tooltip from
a separate question icon to the disabled button itself.
2022-12-30 17:54:00 -08:00
Lauryn Menard 782cc80d99 account-settings: Refactor change email button and modal class names.
Prep commit for updating tooltip from info icon to disabled button.
2022-12-30 17:54:00 -08:00
Zixuan James Li bec8e48616 muted_users: Pop muted_users from page_params.
This avoids accessing the global page_params directly.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-12-30 11:21:23 -08:00
evykassirer 3d4374f2a6 streams: Return early from can_post_messages_in_stream for spectators.
This code path isn't currently reached for the logged out "spectator"
view, but it will be in upcoming commits. This makes sure that case
is handled properly.
2022-12-15 17:26:04 -08:00
evykassirer 763dfbdcfb composebox_typeahead tests: Use zrequire for compose_ui. 2022-12-15 17:26:04 -08:00
evykassirer 53d8abe79b compose_state: Use stream_name() and topic() universally.
This change ensures that every call to find the stream name or topic
in the composebox is calling compose_state functions instead of directly
taking a value from an HTML element specified by a classname.

This has better code readability and abstracts away the classname,
and also makes it easier to change which classname we use (which
will be happening in an upcoming change as part of switching the
stream name field to a dropdown).

Note that this change means that the stream name will always be
trimmed, whereas before it was whatever the user had written even
if it had trailing whitespace. This shouldn't be an issue as far
as we (me + Tim) can tell, and also it will become irrelevant as
soon as the dropdown changes land.
2022-12-15 17:26:04 -08:00
evykassirer 7f9989003a compose_state: Break out stream_name() into separate getter and setter.
This code is equivalent, because the keep_leading_whitespace parameter
of get_or_set was never used for the stream name.

This addresses an open TODO and makes the code more readable.
2022-12-15 17:25:36 -08:00
Lauryn Menard 7c083edb96 narrow: Update narrow title for undefined filter views.
Updates `compute_narrow_title` to cover the two cases for views
with undefined filters: "All messages" and "Recent conversations".

Also, moves the call to `notifications.redraw_title` from
`set_narrow_title` and to `update_narrow_title`.
2022-12-15 13:05:22 -08:00
Lauryn Menard 7686bca385 narrow: Refactor logic for getting narrow title for browser/tab.
Creates a new function, `compute_narrow_title`, that returns a
string for the narrow title based on the current filter, so that
`update_narrow_title` can call that function, and then use the
returned string to set the narrow title.

Adds a node test for the new `compute_narrow_title` function for
cases that differ from the title generated by `filter.get_title`.
2022-12-15 13:05:22 -08:00
Anders Kaseorg c7851d9a00 node_tests: Fix failing stream_data test.
Commit 0bc47b1c77 (#23529) broke this.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-14 21:30:53 -08:00
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
Sahil Batra 5c833f0423 compose_ui: Revert changes for replace_syntax done in 1ca4566eb2.
This commit reverts the changes for replace_syntax in 1ca4566eb2
and we again use JS replace instead of replace from text-field-edit.

We do this change because replace from text-field-edit leaves the
replaced text selected, which we don't want. This change is
temporary and we can probably use replace method from
text-field-edit once this issue is fixed in upstream.
2022-11-17 08:29:11 -08:00
Tim Abbott 3aec5564eb popovers: Offer mark as unread regardless of fetch_status.
Now that we're using the new /messages/flags/narrow API endpoint, we
don't need this conditional.
2022-11-17 00:46:26 -08:00
Sahil Batra a0965d7335 activity: Use setTimeout instead of setInterval.
Instead of using setInterval to call send_presence_to_server
repeatedly, we now simluate setInterval using setTimeout.

This change helps us to avoid the condition likely related to resume
from suspend, when the browser tries to catch up by running a large
number of "missed" copies of the setInterval hook, causing the server
to rate-limit the client.

Fixes #23438.
2022-11-14 12:37:14 -08:00
Aman Agrawal fbe9a9e539 left_side_userlist: Remove feature from frontend.
Fixes #23517.

While this feature was added to Zulip very early, it has been troubled
for most of that time; it never looked great visually, had a lot of
implementation complexity around resize.js, and has a weird model (a
setting that changes the UI only in certain window sizes).

This option is not commonly used; while a significant portion of users
have it enabled, many of them just don't use window sizes where it
actually has an effect. So it's not clear that it will be missed if
removed; we got very few bug reports when it was completely broken for
a few days after we first integrated the new left sidebar private
messages design.

Even with it no longer being broken, it does not work very well with
the addition of the new PMs section in the left sidebar. (Having two
scrollbars in the sidebar looks quite awkward.) The new private
messages section in the left sidebar also addresses some of the use
cases for always keeping the Users list always visible, even in narrow
windows.

This option is only removed from frontend for now. To make this
decision easily reversible, the backend code of this feature
is still kept.
2022-11-14 12:23:55 -08:00
Tim Abbott 1ca4566eb2 compose: Use text-area-edit for syntax replacements.
Fixes #23284
The basic approach used by `text-area-edit` is same as we were
using, so there is no real change. There are some nice checks
in `text-area-edit` which we don't do that helps us avoid
common bugs.
2022-11-10 16:15:33 -08:00
Sahil Batra 6ad8e276de settings: Refactor code for realm message retention setting.
This commit refactors the code for realm message retention
setting to make it more similar to code for other time-limit
realm settings. There are still separate functions for the
message retention setting but they are similar to that of
other time-limit settings and can probably help us to
deduplicate the code in future. This refactor also helps
us in reusing some code for stream message retention
setting for changes in #23013.

This commit also fixes a bug where save-discard widget
not being hidden when resetting the setting to original
value. This can only be reproduced when the original
setting value is "retain_forever".

Following changes have been done in this commit -

- Added data-setting-widget-type attribute which is set to
"message-retention-setting" similar to "time-limit" value for
message edit and delete limit settings.

- Added get_message_retention_setting_value function similar
to get_time_limit_setting_value function which is used by
get_input_element_value.

- Removed "message-retention" block from
get_complete_data_for_subsection and the message retention
setting is now added to request data in populate_data_for_request
itself using data-setting-widget-type attribute.

- Updated id and class of elements to support the above changes.
2022-11-10 16:13:49 -08:00
Rixant Rokaha dd39a9747d left_sidebar: Hide stream section separator when there is only one.
Showing section separators in the left sidebar ("Pinned streams",
"Active streams", etc.) is unnecessary when there is only one section,
and can feel confusing. We should show the separators only when there
is more than one section present.

Fixes #22843.
2022-11-09 17:34:58 -08:00
Lauryn Menard aac76bb185 narrow-banner: Update empty title for "pm-with" multiple users.
Instead of using "these people", we use "these users".

Note that the "pm-with" single user case has already been updated
to show the user's full name instead of "this person".
2022-11-08 11:07:38 -08:00
Lauryn Menard 6b4ab21562 narrow-banner: Exclude bots when checking org sending pms policy.
Private messages between a user and a bot are not restricted by
the organization's policy setting for sending private messages.
So, for the empty banner text, we set the default title for
a single bot for the "pm-with" narrow.

Group private messages that include a bot are restricted by
this policy setting, so those messages stay the same.

Also, since bot's aren't people, we update the text for valid
"pm-with", "sender" and "group-pm-with" operands to include the
user's full name in the title.

When there are multiple people in the "pm-with" narrow, we still
send a generic "these people" message instead of listing all the
users in the narrow.

Finally, we make the default message end in a period instead of
an exclamation mark.
2022-11-04 14:37:45 -07:00
Lauryn Menard f06143bc7c narrow-banner: Check private message policy for empty narrow title.
For narrows that focus on private messages ("is:private", "pm-with",
"group-pm-with"), we want to check the organization private message
policy and set an empty narrow title that matches that policy.

For these narrows with invalid users, we prioritize that message
for the empty narrow title, instead of the private message policy
message.

Fixes #21889.
2022-11-04 14:37:45 -07:00
Julia Bichler 74f2d8ca7f stream settings: Allow modifying of email address.
This allows the user to modify the stream email address
by adding or removing tags before copying.

Fixes part of #19519.
2022-11-04 14:22:27 -07:00
Lauryn Menard 09c4e2f662 compose-actions: Load compose box for PMs based on org policy.
If an organization has disabled sending private messages, we do not
want to load the compose box automatically for "pm-with" narrows.

We still open the compose box for private messages narrows with a
single bot user as this is not limited by this organization setting.

Also, if the compose box was active/started in a narrow with a bot
user, but had no content, then we want to close/cancel that in a
new narrow with a person or group.
2022-11-04 14:08:25 -07:00
Aman Agrawal c41c94e36e recent_topics: Improve behaviour of inplace rerender.
We used to hide and show topic rows in the DOM when topics are
updated. This resulted in incorrect calculations in the length of
visible topics. As a consequence, focus is sometimes set to hidden topic.
Removing hidden topics from DOM helps us keep
the calculations correct.

The fixes bugs related to focus being lost when trying to mute
or mark as read the last row.
2022-11-04 13:59:20 -07:00
Aman Agrawal ef067eafad topic_list: Move topic filter out of topics list `ul`.
Instead of topic filter box being a part of the list when keeps
updating, we move it out and fix its position.

This should reduce rendering time of topics list and provide
a smoother experience to users when waiting for topics list to
load.
2022-11-04 13:40:46 -07:00
Anders Kaseorg 3a718d786f js: Fix type issue with FormatJS rich text elements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:48:40 -07:00
evykassirer 6ef5736bfe drafts: Rename undefined draft topics to empty string.
This fixes an error state that came out of #22094.
The code causing the error was fixed in #23238 but some
drafts still have undefined topics which has some strange
side effects. One day we'll have typescript help catch
this kind of thing!

More details on CZO: https://chat.zulip.org/#narrow/stream/9-issues/topic/live.20update.20issue.20with.20drafts/near/1457913
2022-11-02 16:36:36 -07:00
evykassirer 919f08d80f drafts: Catch and log error caused by drafts with undefined topics.
This is a bandaid fix to an error that came out of #22094.
The error was fixed in #23238 but some drafts still have
undefined topics which is raising this error.

More details on CZO: https://chat.zulip.org/#narrow/stream/9-issues/topic/live.20update.20issue.20with.20drafts/near/1457913
2022-11-02 16:20:40 -07:00
Rohitt Vashishtha 1db901cded keydown_util: Check Enter events properly for IME edge cases.
We now check whether an IME is currently composing and do not
process any such key==="Enter" events as the Enter/Return key.

Fixes #22062.
2022-11-02 15:42:42 -07:00
Tim Abbott a1aba2869b settings_org: Fix exception processing stream type events.
The previous check looked at whether the settings overlay as a whole
was open, not whether the specific panel we're going to update was
rendered.

The other code paths calling from server_events_dispatch into this
module already correctly check meta.loaded.
2022-11-02 11:43:07 -07:00
Lauryn Menard af00fd05b2 narrow-banner: Check user exists with "group-pm-with" empty narrow.
When "group-pm-with" is the first operator and setting an empty
narrow banner, check that the operand matches a user and set the
title based on whether the user exists or not.
2022-11-01 08:23:43 -07:00
Lauryn Menard 0901ccdb47 filter: Show pm_with title with near narrow links.
Updates the `filter.get_title` logic to return the list of users
for narrows that include the pm_with and near operators. That way
the browser/tab title remains the same for these views.
2022-10-28 17:41:47 -07:00
Zixuan James Li 79b8219797 unread: Pop unread_msgs from page_params for initialization.
This change is made so that we are not accessing the global page_params
directly. Note that we also rename unread_msgs to params to match other
modules that follow this pattern.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-10-27 13:03:54 -07:00
Tim Abbott d47f29c2d6 reactions: Implement display_emoji_reaction_users setting.
This setting provides a more ergonomic experience when viewing a
message where only a small number of emoji reactions are present; you
no longer need to hover over the reaction to see who reacted, which is
often quite important to understanding what it means.

We added this setting (visible in the development environment only,
and implemented on mobile) a few months ago; so to complete this
feature, we just need to add the frontend rendering/live update logic
and publish it.

As documented in the code comments, the current rule is "messages with
3 or fewer reactions" for which messages will display the names of the
users reacting.

The previous set_reaction_count API made sense when the display of a
given reaction was a pure function of its data. However, we will soon
be making it a function of the total number of reactions on the
message.

Thus, view functions to update reaction display now need to call a
shared update_vote_text_on_message function in all code paths, even
code paths like "add the first vote for a reaction" and "remove the
sole vote of a reaction" which previously did not need to call
set_reaction_count.

Fixes #20890.
2022-10-27 12:41:51 -07:00
Tim Abbott 98c478d994 reactions: Pass full message objects to view functions.
This is not the cleanest API, but it will be necessary in the next
commit in order to update the message's rendering of other emoji.
2022-10-27 12:41:51 -07:00
Tim Abbott 02b670fa66 reactions: Use clean_reaction_object API for view functions.
This substantially reduces the complexity of parameter passing in the
reactions rendering code path.
2022-10-27 12:41:51 -07:00
Aman Agrawal 45f35a464e stream_list: Reduce stream header's height when scrolling elt into view.
Since stream header is now sticky, we need to reduce it's height
when calculation position of the element we want to scroll into view
so that it doesn't hide under the sticky header.
2022-10-26 13:47:08 -07:00
Aman Agrawal 470553b457 left_sidebar: Fix some PMs not being displayed when PMs are zoomed in.
We added sticky headers above the PM list but forgot to subtract
it from the max-height of the scrollable container.
2022-10-26 13:47:08 -07:00
jai2201 6f9e97921d pm_section: Create collapsible private messages section.
This commit introduces the change of rendering private messages
section as collapsible, whose data-fetching logic came with zulip#21357.

We now have separated out `Private messages` from `top_left_corner`
section and shifted it below the `global_filters` in a different
separate section along with stream list with common scroll bar
in left-sidebar.

The new PM section will be opened by-default on loading the page
and will have a toggle-icon in its header, clicking on which makes the
section collapse/expand accordingly.

In default view, only recent 5 PM threads would be shown
and would append the active conversation as the 6th one at last
if not present in those 5, similar to how topics list work.

In PM section with unreads, a maximum of 8 conversations
would be shown and rest of them would be hidden behind
the 'more conversations' li-item, clicking on which takes
to the zoomedIn view of PM section where all the present
PM threads would be visible and rest of the sections of left-sidebar
will get collapsed.

Fixes #20870.

Co-authored-by: Aman Agrawal <amanagr@zulip.com>
2022-10-26 13:47:08 -07:00
Lauryn Menard 95aa9a4f83 compose-box: Remove reset max-height calculation for preview click.
Removes call to reset_compose_message_max_height when clicking on
the markdown preview button, which due to the `#compose` div element
momentarily shrinking to be empty, caused the calculation of the
max-height to grow larger on each click.

Also refactors reset_compose_message_max_height to use the height
from `getBoundingClientRect`, which defaults to zero when empty.

And fixes a small discrepancy in how max-height is applied to
a div element vs a textarea element, so that the visible height
doesn't change between the preview and write modes in the compose
box.

Fixes #23277.
2022-10-25 13:49:29 -07:00
Lauryn Menard e66f125ee6 recent-topics: Update hash for view to be "#recent".
Updates the hash used for the recent conversations view to be
"#recent" instead of "#recent_topics".

We will need to keep the logic for handling "#recent_topics"
permanently because users potentially have messages from
Welcome Bot with links to that hash.

Including "recent_topics" as a web_public_allowed_hash in
hash_util.js can be changed once self-hosted servers cannot
upgrade directly to Zulip 5.x from the current version.

Fixes #23132.
2022-10-25 11:03:44 -07:00