Commit Graph

49984 Commits

Author SHA1 Message Date
Prakhar Pratyush 49577bbdcd user_topics: Move topic muting functions to user_topics.py.
This commit moves topic related stuff i.e. topic muting functions
to a separate file 'views/user_topics.py'.

'views/muting.py' contains functions related to user-mutes only.
2023-02-07 00:23:47 +05:30
Kartik Srivastava 48883f1580 tests: Rename test_muting_topics to test_topic_visibility_policies.
As we'll be adding support for more visibility policies for topics,
this renamed file will contain the necessary tests.
2023-02-07 00:23:47 +05:30
Tim Abbott b36b04e385 user profile: Use stream_data.can_unsubscribe_others.
This is necessary to offer the "Unsubscribe" button in full user
profiles when the current user has the necessary permissions for a
given stream.

We remove settings_data.user_can_unsubscribe_other_users, since we've
changed its only caller and it is no longer a useful abstraction.
2023-02-05 14:46:36 -08:00
Sahil Batra 89f39a8aed stream: Add UI to set can_remove_subscribers_group when creating stream.
This commit adds dropdown-list-widget element in create stream UI
to set can_remove_subscribers_group setting when creating stream.
For now only role-based system groups are shown as options.
2023-02-05 14:46:36 -08:00
Sahil Batra 255dc759b1 stream_settings: Add live update code for can-remove-subscribers-group.
This commit adds code to live update the UI element for
can_remove_subscribers_group setting.
2023-02-05 14:46:36 -08:00
Sahil Batra b9801073bd stream_settings: Add UI element for can-remove-subscribers-group setting.
This commit adds dropdown-list-widget element in "General" section of
stream settings for can-remove-subscribers-group setting. For now we
only show role-based system groups as the options.
2023-02-05 14:46:36 -08:00
Sahil Batra 37964b1ccc user_groups: Add helper functions to get options for group-based setting.
This commit adds get_realm_user_groups_for_dropdown_list_widget function
which returns the list of objects containing the display name and id
of system user groups and adds tests for this function.
2023-02-05 14:46:36 -08:00
Sahil Batra 73a378d23f stream_settings: Use can_remove_subscribers_group setting in webapp.
This commit updates the frontend to show or hide the "Unsubscribe"
button in subscribers list in stream settings as per the
can_remove_subscribers_group setting for the stream.
2023-02-05 14:46:36 -08:00
Sahil Batra 73f11853ec streams: Allow setting can_remove_subscribers_group_id while creating streams.
This commit adds API support to set can_remove_subscribers_group setting
when creating streams.
2023-02-05 14:46:36 -08:00
Sahil Batra c3759814be streams: Allow changing can_remove_subscribers_group through API.
This commit adds API support to change can_remove_subscribers_group
setting for a stream.
2023-02-05 14:46:36 -08:00
Tim Abbott 6fa0a83d6b user profile: Fix height issues with remove-subscription-button.
Previously, subscription rows with a remove-subscription-button were
much taller than those without. This will be problematic when the new
permissions setting makes it possible for the current user to have
permission to unsubscribe the target user from some streams but not
others.

Fix this by both making the button a bit less tall and setting a
minimum height for the rows. Probably a nicer CSS solution is
possible, but this is enough to unblock merging a much larger project.
2023-02-05 14:46:36 -08:00
Tim Abbott 8bd881c83f message_list: Reorder and document properties of key classes.
This should help considerably in the readability of this part of the
codebase; meanwhile, I also took the opportunity to note various TODOs
where we might have something simple we can do to simplify these data
structures or improve their interfaces.
2023-02-05 10:58:07 -08:00
Aman Agrawal 9965ad2ea3 registration: Track create organization page in GA.
This will help us track if users actually clicked on the
email confirmation link while creating a new organization.

Replaced all the `reder` calls in `accounts_register` with
`TemplateResponse` to comply with `add_google_analytics`
decorator.
2023-02-05 10:24:32 -08:00
Tim Abbott 0f155b597f Revert "click_handlers: Don't treat dropdown menuitem clicks the same as links."
This reverts commit 202c04988f.

See https://github.com/zulip/zulip/pull/24133#issuecomment-1416921919.
2023-02-05 10:03:38 -08:00
evykassirer 9881760796 upload: Rename upload.js get_item keys to reflect upload banner.
Previously the banner was displayed through send_status, but
that is no longer an accurate name for identifying parts of
the upload HTML.
2023-02-04 19:50:52 -08:00
evykassirer 97d355fa72 compose: Migrate upload banner to new banner styling.
Fixes #22524.

This affects both the banner in the main compose box and the banner
in the message edit compose box. The use of ProgressBar has been
replaced with a more simple CSS (with light Javascript) solution.

The classnames are changing because the upload banner is now a
template rendered and remove()-ed from a banner container
(#compose_banners in the composebox, and a new div for banners in the
message edit view). It used to be in the send_status container so
there are a lot of class renames across the codebase.
2023-02-04 19:50:52 -08:00
evykassirer b01ac3623f upload: Remove and reduce timeouts for closing upload bar.
This timeout was introduced in this commit: 02c3223985

The UI should close immediately when the user clicks cancel,
and the rest of the canceling code can run behind the scenes.

We want to keep a short timeout for upload completion
so that the user sees the 100% complete upload bar.
2023-02-04 19:50:52 -08:00
evykassirer beef7611da upload tests: Move compose_ui out of mock_esm. 2023-02-04 19:50:52 -08:00
evykassirer d54618fb4b node tests: Exclude zjquery_element.js and upload.js.
CZO discussion
[here](https://chat.zulip.org/#narrow/stream/6-frontend/topic/code.20coverage/near/1487773).

This allows `zjquery_element.js` to have test utils that aren't always being used.
`upload.js` is mostly UI focused and has upcoming commits that are hard
to write unit tests for (and for which unit tests wouldn't make much sense).
2023-02-04 19:50:52 -08:00
evykassirer 202c04988f click_handlers: Don't treat dropdown menuitem clicks the same as links.
This is a prep commit for adding a new dropdown for stream selection.
2023-02-04 19:08:13 -08:00
evykassirer 5f59ea0036 compose banner: Consolidate two functions that clear success banners.
Previously notifications.clear_compose_notifications was used accross
the codebase. Since introducing the new
compose_banner.clear_message_sent_banners function, the two functions
are similar enough that we can just use clear_message_sent_banners
everywhere. This commit also moves scroll_to_message_banner_message_id
to compose_banner.
2023-02-04 18:53:35 -08:00
evykassirer ea9c4682a8 compose: Migrate out-of-view-notification to new banner style. 2023-02-04 18:53:35 -08:00
evykassirer d9723a3dd4 compose tests: Move notifications out of mock_esm. 2023-02-04 18:53:35 -08:00
evykassirer 3a264c37b5 compose: Rename message_sent_banner template variables.
This is a prep commit for redesigning this banner. The
change from `note` to `banner_text` is more consistent
with `compose_banner`. `link_class` is renamed to classname
and will be used for the banner a whole and not the link
class anymore, which is why the check for displaying a link
now looks to see if `link_text` is defined instead.
2023-02-04 18:53:35 -08:00
Joelute 2c94d2b22f popovers: Fix missing top border for avatar in user profile.
The top border on the avatar wasn't showing up since there wasn't
enough space provided. Added top margin to fix the issue.

Fixes #24210.
2023-02-04 17:44:37 -08:00
Anders Kaseorg b91788b945 markdown: Replace deprecated UnescapePostprocessor.
See https://github.com/Python-Markdown/markdown/pull/1272.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:36:47 -08:00
Anders Kaseorg 5aaa36b8fc ruff: Enable logging format rules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:36:20 -08:00
Anders Kaseorg b08c81b312 ruff: Fix G201 Logging `.error(..., exc_info=True)` → `.exception(...)`.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:36:20 -08:00
Anders Kaseorg 59eca10a43 ruff: Fix G004 Logging statement uses f-string.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:36:20 -08:00
Anders Kaseorg 61f672c652 ruff: Enable raise rules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:34:55 -08:00
Anders Kaseorg da3cf5ea7a ruff: Fix RSE102 Unnecessary parentheses on raised exception.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:34:55 -08:00
Tim Abbott 3099487bc3 stream_popover: Remove useless old_topic_name check.
This has been present since this modal was first introduced in
b9098a42d4, but as far as I can tell, it
has never been correct. We know `old_topic_name` is not
null/undefined, since we do a check with it trimmed earlier in the
function, and there is no product reason why we would would to
silently fail to move a topic because its name was the empty string.
2023-02-03 18:20:39 -08:00
Prakhar Pratyush 9997131df3 message_edit: Fix resolve topic notifications.
When 'resolve|unresolve' and 'move stream' actions occurs in
the same api call, 'This topic was marked as resolved|unresolved'
notification is not sent.

Both 'topic moved' and 'topic resolved' notification should be generated.

This commit updates the logic of when and where to send
'topic resolve|unresolve' notification. Unlike previous logic, notification
may be sent even in the case 'new_stream' is not None.

In general, 'topic resolved|unresolved' notification is sent to
'stream_being_edited'. In this particular case ('new_stream' is not None),
notification is sent to the 'new_stream' after check.

Test case is included.

Fixes: #22973
2023-02-03 18:20:39 -08:00
Prakhar Pratyush 62437e6930 topic_edit: Fix resolve topic notification.
When 'resolve|unresolve' and 'change topic' actions occurs in
the same api call using 'topic sidebar icon', only 'topic_moved'
notification is sent.

Both 'topic moved' and 'topic resolved' notification should be generated.

Currently, 'select_stream_id' is not set to 'undefined',
even if we only change 'topic name' and/or 'resolve|unresolve' topic.
Resulting in no 'resolved_topic' notification.

This commit sets 'select_stream_id' to 'undefined' to fix the issue.
2023-02-03 18:20:39 -08:00
Prakhar Pratyush 01961b4282 stream_popover: Fix confirm button not disabled bug.
On updating the stream from the dropdown menu in the move-messages popover,
the confirm button is enabled. On changing the stream back to the initial
value, doesn't disable the confirm button. It can result in the
creation of infinite notifications.

On stream update, 'update_submit_button_disabled_state()' doesn't receive
'stream_id' as a parameter, resulting in 'undefined' stream_id,
'button.disabled' is always set to false after the first update.
2023-02-03 18:20:39 -08:00
Anders Kaseorg 8dc3e086c9 semgrep: Remove typing.Text rule superseded by Ruff UP019.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 17:37:31 -08:00
Anders Kaseorg 81a7c7502f requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 16:36:54 -08:00
Anders Kaseorg 5b7c4206d7 ruff: Fix SIM300 Yoda conditions are discouraged.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 16:36:54 -08:00
Anders Kaseorg b85cb1e700 exceptions: Accept lazy translation as JsonableError argument.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 16:36:54 -08:00
Anders Kaseorg b4ee94e758 readthedocs: Add a configuration file.
This overrides the settings in the web interface, and enables much
more flexible configuration of the build environment (which previously
defaulted to Python 3.7).

https://docs.readthedocs.io/en/stable/config-file/v2.html

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 16:36:54 -08:00
Tim Abbott a8ce7df649 notifications: Avoid misleading href on scroll to bottom notice. 2023-02-03 15:45:06 -08:00
evykassirer dd95f79ab7 notifications: Hide out-of-view notification once user scrolls to message.
The banner telling the user to scroll down to the message previously
didn't disappear when the user scrolled past it manually, which is
not ideal.

Keep track of which message is associated with this notification,
and clear the banner when the message scrolls above the bottom of
the viewport.
2023-02-03 15:45:06 -08:00
evykassirer e789e7aa4f compose: Leave scroll-to-message banner open until explicitly closed.
Previously the message would disappear after 300ms, but it can be
annoying for a useful link to disappear so quickly like that.

This commit removes that logic. Now the banner is closed only when
the user explicitly closes it or clicks on the link.

Note that the banner doesn't go away if the user manually scrolls
down. I still think this change is overall better, but if there's
an easy way to add that as well we should do it!

Fixes part of #19857.
2023-02-03 15:45:06 -08:00
evykassirer fbad0b273b compose: Add url to 'scroll down' sent banner.
This notification ("scroll down to view your message" with a link
for the user to click to scroll down) was added in e2c388c and
removed in 657e1f1 in a commit almost immediately afterwards.

Later the notification was added again, but there was notably no
link to scroll, just the message to scroll down. 372cb20

The link to scroll down was "added" in 1a63c2d when it was fixing
a similar link in another notification. But the implementation
didn't actually use the link (because there was no classname passed
through).

This commit adds a classname so that the link is clickable by
the user.

Fixes part of #19857.
2023-02-03 15:45:06 -08:00
Alessandro Toppi ff89590558 auth: Add JWT-based user API key fetch.
This adds a new endpoint /jwt/fetch_api_key that accepts a JWT and can
be used to fetch API keys for a certain user. The target realm is
inferred from the request and the user email is part of the JWT.

A JSON containing an user API key, delivery email and (optionally)
raw user profile data is returned in response.
The profile data in the response is optional and can be retrieved by
setting the POST param "include_profile" to "true" (default=false).

Co-authored-by: Mateusz Mandera <mateusz.mandera@zulip.com>
2023-02-03 15:23:35 -08:00
Tim Abbott 7c7ca61e9f auth: Remove now unnecessary return_data parameter. 2023-02-03 15:23:35 -08:00
Mateusz Mandera 75b44337a8 auth: Extract get_api_key_fetch_authenticate_failure. 2023-02-03 15:23:35 -08:00
Mateusz Mandera 3a1d974cee auth: Extract process_api_key_fetch_authenticate_result function.
This will be useful for re-use in the implementation of another JWT
endpoint in the upcoming commits.
2023-02-03 15:23:35 -08:00
Mateusz Mandera 100f4a7152 auth: Add @require_post to remote_user_jwt. 2023-02-03 15:23:35 -08:00
Mateusz Mandera d466da1064 auth: Use REQ for getting token value and rename param in jwt paths.
This makes us use REQ properly instead of fetching from request.POST
manually - also renaming the param to "token" which is more standard.
2023-02-03 15:23:35 -08:00