Commit Graph

283 Commits

Author SHA1 Message Date
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
Umair Khan ab25cd7401 casper: Redirect to english url. 2016-12-15 13:44:13 -08:00
Umair Khan 770a899239 Django 1.10: Use single cache prefix for casper tests.
There is a change in Django 1.10 due to which whenever the password
of the user is changed the session hash changes. This change affects
us because we cache user profile objects and these cached objects need
to be refreshed. However, the signal sent by Django in which objects are
refreshed fails to refresh the cache for Tornado because it uses a
different cache prefix.

Note: Backend tests are not affected because they don't rely on Tornado.
2016-12-14 22:40:33 -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
Brock Whittaker a460fcddef Add Date Headers to Floating Bar and Message Headers.
This adds the date of a block of messages to the floating recipient
bar along with message headers of blocks that are the first of a
particular day.
2016-12-13 20:36:39 -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
Arpith Siromoney 6ae613c235 Eslint: Add additioanl rules, some for GCI.
This commit adds rules for GCI, turns on rules that do not error
on our codebase, and changes frontend_tests/.eslintrc.json's no-sync
rule to off (as per AirBnB's style guide).

Rules for GCI:
no-restricted-syntax, no-nested-ternary, spaced-comment,
space-infix-ops, newline-per-chained-call, padded-blocks,
no-whitespace-before-property, space-in-parens

Rules that do not error:
no-useless-constructor, no-dupe-class-members, no-duplicate-imports,
no-iterator, no-undef, dot-notation, no-case-declarations, no-unneeded-ternary,
eol-last,

Finally, eqeqeq is changed from 2 to ['error', 'allow-null'], going
from jslint defaults to airbnb's recommendation (there were no errors)
2016-12-05 10:01:56 -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
lonerz 025fe9980b Switch no-empty eslint rule from warning to error (in .eslintrc) 2016-12-05 01:35:14 +00: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 1a161c6e33 eslint: Fix comma-dangle rules in JS support files.
This was done via eslint --fix.
2016-12-03 15:00:24 -08:00
Tim Abbott 2447f4a5b4 eslint: Update most casper 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 as lists/objects and added commas; these are
detectable with linters, and we fixed 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
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
Rafid Aslam e6fa4bc2fd tests: Change doc file in run-casper 'Tips for debugging'.
Change `docs/testing.rst` to `docs/testing-with-casper.md` in
'Tips for debugging' because there is no `testing.rst` file, and
remote debugging description is placed in `testing-with-casper.md`.
2016-12-03 10:45:44 -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
Tim Abbott 07565c4a3e Revert "Fix race conditions in Admin casper tests."
This reverts commit aa5a7bc659.
2016-11-29 09:50:56 -08:00
Arpith Siromoney f7dc2f33cd Change name of eslintrc file to .eslintrc.json
Currently it does this for the eslintrc files in zulip,
zulip/frontend_tests and static/js

This commit also fixes json style issues (quotes)
2016-11-29 08:58:39 -08:00
Umair Khan aa5a7bc659 Fix race conditions in Admin casper tests. 2016-11-29 08:53:27 -08:00
Calvin Lee 5c262d3557 tests: Add tests for creating a new stream with a description
Modify backend test of create_streams_if_needed so that the newly
created streams have descriptions.

Modify casperjs test of filling out stream_creation_form so that
the newly created stream has a description.

Fixes: #2428.
2016-11-27 09:45:38 -08:00
Umair Khan 92869940c6 Fix race conditions in user settings casper tests. 2016-11-26 14:56: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
Arpith Siromoney 497c7702cc Run eslint in tools/lint-all with npm run --silent lint
This commit adds a basic eslintrc that emulates jslint defaults.
Rules that conflict with our existing code have been switched to
warnings instead of errors. Globals have been added to the eslintrc. The
bundled js file (generated by webpack) and blueslip.js are ignored with
.eslintignore.

To display warnings, run npm run lint-loud. This runs eslint without the
--quiet option on static/js and frontend_tests.

npm run --silent lint is run by tools/lint-all (in addition to jslint).
The --silent option is used to suppress the default output from npm run.

Fixes #535.
2016-11-18 16:15:45 -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