Commit Graph

542 Commits

Author SHA1 Message Date
Tim Abbott bfe512335b hotkey: Clean up state more consistently in node tests. 2017-04-05 11:59:48 -07:00
Steve Howell e2a21303eb hotkeys: Simplify up/down handling for stream settings.
We've had this kind of hacky setting called message_view_only for
a long time in the hotkeys code, and it originally helped optimize
the code a bit.  It wasn't well maintained, and people started
adding non-message-view behavior to the arrow keys without flipping
that flag to false.  This change finally flips the flag to false,
which simplifies some of our logic.
2017-04-05 11:53:52 -07:00
Steve Howell 4a3211d6af hotkeys: Clean up dispatching of drafts hotkeys.
We now explicitly return true from process_hotkey() when we
handle up/down/backspace for the drafts modal.  Also, we no longer
call preventDefault() from drafts.draft_handle_events(), since the
caller does that, and we no longer return `true`, since we were
never inspecting the return value anyway.
2017-04-05 11:53:52 -07:00
Steve Howell 2ef9957cbc hotkeys: Handle up/down arrows in settings page.
The up/down arrows now navigate the left pane of the settings menu.
The code here was originally implemented as part of our settings
redesign, but the code was added in a place that became unreachable
after we fixed a bug with home_tab_obscured().  This commit
resurrects the code and places the guts of it in settings.js.  It
is possible that we want to clean this code up eventually to deal
better with hidden blocks.
2017-04-05 11:53:52 -07:00
Steve Howell 4bbd73a9a2 Extract list_util.js for navigating lists.
The code here used to live in hotkey.js.  Its complicated calling
protocol made it difficult to unit test.  We are also trying to
slim down hotkey.js.

Our arrow navigation for things like `#stream_filters` has always
been kind of awkward, since it's difficult to get the focus to
their list items.  This commit does nothing to fix that yet.
2017-04-05 11:53:52 -07:00
Steve Howell 2420df8415 buddy list: Make small realms show all users.
For small-ish realms (<= 250 users), we ensure that the presence
info includes all realm users the front end knows about, even in
cases where the server sends down a slimmed version of presence
data.  We make the users "offline" by default, of course.

This commit sets us up to optimize larger realms without concerns
of breaking small realms.  Small realms may want to continue to
show all users, even users who may have been offline several weeks,
since it doesn't clutter their API as much as it would for big
realms.
2017-04-04 15:57:10 -07:00
Steve Howell a4d5a12ca0 Add people.get_realm_count(). 2017-04-04 15:57:10 -07:00
Steve Howell 2718bd0b5d Extract presence.js to track presence info.
Most of this code was simply moved from activity.js with some
minor renaming of functions like set_presence_info -> set_info.

Some functions were slightly nontrivial extractions:

    is_not_offline:
        came from activity.huddle_fraction_present

    get_status/get_mobile:
        simple getters

    set_user_status:
        partial extraction from activity.set_user_status

    last_active_date:
        pulled out of admin.js code

We also fixed activity.filter_and_sort to take user_ids.
2017-04-04 15:57:10 -07:00
Harshit Bansal 0605a9fb0f templates: Rename `admin-alias-list.handlebars`.
Rename `admin-alias-list.handlebars` to
`admin-realm-domains-list.handlebars`.

Fixes: #3145.
2017-04-04 15:48:03 -07:00
Harshit Bansal 885ec07192 frontend: `realm_alias` to `realm_domain` migration.
* Change the classes and ids of different widgets and modals
and make suitable changes in `admin.js`.

* Remove any other occurrences of `alias` or `realm_alias`
from admin.js.
2017-04-04 15:48:03 -07:00
Steve Howell 3f4301bcec node tests: Simplify i18n.js and avoid jquery leak.
We remove the jquery dependency here and just search for strings
in the text.  It turns out the test was leaking jquery into
message_edit, so now we explicitly stub jquery in message_edit.
2017-04-04 06:51:31 -07:00
Steve Howell e4e0b6d572 node tests: Speed up echo.js by stubbing window. 2017-04-04 06:31:37 -07:00
Steve Howell fa729f11bd node tests: Speed up activity.js by stubbing jquery. 2017-04-04 06:31:37 -07:00
Steve Howell 79e945edb1 node tests: Test people.small_avatar_url(). 2017-04-03 16:34:16 -07:00
Steve Howell e21bb2ebfe node tests: Test people.pm_reply_to(). 2017-04-03 16:34:16 -07:00
Steve Howell 7d3a7e12e8 node test: Add test_get_recipients(). 2017-04-03 16:34:16 -07:00
Steve Howell 4ec4b28562 Add tests for people.reply_to_to_user_ids_string(). 2017-04-03 16:34:16 -07:00
Steve Howell 99d603b424 node tests: Add test cases for pm-with filter.
This commit gets us to 100% line coverage for filter.js.
2017-04-03 16:31:57 -07:00
Steve Howell 3ddb8690af node tests: Test some zero-count cases for unread.js.
Our unread.js code basically silently treats empty recipient
strings or unknown streams as having zero unread messages,
which is probably the correct behavior.  We now have tests
that cover this.  This commit also gets us to 100% line
coverage on the module (but not yet 100% branch coverage).
2017-04-03 16:31:57 -07:00
Steve Howell 8d647868ca Use fewer messages in test_num_unread_for_subject().
I am not sure why I originally coded this to use 10000
messages, since it's not really a performance test.
2017-04-03 16:31:57 -07:00
Brock Whittaker 34f9ccb87c alerts: Change sidebar alerts to be at top of the screen.
This changes the alerts to be individual boxes that slide down from
the top of the screen for a better UI experience.
2017-04-03 16:22:05 -07:00
Sampriti Panda 32e76c2c60 drafts: Move snapshot_message from compose to drafts
Previously drafts called compose.snapshot_message which would then
get the message object from compose.create_message_object. This method often
checked for the validity of stream/user recipients which would often cause tracebacks.

The new method in drafts.snapshot message just gets the data from the fields and
stores them in the draft model without any additional checking.
2017-03-30 10:20:37 -07:00
Sampriti Panda 400a2e0ff1 drafts: Fix faulty draft_model addDraft and editDraft tests
The addDraft and editDraft tests were copying objects by reference
which meant the methods weren't tested properly. Due to this, a bug with
stubTimestamp was also discovered where the method wasn't getting stubbed
2017-03-30 10:20:37 -07:00
Jonathan Pan 5556d2341c hotkey.js: Add hotkey for drafts.
* 'd' in message view opens drafts.

This also adds hotkeys within the drafts UI:
* Up/down arrow keys navigate the drafts.
* Pressing enter edits the selected draft.
* Pressing backspace deletes the selected draft.

Some variable names tweaked by tabbott.
2017-03-27 14:05:00 -07:00
Harshit Bansal d17b759fa2 admin: Display last active time of users in admin users table.
Fixes: #2097.
2017-03-27 13:39:47 -07:00
Steve Howell cf6545a71f reactions: Only warn for unknown user ids.
If we get reactions for deactivated users, or otherwise missing
users, we only issue a blueslip warning now.  The function
get_message_reactions() was indirectly causing blueslip errors
before this fix, but we can downgrade to warnings now that this
function has better unit tests around it.

We eventually want to track deactivated users on the client.

Fixes #4289
2017-03-26 11:51:36 -07:00
Steve Howell 3da047e10e Add people.is_known_user_id(). 2017-03-26 11:39:06 -07:00
Steve Howell 03b7e59b59 node tests: Add reactions.js test module.
We test get_message_reactions() in our first test here.
2017-03-26 11:39:05 -07:00
Cynthia Lin 6e2d180a34 hotkeys: Add hotkey `n` for opening New streams modal in Streams menu. 2017-03-25 18:35:21 -07:00
Cynthia Lin ca460fad1f hotkeys: Add hotkey `V` for viewing selected stream in Streams menu. 2017-03-25 18:35:21 -07:00
Cynthia Lin b800cb05c0 hotkeys: Add left/right arrow keys to toggle views in Streams menu.
Fixes #4228
2017-03-25 18:35:21 -07:00
Cynthia Lin 69c32daffa hotkeys: Add `U` hotkey for unsubscribing/subscribing in Streams menu.
Fixes #4229
2017-03-25 18:35:21 -07:00
Cynthia Lin d17131dcb4 hotkeys: Rename subs.arrow_keys() to subs.switch_rows(). 2017-03-25 18:35:21 -07:00
Joshua Pan 7adf70e5ad Add node tests for M hotkey. 2017-03-25 09:42:49 -07:00
Tim Abbott e16b082b70 casper: Attempt to fix flakiness in new reload test. 2017-03-23 13:56:59 -07:00
Tim Abbott 49f5be1dba hotkey: Extend tests for message_view_only_keys. 2017-03-23 11:38:37 -07:00
Joshua Pan f40b43a491 hotkeys: Add hotkey `G` an alias for End.
Fixes #4195.
2017-03-23 11:38:36 -07:00
Tim Abbott 5d030e9173 casper: Add test for the reload hashchange logic. 2017-03-22 23:06:08 -07:00
hackerkid ed72ee476f Make user_popover use user_info_popover template. 2017-03-22 16:04:38 -07:00
hackerkid b2fc8d6fa2 Rename message_info_popover* templates to user_info_popover*. 2017-03-22 16:04:38 -07:00
hackerkid 23a5f56023 Add sender avatar in message popover. 2017-03-22 16:04:38 -07:00
hackerkid 32bc5893d0 Remove arrow from message info popover by providing template.
Provide custom template (user_info_popover.handlebars) to message info popover.
2017-03-22 16:04:38 -07:00
hollywoodno d6716838ad bugdown: Remove trailing whitespace on fence code blocks.
This fixes fenced code blocks that are copy-pasted from certain
clients having trailing whitespace anoyingly often.

Fixes #3998.
2017-03-22 14:17:34 -07:00
Steve Howell 2991c19fea Extract typing indicator inbound timing logic.
We now track our inbound timing events using code in
typing_data.js.

This code may be a little more robust with variations on how
recipients are represented in events, although there are no known
bugs here.
2017-03-22 08:20:21 -07:00
Steve Howell 642be6ad18 Revamp state tracking for outbound typing indicators.
This change moves most of the logic related to starting and
stopping outbound typing indicators to a new module called
typing_status.js that is heavily unit tested.

While this was in some sense a rewrite, the logic was mostly
inspired by the existing code.

This change does fix one known bug, which is that when we
were changing recipients before (while typing was active), we
were not stopping and starting typing indicators.  This was
a fairly minor bug, since usually users leave the compose
box to change recipients, and we would do stop/start under
that scenario.  Now we also handle the case where the user
does not leave the compose box to change recipients.
2017-03-22 07:01:20 -07:00
Cynthia Lin 1dfac12c4b hotkeys: Add arrow key navigation in streams/subscriptions menu.
Fixes #4198.
2017-03-21 20:32:28 -07:00
Steve Howell 67a2094ed1 Add typing_data.js, which can track users who are typing.
(A subsequent commit will actually integrate this into the app.)
2017-03-21 17:24:40 -07:00
Tim Abbott 8b9e78e486 compose: Extract and test get_focus_area. 2017-03-21 17:24:40 -07:00
Yago González 34a9e1ae11 markdown: Add TeX typesetting support.
Co-authored-by: Reid Barton <rwbarton@gmail.com>

Fixes #2056.
2017-03-21 16:40:00 -07:00
Brock Whittaker 9c38dc84a7 Change two console.log statements to one with prefixed newline.
The console.log statement that is empty can be replaced with just a
single newline.
2017-03-21 14:28:13 -07:00