Commit Graph

11526 Commits

Author SHA1 Message Date
Anders Kaseorg 6de39ae92d js: Clean up typeof … === "undefined" checks.
The only reason to use typeof foo === "undefined" is when foo is a
global identifier that might not have been declared at all, so it
might raise a ReferenceError if evaluated.  For a variable declared
with const or let or import, a function argument, or a complex
expression, simply foo === undefined is equivalent.

Some of these conditions have become impossible and can be removed
entirely, and some can be replaced more idiomatically with default
parameters (note that JavaScript does not share the Python misfeature
of evaluating the default parameter at function declaration time).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-24 13:15:01 -07:00
Steve Howell 57d79e8fd6 refactor: Extract color_class module.
This breaks some indirect dependencies on subs
and message_view_header.
2021-03-24 12:22:27 -07:00
Steve Howell f3b1e723e0 typeahead: Eliminate render caches.
These were introduced in ff9a929d7a
with no explanation of why they were necessary.

Generally you only render a few things, and it's
important that they're up to date.

We weren't doing a good job of invalidating the cache.

Eliminating the cache will fix bugs (like presence circles
being out of date) and break some dependencies.

I removed some very fragile test code that was relying
on invalid values taken out of the cache.  (We now have
less line coverage, but if we want to test our rendering,
there are much cleaner ways to do it.)

As part of testing this, I renamed Hamlet to "aaron", so
that there are two aarons, and then I logged on as Iago
to see the "secondary" code in action that shows their
emails to distinguish them.
2021-03-24 12:15:36 -07:00
smit_patel 5ddb5fc534 popovers: Change "Delete all messages in topic" to "Delete topic".
This cleans up the copy a bit to be more readable.

Documentation changes cleaned up by tabbott.

Fixes #16856.
2021-03-23 15:46:00 -07:00
Anders Kaseorg fb688e8e5d server_events_dispatch: Fix Prettier formatting.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-23 14:17:08 -07:00
YashRE42 592eb1a197 server_events_dispatch: Refactor user_group to use switch/case. 2021-03-23 13:56:21 -07:00
YashRE42 8d578c248f server_events_dispatch: Refactor typing event to use switch/case. 2021-03-23 13:56:21 -07:00
YashRE42 60b7211b1f server_events_dispatch: Refactor stream case to use switch/case. 2021-03-23 13:56:21 -07:00
YashRE42 1b4fc178c1 server_events_dispatch: Refactor realm_user to use switch/case.
This should make no functional changes.
2021-03-23 13:56:21 -07:00
YashRE42 33fb78af42 server_events_dispatch: Refactor realm_domain to use switch/case.
This should make no functional changes.
2021-03-23 13:56:21 -07:00
YashRE42 d575517035 server_events_dispatch: Refactor update_dict op of realm case.
This should make no functional changes.
2021-03-23 13:56:21 -07:00
YashRE42 f4afe770e4 server_events_dispatch: Refactor subscription case to use switch/case.
This commit should make no behavioural changes.
2021-03-23 13:53:23 -07:00
shanukun cfe0fa3788 event_schema: Add schema check for realm/deactivated event.
This add the schema checker, openapi schema, and also a test for
realm/deactivated event.

With several block comments by tabbott explaining the logic behind our
behavior here.

Part of #17568.
2021-03-23 12:16:16 -07:00
Steve Howell 65ec8f2000 refactor: Move suspect_offline logic into watchdog.
This breaks some indirect dependencies in presence.js.
2021-03-23 14:08:39 -04:00
YashRE42 5b0db2e7ed templates.js: Remove unused "plural" helper.
This helper was added in eac6463031 and
used by the "message.handlebars" file. This is no current call for
this helper in the codebase, hence it is removed to improve coverage.

This commit also marks template.js to have 100% test coverage.
2021-03-23 10:46:04 -07:00
Anders Kaseorg 9553f11387 eslint: Forbid CommonJS variables in ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-23 01:42:43 -07:00
Abhijeet Prasad Bodas 42aea49784 left sidebar: Add support to unstar all messages in topic.
This adds support for unstarring all (starred)
messages from a particular topic, from the topic
popover.

The earlier implementation of this in #16898
was reverted in bc55aa6a01 (#17429)
because it had two problems-

1. The crash reported in bc55aa6a01
was due to message_store returning undefined. This happens
when the message itself hasn't been fetched from the server
yet, but we know that the message is starred from the ids
in `page_params` in `starred_messages.js`.
This commit handles this case explicitly.
Note that, we simply ignore those messages which
we haven't fetched, and because of this, it may
happen that we don't unstar some messages from that
topic. The correct implementation for this would
be to ask the backend for starred IDs in a topic.

2. The earlier implementation actually unstarred **all**
messages. This was because it grabbed the topic and stream_id
from the topic popover `data` attributes, after the topic
popover had been closed. This passed `undefined`, which
the function then interpreted as an action to unstar all
messages.
With this commit, we use the confirm_dialog widget,
which eliminates the need to store this data in the DOM.
2021-03-23 00:17:15 -07:00
Abhijeet Prasad Bodas f17a52b2f3 refactor: Use confirm_dialog for unstar-all-messages.
This replaces the separate modal shown on clicking
"Unstar all messages" from the left sidebar to use
the confirm_dialog widget instead.
2021-03-23 00:17:15 -07:00
Abhijeet Prasad Bodas eb7b699ac9 confirm_dialog: Make it usable outside settings.
* Currently, the confirm_dialog is used only in
the settings pane, which already has the `new-style`
class in the main `settings_overlay.hbs` file. So,
the confirm modal is rendered correctly there. But to
make it available for use outside of the settings pane,
we add the `new-style` class to the confirm container
itself, without which, the buttons look ugly.

* The other change here is the click handler for
removing the modal element. Previously, when the
modal was closed (with any of the "yes"/"no"/"cross"
buttons), there was a small time interval of around
a second during which the modal had disappeared,
but the background content was still in the faded-out
state. This change fixes this glitch. This glitch was
probably not noticable earlier, because the settings
pane itself causes the background to be slightly faded
out.
2021-03-23 00:17:15 -07:00
Abhijeet Prasad Bodas 1cc6f6158e left sidebar: Fix exception on opening all/starred popovers.
This code was added in 2d414fa897, after
the `window.exports` variable was removed from
`stream_popovers.js`, while converting it to an ES6 module
in c71af35461. This resulted
in opening the starred messages or all messages
popovers throw `Error: exports in undefined.`.
2021-03-22 23:56:50 -07:00
Anders Kaseorg d22a61443e notifications: Remove in_browser_notify and bootstrap-notify.
Follow up to #14768.  This feature was already non-functional due to
.alert-display { display: none; }, and if we want to reimplement it,
we should do it using a modern library.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-22 23:40:38 -07:00
Anders Kaseorg aff8a32bc1 notifications: Simplify sound playing.
Remove the unused notifications-area wrapper.  Remove the feature
detection code as all browsers recognize the <audio> element.  Create
the <audio> statically with the page template.  Use multiple <source>s
to let the browser detect the appropriate format instead of trying to
do its job for it.  Remove the absurd loop="yes" attribute, which had
fortunately been specified on the wrong element.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-22 23:36:38 -07:00
Steve Howell 72e0f2e901 bots: Lift render_bots calls to dispatcher code.
This is mostly a refactoring to break the unnecessary
dependency of bot_data on settings_bots.

This is a bit more than a refactoring, as I remove all
the debounced calls to render bots during the
initialization of bot_data. (The debouncing probably
meant we only rendered once, but it was still needless
work.)

We don't need to explicitly render bots during
bot_data.initialize(), which you can verify by loading
"#settings/your-bots" as the home page. It was just an
artifact of how add() was implemented.

Note that for the **admin** screen, we did not and
still do not do live updates for add/remove; we only do
it for updates. Fixing that is out of the scope of this
change. The code that was moved here affects
**personal** bot settings.

Note that the debounce code is quite fragile. See my
code comment that explains it. I don't have time to go
down the rabbit hole of a deep fix here. The puppeteer
tests would fail without the debounce, even though I
was able to eliminate the debounce in an earlier
version of this fix and see good results during manual
testing. (My testing may have just been on the "lucky"
side of the race.) I created #17743 to address this
problem.
2021-03-22 19:40:06 -07:00
Gaurav Pandey dea5245590 right-sidebar: Fix design bugs with keyboard-shortcuts.
The keyboard-shortcuts icon currently has a fix position
causing design related bugs such as overlapping with userlist
in the sidebar.

The fix wraps the invite-more-users link and keyboard icon inside
a div with display property as flex instead of just using the anchor
tags inside the side-bar items.
2021-03-22 19:29:46 -07:00
Steve Howell 746cc9e1f6 refactor: Extract browser_history module.
This mainly extracts a new module called
browser_history. It has much fewer dependencies
than hashchange.js, so any modules that just
need the smaller API from browser_history now
have fewer transitive dependencies.

Here are some details:
    * Move is_overlay_hash to hash_util.
    * Rename hashchange.update_browser_history to
      brower_history.update
    * Move go_to_location verbatim.
    * Remove unused argument for exit_overlay.
    * Introduce helper functions:
        * old_hash()
        * set_hash_before_overlay()
        * save_old_hash()

We now have 100% line coverage on the extracted
code.
2021-03-22 13:29:32 -07:00
Steve Howell 67a487db79 refactor: Extract message_parser module.
I moved four functions, verbatim, to a new module.
They were in message_util before, which led to
filter.js having several accidental indirect
dependencies.

I considered just putting these four functions in
filter.js, but I think it's a nice abstraction boundary
that filter.js delegates actual message parsing, and
the original author apparently had a similar thought
process.

I also wanted to make it so that a casual reader of
filter.js doesn't think we are manipulating DOM. It's
true that we still indirectly require jquery here, but
it's only for parsing, and it seems plausible we would
eventually use a more low-level parser.

I can see us maybe using these functions in something
like MessageListData in the future, so speculatively
splitting them out might future-proof us from some
cyclical dependencies.

I also think it's plausible that we will just modify
our two markdown processors to attach that kind of
metadata to the messages.

Last but not least, I think there might be opportunity
here to simplify the filter tests and remove some of
the zjquery hacks. We would instead just mock the
message_has_* helpers for the filter tests, and then
do more detailed direct testing on the functions
themselves.
2021-03-22 13:21:56 -07:00
Steve Howell 1cee29c2d1 refactor: Extract stream_bar.decorate.
This makes input_pill no longer depend on
stream_data and stream_color, and it
probably reduces some other dependencies.
2021-03-22 13:21:56 -07:00
Steve Howell dbf19fe8d7 refactor: Extract watchdog module.
We now have 100% code coverage on this somewhat
fiddly code.

We also break activity's dependency on server_events.
2021-03-22 13:17:37 -07:00
Steve Howell d644e42dc1 refactor: Move desktop_icon_count_display_values. 2021-03-22 13:17:37 -07:00
Steve Howell a429ecbb1b refactor: Move get_notifications_table_row_data.
The only caller for this function was settings_config,
so we put it there.

For the stream_edit test we no longer mock the function.
(The reason we mocked the function was more about avoiding
the heavy settings_notifications import than the function
itself.)  This gives some incidental coverage, but then I
also add some more real coverage on it.
2021-03-22 13:17:37 -07:00
Steve Howell 855ac26c48 compose fade: Extract compose_fade_users class.
We extract compose_fade_users and compose_fade_helper.

This is a pretty verbatim extraction of code, apart from adding a few
exports and changing the callers.

This change makes the buddy_data module no longer sit "above" these
files in the dependency graph (at least not via compose_fade):

    * jquery
    * lodash (not a big deal)
    * compose_state
    * floating_recipient_bar
    * message_viewport
    * rows

The new moules have dependencies that buddy_data already
had directly for other reasons:

    * people
    * util

And then buddy_data still depends on stream_data indirectly through
the compose-fade logic for stream_data. Even without compose-fade, it
would depend indirectly on stream_data via hash_util.

Note that we could have lifted the calls to compose_fade out of
buddy_data to move some dependencies around, but it's useful to have
buddy_data fully encapsulate what goes into the buddy list without
spreading responsibilities to things like activity.js and
buddy_list.js. We can now unit-test the logic at the level of
buddy_data, which is a lot easier than trying to do it via modules
that delegate drawing or do drawing (such as activity.js and
buddy_list.js).

Note that we still don't have 100% line coverage on the
compose_fade.js module, but all the code that we extracted now is
covered, mostly via buddy_data tests.
2021-03-21 20:16:08 -07:00
Signior-X 31b7eb7439 style: Fix the vertical alignment in message controls.
This commit adds vertical-align: middle to .message_failed in zulip.css
which was necessary as the alignment of .message_failed wasn't matching
with rest of the message controls like .edit_content. This makes the
look of the message controls better that they don't look shifted.

Follow up #17666
2021-03-21 17:38:14 -07:00
Steve Howell ec46827ebd refactor: Move user_can_change_* to settings_data.
This simplifies our dependency graph and puts easily
testable functions into a module where we enforce
100% coverage.

All the code was moved verbatim.
2021-03-21 17:07:41 -07:00
Steve Howell 0014bc1549 node tests: Add test() wrapper for channel. 2021-03-20 11:00:48 -04:00
Anders Kaseorg 0d218a4b76 eslint: Enable @typescript-eslint/consistent-type-imports.
TypeScript type-only imports will probably become important eventually
for reducing our circular import problem.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-18 17:26:19 -07:00
Abhijeet Prasad Bodas 206fe1ef3b node tests: Introduce message_store.create_mock_message() helper.
Previously, it was tedious to create actual message
objects in message_store for use in node tests.
This was mainly because, `add_message_metadata`
in message_store has many dependencies and
validation checks. Since it was difficult to create
actual message objects, many tests just mocked
the `message_store.get()` method to return the desired
message.

This commit adds a new helper method (`create_mock_message`)
to message_store, for use in node tests. This just stores
the object passed to it in the `stores_messages` map,
without any validation. We do not add any
default fields to the message object before saving
it from this helper, because doing so would decrease
the utility of this helper, and, if a test
depends on some field having a particular value,
then it would be better to just pass the field: value
pair from the test itself, for readability, rather
than relying on the helper to add the field for us.

This helper allows us to write deeper tests.

This commit also replaces some instances of mocking
`message_store.get()` to use this new helper method.
2021-03-18 15:55:39 -07:00
Abhijeet Prasad Bodas aa0e5dd35b refactor: Extract update message flags POST call.
This modifies the helper to take in an array
of message ids, so that it can be used in the
`unstar_all_messages` function too.
2021-03-18 15:55:31 -07:00
Abhijeet Prasad Bodas b37e5cc017 left sidebar: Don't show unstar-all button when redundant.
Previously, if a user had zero total starred messages,
we would still show the "Unstar all messages" in the
left sidebar on opening the starred messages popover.

This commit adds a check to show button only if the
user had non-zero starred messages. This is done
because-
1. The button, when shown when the user has zero
   starred messages, is redundant and may be confusing.
2. Clicking on the button when having zero starred
   messages sends a zero-length array to the backend,
   resulting in HTTP 400 error.
2021-03-18 15:52:06 -07:00
Anders Kaseorg fe28ecb71d hash_util: Convert object characterToBeReplaced object to map.
Computed indexing into an object, especially with a user-provided key,
can be dangerous in JavaScript because of nonsense features like
obj["__proto__"].  In this case there’s no vulnerability because the
possible keys are strictly limited by the regex, but it’s always
better practice to use a Map for computed indexing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-18 15:07:17 -07:00
Signior-X e1c4c7b802 message view: Show message source button until message successfully sent.
This commit removes the unless msg/locally_echoed condition for the
edit content div, which has the consequence of making the "view
message source" widget always available for locally echoed
messages. This ensures that the message source can be seen if a very
long message has been drafted and it fails due to a server-side error
(See #17425 for the original report).

Fixes #17650.
2021-03-18 14:49:09 -07:00
Steve Howell 728905d4bc node tests: Clean pm_conversations more simply. 2021-03-18 16:37:20 -04:00
Steve Howell b2be16c4d0 node tests: Use clean BuddyList instance in tests.
As part of this, we inline one function call rather
than changing it to have buddy_list be passed in.
2021-03-18 16:37:20 -04:00
Megamind e6ee1b0760
recent typos: Fix incorrect aria-label of mute (should be unmute). 2021-03-18 10:13:25 -07:00
100RABHpy 62676e5a3d encoding: Reduce the number of replace calls while encoding URL.
We are making two calls to replace function while encoding
URL. But we can optimize it to make only one.
2021-03-18 10:12:08 -07:00
YashRE42 e268debdc6 minor: Fix mention of success handler in error wrapper. 2021-03-18 10:09:22 -07:00
Signior-X 10e6ccc3a1 refractor: Created set_calculated_message_container_variables function.
This commit takes the blocks of code from "build_message_groups" that are the
same as "_rerender_message", and move those into a function called
"set_calculated_message_container_variables". This helps to avoid bugs in
future as in #17663. Like timestr was being updated in one of them, but needed
in both. So, it takes care that message variables are correctly set.

Part of #17663
2021-03-17 17:21:42 -07:00
Signior-X 0487503cc4 message view: Fix the wrong time shown for message locally echoed.
This commit updates the _rerender_message to update the message_time
string with the current timestamp on the message rerender.

When we locally echo a message, we store a local timestamp that will
generally not be used as it is replaced by the server time in
echo.process_from_server when we confirm receipt of the message.

echo.process_from_server correctly updates the .timestamp field on
the message and triggers a rerender but that rerender reuses
the message_container object without recomputing the
message_container.timestr due to which wrong older timestr was shown
on the message box.

This commit fix this by calling set_timestr in the rerender code path,
alongside calls to update similar data structures like
this._maybe_format_me_message.

Fixes #17655
2021-03-17 17:21:42 -07:00
yasiruRathnayaka97 2d414fa897
left-sidebar: Fix 3-points-menu responsive bug.
In responsive narrow windows where the left sidebar is an overlay, clicking the \vdots menus for  
'All messages' and 'Starred messages' would result in the navigation closing and the menu appearing
somewhere weird.

We fix this the same way that we address this issue with the similar stream/topic menus, by calling
the function to show this sidebar after closing all popovers.

Fixes: #17537.
2021-03-17 15:11:23 -07:00
Nikhil Maske d9776159f1 account_settings: Change the position of the custom-profile-fields-form.
The custom-profile-fields-form element custom_user_field contains
the textarea for Biography that expands. The textarea treats the
user-avatar-section as an disturbing obstacle when expanded beyond
the certain width. To fix this, the custom-profile-fields-form
is placed out from the account-settings-form.

Fixes #17617.
2021-03-17 12:25:12 -07:00
Anders Kaseorg 3ef6f6e2e2 js: Convert static/js/blueslip.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-17 08:47:15 -04:00
100RABHpy 039dd256a1 markdown: Fix a bug in query_and_reply.
Fixes #17466
This commit will change encoding logic. Initial logic
was not encoding parenthesis, and this creates conflicts
with the markdown link format. To resolve this while encoding,
we're now replacing parenthesis with ".28" and ".29."

There is no need to change decoding logic because before
decoding any URL, we first convert all the “.” to “%.”

optimization: No need to replace parenthesis in popovers.js.
2021-03-16 16:40:37 -07:00
Aman Agrawal f79a59d5f8 recent_topics: Directly pass jquery element instead of event object. 2021-03-16 14:54:22 -07:00
Aman Agrawal 493c00f2ad recent_topics: Set focus to element on click.
The scroll position of recent topics table is according to the
element which is in focus.

While this behaviour is correct, when
user clicks on an element in recent topics after scrolling to
a different position, the scroll position is lost as the focus
was not being set on the element. This commit ensures that
we set focus on the element when user clicks on it. Thus, the
scroll position being lost is naturally fixed.

Fixes #17587
2021-03-16 14:54:22 -07:00
Aman Agrawal 16a7753390 click_handlers: Extract function to mute topic. 2021-03-16 14:54:22 -07:00
pilgrim2308 2495f4498b recent_topic: Add role and area properties according to MDN docs.
Add role and area properties to recent topics filter buttons.
2021-03-16 14:54:22 -07:00
pilgrim2308 2cc96d981e recent_topics: Go to stream narrow on stream cell click.
Increase clickable area in recent topics stream cell to imporove
UX.
2021-03-16 14:54:22 -07:00
Gaurav Pandey 7ddf6435a9 left-sidebar: Remove add-streams option out of scrollbar.
This commit removes the option to add more streams out of scrollbar
as it is not visible on mobile devices or organizations with large number of
streams until scrolled down.
2021-03-16 14:10:04 -07:00
Steve Howell 15d99f87fb node tests: Clear more data for typeahead_helper.
We also use a more realistic method of setting
recipient counts, and we make the pm count test
a bit more explicit.
2021-03-16 09:04:26 -04:00
Steve Howell e9e8bcd26e node tests: Add popovers.clear_for_testing(). 2021-03-16 09:04:26 -04:00
Abhijeet Prasad Bodas 2ea330b025 linkifier settings: Remove loading indicator.
There is no element on the settings page with
id="admin_page_filters_loading_indicator", so
the indicator doesn't appear. And even if we make
a div for an indicator, it would be hardly visible,
because we don't call the server to fetch linkifiers
in this page, and there generally won't be too many
linkifiers to render.
2021-03-15 11:19:59 -07:00
Abhijeet Prasad Bodas 0acfbc385b linkifier settings: Fix empty list message not shown.
Previously, if there weren't any linkifiers set, only
non-admins could see the "No linkifiers set." message
below the list header. We do not hide the linkifiers
(when there are some of them) from non-admins, so there
seems to be no reason hide the above message when there
aren't any linkifiers.
2021-03-15 11:19:59 -07:00
Abhijeet Prasad Bodas 9223dced3b refactor: Rename filter to linkifier in frontend code and docs.
This only leaves `page_params.realm_filters`, which
will be changed in further commits along with the
API change.
2021-03-15 11:19:59 -07:00
tushar912 c6d1fbd051 settings: Fix input mouse behaviour in custom profile fields.
Add input to filter in sortablejs config. This prevents drag
and drog from being called on clicking input field. Also
set preventOnFilter to false. This prevents disabling the
default behaviour on the click event.

Fixes #17619
2021-03-15 11:11:47 -07:00
Steve Howell ece986bd10 node tests: Clear data for sort_recipients. 2021-03-15 13:05:49 -04:00
Steve Howell d7d357f61e node tests: Add test_all() wrapper for widgetize.
I also move around a couple set_global/mock_esm
calls.
2021-03-15 13:05:49 -04:00
Steve Howell 09bad82131 node tests: Add test() wrapper for typing_data. 2021-03-15 13:05:49 -04:00
YashRE42 1247b4f341 hotkeys: Deduplicate popover event calls.
This enables us to only have one block with all the calls instead of
duplicating the enter case.
2021-03-14 23:10:51 -07:00
YashRE42 b15f5c7214 hotkey: Add "enter" support for user info popover from message.
Previously we could navigate the user info popover on messages by
using the up/down arrow keys, but we could not use the enter key to
select an item, this commit fixes the bug.

Fixes: #17589.
2021-03-14 23:06:31 -07:00
Nikhil Maske f5544e36ed markdown: Add fa-clock icon before markdown timestamps.
These sigils will help make it easier to see that this is a special
Zulip syntax feature, not just something the other user typed, which
might help set the expectation that we're showing the time in the
user's timezone.

Tweaked by tabbott to improve variable/template naming.
2021-03-14 22:57:01 -07:00
Harsh Srivastava cd1601a858
left sidebar: Fix exception when deleting last stream.
Apparently, we never tested the unlikely behavior of deleting the last stream,
and doing so would result in exceptions being thrown (and thus no UI update).

Fixes: #16691
2021-03-14 22:34:07 -07:00
Tim Abbott e1aa7dd882 portico: Fix line-wrapping of bulleted lists with 2-digit numbers.
As demonstrated with the recent Zabbix integration, our line-wrapping
of numbered lists was busted in the presence of 2-digit numbers of steps.

Fixes #17634.
2021-03-14 19:36:29 -07:00
Anders Kaseorg 32df287818 ready: Wait for other ready callbacks before marking app loaded.
This is needed not because the DOM isn’t ready here (we’re in a
<script defer>), but because we want to wait an asynchronous tick
until after all the other callbacks that waited an asynchronous tick
for the DOM to be ready.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-14 17:36:22 -07:00
Steve Howell bbe12a3967 node tests: Ensure clean data for timerender tests.
We explicitly initialize things that future tests
could possibly mutate.
2021-03-14 11:38:21 -04:00
Steve Howell 92e611a787 node tests: Add test() wrapper for lightbox. 2021-03-14 10:46:45 -04:00
Steve Howell ae6c435bb4 node tests: Clean up hashchange tests.
* use override
* localize window_stub
* add clear_for_testing() helper
2021-03-14 08:11:25 -04:00
Steve Howell 85bd196bfc node tests: Add test() wrapper to bot_data. 2021-03-14 08:11:25 -04:00
Steve Howell fbd3669461 zjsunit: Do not run $(...) automatically.
We have generally gone away from using $(...)
initialization in modules that we test with
zjsunit, but there are a few remaining special
cases related to our billing and portico
codebases.
2021-03-13 11:48:50 -05:00
Steve Howell bc8647539c code cleanup: Remove obsolete stream_sort code.
I remove an obsolete comment--we use get_streams()
for the `n` key now.

I also remove a guard statement from sort_groups()
that returned `undefined` for empty lists.

That guard statement would break this code:

    const stream_groups = stream_sort.sort_groups(streams, get_search_term());

    if (stream_groups.same_as_before && ...

The calling code prevents the situation anyway:

    const streams = stream_data.subscribed_stream_ids();
    if (streams.length === 0) {
        return;
    }

I modify the "no_subscribed_streams" test to test
the new behavior.  (Even though stream_list currently
short-circuits the call here, that may change in the future.)

I also introduce the test() wrapper to explicitly clear
our data.
2021-03-13 11:48:50 -05:00
Aman Agrawal d8af33d24e recent_topics: Don't switch focus to input on `k` / `j` keypress.
Don't focus on search box when user is at end or start of
the table and is using vim keys. This ends up being a
bad UX as once user is inside the search box, vim
navigation keys cannot be used to take user out of
the search box.
2021-03-13 05:43:24 -05:00
Steve Howell 154daf353b node tests: Add test() wrapper for suggestions. 2021-03-12 15:29:23 -05:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Anders Kaseorg 92a46888f0 node_tests: Mock sortablejs to avoid __Rewire__.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Steve Howell 87a3650176 node tests: Clean up recent_senders test.
This introduces the make_stream_message()
helper to avoid all the strange
`messages[0] === message1` confusion.

We also clear data explicitly at the beginning
of the test.

It's still a messy test.
2021-03-12 11:18:44 -05:00
Steve Howell f5506c78aa node tests: Clear data for presence tests.
I considered using set_info({}, 0) to clear data,
but it has a lot of machinery that could lead
to accidental line coverage and/or extra test
complexity.
2021-03-12 11:18:44 -05:00
Steve Howell bbf529f2a5 node tests: Clear data for pm_list tests. 2021-03-12 11:18:44 -05:00
Steve Howell 67a5fe95dc minor: Remove empty pm_list.initialize().
The commit 3cfc3ca24b
made this function do nothing, but I guess that
we thought we might resurrect the click handler
in the short term.  We never did.
2021-03-12 11:18:44 -05:00
m-e-l-u-h-a-n e781136acd css: Add separate class for typeahead items with no presence circle.
This commit adds a new class for typeahead items that do not need
a presence circle. It is changed to support addition of new items
that do not require presence circle.

There should not be any visual change due to this.
2021-03-12 02:10:21 -08:00
m-e-l-u-h-a-n 629aeced16 compose: Remove presence circles for wildcard users.
This commit removes presence circles for special users like
all, stream, and everyone. This was discussed at
 #design>Presence circles in typeahead, and this was justified
as presence circles for these special users will always be grey
circle and do not convey any information about presence of anyone.
2021-03-12 02:10:21 -08:00
m-e-l-u-h-a-n cd0d3347ab compose: Fix spacing of presence circles in typeahead.
This commit increases spacing between presence circles and user avatar
in typeahead suggestions.
These changes were discussed in #design>Presence.
2021-03-12 02:10:21 -08:00
Steve Howell 71ccb99531 node tests: Clean up pm_conversations.
* Hoist zrequire("people") to the top.
    * Add clear_for_testing() hook.
    * Add initialize_recents() helper.
2021-03-12 04:42:37 -05:00
Anders Kaseorg 7f30e5f9df info_overlay: Render Markdown help with frontend Markdown library.
Fixes #15375.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-11 21:24:39 -08:00
Tushar912 dc67870e0c avatar: Add confirmation dialog before deleting profile picture.
Use confirm_dialog here as this change is destructive and thus not
easy to undo.

We may want to consider using settings_ui.do_settings_change()
instead.

Fixes #17073.
2021-03-11 19:58:38 -08:00
Tushar912 cda3da18f4 settings: Refactor check_profile_incomplete.
Split the logic of check_profile_incomplete into two functions
show_profile_incomplete and check_profile_incomplete.

The latter is passed to the former which shows the message if the
profile is incomplete.
2021-03-11 19:55:29 -08:00
Tushar912 432751c319 settings: Improve check for incomplete org profile.
Use a regex to check for the pattern "Organization
imported from ..." instead of the previous approach
where we just checked if pattern startswith "Organiztion
imported from".

This allows users to extend the description from the original
"Organization imported from Slack." with a few extra sentences without
this warning remaining indefinitely.

Fixes #17463
2021-03-11 19:54:46 -08:00
Aman Agrawal e587c029f6 display_settings: Allow user to set default_view.
TextField is used to allow users to set long stream + topic narrow
names in the urls.

We currently restrict users to only set "all_messages" and
"recent_topics" as narrows.

This commit achieves 3 things:
* Removes recent topics as the default view which loads when
  hash is empty.
* Loads default_view when hash is empty.
* Loads default_view on pressing escape key when it is unhandled by
  other present UI elements.

NOTE: After this commit loading zulip with an empty hash will
automatically set hash to default_view.  Ideally, we'd just display
the default view without a hash, but that involves extra complexity.

One exception is when user is trying to load an overlay directly,
i.e. zulip is loaded with an overlay hash. In this case,
we render recent topics is background irrespective of default_view.

We consider this last detail to be a bug not important enough to block
adding this setting.
2021-03-11 18:09:08 -08:00
Aman Agrawal 709fbe5c0a recent_topics: Return false when escape is unhandled.
When user presses escape but there is no action that recent topics
can perform on it, it returns false.

The final state of focus is the focus on topics table. If the focus
is on table and not on RT search or filters, we return false to
indicate that the key was unhandled by recent topics.

This will allow escape to take user to another view if recent topics
is not the default view.
2021-03-11 17:53:36 -08:00
Steve Howell a4ab6065cd node tests: Clear data for peer_data tests. 2021-03-10 07:07:34 -05:00
Steve Howell dd7420ff11 minor: Don't export unread_topic_counter.
The only places we called it now use the
helper function.

In passing I move another const to the top
of the file.
2021-03-10 07:07:34 -05:00
Steve Howell 4621e54059 node tests: Clear data for message_store tests. 2021-03-10 07:07:34 -05:00
Steve Howell c6dc9e9014 refactor: Remove message_store.each helper. 2021-03-10 07:07:34 -05:00
Anders Kaseorg 6540285a9c channel: Sever dependency on reload.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-09 17:43:07 -08:00
Steve Howell 8c6469314b node tests: Avoid intra-test leaks in buddy_data. 2021-03-08 10:45:17 -05:00
Steve Howell ab34f63ad5 node tests: Clear pending channel requests. 2021-03-08 10:45:17 -05:00
Steve Howell 7cf62cd6b1 node tests: Avoid __Rewire__ for clipboard API. 2021-03-06 14:33:30 -05:00
Steve Howell 8006c29748 node tests: Extract create_sortable for testing. 2021-03-06 11:10:57 -05:00
Josh Gilley de74d2fd7c settings: Use HTML table for "Alert Words" for better icon alignment.
"Alert Words" is one of Zulip's oldest settings UI elements, and as a
result is buggy.  This commit converts it to use our standard
progressive-table-wrapper system used for settings tables, which has
the side effect of fixing a bug that mad ethe tables look pretty bad
if one adds a very long word.

Fixes #17172.
2021-03-05 14:38:56 -08:00
Steve Howell f6edaaab96 node tests: Test upload.feature_check directly. 2021-03-05 12:57:20 -05:00
Anders Kaseorg 62532777b1 server_events: Replace deprecated $.now alias.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 18:07:47 -08:00
Anders Kaseorg 4a3d66f776 setup: Remove unused $.fn.within.
It’s unused since commit 805ac2475b
(#14162).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 18:04:14 -08:00
smit_patel fb8d18caf8 compose: Fix alignment of Drafts button.
Fixes #17095.
2021-03-04 17:33:01 -08:00
Ganesh Pawar 3dbbbb04f8 message_list_view: Remove duplicate comment.
The comment and the conditional check is already present at the
start of the function.

This seems to have been introduced in
a9235a74f4, back in 2014.
2021-03-04 17:17:12 -08:00
m-e-l-u-h-a-n f4a111e314 compose: Add user presence circles in mention and pm typeahead.
This commit addresses the problem of user's status visibility to
some extent. It adds presence circles, like we have in buddy_list to the
typeahead suggestions that are given for mentioning users in messages.

Tweaked by tabbott to adjust vertical alignment of group mentions as well.

Testing for the changes is done manually in the developement server,
and also by updating frontend tests to address these changes.

Fixes: #17138
2021-03-04 17:06:02 -08:00
Tim Abbott 7def3e7832 css: Fix vertical alignment of mention typeahead.
Somehow the previous styling was oddly off-center.
2021-03-04 17:05:04 -08:00
pilgrim2308 ec88ba38a9 UI: Fix redundant condense message appearing in edit message menu.
Added the handler functions which were previously missing
for when a user tries to edit/view source of a message
after expanding it.

Fixes #17478
2021-03-04 15:28:17 -08:00
Gaurav Pandey 3dcf97bf27 tooltip: Hide tooltip for touch events on touch-enabled devices.
Fixes #16674.
The commit hides the tooltip for touch events on touch enabled device.

Touch events trigger both click and hover action,
leaving the hover action sustained until next click.

Hence it is better to hide the tooltip to avoid the clutter in UI.
2021-03-04 12:32:16 -08:00
Anders Kaseorg e271936aae logos: Optimize jotform.svg with svgo 2.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 12:24:25 -08:00
Gaurav Pandey 3d7462a0e7 integration: Add jotform integration.
Fixes #16554
2021-03-04 11:40:58 -08:00
Anders Kaseorg 63eae63a07 timerender: Fix comparison of Date objects.
This === comparison between two Date objects added by commit
9896782fd1 (#17220) always returned
false, so the body of timerender was running every minute instead of
every day.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 11:04:54 -08:00
Anders Kaseorg 23b589cce3 timerender: Do not duplicate entries of update_list!!
Commit 13915740bb (#5199) added a loop
in update_timestamps that appended an entry to update_list once for
each element that its className matched.  If there were two such
elements, this would double the length of update_list each time the
body of update_timestamps ran.  So let’s not do that.

Also fix the incorrect elements !== null check from the same commit.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 11:04:54 -08:00
Gaurav Pandey a3561c15d2 invites: Remove odd box-shadow for invite link clipboard svg. 2021-03-03 21:57:41 -08:00
Anders Kaseorg 9613c66560 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-03 21:46:42 -08:00
Aryan Shridhar bfefec31f4 Revert "edit_bot: Fixed dropdown username capitalization."
This reverts commit ea02d48e81.
2021-03-03 23:58:50 +05:30
Aryan Shridhar d1198c46c5 Revert "frontend: Fixed broken label tag and removed label expression."
This reverts commit 17bae43052.
2021-03-03 23:58:50 +05:30
Steve Howell b1a871f2e0 node tests: Avoid reset_module for recent_topics. 2021-03-03 07:08:51 -05:00
Anders Kaseorg a58e832884 eslint: Remove unneeded globals.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 099e8fb00e js: Convert static/js/settings_profile_fields.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7ec8b8980f js: Convert static/js/dropdown_list_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 9e613b1487 js: Convert static/js/message_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg d8c793f791 js: Convert static/js/composebox_typeahead.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 5cc1f8d289 js: Convert static/js/ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 8dbaf2d680 js: Convert static/js/subs.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 0e90f3be6d js: Convert static/js/compose_actions.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg e74598da17 js: Convert static/js/narrow.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7a67c06581 js: Convert static/js/message_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 68872f44f6 js: Convert static/js/widgetize.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 3e8ddc229b js: Convert static/js/stream_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 727208b84c js: Convert static/js/unread.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 9997e13032 js: Convert static/js/unread_ops.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7ec3fc38fa js: Convert static/js/input_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg ac4e293da5 settings_profile_fields: Use named export from sortablejs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 4a2f937732 narrow: Add setter for narrow_title.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg b38712d8d2 js: Convert residual require() calls to import in ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 79ac5c25b5 zulip_test: Re-export internal functions used by Puppeteer tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Gaurav Pandey 60c6ba7c3a right-sidebar: Display ellipsis icon by default on touch-based devices.
Hover does not work for touch-based devices like mobile phones.
Hence the icons on the right sidebar do not appear, making the
user unaware of its presence on such devices. The following
media property displays the icon by default for such behaviour.
2021-03-02 12:05:50 -08:00
Gaurav Pandey 56f16ca9dd left-sidebar: Display ellipsis icon by default on touch-based devices.
Hover does not work for touch-based devices like mobile phones.
Hence the the icons does not appear, making the user unaware of its
presence on such devices. The following media property displays the
icon by default for such behaviour.
2021-03-01 15:40:39 -08:00
Anders Kaseorg d8ad63126d js: Convert static/js/billing/helpers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 2a49ce1b6c js: Convert static/js/search_pill_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1a8422b152 js: Convert static/js/recent_topics.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 934d4e4e10 js: Convert static/js/panels.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg dc95f06b62 js: Convert static/js/compose_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00