Commit Graph

50916 Commits

Author SHA1 Message Date
Lalit 915b6cd9e7 js: Break cyclic dependency between `admin.js` and `settings.js`.
There was a direct dependency between `admin.js` and `settings.js` which
was due to the fact that we needed to call `build_page` of both modules
in each other's `launch` function.

This is solved by lifting those `build_page` calls up from both modules to
`hashchange.js` which is the module which calls the `launch` function
of both modules.
2023-04-19 16:41:49 -07:00
Hardik Dharmani 98176ddb57 left sidebar: Improve tooltip for show_all_private_messages.
Switch to a full keyboard-shortcut advertising tippy tooltip for
show_all_private_messages in left sidebar by adding a class
`.tippy-left-sidebar-tooltip` which adds tooltip with LONG_HOVER_DELAY
and default placement right with fallback placement equal to bottom.

Fixes part of #24311.
2023-04-19 16:21:17 -07:00
Hardik Dharmani bfdd9adaa4 tooltips: Add tippy tooltips for all_messages, recent_topics, and drafts.
Added tippy tooltips for all_messages, recent_topics, and drafts
in left sidebar by adding class `.tippy-left-sidebar-tooltip`
which add tooltips with LONG_HOVER_DELAY and default placement right
with fallback placement equal to bottom.

Fixes part of #24311
2023-04-19 16:16:08 -07:00
Hardik Dharmani de6bca9fc5 tooltips: Add new tippy tooltip class for left sidebar elements.
Added new tippy tooltips class `.tippy-left-sidebar-tooltip`
which add tooltips with `delay: LONG_HOVER_DELAY`, appended to body,
and default placement right with fallback placement equal to bottom.

Fixes part of #24311
2023-04-19 16:16:07 -07:00
Hardik Dharmani a32c30e34c tooltips: Remove the title attribute for Mentions, Starred_messages.
This commit removes tooltips from the Mentions and Starred messages
as they do not advertise any keyboard shortcuts and do not provide
any additional information beyond what is already visible in the UI.

Fixes part of #24311
2023-04-19 16:15:06 -07:00
Hardik Dharmani ab70df5f44 tooltips: Change compose-send-button tooltip dynamically.
Added a tippy tooltip in `tippyjs.js` that delegates to
`#compose-send-button`. Content of tippy tooltip is changed
dynamically as per value of `user_settings.enter_sends`.
`user_settings.enter_sends` returns true if send shortcut is
`enter` and flase if shortcut is `Ctrl + Enter`.

Fixes #24619
2023-04-19 16:13:29 -07:00
Alya Abbott 0c12a3bcb4 portico: Remove Senior Frontend Engineer position from `/jobs` page.
Also add a note about reaching out to us, since there are no open
positions remaining at this time.
2023-04-19 16:07:46 -07:00
Tim Abbott 262e8c8e8d events: Fix live update when deleting a starred message.
Previously, we didn't notify the starred messages code path when
processing the event that a message was deleted, resulting in the
displayed counter potentially being stale until the app is reloaded.

Fixes #25190.
2023-04-19 12:43:13 -07:00
Zixuan James Li 05a3456581 settings: Use url_template for internal names.
This replaces any "url_format_string" or "url_format" with
"url_template" for the linkifier settings, including HTML ids, template
variables, and etc.

This is not affected by any external API changes.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li 6f42542320 migrations: Remove filter_format_validator.
This removes the validator argument for 0423_realmfilter_url_template,
which do not really alter the database schema. It otherwise fails
the migration because the filter_format_validator function is removed.

Migration 0094_realm_filter_url_validator is modified because we can no
longer refer to filter_format_validator.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li 032e6f8cb4 linkifier: Update edit_linkifier command to use url_template.
This is mainly updating the variable names and relevant docstrings
without actual change to the behavior of the command.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li 268f858f39 linkifier: Support URL templates for linkifiers.
This swaps out url_format_string from all of our APIs and replaces it
with url_template. Note that the documentation changes in the following
commits  will be squashed with this commit.

We change the "url_format" key to "url_template" for the
realm_linkifiers events in event_schema, along with updating
LinkifierDict. "url_template" is the name chosen to normalize
mixed usages of "url_format_string" and "url_format" throughout
the backend.

The markdown processor is updated to stop handling the format string
interpolation and delegate the task template expansion to the uri_template
library instead.

This change affects many test cases. We mostly just replace "%(name)s"
with "{name}", "url_format_string" with "url_template" to make sure that
they still pass. There are some test cases dedicated for testing "%"
escaping, which aren't relevant anymore and are subject to removal.
But for now we keep most of them as-is, and make sure that "%" is always
escaped since we do not use it for variable substitution any more.

Since url_format_string is not populated anymore, a migration is created
to remove this field entirely, and make url_template non-nullable since
we will always populate it. Note that it is possible to have
url_template being null after migration 0422 and before 0424, but
in practice, url_template will not be None after backfilling and the
backend now is always setting url_template.

With the removal of url_format_string, RealmFilter model will now be cleaned
with URL template checks, and the old checks for escapes are removed.

We also modified RealmFilter.clean to skip the validation when the
url_template is invalid. This avoids raising mulitple ValidationError's
when calling full_clean on a linkifier. But we might eventually want to
have a more centric approach to data validation instead of having
the same validation in both the clean method and the validator.

Fixes #23124.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li ab53e8d3e6 migrations: Backfill url_template from url format string.
This is implemented by replacing all matches of "%(var_name)s" in a URL
format string with "{var_name}". Since we do want to ensure that the
templates aren't broken after this migration, a RuntimeError is raised
to let the maintainer know that certain linkifier cannot be converted
automatically if it does not pass the uri_template.validate check.

Also, we need to escape "%%", which is used to represent "%" in the old
format string syntax, as well as "{" and "}", which is a part of the
URL template syntax.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li a19c80df43 linkifiers: Add url_template field.
This will later be used to expand matching linkifier patterns.
Making it nullable for now, but we will make it required in
the APIs.

As a part of this transition, we temporarily make url_format_string
nullable as well, which will be later removed. This allows us to
switch to populating url_template without caring about passing
url_format_string.

Note that the validators are imported in the migration because Django
otherwise diffs it and considers the schema to be different, generating
a migration, failing the "tools/test-migrations" test.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li 8b43a50a78 requirements: Add uri-template.
This is later used for supporting RFC 6570 URI Template in place of the
URL format string that we were using for linkifiers.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
palashb01 acb4d7efa6 recent: Add support for unmuted topics within muted streams.
This commit refactors the logic of message filtering for
'Recent conversations' narrow.

Previously, we used to filter the recent conversations messages
based on the state of the stream and topic. If the stream or topic
was muted, we would avoid displaying the message. However, with
the new changes, we check if the topic is unmuted before applying
the aforementioned condition. If the topic is unmuted, we add the
message to the all 'Recent conversations' narrow.

Fixes part of: #24243
2023-04-19 10:05:48 -07:00
Alex Vandiver ed4de6da4a migrations: Add a migration to fix invalid deleted user emails.
208c0c3034 fixed this for new deleted users, but left existing users
with potentially invalid email addresses.  This is problematic if the
realm is ever exported and re-imported, as the addresses will not
validate.

Add a migration which attempts to fix these invalid email addresses.
2023-04-19 10:01:03 -07:00
Aman Agrawal 5f0fa1b730 compose: Fix send later tooltip being cut by compose box container. 2023-04-19 09:43:50 -07:00
Aman Agrawal 1b89ab8095 tippy: Add a short delay to narrow to topic tooltip. 2023-04-19 09:43:50 -07:00
Alex Vandiver 7dc7962c04 zulip-puppet-apply: Any resources failing to apply should exit 2.
The existing `except subprocess.CalledProcessError` only catches if
there are syntax errors which prevent the `lastrun` file from being
written; it does not handle if there are properly-defined resources
which fail to evaluate (e.g. due to a missing dependency or file).

Check the `failed` resource count, and exit 2 if there are any such
resources.  This will cause `zulip-puppet-apply --force --noop` (which
is used as a pre-flight check during upgrades) to properly detect and
signal on more types of invalid puppet configurations.  In turn, this
will cause `upgrade-zulip` to not attempt to power through upgrades it
knows are destined to fail.
2023-04-19 09:35:19 -07:00
Alex Vandiver cace8858f9 puppet: Move logrotate config into app_frontend_base.
7c023042cf moved the logrotate configuration to being a templated
file, from a static file, but missed that the static file was still
referenced from `zulip_ops::app_frontend`; it only updated
`zulip::profile::app_frontend`.  This caused errors in applying puppet
on any `zulip_ops::app_frontend` host.

Prior to 7c023042cf, the Puppet role was identical between those two
classes; deduplicate the rule by moving the updated template
definition into `zulip::app_frontend_base` which is common to those
two classes and not used in any other classes.
2023-04-19 09:34:37 -07:00
Lauryn Menard b910bb107a api-docs: Clean up documentation of API events with `message_type`.
Cleans up the API documentation for get events with a `message_type`
value: `delete_message`, `typing op:start` and `typing op:stop`.
2023-04-19 09:33:58 -07:00
Alex Vandiver 775c7ca4ea hooks: Give a bit better Zulip deploy message. 2023-04-19 09:32:39 -07:00
Joelute 938b7917d3 user_settings: Add option to not mark messages as read on scroll.
These changes introduces an new user option where it allows
users read messages and scroll through their feed without
marking those messages as read.

Fixes: #22804.
2023-04-18 18:32:02 -07:00
Joelute ffbe6e870a unread_ui: Rename functions names to offer a general clarity.
Previously, the naming of functions in unread_ui was targeted towards a
specific unread banner. This is terrible if we plan on having multiple
types of unread banners and this change aims to offer that level of clarity.
2023-04-18 18:32:02 -07:00
Joelute afbd0a9b43 user_settings: Add web_mark_read_on_scroll_policy field.
This is a backend change that will help support the new
`Mark messages as read on scroll` user setting.
2023-04-18 18:32:02 -07:00
Joelute 82a805e286 compose: Fix incorrect preview area first/last child selectors.
Following up to #24961, it was discovered that emojis looked worse with
the new changes as the spacings became uneven with each emojis.

Debugging determined that the root cause that the selectors used
applied to __every__ first child of its parent inside the
rendered_markdown area, not just the first child of the main
container.
2023-04-18 17:41:37 -07:00
Joelute cdad925add popover: Scroll to top of long message when viewing message actions.
Previously, when a user scrolls down a long text of message and presses
the hotkey for viewing the message actions, the popover menu would continue
to open where the message actions button. Thus, the popover menu would be
cut short and sometimes off the screen. These changes will scroll the
client to the top of the message and ensure that the popover menu is
always visible.

Fixes: #23774.
2023-04-18 17:06:24 -07:00
brijsiyag 0c30acbe39 streams: Fix notice appears even when the panel is not empty.
This fixes regression in 55bd3220b6,
Where notice gets rendered even when there are streams shown in panel.
Now the check var to render message conditionally checks for both
`subscribed` and `all streams` tabs. We are avoiding the fully use of DOM
in this context because if the filter results in no stream, then also
it will display a notice. Also this commits swaps order of calling
`stream_data.delete_sub()` and `stream_settings_ui.remove_stream()`
functions in server_events_dispatch because `update_empty_left_panel_message`
uses stream_data, which was giving outdated data.
2023-04-18 17:02:01 -07:00
Prakhar Pratyush 83bbd8c767 user_topics: Update 'do_update_message' to handle 'merge userTopic states'.
This commit updates the logic for migrating user_topic rows
during the move-messages operation when the target topic
already has messages.

Previously, the target_topic's visibility_policy was simply
set to the original_topic's visibility_policy,
and the original_topic's visibility_policy was set to INHERIT.

This commit updates the move-messages code path to determine
the new visibility_policy depending on the visibility policies
of the original and target topics.
The target_topic's visibility_policy is then updated.

The number of db queries has increased by two:
One query corresponds to determining if 'target_topic_has_messages'.
Another query corresponds to 'get_users_with_user_topic_visibility_policy'
to determine 'target_topic_user_profile_to_visibility_policy'.
2023-04-18 16:40:57 -07:00
Prakhar Pratyush d5f148aa36 user_topics: Update 'topic_has_visibility_policy' to support INHERIT.
This prep commit updates the lib function
'topic_has_visibility_policy' to add support for the case
when visibility_policy=INHERIT.

Previously, it had support for all the visibility policies
except INHERIT.
2023-04-18 16:40:57 -07:00
Prakhar Pratyush 18eea3fc4a message_edit: Refactor the move user_topic records code block.
This commit refactors the move user_topic records
code block in 'do_update_message', resulting in
clean code.

We directly iterate over the dictionary items
instead of looping over the keys and fetching
values if the key exists.
2023-04-18 16:40:57 -07:00
brijsiyag 5cef364c74 upload: Open compose immediately on file drop or paste event.
This commit changes the way compose box responds to a file drop or paste.
Currently, the compose box expands only after the file is uploaded to the
server, which can cause confusion if the upload fails and there is also no
progress bar. With the update, the compose box will expand immediately upon
drop or paste events showing the status of upload. Also it was opening
the stream compose box even if we are in a direct message, now it starts
a reply.

Fixes #24654.
2023-04-18 16:37:56 -07:00
Ruchir Harbhajanka e08256ce88 urls: Move jwt_fetch_api_key endpoint to v1_api_mobile_patterns.
Moves jwt_fetch_api_key endpoint to v1_api_mobile_patterns so
that tools/test-api detects it as an API endpoint that is pending
documentation.

Fixes #24982.
2023-04-18 15:44:31 -07:00
Anders Kaseorg 1f05ed2486 emails: Remove compiled from .gitignore.
It’s unused since commit 2f203f4de1
(#24991).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-18 13:25:52 -07:00
Lauryn Menard 2c043c6242 message-type: Add support for "direct" as value for type parameter.
For endpoints with a `type` parameter to indicate whether the message
is a stream or direct message, `POST /typing` and `POST /messages`,
adds support for passing "direct" as the preferred value for direct
messages, group and 1-on-1.

Maintains support for "private" as a deprecated value to indicate
direct messages.

Fixes #24960.
2023-04-18 12:29:33 -07:00
Lauryn Menard 42d9560413 message: Use `recipient_type_name` for API message type references.
Refactors instances of `message_type_name` and `message_type`
that are referring to API message type value ("stream" or
"private") to use `recipient_type_name` instead.

Prep commit for adding "direct" as a value for endpoints with a
`type` parameter to indicate whether the message is a stream or
direct  message.
2023-04-18 12:29:33 -07:00
Lauryn Menard c87fbacaed message: Use more accurate `recipient_type` when applying unread event. 2023-04-18 12:29:33 -07:00
palashb01 3ad5e7dfc0 tippy: Prevent second appearance of tooltips for recipient bar icons.
There are four icons in the recipient bar that have tooltips, and
each of them shows a second appearance if we click on a button of
the topic menu that is just over the area of the icon. To prevent
the second tooltip, we have used the
'hide_tooltip_if_reference_removed' function to observe changes in
the DOM and hide the tooltip if the reference is removed.
2023-04-18 10:03:09 -07:00
Palash Baderia 054098fa01 tippy: Prevent appearance of second `view_user_card` tooltip.
With the recent migration of the topic_menu popover to Tippy,
some tooltips have been impacted. If we click on a popover menu
and then click on any button where the area is above the tooltip
icon, two tooltips appear. The first one is expected to appear over
the reference element, but the second tooltip appears on the top
left corner of the screen because the associated reference element
is hidden.

This commit fixes this issue for the view_user_card tooltip with
the help of the 'hide_tooltip_if_reference_removed' function.
We have set the attributes config to be 'true', since when the
tooltip appears, the parent div with classname
'message_row include_sender' is added with the value
'sender_name_hovered' in its className. We just need to observe
this classname change to hide the tooltip.
2023-04-18 10:03:09 -07:00
Mateusz Mandera eb4fc7568c auth_enabled_helper: Add realm_authentication_methods argument.
This allows removing pointless db queries when calling
*_auth_enabled(realm) repeatedly.
2023-04-18 09:22:56 -07:00
Mateusz Mandera 72d56d5d59 auth: Remove Realm.AUTHENTICATION_FLAGS class attribute.
With the removal of the authentication_methods bitfield this is now
useless and just duplicates AUTH_BACKEND_NAME_MAP keys.
2023-04-18 09:22:56 -07:00
Mateusz Mandera ffa3aa8487 auth: Rewrite data model for tracking enabled auth backends.
So far, we've used the BitField .authentication_methods on Realm
for tracking which backends are enabled for an organization. This
however made it a pain to add new backends (requiring altering the
column and a migration - particularly troublesome if someone wanted to
create their own custom auth backend for their server).

Instead this will be tracked through the existence of the appropriate
rows in the RealmAuthenticationMethods table.
2023-04-18 09:22:56 -07:00
Sahil Batra 41f17bf392 popovers: Fix showing resolve topic option in sidebar popover.
We previously showed "Mark as unresolved" or "Mark as resolved"
option in topic sidebar popover only is user was allowed to
move messages between streams. This commit fixes it to show
if user is allow to move within stream, or in other words edit
the topic, since resolving or unresolving topics is essentially
topic ediitng only.

Note that we still cannot show or hide the option as per the time
limit setting (since client may not have the first message of the
topic locally), so we just show or hide it as per
move_messages_within_stream_policy setting.
2023-04-18 09:01:39 -07:00
Sahil Batra 8874328b87 stream_popover: Add "Rename topic" option in topic sidebar popover.
This commit adds "Rename topic" option in topic sidebar popover
which will be shown when user is only allowed to edit topics and
not streams.

Note that we still cannot show or hide the option as per the time
limit setting (since client may not have the first message of the
topic locally), so we just show or hide it as per
move_messages_within_stream_policy setting.

Fixes #19886.
2023-04-18 09:01:39 -07:00
Sahil Batra 0b608d7952 message_edit: Add buffer when checking time to disable move message inputs.
This commit adds 5 seconds buffer when checking the permission to edit
stream and topic for disabling the inputs in "Move message" and
"Move topic" modal.

We already do this for the message content edit UI.
2023-04-18 09:01:39 -07:00
Aman Agrawal d3dc26cbad header: Improve dropdown click handler.
Minor tweaks that make sense to do.
2023-04-18 08:54:55 -07:00
Aman Agrawal 2553858c91 portico-header: Fix navbar user dropdown not working.
As part of #24678, this code was accidentally removed. We just
add it back to fix the broken user profile dropdown in the navbar
of non corporate pages.
2023-04-18 08:54:55 -07:00
Sahil Batra c27ff12b8c user_groups: Update ID of overlay container element.
This commit renames ID of the container element of group
settings overlay to group_overlay_container. We also
rename the variables used for this element. This makes
it consistent with the container element of settings overlay.
2023-04-18 08:53:08 -07:00
Sahil Batra a5580264eb stream_settings: Update ID of overlay container element.
This commit renames ID of the container element of stream
settings overlay to streams_overlay_container. This makes
it consistent with the container element of settings overlay.
2023-04-18 08:53:08 -07:00