Commit Graph

50927 Commits

Author SHA1 Message Date
Anders Kaseorg 60d49ae4a6 eslint: Fix @typescript-eslint/prefer-nullish-coalescing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg b280843e51 eslint: Fix @typescript-eslint/prefer-optional-chain.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 5ac9b644eb eslint: Fix @typescript-eslint/prefer-return-this-type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 079b74e67e eslint: Fix @typescript-eslint/no-unnecessary-type-arguments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg d958948f43 eslint: Fix @typescript-eslint/no-unnecessary-boolean-literal-compare.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 61b72f5117 eslint: Fix @typescript-eslint/non-nullable-type-assertion-style.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg b9a28df63c eslint: Fix @typescript-eslint/consistent-indexed-object-style.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg cd5fba24e0 eslint: Fix @typescript-eslint/consistent-generic-constructors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 084771ce74 eslint: Fix @typescript-eslint/consistent-type-definitions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Lalit ccbba1acb0 dialog_widget: Refactor `AjaxRequest` type and moved it to `types.ts`.
Changes `AjaxRequest` name to more clear one `AjaxRequestHandler`,
also moved this type to `types.ts` with a comment to move it into
`channel.js` once it migrates to typescript.
2023-04-19 16:43:27 -07:00
Lalit cfa92aa60b js: Break cyclic dependency between `reload,js` and `server_events.js`.
Removes direct dependency cycle between `reload.js` and `server_events.js`
by calling `reload.add_reload_hook(cleanup_event_queue)` from `server_events`
initialize function which registers a hook to run on reloading.

Created a function `call_hooks` which loops over all the registered hooks
and executes them on performing a reload.
2023-04-19 16:42:45 -07:00
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