Commit Graph

228 Commits

Author SHA1 Message Date
Raghav Luthra 4dad9fa158 user_settings: Add user setting to control the user list style.
Added a user_list_style personal user setting to the bottom of
Settings > Display settings > Theme section which controls the look
of the right sidebar user list.

The radio button UI includes a preview of what the styles look like.

The setting is intended to eventually have 3 possible values: COMPACT,
WITH_STATUS and WITH_AVATAR; the final value is not yet implemented.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2022-09-09 16:30:54 -07:00
Anders Kaseorg e0b593f67e js: Use .empty() instead of .html("").
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-08-17 16:04:55 -07:00
Anders Kaseorg c520890f54 node_tests: Remove low-hanging uses of __Rewire__.
When we were preparing the conversion to ES modules in 2019, the
primary obstacle was that the Node tests extensively relied on the
ability to reach into modules and mutate their CommonJS exports in
order to mock things.  ES module bindings are not mutable, so in
commit 173c9cee42 we added
babel-plugin-rewire-ts as a kludgy transpilation-based workaround for
this to unblock the conversion.

However, babel-plugin-rewire-ts is slow, buggy, nonstandard,
confusing, and unmaintained.  It’s incompatible with running our ES
modules as native ES modules, and prevents us from taking advantage of
modern tools for ES modules.  So we want to excise all use of
__Rewire__ (and the disallow_rewire, override_rewire helper functions
that rely on it) from the tests and remove babel-plugin-rewire-ts.

Commits 64abdc199e and
e17ba5260a (#20730) prepared for this by
letting us see where __Rewire__ is being used.  Now we go through and
remove most of the uses that are easy to remove without modifying the
production code at all.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-07-13 16:27:30 -07:00
YashRE42 20f36431ec presence: Rename hbs templates to not have the word "user".
This is a prep commit for enabling a two section layout in the
buddy_list. The sections will be for "users" and "others".

Hence, this commit performs a simple rename of:
- `user_presence_row.hbs` -> `presence_row.hbs`
- `user_presence_rows.hbs` -> `presence_rows.hbs`
And then a search and replace of `user_presence_row` to
`presence_row` (which also handles the second rename).

It also makes one modification in buddy_list.js where it changes a
template variable we're passing from "users" to "row_members".
2022-07-13 14:34:44 -07:00
Anders Kaseorg 4d0fca8285 zjsunit: Merge with_field, with_…_disallowed into with_overrides.
This increases consistency and saves a bit of code, but more
importantly, it makes it much easier to switch between these APIs
while refactoring tests.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-07-11 11:35:49 -07:00
Anders Kaseorg a682530fd4 node_tests: Enforce 100% coverage for test files.
This makes it easier to find obsolete parts of the tests that should
be cleaned up.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-10 19:31:56 -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
Anders Kaseorg 64abdc199e zjsunit: Split deprecated __Rewire__ functionality out of override.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-08 10:01:27 -05:00
Yash Rathore 345616ad02
user_sidebar: Set personal presence dot based on the user's settings. (#20376)
If a user chooses to not broadcast their presence status to others, we
still show the user as available in their own user sidebar. Instead, one's
own availability should appear the same as it does for other users.

With tweaks from YashRE42: rebasing to use user_settings instead of
page_params, as introduced in the series of commits ending with
8755a76cf6, adding code comments and
moving the redraw call to `server_events_dispatch.js`.

Fixes part of #18846.  Further work is required to display the user's own idle
status properly to complete #18846.

Co-authored-by: YashRE42 <33805964+YashRE42@users.noreply.github.com>

Co-authored-by: Ganeshprasad Biradar <biradarganesh25@gmail.com>
2021-12-03 16:20:20 -08:00
Riken Shah 840ab92f7f user_status: Add architecture to support status emoji feature.
In this commit, we only update the existing architecture
to support the status emoji feature:

* We add the `user_status_emoji_info` map so we can
keep track of the users' staus emoji.

* Listen to the server event to update/set the
`user_status_emoji_info` map.

* Add `status_emoji_info` field, when getting user's data.
2021-07-28 09:50:11 -07:00
Priyank Patel 968a8c4e50 js: Split out muted_users module from muting. 2021-06-30 16:32:55 -07:00
Steve Howell 5e824a6d6d node tests: Only expose mock_template via run_test.
We now only expose mock_template as a helper in run_test.

This has the following advantages:

    * less boilerplate at the top of the file
    * more surgical control with setting exercise_templates
    * no more "f" hack (or render_foo consts)
    * we force devs to explicitly mock the template

See frontend_tests/zjsunit for the substantive changes.

All the changes to the tests are very mechanical in nature.
2021-06-27 23:00:34 -04:00
Steve Howell cc4c29fb4a node tests: Use mock_template for activity. 2021-06-27 11:01:12 -04:00
Steve Howell d5c4495fa5 zjsunit: Wire $ to zjquery by default.
I introduce `mock_jquery` for modules that
want their own mock implementation.
2021-06-16 12:55:53 -04:00
Steve Howell 9e657dd795 node tests: Use {override} in run_test. 2021-06-16 12:55:53 -04:00
Aman Agrawal 64f04e9913 web_public_view: Replace `web_public_visitor` with `spectator`.
We use `spectator` term instead of `web_public_visitor` as it is
more concise and better represents this type of users.
2021-06-16 07:46:34 -07:00
Riken Shah f95c539122 custom_check: Avoid use of assert to avoid confusion with assert.equal.
This commit bans the use of `assert` and replaces it
with `assert.ok` to avoid confusion with `assert.equal`.

Fixes #18687.
2021-06-10 09:15:57 -07:00
Anders Kaseorg 40880aa496 node_tests: Use assert.equal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Priyank Patel 6ab66ea17a keydown_util: Use Event.key instead of deprecated properties.
The Event.which and Event.keyCode are deprecated as pointed out by
TypeScript intellisense based on the jQuery types. We use Event.key
instead which behaves similarly to Event.which & Event.keyCode for
our use case.

The only difference in functionality by this change is that the vim
keys won't work when Caps Lock is on. This is because, in this case,
the key property will be "J" instead of 'j'. We can fix this by
adding a mapping for this, however, I think we don't want to handle
this case so I left this change out. Tested by trying out the
everywhere keydown_util is used.

Finally, we also turn off the new-cap rule for tests since I think
it fine to only enforce it on real code and exempting test code is
fine.
2021-05-27 23:33:17 -07:00
Steve Howell 664afd2a1c node tests: Clean up electron_bridge test.
We use with_field to avoid leaks and then
just organize things better.
2021-05-19 11:06:18 -04:00
Steve Howell bdb2fa707c node tests: Use override for insert_or_move. 2021-05-18 18:34:17 -04:00
Steve Howell 1246970c23 node tests: Tweak test for first/prev/next. 2021-05-18 18:34:17 -04:00
Steve Howell eb46ac408d node tests: Add activity.clear_for_testing(). 2021-05-18 18:34:17 -04:00
Steve Howell fb0ba995c3 node tests: Use real version of keydown_util. 2021-05-18 18:34:17 -04:00
Steve Howell 5cbeaf1728 node test: Simplify presence statuses.
The test() wrapper makes a new map every time
with only "mark" as the idle user.
2021-05-18 18:34:17 -04:00
Steve Howell 2d02297f43 node tests: Use test() wrapper consistently.
The diff is slightly noisy due to some lexical
code moves, but otherwise it's search/replace.
2021-05-18 18:34:17 -04:00
Steve Howell 36077774fc node tests: Use override for fill_screen_with_content. 2021-05-18 18:34:17 -04:00
Steve Howell 7a9d0a505d node tests: Avoid rewiring client_is_active. 2021-05-18 18:34:17 -04:00
Steve Howell cd1510c0ef node tests: Extract user_search tests.
This is mostly moving tests from activity.js
into user_search.js, but it's not a verbatim
code move.

The new module continues to make sure that
the boundary between activity and user_search
is correct, as most of the testing uses
the configuration of UserSearch from
static/js/activity.js.

It does not use a real buddy_list, though,
which simplifies some tests.

I cleaned up some tests by making sure we
were testing both sides of conditions more
rigorously.

After this change we no longer need the
bloated activity.js tests to maintain full
coverage on static/js/user_search.js.
2021-05-18 14:16:55 -04:00
Steve Howell ee066a1a91 node tests: Use per-test overrides for activity tests. 2021-05-18 14:16:55 -04:00
Abhijeet Prasad Bodas 3e9b4a2090 mute user: Hide from right sidebar users list.
This commit makes it so that muted users never appear
in the right sidebar buddy list, filter text or not.

The hiding is done in the frontend only, and we still
recieve presence data from the server as before, so
no extra work is required on unmuting someone, other
than to rerender the user list.
Long term if we find that there are too many muted users,
we may want to optimize how we send presence data, but
that is unlikely to happen.

The other less extreme option is to gray out muted users,
but that cannot be done because it would conflict
with the graying out we do for non-recipients when the
compose box is open.
2021-04-26 17:44:18 -07:00
Aman Agrawal e5acbf9498 activity: Fix buddy_list unread count not being updated instantly.
While rest of the app has ported to the new system of updating
unread_counts `activity` was not ported. This resulted in
unread count in buddy list not being updated when new
PMs arrive.
2021-04-15 10:08:50 -07:00
Steve Howell 58d5778368 node tests: Explicitly set page_params values. 2021-04-03 15:03:00 -04:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17: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
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
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 876806eb4d zjsunit: Lift restriction against mocking third party modules.
Use fully resolvable request paths because we need to be able to refer
to third party modules, and to increase uniformity and explicitness.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:30 -08:00
Steve Howell 9c8fa3930f node tests: Eliminate many __Rewire__ calls.
For most functions that we were using __Rewire__ for,
it's better to just use the override helper, which
use __Rewire__ under the hood, but also resets
the reference at the end of run_tests.

Another nice thing about override() is that it reports
when you never actually needed the mock, and this
commit fixes the instances found here.

I didn't replace every call to __Rewire__. The
remaining ones fall under these categories:

    * I looked for ") =>" in my code sweep,
      so I missed stuff like "noop" helpers.

    * Sometimes we directly update something
      in a module that's not a function. This
      is generally evil, and we should use setters.

    * Some tests have setup() helpers or similar
      that complicated this code sweep, so I
      simply punted.

    * Somes modules rely on intra-test leaks. We
      should fix those, but I just punted for the
      main code sweep.
2021-03-07 11:19:33 -05:00
Steve Howell eea78df688 node tests: Clean up mock_module calls.
This is a deceptively ugly diff.  It makes
the actual code way more tidy.

I basically inlined some calls to mock_module
and put some statements in lexical order.
2021-03-07 09:35:58 -05:00
Steve Howell f54f7cfc33 node tests: Introduce mock_module helper. 2021-03-06 13:15:04 -05:00
Steve Howell 167fda142c node tests: Remove __esModule cruft.
We just set __esModule in our rewiremock helper.
2021-03-06 12:36:07 -05:00
Steve Howell 30c7108955 zjsunit: Remove rewiremock dependency.
We now just use a module._load hook to inject
stubs into our code.

For conversion purposes I temporarily maintain
the API of rewiremock, apart from the enable/disable
pieces, but I will make a better wrapper in an
upcoming commit.

We can detect when rewiremock is called after
zrequire now, and I fix all the violations in
this commit, mostly by using override.

We can also detect when a mock is needlessly
created, and I fix all the violations in this
commit.

The one minor nuisance that this commit introduces
is that you can only stub out modules in the Zulip
source tree, which is now static/js.  This should
not really be a problem--there are usually better
techniques to deal with third party depenencies.
In the prior commit I show a typical workaround,
which is to create a one-line wrapper in your
test code.  It's often the case that you can simply
use override(), as well.

In passing I kill off `reset_modules`, and I
eliminated the second argument to zrequire,
which dates back to pre-es6 days.
2021-03-06 11:10:57 -05: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 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 a832983290 js: Convert static/js/activity.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg afe310f64c js: Convert static/js/buddy_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 85ae00ce16 js: Convert static/js/padded_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 170905c065 js: Convert static/js/buddy_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 818b5aacb6 js: Convert static/js/presence.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00