Commit Graph

1374 Commits

Author SHA1 Message Date
Tim Abbott 6a50e13156 uploads: Remove legacy /json/upload_file endpoint.
This migrates Zulip to use the equivalent API endpoint that has been
present for a while.
2017-07-31 13:08:06 -07:00
Tim Abbott 1e5aee054b settings: Migrate main settings-change code to API.
This was one of the few major remaining endpoints that were still on
the old-style legacy API.
2017-07-31 13:08:06 -07:00
Harshit Bansal a26b1188c6 minor: Indentation fix. 2017-07-31 12:42:36 -07:00
Harshit Bansal 3796292913 markdown: Fix the rendering of realm filters.
A realm filter should match only after the start of a line, whitespace
or opening delimiters. But markdown was not configured to respect those
rules which was causing some weird rendering behavior. This commit fixes
the regex used for matching realm filters. On the backend we are using
regex with negative lookbehind to perform matches but since javascript
regex don't support lookbehind we are using a workaround on the frontend
using `contains_backend_only_syntax()` function which detects if a realm
filter can be rendered correctly by backend only and if so it stops the
message from getting echoed locally.

Fixes: #5154.
2017-07-31 12:42:36 -07:00
Steve Howell 19ebf1e23b bankruptcy: Clear unread counts for mentions. 2017-07-31 08:30:46 -04:00
Steve Howell bf81782e59 Rename num_unread_for_subject -> num_unread_for_topic. 2017-07-31 08:11:18 -04:00
Steve Howell fe74e79a17 Rename subject_count -> topic_count.
This fixes all names in the JS codebase.
2017-07-31 08:04:20 -04:00
Tim Abbott 76c92ad676 markdown: Enforce backend-only-syntax checks in node tests.
While we do have some known cases where syntax diverges intentionally,
this change should make it a lot easier to maintain
markdown.contains_backend_only_syntax over time.
2017-07-28 18:17:25 -07:00
Tim Abbott 1360e1c5fd markdown: Add support for specifying marked output when not matching.
This lets us document cases where the syntax is intentionally
different in ways that we don't think are problematic.
2017-07-28 18:13:15 -07:00
Tim Abbott 4b7c23f133 markdown: Rename bugdown-data.json to a more reasonable name. 2017-07-28 17:54:01 -07:00
Tim Abbott 4f4d28477d markdown: Rename markdown.contains_bugdown.
This name was confusing, since "bugdown" doesn't exactly suggest
"backend markdown processor" to people.
2017-07-28 17:51:33 -07:00
Jack Zhang 7ec51a540e hotspots: Unit test hotspots.js. 2017-07-28 16:34:15 -07:00
Jack Zhang 5a8b1e6253 hotspots: Implement hotspots frontend. 2017-07-28 16:34:15 -07:00
Jack Zhang 6a7a4132b4 hotspots: Create hotspot_overlay template. 2017-07-28 16:34:15 -07:00
Joshua Pan e6611fec99 markdown.js: Remove paragraph break from numbered lists.
Fixes #5902.
2017-07-28 12:32:20 -07:00
Tim Abbott e729814cfd recent_senders: Fix exception in certain typeahead flows.
It appears that a regression introduced in
3f60074c33 caused undefined to be passed
as the subject to the recent_senders library much more often; this
fixing that, and makes the library handle such cases reasonably
without an exception regardless.

This was causing a huge number of "Tried to call a Dict method with an
undefined key." exceptions.
2017-07-28 11:04:11 -07:00
Steve Howell 724e988102 Add topic_data.add_history(). 2017-07-27 14:26:22 -07:00
Steve Howell 466757c3f1 node tests: Extract topic_data.js.
This mostly moves code, and it also removes some unnecessary
coupling to stream_data.js.  The topic_data code purely
works in the stream_id space, so there's no need to set up
actual stream data for it.
2017-07-27 14:26:22 -07:00
Steve Howell a9e296db74 Remove topic_data.process_message().
We now call topic_data.add_message() and
topic_data.remove_message() when we get info about
incoming messages.  The old way of passing in a boolean
made the calling code hard to read and added unncessary
conditional logic to the codepath.

We also have vague plans to change how we handle
removing topics, since increment/decrement logic is now
kind of fragile, so making the "remove" path more explicit
prepares us to something smarter in the future, like just
figure out when the last topic has been removed by calling
a filter function or something outside of topic_data.js.

Another thing to note here is that the code changed here
in echo.js is dead code, since we've disabled
message editing for locally edited messages.  I considered
removing this code in a preparatory commit, but there's
other PR activity related to local echo that I don't want
to conflict with.

One nice aspect of removing process_message() is that
the new topic_data.js module does not refer to the legacy
field "subject" any more, nor do its node tests.
2017-07-27 14:26:22 -07:00
Steve Howell 5a8bccfe08 topic_data.js: Refactor topic history internals.
This commit introduces a per-stream topic_history class
inside of topic_data.js to better encapsulate how we store topic
history.

To the callers, nothing changes here.  (Some of our non-black-box
node tests change their way of setting up data, though, since the
internal data structures are different.)

The new class has the following improvements:

    * We use message_id instead of timestamp as our sorting key.
      (We could have done this in a prep commit, but it wouldn't
      have made the diff much cleaner here.)

    * We use a dictionary instead of a sorted list to store the
      data, so that writes are O(1) instead of O(NlogN).  Reads
      now do sorts, so they're O(NlogN) instead of O(N), but reads
      are fairly infrequent.  (The main goal here isn't actually
      performance, but instead it just simplifies the
      implementation.)

    * We isolate `topic_history` from the format of the messages.
      This prepares us for upcoming changes where updates to the
      data structure may come from topic history queries as well
      as messages.

    * We split out the message-add path from the message-remove
      path.  This prepares us to eventually get rid of the "count"
      mechanism that is kind of fragile and which has to be
      bypassed for historical topics.
2017-07-27 14:26:22 -07:00
Steve Howell bc0761b22b Extract topic_data.js.
This new module tracks the recent topic names for any given
stream.

The code was pulled over almost verbatim from stream_data.js,
with minor renames to the function names.

We introduced a minor one-line function called stream_has_topics.
2017-07-27 14:26:22 -07:00
Steve Howell b95e785335 recent topics: Extract get_recent_topic_names().
We now have all of our callers into recent_topics code just
receive a list of topic names from get_recent_topic_names().

This is more encapsulated than handing off tiny little
structures to the three callers, two of whom immediately
mapped the objects to names, and one of whom needlessly
used the now defunct name canon_subject field.

The consolidation here removes some "subject" references, and
now all lookup are by stream id, not stream name.

The diff here is a bit daunting, but it's mostly simplification
of tests and calling code.  Two of the callers now need to look
up stream ids, but they are otherwise streamlined.

The main change here is to stream_data.js, and we replace the
`canon_subject` and `subject` fields with `name`.
2017-07-27 14:26:22 -07:00
Steve Howell 611f44b339 node tests: Test topic casing for unread counts.
We use multiple casings of "lunch" as a topic in our tests, so
that we verify that unread counts respect that topics are
not case sensitive.

We also eliminate an obsolete stub.
2017-07-27 14:26:22 -07:00
Harshit Bansal eeb25b6b4b populate_db: Add a test realm emoji while populating databases.
Add `green_tick` realm emoji which can be used while performing tests.
2017-07-27 18:57:06 +00:00
digi0ps 3f60074c33 emoji: Create tests to check the typeahead resuts.
Also, this commit exports the typeahead matcher and sorter functions.
Fixes #4126.
2017-07-26 09:27:17 -07:00
digi0ps 2d92f9dc0b emoji: Change emoji image titles to use spaces instead of underscores.
Previously, the emoji images title display `🍼`.
This commit changes the title to display `baby bottle`.
2017-07-26 09:27:17 -07:00
digi0ps 0f3c1c04d5 emoji: Use spaces instead of underscores for emojis in composebox.
Adds support to use spaces for multi word emojis instead of
underscore in compose box.
2017-07-26 09:27:17 -07:00
David Coleman 159064ccaa uploads: Only display year uploaded if previous year.
Modified timerender.js absolute_time() to include the year
in the returned string when the supplied timestamp is in
an older year. This included adding an optional second
argument to specify the current date to facilitate unit
tests.

Fixes #5737.
2017-07-25 23:06:58 -07:00
hollywoodno f7d1abaa25 compose.js: Prevent sending empty messages in preview mode.
This commit specifically addresses the issue when in preview mode,
while "enter sends" is enabled. Previously the messages were just
sent, now they must pass validation.

Fixes #5574.
2017-07-25 22:33:22 -04:00
Greg Price 192ec7c0f6 middleware: Use a proper error code on CSRF failure.
This allows us to reliably parse the error in code, rather than
attempt to parse the error text.  Because the error text gets
translated into the user's language, this error-handling path
wasn't functioning at all for users using Zulip in any of the
seven non-English languages for which we had a translation for
this string.

Together with 709c3b50f which fixed a similar issue in a
different error-handling path, this fixes #5598.
2017-07-25 14:02:12 -07:00
Sarah 31e47954f7 settings_org: Change update_realm_description to read from page_params.
Also refactor server_events_dispatch, move update_realm_description
into the realm_settings object.

Fixes #5696.
2017-07-24 17:36:50 -07:00
Sarah f132652717 server_events_dispatch: Deduplicate realm and user_display settings code.
Deduplicate code updating page_params for realm settings
and user display settings.

Addresses issue #5696.
2017-07-24 17:35:41 -07:00
Rishi Gupta ad47d3b651 settings: Update wording in organization-permissions-admin.handlebars. 2017-07-24 17:33:14 -07:00
Rishi Gupta 481c85fb48 settings: Update text in templates. 2017-07-24 17:33:14 -07:00
Cory Lynch d32e89aae4 jQuery: Remove broken use of "removeAttr".
This function no longer sets properties to false, so the supported
way of doing this is to instead use prop(foo, false). Some tests
had to be fixed to accommodate this.
2017-07-24 10:54:47 -07:00
Cory Lynch 02c6672499 drafts: Fix casper timing bug in jQuery 3. 2017-07-24 10:54:47 -07:00
Harshit Bansal c1dc48f41b emoji: Merge the two semantically same tips on the `Custom emoji` page.
In case the user was not allowed to upload an emoji, we were displaying
two different but sematically same tips. This commit merges them and
also updates `update_custom_emoji_ui()` function in settings_emoji.js
to live update tooltip.
2017-07-21 13:29:27 -07:00
Cynthia Lin 4a545728a5 node tests: Add tests covering new subsetting functionality. 2017-07-21 12:13:43 -07:00
Steve Howell 0e25055c1d Add explicit message field for locally_echoed.
We now set locally_echoed to true for messages that are
locally echoed, and we change some of our code to look
for this flag.
2017-07-21 11:38:25 -07:00
Steve Howell 7134bbfbe3 message edit: Prevent editing any failed messages.
Our logic for editing failed messages is broken in various ways,
so we are removing the codepath for editing for now.  We will
try to restore these features as part of #5841.
2017-07-21 11:38:25 -07:00
Steve Howell bd59b91faa reactions: Simplify markup related to message ids.
Because of local echo, message ids can change in message rows.
Having reactions use markup to indicate their message id just
creates more moving parts, since we would need to handle
message_id_changed events.

Now our handlers just call row.get_message_id() as needed.
2017-07-21 11:38:25 -07:00
Steve Howell c256b1663e local echo: Extract message_store.reify_message_id().
We no longer do the message_store piece of reifying ids
via a trigger.  We now make an explicit call to an
ordinary function.

This has several benefits:
    - no more initialize() function
    - no more scary comments about garbage collection
    - the function has a real name now
    - the function is less indented
    - we can easily see when the message_store step happens
    - simpler node tests
    - simpler tracebacks (no jQuery cruft)
2017-07-21 11:38:25 -07:00
Joshua Pan 09043c25ca markdown.js: Move markdown.js test to bugdown-data.json. 2017-07-18 12:56:47 -07:00
Joshua Pan 5e5ca48063 markdown.js: Fix inconsistent #**stream** on new line.
This commit removes all code related to headers because
(1) we don't need the code and (2) it splits #**stream**
as a paragraph, which we don't want. This commit also
fixes the inconsistency when #**stream** is on a new line.

Fixes #4678.
2017-07-18 11:07:25 -07:00
Pweaver (Paul Weaver) d3ffc81726 Enable Hot Module Replacement in webpack.
This allow the webbpack dev server to properly reload JavaScript modules
while running in dev without restarting the server. We need to connect
to webpack-dev-server directly because SockJS doesn't support more than
one connection on the same host/port.
2017-07-18 11:02:05 -07:00
Steve Howell 1ed35be88c stream_list: Use more direct code in build_stream_list.
We eliminate `.get(0)` calls in buld_stream_list.

The easy case is that we stop building jQuery objects
for the splitters only to pull out the DOM immediately.

The more subtle case is that we also don't do `.get(0)` calls
to get DOM out of our individual list items.  By passing
in full jQuery objects to `append()`, we should prevent ourself
from orphaning the old objects, which may in the future have
things like tooltip logic attached to them.
2017-07-18 09:58:16 -07:00
Joshua Pan ec669a0c45 markdown.js: Fix inconsistent user mention on new line.
The user mention regex was checking for multiple lines,
so it broke when the user mention was on a new line.
This changes the regex AND adds a couple tests to
test inline markdown regexes.
2017-07-18 00:07:49 -07:00
Brock Whittaker 0d3ea50379 settings: Change .btn => .button components.
This changes all of the old bootstrap .btn buttons in the settings UI
to the new .button classes that they should be.
2017-07-17 17:20:09 -07:00
Brock Whittaker e5e73f364b settings: Change [Change] button styles. 2017-07-17 16:18:46 -07:00
Brock Whittaker 330a3bd144 setttings: Indent display settings checkboxes and fix header styles.
Aside from the indentation of checkboxes, the headers are added and
changed to become more unified with other page styling.
2017-07-17 16:15:04 -07:00
Cory Lynch a607130cae search_suggestion: Add tests for query with spaces.
Specifically, this checks to make sure that if you
surround an operand with quotes, having spaces inside
is permitted. Also, an extra space after the operator is
also permitted.
2017-07-14 17:33:09 -07:00
Cory Lynch 8125857999 filter.js: Add test coverage for space after operator. 2017-07-14 17:33:09 -07:00
Cory Lynch 35eb878e31 filter.js: Add test coverage for quoted operands. 2017-07-14 17:33:09 -07:00
Cory Lynch 1dba70ca0d search_suggestion: Fix highlighting for multi-word streams.
I deleted a test case that involved a highlighted stream, but
the query was empty. This produces kind of a weird result with
typeahead_helper.highlight_with_escaping, but this function already
has coverage in node_tests/typeahead_helper.js, so the check here
was essentially redundant anyway. Specifically, the highlighter
wraps every character individually with <strong>, and looks really
messy in html.
2017-07-14 17:33:09 -07:00
Vaida Plankyte 28ea174ed9 backend: Implement high contrast mode display setting. 2017-07-14 14:53:24 -07:00
Steve Howell 475eb21a5e Revert commits related to client_message_id.
I pushed a bunch of commits that attempted to introduce
the concept of `client_message_id` into our server, as
part of cleaning up our codepaths related to messages you
sent (both for the locally echoed case and for the host
case).

When we deployed this, we had some strange failures involving
double-echoed messages and issues advancing the pointer that appeared
related to #5779.  We didn't get to the bottom of exactly why the PR
caused havoc, but I decided there was a cleaner approach, anyway.
2017-07-14 12:13:35 -07:00
Steve Howell bc67f6a8ca Add sent_messages.track_messages().
This change has us tracking messages as soon as we start
sending the message to the server.  The next step is to
reconfigure the timeouts a bit to deal with the server not
responding.
2017-07-13 23:42:27 -04:00
Steve Howell 9ee2be4a0d Use client_message_id as key for sent_messages lookups.
We now use a client-side message id to track the state of our
sent messages.  This sets up future commits to start tracking
state earlier in the message's life cycle.

It also avoids ugly reify logic where we capture an event to
update our data structure to key on the server's message id
instead of the local id.  That eliminates the node test as well.

Another node test gets deleted here, just because it's not
worth the trouble with upcoming refactorings.
2017-07-13 23:42:27 -04:00
Steve Howell 7e88fb25b3 Move sent_messages callbacks into transmit_message().
This mostly sets the stage for a subsequent commit to start
using client_message_id as the key into sent_messages.

It has the nice side effect of making it more explicit that
certain things should always happen when transmit_message()
succeeds.

This commit does regress our node test coverage a bit.
2017-07-13 23:42:27 -04:00
Steve Howell 68f8ba0449 Generate client_message_id() sequentially.
This commit starts to decouple client_message_id from local_id.

We don't really take advantage of the decoupling in this
commit--in fact, it's a bit of a pain at first.  But this should
be a fully working checkpoint commit.
2017-07-13 23:42:27 -04:00
Steve Howell 25b59d0044 Extract sent_messages.message_state class.
This class helps us encapsulate the state of a message, with all
the dates/flags that get sent as part of /json/report_send_time.
2017-07-13 23:42:27 -04:00
Steve Howell f6d670ae3d Extract sent_messages.js.
This is mostly straightforward moving of code out of compose.js.

The code that was moved currently supports sending time
reports for sent messages, but we intend to grow out the new
module to track more state about sent messages.

The following function names in this commit are new, but their
code was basically pulled over verbatim:

    process_success (was process_send_time)
    set_timer_for_restarting_event_loop
    clear
    initialize

All the code in the new module is covered by previous tests that
had been written for compose.js.  This commit only modifies
a few things to keep those tests.

The new module has 100% node coverage, so we updated `enforce_fully_covered`.
2017-07-13 23:42:27 -04:00
Steve Howell 8fbb55df85 Introduce client_message_id on the server.
We are deprecating local_id/local_message_id on the Python server.
Instead of the server knowing about the client's implementation of
local id, with the message id = 9999.01 scheme, we just send the
server an opaque id to send back to us.

This commit changes the name from local_id -> client_message_id,
but it doesn't change the actual values passed yet.

The goal for client_key in future commits will be to:
    * Have it for all messages, not just locally rendered messages
    * Not have it overlap with server-side message ids.

The history behind local_id having numbers like 9999.01 is that
they are actually interim message ids and the numerical value is
used for rendering the message list when we do client-side rendering.
2017-07-13 23:42:27 -04:00
Aditya Bansal 85289163a4 compose.js: Refactor to extract of a helper func in test_on_events. 2017-07-11 12:14:09 -04:00
Aditya Bansal 783f75ef10 compose.js: Add a setup statement in an on() test. 2017-07-11 12:14:09 -04:00
Tim Abbott 32af1ed7b4 casper: Fix nondeterministic failures in realm creation tests.
This was previously failing because we didn't wait for a particular
state after logging in, and the title changes at least once during the
process after the URL changes to the Zulip homepage.
2017-07-10 16:18:17 -07:00
Durga Akhil Mundroy 38b70f27d9 typeahead: Use recent_senders/pm_conversations to sort suggestions.
In typeahead_helper.js, added a compare function to first sort by
subscription, then by pm partners and lastly based on recency in the
current topic. Altered function sort_for_at_mention to take topic data
and sort using the above function. Also altered node tests for
typeahead_helper.js to test for the above added functionality.

Fixes: #4249
2017-07-09 10:51:19 -04:00
Aditya Bansal 2479e74867 compose.js: Add coverage for message_id_changed event on document. 2017-07-09 08:49:45 -04:00
Aditya Bansal 51257ee93d compose.js: Add coverage for uploadFinished() function. 2017-07-09 08:49:45 -04:00
Aditya Bansal 18d2be0d5c compose.js: Add coverage for uploadError() function. 2017-07-09 08:49:45 -04:00
Aditya Bansal 43aaab3adf compose.js: Add coverage to progressUpdated() function. 2017-07-09 08:49:45 -04:00
Aditya Bansal 1f6ad92121 compose.js: Add coverage for uploadStarted() function. 2017-07-09 08:49:45 -04:00
Aditya Bansal d9a0217cfe compose.js: Add coverage for undo_markdown_preview_clicked event. 2017-07-09 08:49:45 -04:00
Aditya Bansal f67c9ae9d7 compose.js: Add coverage for markdown_preview_compose_clicked event. 2017-07-09 08:49:45 -04:00
Aditya Bansal 0b363b427f compose.js: Add coverage for attach_files_compose_clicked event. 2017-07-09 08:49:45 -04:00
Aditya Bansal ed3ab27908 compose.js: Add coverage to compose_invite_close_clicked event. 2017-07-09 08:49:45 -04:00
Aditya Bansal f9cbd015cb compose.js: Add coverage for compose_invite_users_clicked event. 2017-07-09 08:49:45 -04:00
Steve Howell 359c9aaec8 zjquery: Remove jquery_array().
This commit simplifies how our zjquery objects are constructed.

We used to have a strange array proxy (my fault) that turns out
to be unnecessary.
2017-07-09 08:31:22 -04:00
Steve Howell 203a0bf119 minor: Set object length for stream_list test. 2017-07-09 08:31:22 -04:00
Steve Howell 1cf18cfbeb compose: Avoid render for duplicate mentions.
There is no reason to render the template for compose mention
warnings if the user is already in the widget.

This commit also restructures the unit test significantly to more
carefully exercise each case, particularly in regard to when
templates get rendered.
2017-07-09 08:30:46 -04:00
Aditya Bansal bea44fb28a compose.js: Add coverage to compose_all_everyone_confirm_clicked.
(Steve Howell also helped.)
2017-07-08 10:50:48 -04:00
Aditya Bansal 777581a1e4 compose.js: Add coverage for usermention_completed.zulip event. 2017-07-08 10:42:20 -04:00
Steve Howell 7376934a77 zjquery: Add $.create() method.
This commit add $.create(), which allows you to create a
jQuery object that just has a name to identify it, as opposed
to some selector or HTML fragment.  It's useful for things that
are really used as stubs.

This also fixes a bunch of the existing tests to use $.create().

Before this fix, you could actually just do $('some-stub'), but
now we enforce that the input to $() looks like a valid selector
or HTML fragment, and we make some exceptions for things like
window-stub and document-stub.
2017-07-08 10:32:32 -04:00
Steve Howell 90777fd1fa zjquery: Add parents() and set_parents_result(). 2017-07-08 08:49:09 -04:00
Steve Howell ccd821e29b zjquery: Rename add_child() to set_find_results().
Hopefully this will make it more explicit that zjquery does
not truly simulate DOM, but it instead allows you to dynamically
set what you want the results of $('foo').find(some_selector)
to be.
2017-07-08 08:31:18 -04:00
Steve Howell 70407e080d zjquery: Require explicit set_parent() calls.
Before this commit, we were erroneously setting up parents
as part of add_child() calls, but it's not necessarily the
case that those children are immediate children, and therefore
the first object is not necessarily the immediate parent.
2017-07-08 08:21:27 -04:00
Steve Howell c91eca291c zjquery: Remove broken code related to remove().
The logic to remove ourself from the parent's children wasn't
correct.
2017-07-08 07:57:02 -04:00
Tim Abbott 9657c4c176 casper: Fix flaky realm creation test.
This test was failing nondeterministically, because depending on when
the check was done, the unread message may or may not have been read.
2017-07-07 21:16:01 -07:00
Cory Lynch 4f8a2d0c57 filter.js: Make from/sender descriptions more concise. 2017-07-07 20:54:54 -07:00
Cory Lynch 2ce7a20237 search_suggestion: Support autocompleting operator names.
Fixes #5399
2017-07-07 20:54:54 -07:00
Cory Lynch 2e9ec5e958 search_suggestion: Remove unknown operand from 'is'.
Fixes #5400
2017-07-07 20:54:54 -07:00
Tim Abbott cbdffeda82 subscriptions: Edit copy for the new stream creation confirmation flow.
The new text is a bit simpler and clearer.

We also decrease the threshhold for this page to 50 subscribers.
2017-07-07 19:22:34 -07:00
Harshit Bansal 60e5071843 subscriptions: Confirm inviting 100+ users to a new stream.
Our current workflow for creating a new stream allows the user to
invite as many other users as they like but since there can be
mistakes in doing so, we now open a modal with a warning if the
number of invites are more than 100 just to confirm that user indeed
wanted to do this.

Fixes: #1663.
2017-07-07 19:08:04 -07:00
Vaida d5517bae36 Delete the old zulip.com "referrals" system.
This system hasn't been in active use for several years, and had some 
problems with it's design.  So it makes sense to just remove it to declutter
the codebase.

Fixes #5655.
2017-07-07 14:59:18 -07:00
Vishnu Ks fcd944447e common.js: Don't set default password quality/length in frontend.
The min quality/length values are always available via data
attributes. So there is no point of specefying a default value
in common.js.
2017-07-07 14:48:06 -07:00
Vishnu Ks f273e83a85 portico: Explain why password is weak to user. 2017-07-07 14:48:06 -07:00
Cory Lynch 75617d07de search_suggestions: Prioritize recent huddles.
Fixes #5612. What this specifically does is that if you are
typing a group PM, this logic iterates through the possible
search suggestions for the next autocomplete. If that suggestion
contains a group PM that already exists, then prioritize it with
the most recent one on top.
2017-07-07 12:12:30 -07:00
Cory Lynch 7efba29b0c search_suggestions: Hide own name in huddle suggestions. 2017-07-07 12:12:30 -07:00
Vishnu Ks cf2dec539f urls: Use POST for zerver.views.realm_icon.upload_icon.
This upload_icon endpoint is changed from PUT to POST becuase
this endpoint is not idempotent.
2017-07-07 10:31:43 -07:00
Aditya Bansal e99067cfc3 compose.js: Add node test coverage for abort_xhr() function. 2017-07-07 12:01:41 -04:00
Aditya Bansal d9009f0c84 node tests: Add test_trigger_submit_compose_form().
(Steve Howell also contributed to this.)
2017-07-07 12:01:26 -04:00
Aditya Bansal ada54d4574 compose.js: Add node test coverage for update_fade().
(Steve Howell made small changes.)
2017-07-07 11:57:43 -04:00
Aditya Bansal cf2a9b74d5 compose.js: Add node test coverage to initialze() function.
(Steve Howell contributed to this as well.)
2017-07-07 11:19:02 -04:00
Aditya Bansal a6082a2b95 compose.js: Add coverage for transmit_message() function. 2017-07-07 08:29:33 -04:00
Aditya Bansal f7e37d37b3 compose.js: Add coverage for finish() function. 2017-07-07 07:50:02 -04:00
Aditya Bansal c17efffa6a compose.js: Add coverage for enter_with_preview_open() function. 2017-07-07 07:50:02 -04:00
Aditya Bansal 55f05a5f53 compose.js: Add coverage for send_message() function. 2017-07-06 17:44:27 -04:00
Steve Howell 1466cfaf0c Add node tests for zjquery.
These tests should serve as a basic form of documentation on
how to use zjquery.  It covers most of the basic principles.
2017-07-06 14:31:34 -04:00
Steve Howell b3848ed8bd zjquery: Assert only one function gets triggered.
If multiple functions get called by trigger(), it is almost
certainly a sign of overly complex test setup.
2017-07-06 10:27:54 -04:00
Steve Howell 74f9612147 node tests: Simplify trigger stubbing in stream_events.js.
This test verifies the following line of code:

    $(document).trigger($.Event('subscription_remove_done.zulip', {sub: sub}));

Before this change, the mocking mechanism used `$(document).on(...)`
to set the function that gets called on trigger, but it didn't clear
any of the other handlers.

Since all we care about is making sure that the event gets triggered,
we now just override `$(document).trigger`.
2017-07-06 10:27:09 -04:00
Steve Howell 38e3d2fc11 node tests: Use get_on_handler in stream_list.js. 2017-07-06 09:23:06 -04:00
Steve Howell 6a8fa55521 node tests: Use get_on_handler() in message_store.js. 2017-07-06 09:13:19 -04:00
Steve Howell 99a6a9b70d node tests: Replace trigger() calls in activity.js.
We now use get_on_handler() to call event handlers, rather
than simulating a triggered event.
2017-07-06 08:46:36 -04:00
Aditya Bansal 9c90a3d1a3 zjquery: Add get_on_handler(). 2017-07-06 08:37:39 -04:00
Aditya Bansal 641b38f79b zjquery: Add get_on_handlers(). 2017-07-06 08:36:38 -04:00
Aditya Bansal 3b30701844 zjquery: Add selector param option to on() function. 2017-07-06 08:29:07 -04:00
Cory Lynch 43544cef28 stream_events: Add tests for mark_unsubscribed. 2017-07-05 17:57:52 -04:00
Cory Lynch 2627c1cde3 stream_events: Add tests for mark_subscribed. 2017-07-05 17:57:52 -04:00
Cory Lynch c8281de492 stream_events: Add tests for update_property. 2017-07-05 17:57:52 -04:00
Harshit Bansal a6cd460f72 emoji: Rename `emoji.realm_emojis` to `emoji.all_realm_emojis`. 2017-07-05 13:02:41 -07:00
David Coleman 77dc5df56a uploads: Display year in attachments UI upload timestamp.
Modified timerender.js absolute_time() to include the
year in the returned time stamp string.

Fixes #5600.
2017-07-04 16:13:20 -07:00
Cory Lynch b13265d135 util: Remove execute_early.
This function was removed in favor of loading everything in
ui_init.js. The asynchronous nature of jQuery 3 document-ready
events may cause an undesirable order in which these are executed.
2017-07-04 13:54:33 -07:00
Cory Lynch e33b178054 message_store: Move initialization to ui_init.js. 2017-07-04 13:54:33 -07:00
Cory Lynch 25be3a402d message_fetch: Move initialization to ui_init.js.
This involves modifying a casper test, because now
upon registration, there is one unread message.
2017-07-04 13:54:33 -07:00
Harshit Bansal d3d6712fa3 left-sidebar: Update the size of the scrollbar after narrowing to a stream. 2017-07-03 09:53:41 -07:00
vaibhav 3cddc4ac93 settings: Add node test for url input box toggle.
This contains node test for toggling the url inputbox of
outgoing webhooks service url in the "Add new bot" form.
2017-07-03 11:09:40 -04:00
vaibhav f003a4c916 settings: Move api_key_button click in casper tests.
api_key_button element has been moved from "your-bots" settings page
to "account-settings" page. This click statement was left by mistake.
2017-07-03 11:09:40 -04:00
Cory Lynch 30c7629212 Change code block typeahead to only sometimes close fence.
Fixes #5556.
Some tests needed to be moved around to make sure the
stubbing wouldn't break future tests.
2017-07-03 11:05:18 -04:00
Harshit Bansal 4cb8ac100a emoji: Fix the title and alt text for unicode emojis.
Unicode emojis when rendered should display canonical short name.
Similarly, the alt text should be of the format `:<short_name>:`.
For both of these we currently display the actual unicode symbol.
As some systems don't have the fonts necessary for displaying them
properly, they are rendered as empty square blocks. This commit also
ensures that the markup generated for emoji generated by canonical
name and by an unicode emoji is same.

Fixes: #5555.
2017-07-01 11:14:24 -07:00
Cory Lynch 8abbb6d781 search: Remove in:all token from suggestions. 2017-07-01 12:19:52 -04:00
Steve Howell 3fe6d12ab6 node tests: Test server_events_dispatch.js directly.
The dispatch.js tests now no longer go through server_events.js,
so the tests are isolated from some of the setup you have to
do for the main event loop.  They now directly call into
server_events_dispatch.js.
2017-07-01 08:50:50 -04:00
Aditya Bansal 74f40a0a58 compose.js: Add node test coverage for report_as_received() function. 2017-06-30 19:57:15 +05:30
Aditya Bansal 4b3c2931ea compose.js: Add test coverage for mark_rendered_content_disparity(). 2017-06-30 19:57:15 +05:30
Aditya Bansal 7e585acfa5 compose.js: Add coverage for send_message_success() function. 2017-06-30 19:57:15 +05:30
Aditya Bansal 7f4781e17d compose.js: Add test coverage for update_email(). 2017-06-30 19:57:15 +05:30
Aditya Bansal 3d043d0109 compose.js: Add coverage for get_invalid_recipient_emails(). 2017-06-30 19:57:15 +05:30
Aditya Bansal 9437895c9e compose.js: Add coverage for validate_stream_message() function. 2017-06-30 19:57:15 +05:30
Steve Howell 6cf4c65d92 node tests: Add 100% coverage for channel.js. 2017-06-30 09:48:04 -04:00
Steve Howell 0b60538570 node tests: Extract test_get_reaction_section(). 2017-06-30 08:05:10 -04:00
Aditya Bansal 1e18863a98 timerender.js: Use stubbed version of i18n from zjsunit. 2017-06-29 15:18:08 -04:00
Aditya Bansal 5eb5b33f21 settings_org.js: Use stubbed version of i18n from zjsunit. 2017-06-29 15:18:08 -04:00
Aditya Bansal a103949c2b i18n.js: Fix issue of i18n stub not returning 'translated: ' prefix. 2017-06-29 15:18:08 -04:00
Aditya Bansal 4d84be16ca i18n.js: Fix issue with i18n being cleaned up in namespace cleanup. 2017-06-29 15:18:08 -04:00
Aditya Bansal 7531a85c4d stream_data: Add get_subscriber_count() function. 2017-06-29 10:34:47 -04:00
Aditya Bansal cc34e3d382 compose.js: Add coverage for validate_stream_message_address_info(). 2017-06-29 18:02:25 +05:30
Umair Khan 12b124ba71 single_message.handlerbars: Use __starred_status__ in tooltip.
We do not allow handlerbars within tranlation tags. To use variables in
translatable strings, enclose variables with double lowdashes.
2017-06-29 07:39:20 -04:00
Steve Howell aae3250155 node tests: Add test_with_view_stubs() for reactions.js. 2017-06-29 07:19:52 -04:00
Steve Howell 791e489938 Use a proper context in insert_new_reaction().
Before this change, we were piggybacking fields on to the event
object, which coupled us to any other function that relies on
the event.
2017-06-29 07:19:52 -04:00
Aditya Bansal 92b43c7965 compose.js: Add test for validate_stream_message_address_info().
In this commit we add only one test for the case of unsubscribed
streams in validate_stream_message_address_info() function."
2017-06-28 07:45:21 -04:00
Aditya Bansal 6c787ac569 compose.js: Add test for validate_stream_message_address_info().
In this commit we only add a single test for the case of subscribed
stream to validate_stream_message_address_info() function.
2017-06-28 07:45:21 -04:00
Aditya Bansal 63401833b4 compose.js: Add node test coverage for validate function. 2017-06-28 07:45:21 -04:00
Aditya Bansal 232966a948 activity.js: Remove unnecessary override of i18n as global var. 2017-06-28 07:34:04 -04:00
Aditya Bansal 103f19e236 zjsunit: Add i18n minimal lib. 2017-06-28 07:34:04 -04:00
Aditya Bansal 1ed499fffc zjquery: Add stop() function. 2017-06-28 07:34:04 -04:00
Aditya Bansal bd370993ea zjquery: Add fadeTo() function. 2017-06-28 07:34:04 -04:00
Aditya Bansal fb723f9477 zjquery: Reorder functions in lexographic order. 2017-06-28 07:34:04 -04:00
Joshua Pan ac64ee355d compose_actions.js: Allow compose to empty narrow.
This allows r/enter hotkeys to compose to
an empty narrow (no messages).

Fixes #4500.
2017-06-27 14:06:59 -04:00
Joshua Pan c4914eeec9 narrow.js: Create narrowed_by_stream_reply().
This function returns if you are narrowed
to a stream.
2017-06-27 14:06:59 -04:00
Yago González 00a7f89ba9 node tests: Add coverage to composebox_typeahead.js. 2017-06-26 19:33:25 -04:00
Yago González e76c9f1200 node tests: Add tests to test_begins_typeahead. 2017-06-26 19:33:25 -04:00
Yago González 4fa6aa2268 node tests: Re-sort begins_typeahead tests. 2017-06-26 19:33:25 -04:00
Aditya Bansal 7f2b6f739c emoji.js: Add test coverage for initialize. 2017-06-26 14:24:20 -04:00
Aditya Bansal 88d9739c45 emoji.js: Add test coverage for build_emoji_upload_widget func. 2017-06-26 14:24:20 -04:00
Aditya Bansal d1fe75ce3b node tests: Enforce 100% node coverage in activity.js. 2017-06-26 14:24:20 -04:00
Yago González 8ae0c90e9f zjquery: Return element in some jQuery methods.
jQuery's behavior in methods that, because of their nature, don't need to
return anything is to return the element itself in the jQuery object form.

Now the zjquery element is returned when one of these methods is called.
2017-06-26 08:38:21 -04:00
Yago González 1343216002 zjquery: Add select function. 2017-06-26 08:38:21 -04:00
Yago González 4b8a52cee0 zjquery: Handle passing elements to $().
There are some cases when the jQuery dollar
function is called with an element as argument.

If such element has already been created using
zjquery, we should simply return it.
2017-06-26 08:38:21 -04:00
Yago González 679325733d zjquery: Add extend method. 2017-06-26 08:38:21 -04:00
Yago González a9c8efe871 zjquery: Add keydown and keyup functions. 2017-06-26 08:38:21 -04:00
Yago González ad154da174 zjquery: Add generic event setter/handler. 2017-06-26 08:38:21 -04:00
Yago González a8c7539497 node tests: Make Othello's name match the dev server. 2017-06-26 08:38:21 -04:00
Yago González f908c2e442 node tests: Store fake users as independent variables.
This makes the fake users' objects reachable along the whole test file,
allowing to make assertions that involve user data more easily.
2017-06-26 08:38:21 -04:00
Yago González add869edcb node tests: Fix line length. 2017-06-26 08:38:21 -04:00
Sampriti Panda b2a1754f8a drafts: Re-narrow on restoring draft.
Fixes #4587
2017-06-25 12:26:42 -04:00
Sampriti Panda 7ac90ad925 casper: Fix flake in drafts tests.
On some developer machines, casper was having trouble clicking on
a hidden button. Added a step to make sure the button was visible
before being clicked on.

Also removed an unnecessary log line.
2017-06-25 11:21:35 -04:00
Aditya Bansal 6b911959d5 pm_lists.js: Reach 100% node test coverage. 2017-06-23 09:40:00 -04:00
Cory Lynch 090d7487cf search_suggestion: Use person matching function from people.js.
Instead of having a custom (duplicate) matching function in
search suggestion, it was refactored to use the function in
people.js. This also gets the diacritic-ignoring feature
of the function in people.js.

Fixes #5315.
2017-06-23 08:29:20 -04:00
Harshit Bansal 6615f2f2e8 common.js: Migrate `common.js` module to use IIFE module style.
This module was exposing its functions as globals. This PR fixes
it use the IIFE module style that we use in our other modules.
2017-06-22 19:06:32 -04:00
Cory Lynch df83cee86b people.js: Ignore diacritics in search bar.
Fixes #5315
2017-06-21 19:13:44 -04:00
Yago González e7bd18ec09 timerender: Make get_full_time produce a ISO 8601 date string.
Having get_full_time produce a date string non-compliant with RFC2822 or
ISO 8601 caused problems when showing edition timestamps on a message's
edit history.

Now it returns an ISO 8601 date string (1978-10-31T13:37:42Z).
2017-06-21 16:46:39 -04:00
Cynthia Lin e832ebdc98 hotkeys: Add collapse/show message hotkey.
Fixes #4540
2017-06-21 15:54:09 -04:00
Cynthia Lin a9afe43735 hotkeys: Add `u` hotkey for opening message sender profile.
Fixes #4873
2017-06-21 10:38:05 -04:00
Joshua Pan 1e4c133430 node tests: Test sort_recipientbox_typeahead() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan b48f8447e2 node tests: Fully cover compare_by_pms() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan 1c34a3ae54 node tests: Fully cover sort_streams() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan ffde90fcd1 node tests: Add tests for sort_emojis() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan 0563337240 node tests: Fully cover split_by_subscribers() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan a53a4b7f0d node tests: Add tests for render stream typeahead item. 2017-06-21 00:03:05 -04:00
Joshua Pan 7a93a425f8 node tests: Add tests for render person typeahead item. 2017-06-21 00:03:05 -04:00
Joshua Pan ee48ac1854 node tests: Fully cover compare_by_popularity() in typeahead_helper.js. 2017-06-21 00:03:05 -04:00
Joshua Pan 649558476e node tests: Get rid of typeahead_helper dependency.
This also puts the global tests into their
own specific tests, which then allows us to
get rid of the typeahead_helper dependency.
2017-06-21 00:03:05 -04:00
Cory Lynch 6d90d7ccbb people.js: Ignore own email address in group PMs. 2017-06-20 21:22:45 -04:00
Aditya Bansal 4c8e4eea4e user_events.js: Make node test coverage reach 100%. 2017-06-20 20:57:10 -04:00
Cory Lynch ff9498f85b bookend: Hide re-subscribe button for private streams.
Fixes #5181
2017-06-20 20:56:26 -04:00
Joshua Pan 5e611826da node tests: Call settings_bot.set_up() to get initial line coverage. 2017-06-20 19:49:23 -04:00
Joshua Pan 8a6e8906bd zjquery: Add .click() function. 2017-06-20 19:49:23 -04:00
vaibhav d9bc3932ec settings: Move "download personal API key" from "your-bots" to "your account"
Fixes: #5355.
2017-06-20 15:46:23 -04:00
vaibhav 9a6e326305 Add support for generating and downloading flaskbotrc.
Flaskbotrc is a file containing config of all active
outgoing webhook bots. It is used to provide configuration
of all active outgoing webhook bots to zulip-bot-server.
2017-06-20 09:43:45 -04:00
Cory Lynch 005d06eb38 message_store.js: Add tests for message id change.
This gets message_store.js to 100% line coverage.
2017-06-20 06:24:27 -04:00
Cory Lynch 10b86da128 message_store.js: Add tests for erorrs/edge cases. 2017-06-20 06:24:27 -04:00
Cory Lynch 24b9108d09 message_store.js: Increase coverage for add_message. 2017-06-20 06:24:27 -04:00
Steve Howell 6c722843ef node tests: Fix namespace leaks related to require().
The node tests have purged modules from cache that were
included via things like set_global(), but calling require
directly would leak modules into the next test, which made
a couple tests only work when you ran the whole suite.  I
fixed those tests to work standalone.  And then I now make
dependencies explicitly clear the require cache before we
require them in namespace.js.
2017-06-19 22:36:58 -04:00
Vishnu Ks 9b16835c99 user_popover: Handle the case when user presence is unknown.
For bots and users who have not logged in for a long time the presence information is not known. For the these users make the presence indicator hidden.
2017-06-19 17:25:06 -04:00
Joshua Pan ecaf628d76 node tests: Add test_set_user_status(). 2017-06-19 08:00:55 -04:00
Joshua Pan a71a8d2343 node tests: Fully cover status_from_timestamp in presence.js. 2017-06-19 08:00:55 -04:00
Joshua Pan 8011212384 node tests: Fully cover update_info_for_small_realm in presence.js. 2017-06-19 08:00:55 -04:00
Joshua Pan 65c68d385e node tests: Add test_last_active_date(). 2017-06-19 08:00:55 -04:00
Joshua Pan 71dab26c84 node tests: Fully cover test_set_info in presence.js. 2017-06-19 08:00:55 -04:00
Cory Lynch 7f8ecb62c9 fenced_code.js: Improve coverage to 100%. 2017-06-19 06:53:25 -04:00
Cory Lynch 58a2ffbe1d Add search suggestion support for is:unread. 2017-06-19 06:51:13 -04:00
Cory Lynch 86d3e00bd0 Add search support for is:unread.
Fixes #1423.
2017-06-19 06:51:13 -04:00
Steve Howell 7e99262331 Add tests to settings_org.js.
This gets about 80% line coverage.
2017-06-16 18:57:07 -04:00
Steve Howell e0d79acac0 zjquery: Add attr() method. 2017-06-16 14:58:27 -04:00
Steve Howell f91dc2fec9 zjquery: Add prop() function. 2017-06-16 08:47:54 -04:00
Abhijeet Kaur af7e08acb0 bots: Add UI to view bot types of existing bots in "Your bots".
Tweaked by tabbott for more standard internationalization.
2017-06-15 10:08:31 -07:00
Steve Howell d2b710b307 Add maybe_show_keyboard_shortcuts().
This prevents some strange UI experiences and some blueslip
errors by not opening keyboard help when other overlays or
popovers are open.
2017-06-15 10:15:29 -04:00
Yago González 1d47a7b505 node tests: Replace stub jQuery with zjquery. 2017-06-15 09:08:40 -04:00
Yago González 98e74db6e8 node tests: Remove unnecessary dependency (hashchange). 2017-06-15 09:08:40 -04:00
Yago González 31d81e2c9b node tests: Add coverage for unexpected exceptions in handleTex. 2017-06-15 09:08:40 -04:00
Yago González 6c0dfa7f8f node tests: Fix format in markdown.js tests.
Replaced 2-space indentation with 4 spaces, and removed a couple
unnecessary newlines.
2017-06-15 09:08:40 -04:00
Yago González 44078a73bf node tests: Add coverage for python_to_js_filter. 2017-06-15 09:08:40 -04:00
Yago González 97a07f311e node tests: Add coverage for add_subject_links. 2017-06-15 09:08:40 -04:00
Yago González ae67f9044d node tests: Add coverage for handleUnicodeEmoji. 2017-06-15 09:08:40 -04:00
Akhil 1bcc0dbd81 org-settings: Add UI for changing the notifications stream.
Added a dropdown in the organization settings page with a search-box and
required styles. Also added an element to disable it. Added a method to
populate the dropdown using list_rendering.js. Also altered response to
the event of deletion of the notifications stream on the frontend. On
selection of a new stream or on clicking 'Disable', a patch request is
made with stream-id to /json/realm.

Fixes: #3708.
2017-06-15 04:08:29 -07:00
Cory Lynch 11a7a476d7 search_suggestion: Add negation support for 'has' operator. 2017-06-15 02:32:00 -07:00
Cory Lynch da4e2954fe search_suggestion: Remove is:private as default suggestion. 2017-06-15 02:20:50 -07:00
Cory Lynch 89b8d07420 Make search suggestion messages more concise.
This involves updating filter.js, mostly. The
tests were updated appropriately for this change,
which also involved changing a caspar test for
narrowing.
2017-06-14 22:34:46 -07:00
Cory Lynch ab5b0e938d Add support for "has" operator in search_suggestions.
This was never a feature in the old search_suggestions
version, so a new helper function for it was added.

Relevant tests were also added, maintaining 100% coverage.
2017-06-14 22:34:46 -07:00
Cory Lynch a7ec8cd1f3 Improve topic in search_suggestion.js.
Also added some additional testing to handle
some edge cases that I'd like to make sure
don't break down.
2017-06-14 22:34:46 -07:00
Cory Lynch 69e8074d14 Improve person/group in search_suggestions.js.
The get_person_suggestions and get_group_suggestions functions
were updated to the new system. Support for negation is also
added in the new system.

Relevant tests were also updated. Also, note that the function
get_private_suggestions was removed, as it was rendered
obsolete by these updates.
2017-06-14 22:34:46 -07:00
Cory Lynch c8d4eff8aa Improve sent_by_me in search_suggestions.js.
Added appropriate tests.
2017-06-14 22:34:46 -07:00
Cory Lynch 79d56c94dc Improve default and special_filter in search_suggestion.js.
Special filter was updated to work even when it is not the first
token in a search query. Furthermore, the default query was
moved around to work with the changes to come for the new
suggestion system.

A test also had to be modified to work with the new system.
2017-06-14 22:34:46 -07:00
Steve Howell 5482a6e129 Add test_narrowing() for stream_list. 2017-06-14 15:29:17 -04:00
Steve Howell dc9ea24d79 zjquery: Add get(). 2017-06-14 15:29:17 -04:00
Steve Howell 7722539504 zjquery: Add better trigger stubbing. 2017-06-14 15:26:41 -04:00
Steve Howell 39e8bed9ef Test stream_list.update_dom_with_unread_counts(). 2017-06-14 12:28:08 -04:00
Steve Howell 499962bb6b Change arg for stream_list.redraw_stream_privacy().
We now pass in a sub, not a stream name.
2017-06-14 11:24:42 -04:00
Steve Howell bc575685a9 Add more test coverage to stream_list.js. 2017-06-14 11:24:20 -04:00
Steve Howell bc5165a54e Add test coverage to stream_list.js. 2017-06-14 09:27:28 -04:00
Steve Howell 5272b6644e zjquery: Support $('<div>').html(). 2017-06-14 08:17:03 -04:00
Harshit Bansal 0e8f1f4e5d alert_words: Fix the UI to not allow users to create duplicate alert words. 2017-06-13 16:37:49 -07:00
Harshit Bansal 947f6e9190 casper_tests: Fix the broken alert words casper tests.
This commit fixes the broken alert word casper tests that were
commented out earlier due to flakes(see issue #1244).

Fixes: #1269.
2017-06-13 16:36:11 -07:00
Harshit Bansal 94fc7dfe20 alert_words_ui: Fix the data flow while removing an alert word.
Add `remove_alert_word()` function which uses the correct data flow
while removing an alert word.

`alert_words_ui.js` was structured differently from most of the other
settings. It was not using the triggers from the server for running
the success/failure handlers.
2017-06-13 16:36:11 -07:00
Steve Howell 66673f508b node tests: Add test_update_count_in_dom(). 2017-06-13 18:37:02 -04:00
Akhil ff9a929d7a typeahead: Remove highlighting and add common template. 2017-06-13 16:16:17 -04:00
Steve Howell 736f4c2930 zjquery: Fix missing wrapper from last commit. 2017-06-12 07:43:04 -04:00
Steve Howell 8da391b51e zjquery: Fix chaining semantics.
We now make it so that $('foo').addClass(whatever) and similar
functions properly return the wrapper object for chaining
purposes.  We may eventually want to change the wrapper object
to automatically dispatch to the first child object, but this
should work for now.
2017-06-12 07:28:23 -04:00
hackerkid a158676fb0 Add function to get last seen status from last active date. 2017-06-11 07:09:21 -05:00
Cory Lynch 12d1086d14 message_list: Add tests for sent_by_me. 2017-06-08 16:48:34 -07:00
Cory Lynch 863c298d3c message_list: Add tests for change_message_id. 2017-06-08 16:48:34 -07:00
Cory Lynch 6ecd7545ae message_list: Add tests for updates. 2017-06-08 16:48:34 -07:00
Cory Lynch d1e1e69abe message_list: Add tests for message_range. 2017-06-08 16:48:34 -07:00
Cory Lynch e229f79474 message_list: Add tests for add/remove and rerender. 2017-06-08 16:48:34 -07:00
Cory Lynch 537ae79398 message_list: Add tests for unmuted messages. 2017-06-08 16:48:34 -07:00
Cory Lynch 0f848b1770 message_list: Add tests for bookend. 2017-06-08 16:48:34 -07:00
Cory Lynch 4bd28a3ff3 message_list: Add more basic tests. 2017-06-08 16:48:34 -07:00
Joshua Pan ccd880094e util.js: Refactor util.strcmp into util.make_strcmp. 2017-06-07 19:45:46 -05:00
Joshua Pan 2bf48e58aa node tests: Get util.js to 100% node coverage. 2017-06-07 19:45:46 -05:00
Joshua Pan 9d862ab3d3 node tests: Make util.js use zjquery. 2017-06-07 19:45:46 -05:00
Umair Khan 520d1de052 12-toggle-message-editing.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan 591098cd27 11-mention.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan 33e46af898 08-edit.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan 5ae822fc54 07-stars.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan fe8204f1f0 05-subscriptions.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan 0c952dca73 04-compose.js: Remove waitForText. 2017-06-07 13:41:59 -07:00
Umair Khan e4f6f53e74 casper: Add waitForSelectorText.
Fixes #1110
2017-06-07 13:41:59 -07:00
Jack Zhang 98a785bb25 message_edit: Replace highlighting replaced text with delete / insert.
Rationale: For the more off-to-the-side edit history view, changes
are easier to digest by highlighting deleted content in red followed
immediately by added and changed content in green.

TODO: Toggle for showing the edited messages without highlighting;
deleted content would not be shown in this view.
2017-06-07 11:06:15 -07:00
Steve Howell ce1dd9f50b presence: Do not show bots in the buddy list.
(Before this fix, we were showing empty circles for bots
in small realms.)
2017-06-07 10:36:26 -06:00
Joshua Pan 6a5c01a36e node tests: Get unread.js to 100% node coverage. 2017-06-07 03:23:57 -06:00
Joshua Pan 0a56156017 node tests: Get stream_sort.js to 100% node coverage. 2017-06-07 03:23:57 -06:00
Joshua Pan 9f9cb618c9 node tests: Get recent_sender.js to 100% node coverage. 2017-06-07 03:23:57 -06:00
Joshua Pan a6efbddd65 node tests: Test drafts_overlay_open(). 2017-06-07 00:02:14 -07:00
Joshua Pan bbc0103183 drafts.js: Create initialize() function. 2017-06-07 00:01:55 -07:00
Cory Lynch 60b62ac81d typeahead_helper: Add test coverage for highlighting.
Specificially, the test_highlight_with_escaping, used in
most of our typeaheads.
2017-06-06 21:19:28 -07:00
David Coleman 13915740bb refactoring: use class attr to identify timerender date <span>.
The floating_recipient_bar is cloned from recipient_bar elements.
The cloning created elements in the DOM with duplicate id
attributes, specifically <span id="timerender{id}">, which
contains the date of the message stream. The timerender span
will now use class="timerender{id}" instead.

Fixes #4997.
Fixes #5128.
2017-06-06 20:01:21 -07:00
Jack Zhang 84e5fe733c message-editing: Show date lines between edits from different days.
Added show_date_row field to each item of content_edit_history.
We use date lines to separate events that happened on different days.

Fixes #4638.
2017-06-06 11:04:30 -07:00
Tim Abbott b89be3f54b bookend: Make ordering of subscribe bookends consistent.
Previously, if we had both a date and a subscribe bookend, they would
appear in one order after new messages were sent (bookend_bottom of
the top group), and another after a reload (bookend_top of the bottom
group).  This makes the experience consistently a bookend_top.
2017-06-05 16:43:26 -07:00
Cory Lynch 080a3b9286 Add test coverage for 'stream_sort.js'.
Added new file to test stream sort. Specifically,
it tests the `sort_group` function's ability to put
streams into the corect pinned/normal/dormant category,
filter them based on keyword, and sort alphabetically.
2017-06-02 18:13:33 -06:00
Cory Lynch 5d7828096e Split out server_events_dispatch.js from server_events.js. 2017-06-02 16:49:18 -07:00
Steve Howell ed9eca90f2 node tests: Isolate timerender.js from i18n/jquery.
This makes the test run a lot faster, and it fixes
some leaky behavior where the test used to work only
when other tests ran before it.
2017-06-02 14:18:51 -07:00
Steve Howell 0aaa182fbe node test: Use zjquery to test stream_list.js.
We use zjquery now for testing stream_list.js, which runs faster
than the real jQuery and allows some test isolation.  The nature
of the test is basically the same, but we don't actually render
templates.  Instead of making assertions about the DOM, we are
now making assertions about how the stream lists get constructed
from other elements.
2017-06-02 14:11:11 -07:00
Steve Howell 5dad7372f9 minor: Remove unneeded render in template tests.
(We have had ways to track partial templates for a while.)
2017-06-02 14:11:11 -07:00
Joshua Pan 3905602da5 node tests: Test user timezone functions in people.js. 2017-06-02 06:30:40 -06:00
Steve Howell 1a4c8a598d tests: Add more coverage to narrow_state.js in test_stream(). 2017-06-01 22:14:11 -07:00
Steve Howell 8a39e67876 node tests: Extract narrow_state tests to new module. 2017-06-01 22:14:11 -07:00
Joshua Pan 52518fbc29 node tests: Get people.js to 100% node coverage. 2017-06-01 20:27:58 -07:00
Akhil 64f2b51496 typeahead: Add pm_conversations module.
In pm_conversations.js, added function to make a user a PM partner and
another function to check if a user is a PM partner. A PM partner is
someone with whom the user has been in a PM with.
2017-06-01 08:05:37 +00:00
Akhil f04da3d52e typeahead: Add recent_senders module.
In recent_senders module, added a data structure to hold timestamps of
users' latest message in a topic. Also added a function to compare 2
users based on above timestamp. Added a function to process messages for
the data structure and a call in add_message_metadata. Also added node
tests for insertion of data into recent_senders.senders.
2017-06-01 08:05:37 +00:00
Cory Lynch aa3ef439eb Add coverage for 'typing' dispatch. 2017-05-31 18:07:25 -07:00
Cory Lynch cd3f9354c0 Add coverage for 'delete_message' dispatch. 2017-05-31 18:07:25 -07:00
Cory Lynch 4449aba471 Add coverage for 'realm_domains' dispatch. 2017-05-31 18:07:25 -07:00
Cory Lynch 93a8ae852e Add coverage for 'reaction' dispatch. 2017-05-31 18:07:25 -07:00
Cory Lynch 93dc288e5e Add coverage for 'hotspots' dispatch. 2017-05-31 18:07:25 -07:00
Joshua Pan fd57fcbc1c node tests: Add coverage for blueslip errors in people.js.
This covers all blueslip errors and warnings
in people.js. These do not need to be tested
to rigorously and just need to be covered to
get people.js to 100% coverage.
2017-05-31 16:04:49 -06:00
Steve Howell e1f5a4e0bb Add test_expand_and_update_private_messages(). 2017-05-31 09:10:43 -07:00
Steve Howell 22dfb9f09d Add test_update_dom_with_unread_counts(). 2017-05-31 09:10:43 -07:00
Steve Howell 0b0c57bbe0 zjquery: Throw Error() object to get tracebacks.
If you throw a raw string in node, you don't get a traceback.
2017-05-31 09:10:43 -07:00
Umair Khan 6ee08e0602 casper: Fix waiting condition in message deletion tests.
We now specifically wait for the length to decrease by one. This seems
like a more deterministic condition to wait on.

Previously we were waiting till the id of the deleted message remained
visible; intuitively, this should have worked but it seems that there
is some race condition that was causing the test to fail sporadically.
2017-05-30 22:49:59 -07:00
Steve Howell 4ec1260b41 reactions.js: Have an initialize() function. 2017-05-30 21:43:18 -07:00
Steve Howell 6149111b5e Add test_error_handling() for reactions.js. 2017-05-30 21:43:18 -07:00
Steve Howell b0b647c9e5 Add more code to test_add_and_remove_reaction().
This increases our line coverage a bit.
2017-05-30 21:43:18 -07:00
Steve Howell b559364614 Use zjquery to test pm_list.js.
We now stub templates.render() to see what data gets passed in
to the template, rather than using jQuery to inspect the DOM that
gets created.  This changes the nature of the test to be less about
integration with the templating layer and more about how we pass
data into the template.

To compensate, we add more assertions to the relevant test
in templates.js.
2017-05-30 20:46:30 -07:00
K.Kanakhin 2434f2d96c messages: Add support for admins deleting messages.
This makes it possible for Zulip administrators to delete messages.
This is primarily intended for use in deleting early test messages,
but it can solve other problems as well.

Later we'll want to play with the permissions model for this, but for
now, the goal is just to integrate the feature.

Note that it saves the deleted messages for some time using the same
approach as Zulip's message retention policy feature.

Fixes #135.
2017-05-29 21:59:38 -07:00
Steve Howell 879abd6290 Add coverage for update_existing_reaction(). 2017-05-29 20:10:53 -07:00
Steve Howell 1ae66cda6f Increase test coverage for insert_new_reaction. 2017-05-29 20:10:53 -07:00
Steve Howell 80920438a5 Add coverage for get_emojis_used_by_user_for_message_id. 2017-05-29 20:10:53 -07:00
Steve Howell ecbbc8788a Move code from reactions -> emoji_picker.
This moves all the code dealing with emoji_picker
navigation and click/enter events to emoji_picker.js.

Some of the code still delegates back to reactions.js
in some way.

The navigate() code really does nothing reaction-specific,
nor does filter_emojis(), nor do some of their helpers.

This was mostly moving code, but I also did some
s/reaction// or s/reaction/emoji/ in names.
2017-05-29 17:10:05 -06:00
Steve Howell ed2ceb49cb Use toggle_emoji_reaction for "+" hotkey.
This is a more direct codepath when we know which emoji
we want to toggle.
2017-05-29 17:10:05 -06:00
Steve Howell 805c99ae27 Add hide_emoji_popover() to toggle_emoji_reaction().
This change sets us up to de-duplicate some code.  It
changes behavior for the edge case situation where
you had the reaction menu open but then decide to
click on one of the existing reactions.  This change
closes the emoji popover, which is probably the
correct behavior.
2017-05-29 17:10:04 -06:00
Steve Howell 63d0711c4b Rename message_reaction_on_click() to toggle_emoji_reaction().
This prepares us to de-duplicate some code.
2017-05-29 17:10:04 -06:00
Steve Howell 49e3ee36c4 Add tests for reactions.remove_reaction(). 2017-05-29 14:59:52 -07:00
Steve Howell affff8ac82 Extract reactions.set_reaction_count. 2017-05-29 14:59:52 -07:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
David 43e76816ff message view: Recipient bar date stamp shows older years.
timerender.js render_now() will always include older
years when rendering the date stamp on the recipient bar
and the date rows above messages.

Fixes #4843.
2017-05-29 08:54:06 -07:00
David fcf97660db testing-coverage: add node tests for timerender.js.
Initial set of tests for the timerender.js module.

Fixes #4819.
2017-05-29 08:51:28 -07:00
Steve Howell cb0527397e Add tests for reactions.add_reaction(). 2017-05-28 16:58:32 -07:00
Steve Howell 8d7cd2e3af Add tests for reactions.message_reaction_on_click(). 2017-05-28 16:58:32 -07:00
Sarah e304c47970 settings_org: Split out separate forms for orgs settings/permissions/auth.
Steve Howell also contributed to this PR.
2017-05-25 14:18:04 -07:00
Yago González d7ecb252df node tests: Add tests for colorspace.js. 2017-05-25 10:09:39 -07:00
Yago González f25c16b573 node tests: Add coverage for get_all_bots_for_current_user. 2017-05-25 09:54:05 -07:00
Yago González 115b2f6b6b node tests: Fix indentation. 2017-05-25 09:54:05 -07:00
Tim Abbott 74ad90533d node: Fix missing bot_data initialization.
This was making the frontend tests fail.
2017-05-24 19:59:40 -07:00
Steve Howell 6518c63b14 node tests: Add tests to activity.js. 2017-05-24 17:41:41 -07:00
Steve Howell 689605dd2e Introduce make_zjquery(). 2017-05-24 17:41:41 -07:00
Steve Howell 6c7a5260fc node tests: Add tests for filtering user ids in user list. 2017-05-24 17:41:41 -07:00
Steve Howell 5c09bec5e9 node tests: Use zjquery for entire activity test. 2017-05-24 17:41:41 -07:00
Steve Howell 46e72289d1 Add features to zjquery. 2017-05-24 17:41:41 -07:00
Steve Howell 4cfd9aa689 Add test coverage for activity unread counts. 2017-05-24 13:08:54 -07:00
Steve Howell 4a062d47a6 Add more features to zjquery. 2017-05-24 13:08:54 -07:00
Cynthia Lin 2045426ab9 hotkeys: Change subscribe stream hotkey to `S`. 2017-05-24 12:19:15 -07:00
Steve Howell a9f6f5f0c0 node tests: Split out presence.js. 2017-05-24 09:18:24 -07:00
Steve Howell c02f4b4756 Add people.initialize().
This makes us not have to stub jquery in many of our node
tests!
2017-05-23 19:35:08 -07:00
Joshua Pan 43487c6c3f node_tests: Get unread.js to 100% node coverage. 2017-05-23 19:04:02 -07:00
Joshua Pan d44626d456 node_tests: Get topic_generator.js to 100% node coverage. 2017-05-23 19:00:56 -07:00
Steve Howell 7c1b555331 node tests: Use zjquery for common.js tests. 2017-05-23 18:52:25 -07:00
Steve Howell 1cb58d72b2 zjquery: Add focus/blur methods. 2017-05-23 18:52:25 -07:00
Steve Howell cd08bbe7d8 zjquery: Add array-like functionality to elements.
(We simulate the behavior that a jquery object looks like an
array, but also has methods that can be called as if it were a
scalar.)
2017-05-23 18:52:25 -07:00
Steve Howell 4c520780a1 zjquery: Support $(func) flavor of $() calls. 2017-05-23 18:52:25 -07:00
Joshua Pan f3369b266a node_tests: Extract and create fake_jquery as zjquery.
This allows us to use fake_jquery (originally only in
compose_actions.js) in all our node tests.
2017-05-23 10:27:07 -07:00
Joshua Pan f8e10ed2f6 node_tests: Add test coverage to autofocus. 2017-05-23 10:26:30 -07:00
Joshua Pan 525cc34491 node_tests: Add test for long low-quality passwords. 2017-05-23 10:26:30 -07:00
Steve Howell e00f9f3dcb Split out Organization Permissions page. 2017-05-18 12:37:03 -07:00
Steve Howell d0ea11f355 Have "n" key skip muted streams. 2017-05-17 11:28:33 -07:00
Steve Howell 6f73b7953f Have "n" key skip muted topics. 2017-05-17 11:28:33 -07:00
Harshit Bansal d827cc878b emoji.js: Remove unnecessary indirection.
Remove unnecessary function `emoji_name_to_css_class()` called while
populating `emojis_name_to_css_class` dict.
2017-05-17 08:09:50 -07:00
Steve Howell 7d153c9f8a Revert "muting.js: Track muted streams using stream id."
This reverts commit c7f710b8d4.

Because the back end still stores muted topics fundamentally using
stream name as a key, trying to cut over the client to use stream
id was just making things more brittle.  Mutes would work after
renaming the stream, which was progress in the change that we
revert here, but only until page load.  The other problem, which
is more severe, is that the order of page loading functions would
cause no mutes to happen at page load time.  This could be fixed
to some degree, but we should do a deeper fix on the back end.
2017-05-17 07:06:32 -07:00
Tim Abbott 00c7f7d42f Remove date separators from the top of the message feed.
Now that we have the date visible in the recipient rows, we no longer
need a top-of-feed date separator.

Fixes #4581.
2017-05-16 14:47:04 -07:00
Tim Abbott df5a0e7c92 hotkeys: Simplify logic for checking for subscriptions page. 2017-05-15 20:28:56 -07:00
Steve Howell c7f710b8d4 muting.js: Track muted streams using stream id.
This should prevent some glitches with stream rename events.
2017-05-15 14:47:41 -07:00
Steve Howell 1a11042fdf refactor: Use stream id more in topic_list.js. 2017-05-15 14:47:41 -07:00
Steve Howell efb35afeb7 Track recent topics (and active streams) using stream id.
This commit changes the key for recent_topics to be a
stream id.  For streams that have been renamed, we will now
get accurate data on recent topics and active streams as
long as stream_data.get_stream_id(stream_name) returns a
valid value.
2017-05-15 14:47:41 -07:00
Steve Howell 5d33d02235 Track unread counts using stream_id. 2017-05-15 14:47:41 -07:00
Steve Howell c125ba1d08 Fix how we find if streams are muted.
This commit changes stream_data.in_home_view() to
take a stream_id parameter, which will make it more
robust to stream name changes.

This fixes a bug.  Now when an admin renames a stream
you are looking at, it will correctly show itself to
be un-muted. (Even with this fix, though, the stream
appears to be inactive.)

Some callers still do lookups by name, and they will
call name_in_home_view() for now, which we can
hopefully deprecate over time.
2017-05-15 14:47:41 -07:00
Steve Howell d3a7aa3a37 Have get_stream_li() take a stream_id.
Rather than having get_stream_li() look up stream id using
stream name, we force the callers to pass in the stream id.

This adds an extra line to most of the callers for now, but
this will eventually change as we fix some of the callers to
have their callers pass in stream_id.

In places where we now call stream_data.get_stream_id() to
get the stream id, we will be more resilient toward stream
renamings, at least until the next reload, since
stream_data.get_stream_id() can resolve old names that
are stored when we process stream-rename events.
2017-05-15 14:47:41 -07:00
Steve Howell 191741a382 Use stream ids to filter messages in client-side narrows.
We now use stream ids to filter messages in narrowing
situations, instead of doing stream name comparisons.

This partially fixes certain stream-renaming scenarios, since
we will be able to match the stream id for an out-of-date
stream operand, but it doesn't fix some other stuff, such
as the query that the server gets.
2017-05-13 21:59:07 -07:00
Steve Howell 8ecfda9344 stream_data: Remember old stream names.
This is not a user-facing change, but it starts us down the
path to having the JS client be able to look up old stream
names for situations like people clicking old external links
or for live-update scenarios.
2017-05-13 21:58:37 -07:00
hackerkid cf15a7b561 presence.js: Make get_status return active for logged in user. 2017-05-12 14:28:23 -07:00
Cory Lynch 68e5898a07 emoji.py: Add restriction that realm emoji must be lowercase.
Raises error if emoji name has an uppercase letter in it.
2017-05-11 19:10:21 -07:00
Steve Howell 87f5c22593 Simplify how we find the current user's emoji reactions.
This adds the current_user_has_reacted_to_emoji() helper.

This new helper is easier to use and slightly more efficient
than calling get_user_list_for_message_reaction() and then
indexOf().

This also replaces one call to get_user_list_for_message_reaction()
with a list of user_ids that we already had locally.

The node tests were improved a bit here, including a minor
whitespace fixup.
2017-05-11 09:39:17 -07:00
Steve Howell 958ed20a0f Only render one stream at a time for editing.
We used to render the subscriptions_settings template for every
stream when you loaded "Manage Streams," which can be very slow
for a big realm.  Now we only render the right pane on demand.
2017-05-11 08:46:52 -07:00
Steve Howell f60a829b4d Remove lightbox.is_open property.
Outside of lightbox.js, we now use modals.lightbox_open() to
detect that the lightbox modal is open.
2017-05-10 09:46:21 -07:00
Steve Howell 5c52495b64 Use modals.settings_open().
We now uses modals.settings_open() to check for the settings
modal being open, rather than doing a regex check on
windows.location.hash.
2017-05-09 18:44:08 -07:00
Steve Howell 0a0f567aeb Split out markdown.js from echo.js.
The new module handles markdown rendering.

The code left behind in echo.js does local-echo kind of things
like reifying message ids.
2017-05-09 11:06:10 -07:00
Mahim Goyal 49fec57768 Add hotkey for narrowing to next unread topic.
Fixes: #4199.
2017-05-09 10:02:54 -07:00
Steve Howell 70d4ac93ce Add modals.info_overlay_open().
This also removes ui_state.js, since its last function
is now replaced by modals.info_overlay_open().
2017-05-09 09:19:27 -07:00
Steve Howell 742c55f514 Speed up key handling by adding modals.is_active().
The function modals.is_active() can see if modals are open
without having to look at the DOM.  This should make it snappier
to type in the compose box.  Even if the speedup is pretty minor,
not having to worry about jQuery slowness should make it easier
to diagnose future compose box issues.

The new function gets used in other places, too, where performance
isn't so much an issue.
2017-05-08 22:04:56 -07:00
Steve Howell 3c0ef6295f Enforce that only one modal can be open at any time. 2017-05-08 22:04:56 -07:00
Mahim Goyal 6464514ca9 Break compose.js and drafts.js dependency. 2017-05-08 14:43:49 -07:00
Brock Whittaker 2ae23054ee informational-overlays: Focus overlay body on shortcut "?".
This focuses the body content of the informational overlay after
going to it from "?" so that you can use up and down arrows to then
scroll the content easily.

Fixes: #4480.
2017-05-05 09:53:58 -07:00
Brock Whittaker 3ff55034fe admin: Restyle administration checkboxes to match new style.
This restyles the administration checkboxes to look similar to those
that are currently present in the settings section.
2017-05-01 16:01:36 -07:00
K.Kanakhin f13d6a18eb realm-emoji: Add realm emoji uploading instead url providing.
- Add file_name field to `RealmEmoji` model and migration.
- Add emoji upload supporting to Upload backends.
- Add uploaded file processing to emoji views.
- Use emoji source url as based for display url.
- Change emoji form for image uploading.
- Fix back-end tests.
- Fix front-end tests.
- Add tests for emoji uploading.

Fixes #1134
2017-05-01 14:50:20 -07:00
Jack Zhang df817f12f4 emoji: Rename reaction-popover to emoji-popover.
The name emoji-popover should now be more appropiate, as there's no more
need to distinguish between reacting to messages and composing messages.
2017-04-30 15:15:33 -07:00
Jack Zhang a9505654da emoji: Replace the old compose emoji picker with the reactions picker.
This removes the old compose emoji picker in its entirety, changing
the few callbacks needed to launch the reactions-style emoji picker
instead and hook it up properly.

Callbacks for reactions and composing messages are distinguished by
selecting for, respectively, the .reaction and .composition classes.

Fixes #4122.
2017-04-30 15:14:42 -07:00
Jack Zhang f8b3ce7d15 emoji: Move all emoji picker logic/events into emoji_picker module.
Added emoji_picker.js to static asset pipeline.
2017-04-30 14:13:36 -07:00
fionabunny d3e7e6542a home.py: move user_profile full_name to register_ret.
Move the user_profile data section down into fetch_initial_state_data
so it entirely pulls from register_ret for #3853.
2017-04-28 23:31:28 -07:00
Tim Abbott df8f4a837c home: Get page_params.enable_desktop_notifications from register_ret. 2017-04-28 23:15:35 -07:00
Tim Abbott 2a16cc1d24 home: Get enable_stream_desktop_notifications from register_ret. 2017-04-28 22:01:46 -07:00
Tim Abbott 2a8a101fe2 home: Get page_params.enable_stream_sounds from register_ret. 2017-04-28 21:56:58 -07:00
Tim Abbott 30db811167 home: Get page_params.enable_sounds from register_ret. 2017-04-28 21:54:05 -07:00
fionabunny 78bcbc79d6 home.py: move people_list as realm_users to register_ret.
Simplify the page_params generation logic #3853
2017-04-28 21:33:33 -07:00
fionabunny 84c4d67916 home.py: move bot_list as realm_bots to register_ret.
Simplify the page_params generation logic #3853
2017-04-28 21:24:44 -07:00
fionabunny 70fe2eab60 home.py: move is_zephyr_mirror_realm as realm_is_zephyr_mirror_realm.
Part of #3853.
2017-04-28 21:12:16 -07:00
Steve Howell 4762673929 Fix how we calculate fields in stream_data.js.
We used to have code scattered in multiple places to
calculate things like admin options, preview urls,
subscriber counts, and rendered descriptions for
streams before we rendered templates in the "Manage
Stream" code.

These are all consolidated into a new function
called stream_data.update_calculated_fields().

This is mostly code cleanup, but it also fixes a bug where
the "View Stream" button would not work for a newly created
stream.
2017-04-28 17:49:33 -07:00
Cory Lynch 0965c43238 Add typeahead for syntax highlighting languages.
Modified composebox_typeahead.js to recognize the triple backtick
and tilde for code blocks, and added appropriate typeahead functions
in that file and in typeahead_helper.js.

Additionally, a new file pygments_data.js contains a dictionary of
the supported languages, mapping to relative popularity
rankings. These rankings determine the order of sort of the
languages in the typeahead.

This JavaScript file is actually in static/generated/pygments_data.js, as it
is generated by a Python script, tools/build_pymgents_data.py. This is
so that if Pygments adds support for new languages, the JavaScript file
will be updated appropriately. This python script uses a set of popularity
rankings defined in lang.json.

Corresponding unit tests were also added.

Fixes #4111.
2017-04-28 17:22:59 -07:00
Cory Lynch ba7b7a9a36 Change edit_message_content to have unique IDs for different messages.
Fixes bugs of when multiple messages are being edited simultaneously.
Specifically, typeahead is no longer broken, copying messages to clipboard
is less buggy, and resizing is no longer
broken when multiple messages are being edited.
2017-04-28 12:15:34 -07:00
Steve Howell 0ced7cfc55 Make newly subscribed streams appear active.
When you subscribe to a stream, we now set a newly_subscribed
flag on the object, and we return true during the is_active()
call.

This solves the problem that immediately after you subscribe, you
don't have any messages in the stream, so it would appear active
by our old criteria.

This is still something of a workaround, as once you reload, the
stream will become inactive again, unless other messages come in.

A more permanent solution here would be to have the backend
indicate newly subscribed streams to us (apart from the initial
event), but we may not really need that in practice.
2017-04-28 07:40:25 -07:00
Steve Howell f9b3ff8f68 Change argument type for stream_data.is_active().
The function now takes a "sub" object instead of a stream
name.
2017-04-28 07:39:52 -07:00
Steve Howell 62d530196b Fix test_sort_streams().
It turns out the check to make sure that "social" filtered to
the bottom could give a false positive, since it was already
alphabetically at the end of the list.

So, I call the stream "cars" now instead, so that it only comes
after "Denmark" if the is_active flag gets respected.

I also check for the divider tags now.
2017-04-28 06:39:17 -07:00
Brock Whittaker 7afbc9ddd6 Redesign login and registration pages.
This completes a major redesign of the Zulip login and registration
pages, making them look much more slick and modern.

Major features include:
* Display of the realm name, description and icon on the login page
  and registration pages in the subdomains case.
* Much slicker looking buttons and input fields.
* A new overall style for the exterior of these portico pages.
2017-04-26 18:04:05 -07:00
Cory Lynch 088d881159 compose: Improve ordering in streams typeahead.
The new logic has 4 tiers of priority:
* Whether a match is found in the name, start of description, middle
of description, etc.
* Importance to the user / activity -- more specifically, the order
used in the left sidebar. This means pinned streams first, active
streams, then inactive streams.
* Subscriber count: How big is the stream?  Bigger is better.
* Alphabetical ordering is a final tiebreak.

Fixes #4508.
2017-04-26 12:46:14 -07:00
Brock Whittaker c506a92d05 left-sidebar: Restyle to have new look.
This restyles the color swatches to either be locks or hashes,
and changes the notifications to be rounded rather than squared.
2017-04-25 17:47:36 -07:00
digi0ps 8fb9d2bff3 settings: Redesign settings/administration panel buttons.
This redesigns all the ugly bold-colored buttons in the settings and
administration pages.
2017-04-25 16:33:59 -07:00
Cory Lynch 0d9b77c8b7 composebox_typeahead.js: Add typeahead cancelling for '# '.
If somebody types '# ', then close the typeahead dialog and
don't autocomplete. Relevant node tests were also added.

Fixes #4505.
2017-04-25 15:55:23 -07:00
Steve Howell 8eb86335b9 Extract narrow_state.js.
Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).

The only new functions are simple setter/getters that
encapsulate the current_filter variable:

    narrow_state.reset_current_filter()
    narrow_state.set_current_filter()
    narrow_state.get_current_filter()

We removed narrow.predicate() as part of this, since it was dead
code.

Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
2017-04-25 09:57:32 -07:00
Steve Howell c999bdf823 compose: Distinguish get_message_type() from composing().
We now only call compose_state.composing() in a boolean context,
where we simply care whether or not the compose box is open.  The
function now also returns true/false.

Callers who need to know the actual message type (e.g. "stream" or
"private") now call compose_state.get_message_type().
2017-04-24 12:42:06 -07:00
Shayan Toqraee 534c951ec4 Add rtl.js library for detecting direction of text.
This comes complete with some documentation and node tests, and is a
key step towards implementing RTL support in Zulip.
2017-04-22 11:25:54 -07:00
Steve Howell ddbe877909 Add narrow.stream_topic(). 2017-04-21 21:59:22 -07:00
Steve Howell 6ddbf12376 Add topic_generator.get_next_topic(). 2017-04-21 21:59:22 -07:00
Steve Howell 079885770b Add unread.topic_has_any_unread(). 2017-04-21 21:59:22 -07:00
Steve Howell 4871b491f3 Add Dict.is_empty(). 2017-04-21 21:59:22 -07:00
Steve Howell b27180a645 Have next_topic() return stream/topic objects.
We now use "map" to have our inner generator of topics be
mapped to objects with both the stream and topic.  Thanks to
Mahim Goyal for helping with this design.
2017-04-21 21:59:22 -07:00
Steve Howell d332df8cc6 Add topic_generator.map(). 2017-04-21 21:59:22 -07:00
Steve Howell 7962710132 Remove 40-streams criterion for flagging dormant streams.
Before this change, we would move "dormant" streams to the bottom
of your stream sidebar, but only if you had 40+ streams.

Now we do this in all cases to be more consistent.

This commit also changes the redraw strategy when we remove rows.
Before this change, we were doing incremental updates, but now we
call build_stream_list to do a complete rebuild.  This was partly
motivated by adding the new divider, which would have complicated
the incrememental approach when you removed the last remaining
dormant stream.
2017-04-19 09:18:18 -07:00
Steve Howell 9591b3a95b Extract stream_sort.js. 2017-04-19 09:16:37 -07:00
Joshua Pan 4fb450d4a9 hotkey.js: Add reactions popover navigation.
Fixes #4197.
2017-04-18 23:25:45 -07:00
Ayush Jain 518d25a0cf Disable proxy setting for test-backend and test-js-with-casper.
This fixes the fact that our test suites would have trouble connecting
to the other parts of the Zulip service when run with a proxy
configuration (e.g. trying to send requests to localhost through the
proxy!).

Thanks for Vishnu Ks for his work on this.

Fixes #971.
2017-04-18 12:35:44 -07:00
Steve Howell 70b7d4c00b Extract compose_state.js.
This is mostly just moving methods out of compose.js.

The variable `is_composing_message`, which isn't a boolean, has
been renamed to `message_type`, and there are new functions
set_message_type() and get_message_type() that wrap it.

This commit removes some shims related to the global variable
`compose_state`; now, `compose_state` is a typical global
variable with a 1:1 relationship with the module by the same
name.

The new module has 100% line coverage, most of it coming
via the tests on compose_actions.js.  (The methods here are
super simple, so it's a good thing that the tests are somewhat
integrated with a higher layer.)
2017-04-18 12:26:58 -07:00
Tejas Kasetty d227a8e35c compose: Re-render emoji picker when realm_emoji is added/deleted.
* reset the emoji popover in case of an event
regarding update of realm_emoji.
* test-node-with-js: Add dependency - popovers module;
In dispath.js to support popovers object.
2017-04-18 12:18:52 -07:00
Aditya Bansal c98cf5ba63 Clean message_edit_history.handlebars to use 4 space indents. 2017-04-18 12:06:28 -07:00
Steve Howell 78803b2e56 Add narrowed_by_topic_reply() helper. 2017-04-17 22:54:36 -07:00
Steve Howell 58aedf985f capser: Close the compose box in un_narrow(). 2017-04-17 22:54:36 -07:00
Steve Howell af887822b5 Add narrowed_by_pm_reply() helper. 2017-04-17 22:54:36 -07:00
Raghav Jajodia d4e1f0a9a8 stream_filter: Add clear-search button to Search stream input field. 2017-04-17 11:12:01 -07:00
Abhijeet Kaur ddfdf0e4c6 Organization settings: "Filter settings" tab view-only support.
This changes the layout of "organization settings" for
non-administrators such that they can view "Filter settings".
("Actions" column and form to add a new filter are not available).

Fixes: #3636
2017-04-16 12:21:36 -07:00
Abhijeet Kaur dc801eb5ed Organization settings: "Default streams" tab view-only support.
This changes the layout of "organization settings" for
non-administrators such that they can view "Default streams" ("Actions"
and the form to add new default stream is not visible).
2017-04-16 12:21:36 -07:00
Abhijeet Kaur 3f0e33e498 Organization settings: "Users" tab view-only support.
This changes the layout of "organization settings" for
non-administrators such that they can view "Users" (Actions are not
visible).
2017-04-16 12:21:30 -07:00
Steve Howell 5ba79f9c3a refactor: Move respond/reply methods to compose_actions.js.
This moves respond_to_mention() and reply_with_mention() to
compose_actions.js.  These methods are basically thin layers
on top of compose_actions.start().
2017-04-14 13:09:19 -07:00
Steve Howell 09d2c42e0e Add unit tests for compose respond/reply. 2017-04-14 13:09:19 -07:00
Steve Howell dd0c50f0df Extract compose_actions.js.
This module extracts these two functions that get called by
several other modules:

    start()
    cancel()

It is a little bit arbitrary which functions got pulled over
with them, but it's generally functions that would have only
been called via start/cancel.

There are two goals for splitting out this code.  The first
goal is simply to make `compose.js` have fewer responsibilities.
The second goal is to help break up circular dependencies.
The extraction of this module does more to clarify
dependencies than actually break them.  The methods start()
and cancel() had actually been shimmed in an earlier commit,
and now they no longer have a shim.

Besides start/cancel, most of the functions here are only
exported to facilitate test stubbing.  An exception is
decorate_stream_bar(), which is currently called from
ui_init.js.  We probably should move the "blur" handler out
of there, but cleaning up ui_init.js is a project for another
day.

It may seem slightly odd that this commit doesn't pull over
finish() into this module, but finish() would bring in the
whole send-message codepath.  You can think of it like this:

* compose_actions basically just populates the compose box
* compose.finish() makes the compose box do its real job,
  which is to send a message
2017-04-14 13:09:19 -07:00
Steve Howell 0bf6dafdc7 node tests: Add compose_actions.js. 2017-04-14 13:09:19 -07:00
Steve Howell f06bd41586 Fix PM list sort ordering during scrollback situations.
Before this fix, if you scrolled back in your PM history for a
person that you've had recent conversations with, then we would
backdate the record of their most recent conversation, and this
would make the sort ordering under the "Private messages"
section incorrect.

This commit fixes this error by re-writing the function
message_store.insert_recent_private_message() to check any
prior timestamps for that user.  It also optimizes the function
a bit to short-circuit in O(1) time for cases where a recipient
already has a more recent timestamp, by having a Dict keyed
on user_ids_string.
2017-04-13 12:13:20 -07:00
Steve Howell 24461762da Add test_insert_recent_private_message(). 2017-04-13 12:13:20 -07:00
Steve Howell 6b549248e8 Extract settings_filters.js. 2017-04-13 10:39:39 -07:00
Steve Howell 3e37f64f71 Extract settings_streams.js. 2017-04-13 10:39:39 -07:00
Steve Howell 70afb59cff Extract settings_users.js.
This affects three admin sections:

    * Users
    * Deactivated users
    * Bots
2017-04-13 10:39:39 -07:00
Steve Howell a3b44148af Extract settings_emoji.js. 2017-04-13 10:39:39 -07:00
Steve Howell 33eb5ad237 Add narrow.is_for_stream_id() helper. 2017-04-13 07:49:55 -07:00
Abhijeet Kaur 8f88b045a4 Rename "Administration" to "Organization" in the settings UI.
This better sets expectatations for the fact that in Zulip, the
Organization settings UI is available read-only to non-administrator
users.

Tweaked by tabbott to update some additional references.
2017-04-07 17:32:56 -07:00
Steve Howell c4b4979a74 Add Dict.clear() method. 2017-04-07 15:20:12 -07:00
Steve Howell 7f17fc020f Extract settings_bots.js. 2017-04-07 15:20:12 -07:00
Steve Howell 153c24d071 Remove dead code related to bot/stream settings.
We had never-enabled code to allow users to set default
streams for their bots (for event registration, default sending, etc.).

This commit removes the code.
2017-04-07 15:20:12 -07:00
Steve Howell 262a4d5da6 Create topic_generator.js. 2017-04-06 12:23:44 -07:00
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