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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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`.
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`.
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.
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.
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.
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.
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.
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.
"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>
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>
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>
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>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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>
`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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
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.
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.
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.
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>
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.
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.
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>
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.
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.