Commit Graph

4688 Commits

Author SHA1 Message Date
Sahil Batra 630abf57d9 settings: Remove bot from "Active bots" list on changing owners.
On changing bot owner, "delete" event is sent to the previous
owner if previous owner is not an admin. We were ignoring the
"delete" event in webapp previously, but now we update the
bots page in personal settings to delete the bot. Note that
we do not remove the bot from the organization list of bots
currently, since list_widget does not support removing a
row as of now.

In case of previous owner being an admin, the previous owner
receives "update" event and thus the bots list is updated
from that event.

The code for ignoring "delete" event was added in fba2708bbc,
to basically avoid failed lookup for id in the organization
list of bots. I have tested and there cannot be a case of
a failed lookup in the list as per current code for list_widget
module and we are anyways safe after a reload or after closing the
overlay as the list will be updated correctly.

Discussion thread -
https://chat.zulip.org/#narrow/stream/321-settings-system/topic/List.20render.20.2315033

Fixes #20856.
2022-03-22 15:38:43 -07:00
Tim Abbott 7bc0e70693 recent topics: Revert time format changes for now.
As detailed in this conversation:

https://chat.zulip.org/#narrow/stream/137-feedback/topic/recent.20topics.20timestamps/near/1337670

This time format change is not working out as an improvement for at
least some users, myself included.

I think we do want to use some of the refinements attempted here (and
in particular, I'm keeping the new function with its nice test suite),
but I think it's better to revert now and fix forward in a future
release.

See #19775 for added background.
2022-03-21 17:37:32 -07:00
Austin Riba 3df0cacd9e messages: Show tippy tooltip for inline images.
This commit adds a tippy tooltip for inline image previews in messages.

There exists some (reasonable) logic in `static/js/util.js` which
overrides all title attributes for links to user-uploaded content to
ensure they always display "Download <filename>". This doesn't make
sense for inline images specifically because they will be opened in a
ligthbox, so we prevent that.

There is an additional tippy instance created in `static/js/tippyjs.js`
to add tippy tooltips to inline images, which takes advantage of the now
preserved title attribute of the parent link.
2022-03-21 15:36:10 -07:00
Lauryn Menard 0844a80d66 edit_history: Check edit history for stream and topic match.
Creates a helper function in `message_edit.js` that loops over
a message's edit history to see if a stream and topic pair
existed at some point in the message history.

Exports `util.lower_same` function to use for comparing
edit history topics as lowercase.

Also adds test for new function in `mesage_edit` node tests.
2022-03-21 13:32:11 -07:00
strifel a967a86b10 integration: Generate dynamic name for BigBlueButton video calls.
The name for a BigBlueButton meeting is now generated from the stream
name and topic name.

The createTime option is used to have the user redirected to a link
that is only valid for this meeting.

Even if the same link in Zulip is used again, a new createTime
parameter will be created, as the Meeting on the BigBlueButton server
has to be recreated.

Fixes #16498.
Fixes #20509.
Fixes #20804.
2022-03-18 17:27:39 -07:00
YashRE42 c4bb181056 recent_topics: Save offset when navigating from narrow or "all".
This is partially a prep commit to correctly saving/restoring the
position of the blue message select box when using browser
back/forward navigation, and partially a bug fix that ensures that
switching from "all_messages" to "recent_topics" preserves one's
position in "all_messages".
Note that this is with regards to saving the visual position of the
selected message, not about saving "which message was selected".
2022-03-18 17:07:53 -07:00
yogesh sirsat 0d31781aed popovers: Support reactivating users from user profile popover.
If the target user is deactivated, `Reactivate this user` will be
shown as one of the options in the small user profile popover, where
`Manage this user` would usually be.

We rename `show_manage_user_option` to `can_manage_user` because now
it will also be used as the common condition for whether the current
user has administrative permission to active or deactivate the target
user.

The implementation closely follows the existing deactivation modal.

Fixes #21428.

chat.zulip.org discussion:
design > reactivate user from user popover
2022-03-18 15:19:13 -07:00
Steve Howell 29e4342738 puppeteer tests: Split stream tests to two files.
This is just moving code around.
2022-03-18 12:20:48 -04:00
Steve Howell db5f39c506 puppeteer tests: Try to diagnose/fix unsubscribe flakes.
Doing these in a loop may help us figure out whether the
flakes are somehow related to the initial conditions when
we run the test vs. some race that can happen later in the
loop.

I add the console statements mostly to facilitate debugging,
but they appear to actually reduce the problem, as the code
comments indicate.
2022-03-18 12:20:48 -04:00
Steve Howell a5ec78c6ab puppeteer tests: Avoid stream creation flake.
We have a flake related to verifying that the app
prevents us from creating stream with duplicate names,
and my hypothesis is that it has to do with us not
waiting for the stream creation UI to fully appear. This flake
is probably a consequence of us recently making the stream
creation UI more like the stream editing UI, and thus
waiting for Desdemona to appear was giving us false
confidence that the page actually loaded.

I could be completely wrong about this solving the
flake, but the code change here is sensible regardless.
2022-03-18 12:20:48 -04:00
Anders Kaseorg b0217d0ec6 password_quality: Switch zxcvbn to zxcvbn-ts.
zxcvbn has had no releases since 2017.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 15:24:46 -07:00
Anders Kaseorg 7aa03e9d2a dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 15:24:46 -07:00
Anders Kaseorg 6aec27e646 js: Fix no-jquery/no-parse-html-literal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:16:34 -07:00
Anders Kaseorg da0658967c js: Fix no-jquery/no-event-shorthand.
The event shorthand methods were deprecated in jQuery 3.3.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:10:23 -07:00
Anders Kaseorg 5d77381667 node_tests: Add a few missing $ prefixes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:10:23 -07:00
Steve Howell bffd73fe44 node tests: Add spectator test for search suggestions.
This is a prep commit to help us soon remove 44 months worth of
bit-rotted code.
2022-03-17 12:07:53 -04:00
Steve Howell 599a70d6f4 node tests: Add test for topic_suggestions.
This is a prep commit to help us soon remove 44 months worth of
bit-rotted code.
2022-03-17 12:07:53 -04:00
Steve Howell 097852bb06 node tests: Add coverage for clear_search_form.
This is a prep commit to help us soon remove 44 months worth of
bit-rotted code.
2022-03-17 12:07:53 -04:00
Steve Howell a9f83a5805 node tests: Add test for people suggestions.
This is a prep commit to help us soon remove 44 months worth of
bit-rotted code.
2022-03-17 12:07:53 -04:00
Steve Howell d162bd17a9 node tests: Use now/future naming scheme for search tests. 2022-03-17 12:07:53 -04:00
Anders Kaseorg f84a2c08d5 js: Prefix jQuery object variable names with $.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-16 12:52:07 -07:00
Steve Howell dfab993e7d node tests: Avoid narrow_state mocking in pm_list* tests.
We now use narrow_state directly in pm_list and pm_list_data
tests, rather than mocking it with our `override*` helpers.

In some places I use an actual Filter() object, but
in places where the only testing concern is that the
active is narrow, I use a stub value.

We will continue to mock narrow_state in most places.
In addition to avoiding test-setup complications, we want
to avoid incidental line coverage on narrow_state that
only indirectly validates its behavior. Part of the
trickiness in avoiding narrow_state mocking is that
you often would have to introduce "real" Filter objects,
and the API for Filter objects is somewhat less than
ideal, and its wordiness can distract from the main
point of the tests.

Hopefully the changes here reflect the correct tradeoffs.
2022-03-16 11:57:58 -04:00
Suyash Vardhan Mathur 20a97bdb05 events: Add functionality to mark messages as unread.
Co-authored-by: Steve Howell <showell@zulip.com>
Co-authored-by: Tim Abbott <tabbott@zulip.com>

This commit adds the backend functionality to
mark messages as unread through update_message_flags
with `unread` flag and `remove` operation.

We also manage incoming events in the webapp.

Tweaked by tabbott to simplify the implementation and add an API
feature level update to the documentation.

This commit was originally drafted by showell, and showell
also finalized the changes.  Many thanks to Suyash here for
the main work here, which was to get all the tests and
documentation work moving forward.
2022-03-15 18:00:35 -07:00
Tim Abbott 562f37b9af compose: Show topic resolve warning only when compose is nonempty.
The resolve topic warning can feel like clutter in the event that the
compose box is empty (which often occurs when the user has no intent
to send a message), so we configure the validation logic to only
display the notice when the compose box is non-empty.

We take some care to minimize work the function is doing, beacuse it
is called on every keystroke in the compose box.

Fixes: #21155.
2022-03-15 17:59:15 -07:00
jai2201 a8b24c830f node tests: Use proper variable names for tests.
Use proper variable names such as `alice.user_id` for assigning
userId as a parameter instead of directly using a number `101`
and avoid using a variable name `timestamp` for assigning message_ids
to function `pm_conversations.recent.insert()`
2022-03-15 11:36:20 -07:00
Steve Howell 68c2ccc81a node tests: Split out pm_list_data module.
Nothing of substance changed here.  For pm_list we
now just call run_test directly.
2022-03-15 11:33:16 -07:00
Steve Howell 6e9511bdca node tests: Remove tricky UI-related tests for pm_list. 2022-03-15 11:33:16 -07:00
Steve Howell 8dcb7c571f node tests: Test get_convos directly.
In order to simplify our node tests, we are willing
to sacrifice coverage on UI-oriented glue modules.
2022-03-15 11:33:16 -07:00
Steve Howell 015cdfe07e pm list: Extract pm_list_data module.
This sets the stage to remove some node test mocking.

This is a pure code move, and we change _get_convos
to get_convos.
2022-03-15 11:33:16 -07:00
Steve Howell 8e05a9fcf7 unread: Replace sender_id with other_user_id.
Note that we still send sender_id for legacy mobile
clients.
2022-03-10 13:33:21 -08:00
Tim Abbott 84bdf86246 message_edit: Don't display resolved topics as MOVED.
We loop through edit history entries and see if any of them
are more interesting than a (un)resolve topic edit, extending
the existing loop we had.

We also update the associated node tests.

Fixes #19919.

Co-authored by: Lauryn Menard <lauryn@zulip.com>
2022-03-10 12:00:53 -08:00
Sahil Batra cbac466658 compose: Show topic required error if topic is "(no topic)".
We already show the error if topic input is empty and it is
not allowed to send messages without topic in the organization,
and this commit also shows error when topic is "(no topic)".

The topic is set to "(no topic)" when someone sends a message
with empty topic input box and when it is allowed to send message
without topics in the organization.

This is not ideal behavior as we may want to treat "(no topic)"
differently from empty topic, but we can fix this in future and
this commit can be a short term fix.

Fixes #21344.
2022-03-09 15:29:13 -08:00
Greg Price 760cfcc603 resolved_topic: Implement resolve, unresolve, and display.
We have two different frontend implementations of computing the
un-resolved form of a topic name, and they have a subtle -- but
intentional -- difference in behavior.

Factor them both out into the resolve_topic module, along with
their inverse, and with comments and tests.
2022-03-07 21:35:00 -08:00
Greg Price 7852d8e015 topic_list_data: Move "if resolved" conditionals to a single place.
These two conditionals are each relying on the other to trigger
on the same condition, and to do complementary things.  Move them
together to a single place so that that relationship is easy to see,
and to refactor.
2022-03-07 21:35:00 -08:00
Greg Price 7bf0fd3fa3 resolved_topic: Add and use predicate is_resolved.
We leave in place a couple of sites where the `startsWith` is
entangled with other string manipulation.  We'll handle those next.
2022-03-07 21:35:00 -08:00
Greg Price 624cdb0a14 resolved_topic: Start module, in shared package.
For the moment, just move the RESOLVED_TOPIC_PREFIX constant.
More next.
2022-03-07 21:35:00 -08:00
Steve Howell c43d48b22f stream create: Overhaul create-stream add-subscribers UI.
The most notable change here is that when you are adding
subscribers to a stream as part of creating the stream,
you can now use the same essential pill-based UI for
adding users as we do when you edit subscribers for an
existing stream.

We don't try to exactly mimic the edit-stream UI or
implementation, since when you are adding subscribers
during create-stream, we are just updating a list in
memory, whereas in the edit-stream UI, we immediately
send info to the server.

Fixes #20499
2022-03-07 16:58:58 -08:00
Anders Kaseorg baa11303ff alert_words: Fix alert words with HTML special characters.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-04 12:26:49 -08:00
Anders Kaseorg 513207523c js: Fix various sloppy uses of String#replace.
Prefer a regexp match over using String#replace to strip expected
prefixes and suffixes because (a) it implicitly verifies that the
input has the expected format and (b) it won’t unexpectedly strip from
the middle of the string.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-04 12:26:49 -08:00
Tim Abbott e54dfda0b1 edit_history: Use modern edit history format in frontend. 2022-03-04 10:25:48 -08:00
Julia Bichler 24673b7a69 settings: Grey out muted streams in personal settings.
Muted streams are now greyed out in the personal settings,
also changes to the notification settings of a muted stream are
not possible anymore.

Also, add a bell-slash icon after the stream name of muted streams,
clicking on it unmutes the stream.

Fixes #19780.
2022-03-03 14:51:15 -08:00
Dinesh 59e057c9d1 puppeteer: Resurrect test_change_password.
353d0f9 removed this test as it was causing alert words test
fail non-deterministically. See 353d0f9's commit message for
some more details.

Rearranging the order to make this test run in the end can
eliminate the non-deterministic failures due to this test.

Because we reset the test database in between test files, we don't
expect there to be any issues with test files running after this.
2022-03-03 10:17:13 -08:00
Anders Kaseorg 44767dd653 tippyjs: Avoid unsafe allowHTML API in favor of <template> elements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-03 10:13:24 -08:00
Steve Howell 353d0f9e4f puppeteer flake: Remove call to test_change_password().
Changing the password seems to randomly cause one of
our calls to /json/events to return a 401.

The symptom of this is that when you update alert words,
we don't get the event, and the alert words list does
not get updated.

More context here:

    https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/alert.20word.20flakes/near/1334824

It is possible that this reflects an actual problem in
our system when you update passwords.

For now, though, the goal is simply to make this test
reliable, so that we don't have to chase down this flake
any more. It was a particularly tricky flake to debug,
since the alert words test really wasn't at fault here.

It's plausible that we don't want to have the app declare
success when the server acks an alert word POST, and the
app should instead wait for the event to come back before
giving any confirmation to the user.
2022-03-03 08:10:28 -05:00
NerdyLucifer c355feea0e dropdown_list_widget: Hide 'disable' button when nothing is selected.
Hides 'disable' button of any kind when nothing is selected
in dropdown list widgets  by removing ':enabled' selector from
the button, the button is not actually a button, it's an <a> tag which
doesn't support "disabled" attribute.

Fixes part of #20831.
2022-03-02 17:18:50 -08:00
Anders Kaseorg c09bca34b8 frontend_tests: Fix unicorn/text-encoding-identifier-case.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-01 23:09:46 -08:00
Austin Riba b22578f975 hash_util: Rename _uri functions to _url.
It's 2022 and the WHATWG no longer recognizes the term URI. Everything
is now a URL or a type of URL. Which is great because it's way less
confusing. Details here:
https://url.spec.whatwg.org/
2022-03-01 18:14:31 -08:00
Austin Riba b39d47995d hash_util: Move stream uri functions to shared.
Moves hash_util.by_stream_uri and hash_util.by_stream_topic_uri to
internal_url so they can be used by external codebases. Due to these
functions being called in many places in the web codebase, wrappers
for both functions are left in hash_util in order to keep these
calls simple.

Also adds test for explicitly testing each function.
2022-03-01 18:14:31 -08:00
Austin Riba 9f1c184311 hash_util: Move encode_stream_id to shared.
Move hash_util.encode_stream_id to internal_url, so it can be shared
with external codebases. Also add a test that explicitly tests escaping
special characters in stream names.
2022-03-01 18:14:31 -08:00
Austin Riba 403310a9e2 hash_util: Move stream_id_to_slug to shared.
Move stream_data.id_to_slug to internal_url, making it shareable. The
function has been renamed to stream_id_to_slug to reflect that it
operates on a stream id.
2022-03-01 18:14:31 -08:00