Commit Graph

4116 Commits

Author SHA1 Message Date
Steve Howell 08bc69f8af huddles: Calculate huddle strings more robustly.
We now build huddle strings used in activity.js from
user ids in message.display_recipient.
2017-02-06 22:38:22 -08:00
khantaalaman c3fd0d4e0c subs: Fix incorrect use of RegExp in stream filtering.
When filtering streams, we were incorrectly treating the regexp input
provided by the user as a regular expression, meaning that terms like
`c++` would trigger errors because they are invalid regular expression
syntax.  We fix this by replacing RegExp with a simple IndexOf check.

Node test added by tabbott.

Fixes #3559.
2017-02-05 13:01:43 -08:00
Steve Howell 85cee51c68 Extract frontend_tests/node_tests/pm_list.js.
This code used to live in node_tests/stream_list.js.
2017-01-30 11:49:19 -08:00
Steve Howell 373c8a0bb5 Live-update PM list for full-name changes.
We now trigger an event in user_events.js, and we dynamically
build the list of names in pm_list.js by calling out to
people.get_recipients().

We have a few variations of functions that build lists of names
for huddles, which should be cleaned up eventually.  They are
called at different times in the code path, so the different
functions, while doing mostly the same thing, start with different
data sources.
2017-01-30 11:49:19 -08:00
Steve Howell a98cbff788 Use user's current full name when rendering messages.
The field message.sender_full_name can be out of date, so
we recompute is using data from people.js in
add_message_metadata().
2017-01-30 11:49:19 -08:00
Steve Howell 97243dcd52 Live update full names for senders in the message pane.
Note that this only works for people who are currently logged in.
Folks that log in after you may pick up the old full name from
the message.  (I'll address this in a separate commit.)
2017-01-30 11:49:19 -08:00
Rishi Gupta 6b3abce541 build_emoji: Generate emoji names and codepoints from emoji_map.
Replaces the hardcoded list of emoji_names and unicode_emoji_names in
static/js/emoji.js with a list generated from emoji_map.json, both to get
the list out of version control and so we can start modifying it for our
autocomplete. This does not change the contents of emoji_names. It sorts and
removes duplicates from unicode_emoji_names (causes no change in behavior,
since unicode_emoji_names is only used as if it were a set).
2017-01-28 17:05:32 -08:00
sinwar 21083278b5 Fix banners for unknown streams.
Fixes #3443
2017-01-28 13:11:31 -08:00
Brock Whittaker 22b74a9e01 Fix node test for emojis.
This fixes the node test for emojis that broke when the type for
displaying the emojis in the popover changed to an object from a string.
2017-01-27 16:42:00 -08:00
Steve Howell f14e2de985 Handle spaces better in compose typeaheads.
We now allow spaces and other special characters to be part
of the token (following "#", "@", or ":") that the typeahead
code will further evaluate as a typeahead candidate.

This is important for folks with short/common first names
on larger realms.
2017-01-27 12:35:46 -08:00
Harshit Bansal b4186fdfdd views/realm_aliases.py: Use domain instead of id as handle for RealmAlias.
We need to make the change for the API, and the next commit introduces a
unique_together constraint on (realm, domain) anyway.
2017-01-26 17:24:25 -08:00
Harshit Bansal f0e5380ff1 handlebar templates: Rename admin_alias_list to admin-alias-list. 2017-01-26 17:24:25 -08:00
Harshit Bansal 38c50a81ad admin settings: Restyle realm alias modal. 2017-01-26 17:24:25 -08:00
Steve Howell 88870c316f Use Dict[user_id] in people.filter_by_search_terms.
The function people.filter_by_search_terms() used
to return a JS object with emails as keys to represent
a set of users.  Now we return a Zulip Dict() object
with user_ids as keys.
2017-01-26 10:24:15 -08:00
Steve Howell 929e8a48d7 Add test_message_flags() to echo node tests. 2017-01-23 16:52:12 -08:00
Steve Howell 01aad70910 bug fix: Fix recent regression with at-mentioning.
One of my commits from yesterday erroneously set the
"mentioned" flag on messages that weren't mentioning
the current user, so you would get the pink/salmon
background when you sent at-mentions to other people.

Now we check the user_id before setting the flag.
2017-01-23 16:42:43 -08:00
Steve Howell e7e2e388c5 Move small_avatar_url() to people.js. 2017-01-21 21:45:12 -08:00
Steve Howell 4eb1a8f07d Extract user_events.js.
This moves people.update() to user_events.person().

We now also use user_id as the key for finding person
objects in people.js (instead of email).
2017-01-21 21:45:12 -08:00
Steve Howell 601bad554e bug fix: Limit updating full names in admin screens.
If we get a realm_user update for a user that is **not**
changing their full name, we no longer call
admin.update_user_full_name().

This was probably a fairly minor bug.
2017-01-21 21:45:12 -08:00
Steve Howell 28164d68b4 Extract people.set_full_name(). 2017-01-21 21:45:12 -08:00
Steve Howell ee00d848b9 refactor: Eliminate use of page_params.fullname.
We now use people.my_full_name().
2017-01-21 21:45:12 -08:00
Steve Howell 53308b49b2 refactor: Remove last uses of page_params.email in JS code.
Earlier commits removed all uses of page_params.email outside
of people.js, and it turns out we have page_params.user_id, so
we don't even need page_params.email for seeding the data.
2017-01-21 21:45:12 -08:00
Steve Howell 2af0302ed0 refactor: Use people.my_current_email() in search_suggestion.js. 2017-01-21 21:45:12 -08:00
Steve Howell 2c684bf39f refactor: Use people.my_current_email() in filter.js. 2017-01-21 21:45:12 -08:00
Steve Howell 8c6dab9750 Use data-user-id for mention buttons in local echo.
The local echo code now marks up mention buttons with user ids
instead of email.  Our code in message_list_view.js deals with
either the old style or the new style of markup now to determine
which mention buttons need to be highlighted.

As part of this commit we extract mention_button_refers_to_me().
2017-01-21 21:45:12 -08:00
Steve Howell efdcfcaea2 Clean up message flag handling for mentions in echo.js.
After this change, if a user sends a message with at-mentions, the
local echo code will add the `mentioned` flag to 'message.flags`
as part of the callback to build the HTML, rather then doing it
hackily during a post-processing step.
2017-01-21 21:45:12 -08:00
Steve Howell 2539ed0563 refactor: Have echo.apply_markdown take message as param.
The function echo.apply_markdown() actually applies markdown to
a message now, instead of simply computing markdown.  Passing
in the outer `message` object will allow us to avoid some hacky
post-processing of messages after rendering, because we can
have our parser callbacks update message on the spot in a more
atomic fashion.
2017-01-21 21:45:12 -08:00
Steve Howell 0b9a3251dd refactor: Use people.my_current_user_id() in stream_data.js.
In stream_data.unsubscribe_myself(), we no longer look at
page_params.email.
2017-01-21 21:45:12 -08:00
Steve Howell 5bce806c4e refactor: Introduce people.my_current_email().
This commit doesn't change any behavior yet, but it starts us
down the road of deprecating page_params.email and allowing
people.js to control all access to the current user's email,
which will be important for email changes.
2017-01-21 21:45:12 -08:00
Steve Howell 73125e2718 refactor: Move is_current_user() to people.js.
We no longer have it in util.js, because we will
want to encapsulate this better for upcoming commits
related to email changes.
2017-01-21 21:45:12 -08:00
Rafid Aslam 10a8c3d2ae deps: Move `xdate` from `static/third` to `npm`
- Remove `xdate` from `static/third` and fetch it from `npm`.
- Bump up the `PROVISION_VERSION` to 4.3.

Part of #1709.
2017-01-19 17:07:55 -08:00
Rafid Aslam 84e802422e deps: Upgrade and move `underscore.js` from `static/third` to `npm`
- Remove `underscore.js` from `static/third` and fetch it from `npm`.
- Upgrade `underscore.js` to 1.8.3.
- Bump up the `PROVISION_VERSION` to 4.2.

Part of #1709
2017-01-19 17:07:45 -08:00
Steve Howell cd6115c24d Make nicer slugs for "sender" narrows.
Slugs are now like our "pm-with" slugs:

    narrow/sender/3-cordelia
2017-01-19 14:54:50 -08:00
Steve Howell 1ae3feac3e Use blueslip.warn, not error, for unknown emails.
In people.emails_strings_to_user_ids_string, we just warn
for bad emails going forward.

Users can enter bad emails into the search location bar,
for example, and that causes us to compute a browser hash,
which in turn uses this function.

(It's possible that we should adjust the search code not
to compute hashes for narrowing when the narrow doesn't
make sense, but that could be a non-trivial fix.)
2017-01-19 14:54:50 -08:00
Steve Howell c94b8c39d0 Add narrow.huddle_with_uri() convenience method.
This will be used in a subsequent commit.
2017-01-17 15:13:49 -08:00
Steve Howell d757f840dd Make nicer slugs for "pm-with" narrows.
The slugs for PM-with narrows now have user ids in them, so they
are more resilient to email changes, and they have less escaping
characters and are generally prettier.

Examples:

    narrow/pm-with/3-cordelia
    narrow/pm-with/3,5-group

The part of the URL that is actionable is the comma-delimited
list of one or more userids.

When we decode the slugs, we only use the part before the dash; the
stuff after the dash is just for humans.  If we don't see a number
before the dash, we fall back to the old decoding (which should only
matter during a transition period where folks may have old links).

For group PMS, we always say "group" after the dash. For single PMs,
we use the person's email userid, since it's usually fairly concise
and not noisy for a URL.  We may tinker with this later.

Basically, the heart of this change is these two new methods:

    people.emails_to_slug
    people.slug_to_emails

And then we unify the encode codepath as follows:

    narrow.pm_with_uri ->
    hashchange.operators_to_hash ->
    hashchange.encode_operand ->
    people.emails_to_slug

The decode path didn't really require much modication in this commit,
other than to have hashchange.decode_operand call people.slug_to_emails
for the pm-with case.
2017-01-17 15:13:49 -08:00
JefftheBest1 a9c8c826a4 Fix 'message' typo in message_list_view.js. 2017-01-16 21:11:17 -08:00
Steve Howell c36932d29e Fix unread counts display when pinning/un-pinning.
The fix works by having build_stream_sidebar_row()
automatically update its own unread count when we
build a sidebar row.  Currently we rebuild sidebar
rows when we pin/unpin rows.

As an aside, we currently don't really need to rebuild
the sidebar row when we pin, since we're only moving
the DOM, not altering it.  But this may change in the
future, so I decided to leave that code path in place.
We may decide to do things in the future like showing
pinned streams with bolder fonts or special icons or
whatever.

Fixes #2902
2017-01-16 20:07:08 -08:00
Steve Howell 9806d429af Add unread.num_unread_for_stream() function. 2017-01-16 20:07:01 -08:00
Steve Howell 030c6649ae tests: Improve hashchange coverage for operators.
Test round tripping of operators in hashchange.js.
2017-01-11 18:31:17 -08:00
Sampriti Panda e666a62c6a search: Extract 'Sent by me' suggestion logic into separate method.
This also adds a nice test suite for it.
2017-01-11 16:30:07 -08:00
Sampriti Panda c613e510ed search: Add autocomplete for 'from' operator.
Fixes #2932.
2017-01-11 16:29:58 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Tommy Ip e863d4d35e frontend test: De-duplicate test.
Merged two tests since they both use the same test data. The file name
of `presence_list_performance.js` also causes confusion as it is no longer
use for performance testing.
2017-01-11 14:12:41 -08:00
Steve Howell b45cd5538e Add node tests for password checks. 2017-01-10 04:55:41 -08:00
Tim Abbott 9ff8c9e358 subs: Access users by ID in new stream creation. 2017-01-06 23:18:53 -08:00
Harshit Bansal ceb636dbd9 Manage allowed domains from admin settings.
Fixes: #1867.
2017-01-06 12:03:31 -08:00
Brock Whittaker 7b00bd6f7e Remove the old spinner, replace with new one.
This removes the old content loading spinner and replaces it with a new
SVG.
2017-01-06 10:37:54 -08:00
Akhil d8caf16e59 compose: Show description in autocomplete.
Stream descriptions are now displayed along with the name. The
autocomplete results include streams with matches in the stream
descriptions. Added styling for description in compose.css.

Fixes #2398.
2017-01-04 22:48:34 -08:00
Steve Howell ef893dc8dd Live-update user list for name changes.
When somebody changes their name, we will now update
the buddy list right away.  The old code was trying
to do this through a code path that was designed for
true presence updates, but it was also passing in an
empty array, instead of undefined, which caused it to
fail to invoke the intended part of the codepath to
redraw the buddy list.

Now we just call the new activity.redraw() function,
which does the right thing for the buddy list.

The group PM list was live-updating before this change,
and it continues to live-update as part of the new
activity.redraw() function.
2017-01-04 19:45:15 -08:00
Bojidar Marinov e293a84331 narrow: Fix the client sending more than one search operator. 2017-01-04 16:02:41 -08:00
Arpith Siromoney 9c64a08cad Add frontend support for emoji reactions.
This commit replaces the placeholder "clipboard" button with a reaction button.
This is done on any message that can't be edited. Also, on messages sent by
the user the actions popover (toggled by the down chevron icon) contains
an option to add a reaction.

When clicked, a popover with a search bar and a list of emojis is displayed.
If the right sidebar is collapsed (the viewport is small), the popover is placed
to the left of the button.
Focus is set to the search bar. Typing in the search bar filters emojis.

Emojis with which the user has reacted to this message are highlighted.
Clicking them sends an API request to remove that reaction.
Clicking on non-highlighted emojis sends an API request to add a reaction.
When the popover loses focus it is closed.

The frontend listens for reaction events. When an add-reaction event is
received, the emoji is displayed at the bottom of the message with a
count initialized to 1. If there was an existing reaction to the message with
the same emoji, the count is incremented.

Old messages fetched from the server contain reactions.
They are displayed (along with title and count) at the bottom
of each message.

When clicking the emoji reaction at the bottom of the message, if the
user has already reacted with that emoji to this message, the reaction
is removed and the count is decremented. Otherwise, a reaction is added
and the count is incremented.

Hovering over the emoji reaction at the bottom of the message displays
a list of users who have reacted with this emoji along with the
emoji name.

Hovering over the emoji reactions at the bottom of the message displays
a button to add a reaction.

Fixes #541.
2016-12-30 21:42:54 -08:00
Brock Whittaker 338dcfc889 Partial match previous search terms in streams page.
Before in a query string like:

“all, s, verona”

It would only strong match the first two terms, but now it’ll partial
string match all terms equally.
2016-12-30 17:13:48 -08:00
Rishi Gupta 386e22c564 Add node tests for message_edit.get_editability. 2016-12-30 16:51:00 -08:00
Tim Abbott 39f0ffdedd Move static/third/gemoji to static/generated/emoji.
Fixes #1153.
2016-12-27 20:16:23 -08:00
Bojidar Marinov 9682d26561 invite: Leave not yet invited users in the invite modal's textarea.
Also, make zerver tell us whether invitations were sent.

Fixes #2287.
2016-12-27 17:14:21 -08:00
Sampriti Panda c6d8d72735 tests: Add tests for subs.filter_table 2016-12-26 07:42:38 -08:00
Yago González ca190bd394 bug fix: Handle empty at-mentions gracefully.
An exception in the webapp was trown when an empty mention was sent.
Examples of problematic messages are "@" or "@****".

In order to fix this, the regex that identifies mentions has been
modified, so it now requires the mention to have a "content" (by
replacing the ? quantifier by +).

A test case has been added to `frontend_tests/node_tests/echo.js` to
check that this works properly in the future.
2016-12-21 15:32:12 -08:00
Tommy Ip 400c8c1f65 Prioritize stream subscribers in typeahead list.
When autocompleting names using @mention, subscribers of the stream
would appear at the top of the list. Added new test module to reflect
this change.
2016-12-21 12:59:43 -08:00
Tim Abbott 7a56f0137e Fix accidentally merged test error in Node tests. 2016-12-21 12:02:05 -08:00
Sanskar Modi e6beaa2711 Improve @all warnings user interface significantly.
* Doesn't pop up the warning until you actually try to send the message
* Eliminates the red warning.
* Changes confirm text to "Yes, send".
* Adds a stream size threshhold of 15 people; smaller streams don't
  prompt about this.

Fixes #2257.
2016-12-21 11:40:47 -08:00
Steve Howell b46d7654f8 Change people.remove() to people.deactivate() and fix bug.
This commit changes people.remove() to be people.deactivate(),
and it fixes a bug where deactivating users was causing tracebacks
in the PM list if somebody had PM'ed the deactivated user
recently.
2016-12-15 17:44:58 -08:00
Steve Howell b2bb2f8ea0 Extract people.init() function.
We need this for node tests, so that you don't have to explicitly
remove every user between tests.  (Also, people.remove() is about
to have different semantics.)
2016-12-15 17:44:58 -08:00
Rafid Aslam 45f39be37f lint: Fix many no-unused-vars eslint rule violations.
These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
2016-12-14 21:34:51 -08:00
Tommy Ip 0329b67048 admin: Limit bots in settings page.
Updated `get_editable()` so that organization admins only see their
own bots in their personal settings page; this removes a lot of
unnecessary clutter.

Fixes #2657.
2016-12-14 19:29:02 -08:00
Steve Howell b11fbf0b4b Consolidate stream/topic logic for unread messages.
This change introduces an unread_topic_counter object
that manages unread counts for streams and topics.  Consolidating
all the logic into a single class will set us up to add
logic for dealing with topic counts that includes provisional
counts of unread messages from the server.  It also makes
the current code a little easier to reason about.

Most of this change was simply extracting functions, but
I also removed a few unnecessary and inconsistent calls to
`stream_data.canonicalized_name` that preceded our use of
Dict with a fold_case argument.
2016-12-14 19:10:55 -08:00
Bojidar Marinov 8b44ace3a8 frontend: Make global notifications live-update on changes.
Fixes #2527
2016-12-13 20:22:13 -08:00
Brock Whittaker 1886f0a015 redesign: Convert subscriptions page to overlay.
This is a major change to the /#subscriptions page, converting it to
by a side-by-side list of streams and their settings in an overlay.
There are no new features added/removed, but it's a huge changeset,
because it replaces the old navigation logic and moves the stream
creation modal to appear in the right side of this overlay.
2016-12-09 11:08:08 -08:00
Tommy Ip fe4a0e72fc Add new button to download ~/.zuliprc from settings page.
Added new option to download .zuliprc file directly from settings
page.  This should help reduce friction when setting up new
bots/integrations. This new feature is available in the bot cards and
the 'show your API key' section. One caveat is that the filename is
automatically set to 'zuliprc' instead of '.zuliprc', since as most
browsers do not allow filenames to start with a dot.

Fixes #2327.
2016-12-07 21:28:41 -08:00
Robert Hönig ce2671c5cf eslint: Apply no-useless-escape rule to casper tests. 2016-12-06 18:06:57 -08:00
lonerz dc6849952b eslint: change space-before-function-paren from warning to error.
Also fix violations.
2016-12-05 09:50:37 -08:00
Rafid Aslam 0290aeb6ab lint: Fix several no-unused-vars eslint rule violations.
These changes were extracted by tabbott from the original commit
to merge now because they have been reviewed as safe.
2016-12-03 18:43:47 -08:00
Rafid Aslam 426cb13e23 Remove `enforce_arity` function from util.js.
Remove `enforce_arity` function from util.js, because it is
not used anymore.
2016-12-03 18:43:46 -08:00
Tim Abbott 459421d045 eslint: Update node tests to use new comma-dangle rules.
* In most cases, eslint --fix with the right comma-dangle settings was
  able to update the code correctly.

* The exceptions were cases where the parser incorrectly treated the
  arguments to functions like `assert_equal` as arguments; we fixed
  these manually.  Since this is test code, we can be reasonably
  confident that just fixing the failures suffices to correct any bugs
  introduced by making changes automatically.
2016-12-03 15:00:24 -08:00
AZtheAsian 5e9918135b eslint: change quote-props from off to error and fix violations. 2016-12-02 18:35:53 -08:00
AZtheAsian 9c0ebc7359 eslint: change no-else-return to error and fix violations 2016-12-02 14:43:09 -08:00
Tommy Ip b3f4feb996 eslint: change max-len from warning to error and fix violations. 2016-12-02 14:16:33 +00:00
kevv87 e6369fc29b eslint: change no-plusplus from warning to 2 and fix violations. 2016-12-01 14:27:17 -08:00
Tommy Ip c90da24541 eslint: change keyword-spacing from warning to error and fix violations. 2016-12-01 14:22:15 -08:00
Steve Howell d953eca14c Make group PMs reply-to's more consistent in case.
We now sort lists of users ids deterministically, and we also
sort list of emails deterministically and without regard to case.

This probably fixes the bug #2343, although I never got a great
repro on that.
2016-11-26 11:48:52 -08:00
Steve Howell 578b276523 node tests: Add tests for message_store.js. 2016-11-26 11:48:52 -08:00
Steve Howell af9ff9a030 Have unread.num_unread_for_person accept a user_id.
(It used to take an email as its parameter.)
2016-11-26 11:48:52 -08:00
Steve Howell 772571fd82 Use data-user-ids-string in Private Messages sidebar.
This commit also changed message_store.recent_private_messages
to use user_ids_string instead of reply_to.
2016-11-26 11:48:52 -08:00
Steve Howell aadfe133e2 buddy list: Use user_ids in DOM list elements. 2016-11-26 11:48:52 -08:00
Vladislav Manchev d7e1e4a2c0 Add initial implementation of custom realm filters.
This PR was abandoned by Vladislav and then substantially modified by
Igor Tokarev and Tim Abbott to complete it and fix a number of bugs.

Fixes #544.
2016-11-17 17:11:25 -08:00
Steve Howell 8f96853fcb presence: Convert presence_info to use user IDs.
When we filtered buddy lists, a recent change introduced some
bugs related to case-insensitive emails.  We now circumvent the
bug by indexing presence_info with user_ids.
2016-11-17 13:27:28 -08:00
Tim Abbott 9c3d448fe4 compose: Clarify @-all errors are about mentions.
Every message to that stream goes to that number of users :).
2016-11-17 12:35:35 -08:00
Steve Howell 9eb825fff5 Refactor PM unread counts to use user_ids as keys.
We now use comma-delimited lists of user_ids for the following
data structures in unread.js:

    - unread_privates[<user_ids_string>]
    - get_counts.pm_count[<user_ids_string>]
2016-11-15 18:31:59 -08:00
Steve Howell 1783879108 people.js: Add methods for user_ids_string/emails_string.
Added:
    * people.user_ids_string_to_emails_string
    * people.emails_strings_to_user_ids_string
2016-11-15 18:31:59 -08:00
Tim Abbott e40e756d47 echo: Fix local echo sending a message to "yourself, ".
Previously, this would incorrectly include a user with name and email
"" in the recipients list shown in the local echo code path.

We fix this and add a test for the issue.
2016-11-14 21:43:13 -08:00
Steve Howell 71d93207cd Match "Charles Dickens" with "ch di" in subscriber search. 2016-11-14 16:01:13 -08:00
Steve Howell 2746518f3c Make subscriber filter match on emails.
We will match emails that start with search terms.
2016-11-14 16:01:13 -08:00
Steve Howell 504045f47d Pass in search terms as arrays to test_filtered_users(). 2016-11-14 16:01:13 -08:00
Steve Howell d867cba90b Add stream_list.stream_sidebar() class.
This new class lets us store sidebar rows inside of stream_list.js
instead of putting them on sub objects from stream_data.js.
2016-11-11 12:12:13 -08:00
Steve Howell 7b0c6459b4 Extract static/js/pm_list.js.
This handles most of the details of building the Private Messages
section in the upper left corner of the app.
2016-11-11 12:12:13 -08:00
Steve Howell 6a3254f83f Clean up how we build individual stream sidebar rows.
We used to have hacky code where various functions would call
build_stream_sidebar_row() to get a jQuery object, and then they
would attach the jQuery object to the "sub" object from stream_data.js.

Now build_stream_sidebar_row() localizes the hack of attaching
a UI object to the "sub" object to just one function (and we can
clean this up in a follow-up commit).

Also, the UI object is now a JS object that can close on some useful
state information like the stream name and encapsulate how we
toggle the inactive_stream class.

Finally, we don't have build_stream_sidebar_row() needlessly append
list items to $('#stream_filters') when we know that our callers are
going to re-build the list anyway.
2016-11-11 12:12:13 -08:00
Steve Howell 06f4857221 buddy list: Make Group PMs appear more quickly.
It used to be the case that you would get new messages for a
huddle, but the huddle wouldn't show up on your buddy list until
the every-50-seconds mass update of the buddy list.

Now we make sure to work with non-stale jQuery objects, and,
more importantly, we resize ourselves if we add new huddles.

(The resize issue arises due to some complicated heuristics
where we don't want group PMs to take up too much of the buddy
list for users who don't have many in their history.)
2016-11-11 12:02:48 -08:00
Steve Howell eef633efa0 minor: Make get_huddles() internal to activity.js. 2016-11-11 10:41:18 -08:00
paxapy ade3bda025 markdown: Fix stream link handler in corner cases.
* Fixes handling of multiple stream links and invalid stream names.
* Fixes text regex so it handle hash sign the right way.
* Adds tests for these stream link cases.
2016-11-10 19:22:19 -08:00
Igor Tokarev 852bc6b491 bugdown: Re-enable support for italics in bugdown.
Fixes: #1103.
2016-11-10 19:14:40 -08:00
Steve Howell f923320de8 topic lists: Add get_stream_name() to topic list widget. 2016-11-10 15:55:31 -08:00
Steve Howell d8b5558699 topic lists: Refactor handling of parent element.
The widget that gets built in topic_list.build_widget()
now knows how to add itself to its parent element and expose
an interface to retrieve the parent.
2016-11-10 15:55:31 -08:00
Steve Howell 853126344e Add narrow.topic() helper method.
This has similar semantics to narrow.stream().
2016-11-10 15:55:31 -08:00
Steve Howell 16e37f8874 Limit compose at-mention typeaheads to realm users.
Fixes #2240
2016-11-09 19:20:58 -08:00
Steve Howell 5e51a93688 Change stream_data.remove_subscriber() to accept user ids. 2016-11-09 15:03:08 -08:00
Steve Howell 00068f3164 Extract stream_data.unsubscribe_myself(). 2016-11-09 15:03:08 -08:00
Steve Howell 537a3b8ca8 Change stream_data.add_subscriber() to accept user_ids.
We no longer require passing in an email to
stream_data.add_subscriber(), since we only track user ids
in stream_data.js.
2016-11-08 15:49:23 -08:00
Steve Howell a03a7d4c95 peer_remove: Send user_id, not email, for unsubscribe events. 2016-11-08 15:36:29 -08:00
Igor Tokarev 07d05390bf markdown: Fix client usermention regular expression.
Fixes #993.
2016-11-06 18:37:09 -08:00
umkay f4c621ffe3 admin: Enable admins to toggle supported auth methods via UI.
Add a table to the administration page that will allow realm admins to
activate and deactivate the supported authentication methods for that
realm.
2016-11-06 16:29:35 -08:00
Steve Howell 165b6c1ff3 topic lists: Improve node test to show HTML correctly. 2016-11-05 10:38:37 -07:00
Steve Howell 1119a24ea3 node tests: Extract node_tests/topic_list.js
This moves one method over from stream_list.js.  There's still a
lot of boilerplate here, unfortunately, as topic lists have a lot
of dependencies on other parts of the system--narrowing state,
muting state, jQuery, handlebars, etc.
2016-11-05 10:38:37 -07:00
Steve Howell e17cb79701 node tests: Remove compile-settings code from templates.js. 2016-11-04 21:23:35 -07:00
Steve Howell 6a1b53a195 node tests: Remove compile-settings code from i18n.js. 2016-11-04 21:23:35 -07:00
Steve Howell 2088e8420f User user_id, not email, in peer_add events. 2016-11-04 11:37:14 -07:00
Steve Howell 17e39a88ef Remove people.test_set_people_name_dict().
We use a cleaner approach to setting up test data in echo.js to
allow us to remove the one call to test_set_people_name_dict().
2016-11-04 11:37:14 -07:00
Steve Howell 8c47f7f7db Remove people.test_set_people_dict(). 2016-11-04 11:37:14 -07:00
Steve Howell 3941334d00 Use user_ids for subscribers in stream_data.js.
We still shim a lot of methods to keep using emails, but the
internal data structure now has user_ids.
2016-11-04 11:37:12 -07:00
Steve Howell 7509f73f02 Clean up stream renaming in the JS code.
We now use stream_id as our key to rename streams, which
should prevent a few race conditions long term.  (We are
still possibly contending with other events that use
stream_name as a key, so this is not perfect.)
2016-11-04 11:30:18 -07:00
Steve Howell e1372ddf5d Add people.get_user_id(). 2016-11-04 11:30:18 -07:00
Steve Howell 2f4c7d2ef9 Clean up page_params initialization in node_tests/echo.js. 2016-11-04 11:30:18 -07:00
Steve Howell 4cd39010d1 Add people.get_person_from_user_id().
This requires the introduction of people_by_user_id_dict
and changes to people.add() and people.remove().
2016-11-04 11:30:18 -07:00
Steve Howell a2874a3fe9 node tests: Simplify compiling of templates.
Now we just have two methods of importance:

    compile_template
    render_template

The compile_template() function will automatically
(and recursively) compile any partials it depends
on and mark those as compiled.
2016-11-04 11:23:11 -07:00
Steve Howell dd4a8eeebd node tests: Extract render.find_included_partials(). 2016-11-04 11:23:11 -07:00
Steve Howell 9b97b5da13 Improve test coverage for people.get_recipient_count(). 2016-11-04 10:05:11 -07:00
Steve Howell 30e01306d9 Eliminate people.reify() and mostly ignore unknown users.
If I try to send a message to an unknown user (which is possible
for some types of realms), then I simply ignore them during the
send codepath, so that I don't later need to patch up their attributes.
2016-11-03 16:20:45 -07:00
Steve Howell 15d44f8d71 Encapsulate pm_recipient_count.
We no longer store pm_recipient_count on person objects, but we
instead use a Dict to store them.  Then the new API is this:

    people.get_recipient_count()
    people.incr_recipient_count()
2016-11-03 16:20:45 -07:00
Brock Whittaker 1432c6613b zjsunit: Remove manual need to call global.use_template.
When the render function is run now, it uses the partial_finder
function to search recursively through files for partials and add them
so that test writers don’t have to.

This means that we no longer have to do any manual work to maintain
the templates.js check that all handlebars templates are rendered by
the node tests.
2016-11-02 22:08:47 -07:00
paxapy 2f711a070d bugdown: Add autocomplete for #StreamName links.
Fixes #1858.
2016-11-01 20:19:44 -07:00
Steve Howell 8c9488a904 Add topic_list.build_widget().
This gets us closer to a component model for topic lists.
2016-11-01 19:30:41 -07:00
Steve Howell aca6ba182e Render topic list items individually.
This is a precursor to being able to find topic list
items without the complexity of iterate_to_find().
2016-11-01 19:30:41 -07:00
Steve Howell d70ac2fc0d Remove obsolete code for page_params.people_list.
The only module that uses people_list now is people.js, and that's
only during the page load process.
2016-11-01 13:55:48 -07:00
Steve Howell 40ec0189e4 Use people.get_all_persons() in at-mention typeaheads.
This is more robust than using page_params.people_list.
2016-11-01 13:55:48 -07:00
Steve Howell 06d7012113 Use people.get_all_persons() for search_suggestion.js.
This is better than using page_params.people_list, which may
go out of sync when live updates happen.
2016-11-01 13:55:48 -07:00
Steve Howell 2d945d7296 Add people.get_realm_persons(). 2016-11-01 13:55:48 -07:00
Steve Howell aa07b32d58 Add people.get_all_persons(). 2016-11-01 13:55:48 -07:00
Tim Abbott 66e2632809 subs: Rename .subscription_name to .stream-name. 2016-10-28 14:47:22 -07:00
Steve Howell 5fd71a6381 Rename var in sidebar_subject_list.handlebars.
s/subjects/topics/
2016-10-28 13:52:25 -07:00
Steve Howell 0a4579711d Add stream_data.get_recent_topics().
This removes the last remaining references to
stream_data.recent_subjects() outside of stream_data.js.
2016-10-28 13:52:25 -07:00
Steve Howell 6a54dfc127 Remove recent_subjects from node tests.
We now use stream_data.populate_stream_topics_for_tests(),
which hides some of the implementation details of initializing
the data structure.
2016-10-28 13:52:25 -07:00
Steve Howell 8acdf718bc Move process_message_for_recent_topics() to stream_data.js. 2016-10-28 13:52:25 -07:00
Steve Howell 10bc093375 Stop using server data to draw "Manage Streams".
We have all the data we need on the client side.
2016-10-28 13:44:46 -07:00
Tim Abbott 2834a2bbbb subs: Extract subscription_settings.handlebars.
This is an early step towards being able to decouple the subscription
settings section from the slideout behavior.
2016-10-27 22:07:42 -07:00
Steve Howell f7e6cfc892 Extract topic_list.build_list().
This used to be stream_list._build_subject_list().  The code
didn't change except for one s/subject/topic fix.
2016-10-27 15:49:25 -07:00
Tim Abbott 14dc98d8b9 server_events: Switch to using REST-style URLs.
This eliminates our use of /json/get_events; we'll remove that
endpoint in a future commit.
2016-10-25 18:02:16 -07:00
Steve Howell de727245aa subs: Add subscriber counts to the /#subscriptions page.
This borrows some work from krtkmj in #525.

Fixes #483.
2016-10-25 14:40:00 -07:00
Tomasz Kolek 4790316b57 Add user setting option to always send push notifications.
Add option in user's settings for getting mobile push notifications
even if a Zulip browser is online.  Default is False.

Fixes: #1596.
2016-10-25 10:52:29 -07:00
sonali0901 1bc7990327 Extract people.filter_people_by_search_terms()
This code used to be in subs.js, but now it's in people.js and has
some unit tests.

I did this w/showell as part of live coding on Zulip.
2016-10-20 21:44:26 -07:00
hackerkid bca1953aa4 Add support for !gravatar syntax in echo.js. 2016-10-20 14:40:45 -07:00
hackerkid 95b5ac1d5d Add support for !avatar syntax in echo.js. 2016-10-20 14:40:33 -07:00
Steve Howell d26942e72d Extract stream_list.create_sidebar_row().
This replaces add_stream_to_sidebar(), which was kind of a misleading
name, and it also adds a couple lines of code that were always
called right after calling add_stream_to_sidebar().
2016-10-17 19:58:23 -07:00
Steve Howell 869a124d7d Extract stream_data.get_streams_for_settings_page().
This function will make it easier to unit test upcoming
changes related to stream counts.

This was mostly moving code, but one change is that we
don't call create_subs() in subs.js any more (which would
have been kind of circular dependency), since the only thing
that it did besides calling a more appropriate function
in stream_data.js was to generate a trigger that was
subsequently ignored and possibly a UI trap, as we don't
want to be messing with the stream sidebar when we go into
the stream settings page.

We now simply call exports.create_sub_from_server_data() for
newly encountered unsubscribed streams (which don't belong in
the sidebar anyway.)
2016-10-17 19:58:23 -07:00
Steve Howell 965c6047db Move add_admin_options() to stream_data.js.
This function used to live in subs.js.  It's mostly a code move,
but I simplified the logic to determine whether it's subscribed
not to do a lookup into the same data structure that the sub
already came from.

I also added some tests.
2016-10-17 19:58:23 -07:00
reyha 537c9755bf search: Fix searching for URLs.
Previously, URLs were being incorrectly treated as unknown search
operators (since they had exactly one ":" in them, just like foo:bar
for an invalid choice of foo).

Fixes #1743.
2016-10-16 15:25:46 -07:00
Tim Abbott d2be9241f2 feature_flags: Eliminate always true negated_search feature. 2016-10-11 20:50:47 -07:00
Kartik Maji 9807ec6539 Fix phrasing when re-subscribing user to a stream. 2016-10-11 18:19:57 -07:00
Umair Khan 36c6a5d758 Add support for changing user's name by admin.
Fixes: #1553
2016-10-11 16:36:48 -07:00
Ilona Brand 4bf908c2d6 Add emoji map to the compose box.
- Expand a box full of emojis into the
compose window for users to graphically select emojis.

- Append an emoji to the end of the message when a user
clicks the emoji in the emoji box.

- Trap the escape key to always close the emoji box
before closing anything else if the box is open.

- Fixes: #147.
2016-10-10 16:12:25 -07:00
Brock Whittaker ff3d5ca4db Separate display settings from settings_tab.handlebars.
This separates the display settings module from the
settings_table.handlebars template.

Additionally, it fixes the node tests to search in the
static/templates/settings directory and initialize any templates in there
while running tests on the settings templates.
2016-10-05 22:26:40 -07:00
Tim Abbott 49bea381b7 zjsunit: Fix running stream_data and node tests individually.
These tests failed if you ran them along with:
 `ReferenceError: $ is not defined` errors.

Fixes #1909.
2016-10-04 18:38:17 -07:00
Sahil Dua 058587da77 Remove extra new lines at the ends of Zulip authoried files.
Fixes #1627.

[tweaked by tabbott to avoid patching third-party modules, for now]
2016-09-26 21:05:24 -07:00
umkay 82d03d603a Update Pygments to latest upstream version.
In HTML, the line break immediately following a start tag is ignored
(see: https://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1). An
extra span tag has been introduced in the upstream Pygments
HtmlFormatter in order to preserve the first new line. The Bugdown
Tests as well as our fenced_code.js frontend markdown processor have
been updated to reflect this new behavior.
2016-09-12 21:58:25 -07:00
Steve Howell e53b0f564f subject/topic: Rename unread_subjects to unread_topics. 2016-08-26 20:26:24 -07:00
Brock Whittaker 64079b382f Channel popup unsubscribe button.
From the popups that appear when clicking the down-arrow in the left
column's streams, you can now unsubscribe from that particular
channel. This runs on the same function that unsubscribes you from
streams in the "Subscriptions" tab.

Fixes: #1554.

[tweaked by tabbott to fix some errors]
2016-08-26 20:22:11 -07:00
Brock Whittaker 8f73701b96 Upgrade jQuery to 1.12.1 and fetch from node_modules.
Fixes: #1196.
2016-08-25 15:32:08 -07:00
Steve Howell 4dbeb66a4c tests: Add render.init() to node tests.
This makes sure we are explicit about partials in
individual test modules.  Eventually, we should figure
out a way to make partials automatically compile as
part of the node tests.
2016-08-25 13:56:08 -07:00
Steve Howell 8e38503d8c tests: Add sidebar_private_message_list() template test. 2016-08-25 13:56:08 -07:00
Tomasz Kolek b1b864341c Fix @all spam warning when typing @all in backticks.
When user'd like to send a message with @all in backticks
they see spam warning in spite of the fact that nobody
would be alerted.

Fixes: #1505.
2016-08-18 16:10:09 -07:00
Steve Howell 01d28458fc Add frontend_tests/node_tests/dispatch.js.
This tests the dispatching code in server_events.js.
2016-08-09 18:49:13 -07:00
Steve Howell 48af751e8d Clean up server_events.js (minor stuff).
Make exceptions more clear and upstream patching of builtins to index.js.
2016-08-09 18:49:13 -07:00
Steve Howell ebe76dd2c3 Add stub_out_jquery() for node tests. 2016-07-30 14:54:30 -07:00
Steve Howell 6ce8f3da6d Fix node tests to be able to run standalone.
These tests would work as part of the whole suite, but
not standalone, because they were getting objects out
of node's require cache that a previous test had cleaned up.

Now they should work standalone as well, and the tests
are more explicit about their dependencies.
2016-07-30 14:54:30 -07:00
Steve Howell 55d8a1e960 Remove unneeded require in node_tests/activity.js 2016-07-30 14:54:30 -07:00
Steve Howell 6a65b3482c Move index.js to frontend_tests/zjsunit. 2016-07-30 14:54:30 -07:00
Steve Howell c57bbf6c77 Introduce index.html for test-js-with-node output.
We now have an index.html for test-js-with-node output
that links to specific HTML files for various handlebar
tests.
2016-07-29 22:07:24 -07:00
Steve Howell 1d7a6c9941 Fix output from test_tr_tag_settings().
For its HTML output, it was using a wrong label and a CSS
setting that clobbered other output.
2016-07-29 22:07:24 -07:00
Steve Howell f301ccdb3e Move source code for settings_tab() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell b3553859f9 Move source code for propagate_notification_change() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell 9e8bff5628 Move source code for message_edit_form() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell 83a92704ee Move source code for admin_tab() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell ec12ea5773 Consolidate bookend tests in node_tests/templates.js.
In templates.js we want to enforce outputting just
one output file per template, and we also keep the source
alphabetical by template name.  This isn't a permanent
decision, but it makes organizing the ouput a little
easier for now.
2016-07-29 22:07:24 -07:00
Steve Howell 5a3a4595f1 Move source code for admin_emoji_list() to top of its file.
We alphabetize the functions in node_tests/templates.js.  This
makes it easier for the test output to be rendered in order.
2016-07-29 22:07:24 -07:00
Steve Howell 87dbdaac68 Extract write_handlebars_output() in node tests. 2016-07-29 22:07:24 -07:00
Steve Howell 6b8e2c406b Write node test output to var/test-js-with-node/output.html
This also fixes some CSS path issues that were regressed
when files were written to 'var.'
2016-07-29 22:07:24 -07:00
Tim Abbott beedfb2939 Revert "[third] Upgrade jquery to version 1.8.3."
This reverts commit be93b6ea28.

Unfortunately, the newer jquery comes with a huge performance
regression affecting the hotkeys code, which has the effect of making
typing super slow.

Fixes: #1449.
2016-07-28 11:39:06 -07:00
Tim Abbott 375551aaa6 Clean up most hardcoding of mit.edu domain checks.
This moves all this code to be gated on a few virtual realm settings.
2016-07-26 20:30:12 -07:00
Taranjeet Singh 9b31f0a67a node tests: Move .test-js-with-node.html to var/." 2016-07-20 18:23:56 -07:00
Tim Abbott be93b6ea28 [third] Upgrade jquery to version 1.8.3.
Also use the modern NPM name of 'jquery' (all lower case), which is
required as part of this migration.

Fixes #1141.
2016-07-08 11:09:54 -07:00
Tomasz Kolek c15695e514 Add support for running test-js-with-node on particular files.
Fixed: #1127.
2016-07-07 14:32:07 -07:00
Kartik Maji f8bb7503e6 Add ability to pin streams to top of the streams sidebar list.
Based on work by Lauren Long, with some tweaks by tabbott.
2016-06-30 22:26:09 -07:00
Alex Wilson b040839c76 Add unicode emoji to frontend markdown parser.
Fixes 2nd half of #1011.
2016-06-30 15:48:02 -07:00
Alex Wilson 434c8d4b08 Add codepointat.js, a polyfill for String.prototype.codePointAt(). 2016-06-30 15:48:02 -07:00
Preston Hansen 57dec15c6c Update alert word UI to match the style of bots.
Resolves #1075.
2016-06-24 16:43:19 -07:00
Umair Khan c8d139b2b1 Fix emoji urls interaction with i18n.
When accessing emojis with relative urls we should start the urls with
a slash so that language code doesn't become part of these urls.

Fixes #1014.
2016-06-13 09:10:11 -07:00
Vishnu Ks f9f31b79d0 Make default_streams web controllable.
Fixes: #665
2016-06-09 15:24:32 -07:00
Caroline Liu 60e5140406 Add warning for @all / @everyone.
* The warning contains a count of the number of people in the stream.
* An error appears if the warning is ignored and the user tries to
  send the message anyway.
* The message cannot be sent until the warning is acknowledged or @all
  / @everyone is removed.
* This only applies to stream messages and not private messages.

Fixes #853.
2016-06-09 14:38:58 -07:00
Tim Abbott b25562ca1d Add and use util.is_current_user helper function.
Previously, we were checking if a particular user was the current user
in dozens of places in the codebase, and correct case-insensitive
checks were not used consistently, leading to bugs like #502.
2016-06-07 21:58:44 -07:00
Givorenon 0bf2d171ae Fix fading of messages in dialog and users in side-bar.
Make comparison of emails in compose_fade.js and util.js
case-insensitive to fix fading of users and messages respectively.
2016-06-07 21:31:47 -07:00
Vishnu Ks d30ea0bc44 Move recent_subjects to stream_data. 2016-06-07 17:50:16 -07:00
Umair Khan 82b5d9304b [third] Integrate i18next with Handlebars 2016-05-19 22:58:25 -07:00
Kartik Maji 3d77aa49db Add subscribe button in narrowed view when stream has no messages.
A temporary message appears on successful subscription, with a button
offering to unsubscribe in case the user subscribed by accident.
2016-05-18 20:06:30 -07:00
Kartik Maji 206452c867 Add stream subscription button added narrowed views.
Fixes: #273
2016-05-18 20:06:23 -07:00
Tim Abbott 5bd94c15c7 Use camo to avoid mixed content warnings when displaying emoji. 2016-05-02 17:21:31 -07:00
Vladislav Manchev f5e6176aea Add custom realm emoji UI to administration page. 2016-04-26 13:15:54 -07:00
Vishnu Ks ae49ad383d Rename all function on MessageList to all_messages. 2016-04-25 13:45:18 -07:00
Vishnu Ks 35b0af2852 Move all_msg_list to message_list.js. 2016-04-21 17:46:21 -07:00
Vishnu Ks ee39f5009f Make message_list.js work like the other modules. 2016-04-20 15:29:30 -07:00
Tim Abbott a72385246e Fix missing whitespace after '=' in python/js code. 2016-04-20 11:36:14 -07:00
Tim Abbott 93b3feda43 Fix node test broken by reloading changes. 2016-03-30 23:40:00 -07:00
Kartik Maji 2b3312cd6e Update unread counts for streams when muting topics.
Fixes #427.
2016-03-27 13:49:52 -07:00
Tim Abbott 29b8d71871 Remove throttling of presence updates coming from server events.
Now that we're doing presence updates in a performant fashion, we
don't need to throttle processing these events, and in fact the
throttling of these events created a correctness problem, since we're
now doing incremental updates rather than just rerendering everything
after each event.
2016-03-21 20:28:05 -07:00
Varshit 72033069ed Extend lint-all to check for newlines at the end of files. 2016-03-17 23:03:56 -07:00
Vladislav Manchev 668d0d9dfa Fix performance issues with user presence list in large realms.
Whenever a user became active, this triggers an immediate presence
update event (to show that user as active).  The implementation for
that event (running on the browsers of all other users in the realm)
would fully rerender the presence list, which can be an expensive
operation in a large realm, just to update the status for that one
user.  This fixes that case to just remove the user from the list and
then re-insert it at the appropriate index.

[Commit message expanded with more details by Tim Abbott]
2016-02-12 20:04:43 -08:00
Kara McNair fd66d9f703 Show 5 most recent "Private messages" when clicked.
Like the Stream Subject lists, Private messages are now shown
when the user clicks on the "Private message" link. User can drill in
to get more than 5 conversations. Selecting PMs from the user or group
PM lists on the right sidebar also opens the list & highlights the
selected conversation.

[Edited by tabbott@mit.edu to fix some small bugs.]
2015-12-15 07:52:54 -08:00
Allie Jones 4de0325a9d Install node dependencies using npm.
The node packages 'jQuery' and 'jquery' are different--'jQuery' is the
legacy support package that is needed for Zulip so the require statements
in the tests were updated.

Travis uses node 4.0 by default and we are using 0.10, so the command to
install the correct version had to be added to the .travis.yml file.
2015-11-06 09:08:59 -08:00
Tim Abbott 10657c1d53 Move node tests to node_tests/. 2015-10-28 10:11:47 -07:00