Commit Graph

1725 Commits

Author SHA1 Message Date
Rohitt Vashishtha a87123ec23 zblueslip: Convert node_tests/input_pill.js to zblueslip. 2018-04-30 10:12:55 -07:00
Rohitt Vashishtha aa0c9a1a2a zblueslip: Convert node_tests/dict.js to zblueslip. 2018-04-30 10:12:55 -07:00
Rohitt Vashishtha 65bb2f3c40 zblueslip: Convert node_tests/channel.js to zblueslip. 2018-04-30 10:12:55 -07:00
Yashashvi Dave 7bbe44d7a0 org settings: Remove "Delete streams" administrative tab from settings.
Fixes #9227
2018-04-30 17:47:34 +05:30
Tim Abbott 7d6bb3dcb4 settings: Remove obsolete default_desktop_notifications setting.
This actually hasn't been hooked up to do anything in years.

While we're at it, we remove the entire "Zulip Labs" settings page.
2018-04-28 13:46:07 -07:00
Shubham Dhama 7f679bcdce org settings: Make allowed domain table status element fade out. 2018-04-28 13:24:59 -07:00
Shubham Dhama da8157d414 message: Extract function for editability of topic. 2018-04-28 13:00:29 -07:00
Steve Howell 160931377f node tests: Test deactivating streams. 2018-04-28 11:15:14 -07:00
Steve Howell 6e851f98f6 node tests: Test refreshing pinned streams. 2018-04-28 11:15:14 -07:00
Steve Howell cf24445809 node tests: Add test for stream_list.rename_stream. 2018-04-28 11:15:14 -07:00
Steve Howell 74e7c81c94 node tests: Add coverage for topic zooming.
These tests cover the stream_list side of the interaction.
2018-04-28 11:15:14 -07:00
Steve Howell c22a1d1f23 refactor: Simplify return values for would_receive_message().
Instead of treating false differently from undefined, our
function is now a regular boolean function, and we limit our
code comments to the one corner case where the true/false
decision is kind of arbitrary and possibly confusing.
2018-04-28 11:15:14 -07:00
Steve Howell fe62dacee0 node tests: Add coverage for stream sidebar search. 2018-04-28 11:15:14 -07:00
Steve Howell e9c6f3a07d stream list: Use newer code for the list cursor.
The new list_cursor class is more generic and saves the state
of your cursor across redraws.

Note that we no longer cycle from bottom to top or vice versa.

The node test code that was removed here was kind of complex
and didn't actually assert useful things after calling methods.
2018-04-28 11:15:14 -07:00
Steve Howell 779535fda3 minor: Extract some vars in stream_sort tests.
This is just to make the next commit a bit more convenient.
2018-04-28 11:15:14 -07:00
Steve Howell 605a90ce36 node tests: Reach 100% coverage for scroll_util.js. 2018-04-28 11:15:14 -07:00
Steve Howell 97b9367d20 refactor: Extract scroll_util.js.
We now use scroll_element_into_container() in two different
places, so it's worth extracting.
2018-04-28 11:15:14 -07:00
Steve Howell 068e4bf32b buddy list: Populate user-fade via templates.
When we populate the buddy list or update it for activity, we now
have buddy_data set a faded flag that is rendered in the template.
This avoids some re-rendering overhead and is on the eventual path
to having our widget be more data-oriented (and all rendering happens
"behind" the widget).

We still do direct DOM updates when the compose state changes or
when we get peer subscription events.
2018-04-28 11:15:14 -07:00
Steve Howell d4fc92c1c7 refactor: Rename method to compose_fade.update_all().
The function was misnamed before.
2018-04-28 11:15:14 -07:00
Steve Howell 5d6c9c1b47 compose_fade: Extract user_fade_config.
This commit extracts the key UI elements of updating the buddy
list for compose fade into a configuration, and we interact with
the buddy_list API.
2018-04-28 11:15:14 -07:00
Steve Howell fb712027bf buddy list: Fix and simplify up/down navigation.
This introduces a generic class called list_cursor to handle the
main details of navigating the buddy list and wires it into
activity.js.  It replaces some fairly complicated code that
was coupled to stream_list and used lots of jQuery.

The new code interacts with the buddy_list API instead of jQuery
directly.  It also persists the key across redraws, so we don't
lose our place when a focus ping happens or we type more characters.

Note that we no longer cycle to the top when we hit the bottom, or
vice versa.  Cycling can be kind of an anti-feature when you want to
just lay on the arrow keys until they hit the end.

The changes to stream_list.js here do not affect the left sidebar;
they only remove code that was used for the right sidebar.
2018-04-28 11:15:14 -07:00
Steve Howell f11b3c9934 buddy_list: Clean up selector references.
In this cleanup I make it so that all jQuery selector references
are toward the top of the module, and we do all finds relative
to the container ('#user_presences').

This will make it easier to make a better list abstraction for
the buddy list, for things like progressive rendering.
2018-04-28 11:15:14 -07:00
Steve Howell 65d8eb3189 buddy list: Extract user_search.js.
This was a bit more than moving code.  I extracted the
following things:

        $widget (and three helper methods)
        $input
        text()
        empty()
        expand_column
        close_widget
        activity.clear_highlight

There was a minor bug before this commit, where we were inconsistent
about trimming spaces.  The introduction of text() and empty() should
prevent bugs where users type the space bar into search.
2018-04-28 11:15:14 -07:00
Steve Howell 2879a63bcc buddy list: Relax count limit when doing searches.
A recent change filtered out offline users from the buddy list
whenever the list size would otherwise exceed 600.

This commit reverts half that change--we can now show 600+ users
again, but only when searching.
2018-04-28 11:15:14 -07:00
Shubham Dhama ccd5581bcd org settings: Handle floating point durations better for time limits.
Fixes: #9253.
2018-04-28 09:33:31 -07:00
YJDave 6bef44a9fa org setting: Add time limits for message deleting.
Add realm setting to set time limit for message deleitng.
Set default value of message_content_delete_limit_seconds
to 600 seconds(10 min).

Thanks to Shubham Dhama for rebasing and reworking this.  Some final
edits also done by Tim Abbott.

Fixes #7344.
2018-04-27 19:22:28 -07:00
Steve Howell e5885fa8e4 Add compose.needs_subscribe_warning.
This function replaces part of compose_fade.would_receive_message(),
which has a real janky interface of returning true, false, or
undefined.

We don't need to couple the semantics of compose fading to whether
we help subscribe a mentioned user.  They're mostly similar, but they
will probably diverge for things like bots, and the coupling makes
it difficult to do email -> user_id conversions.

One thing that changes here is that we get the stream name from
compose_state, instead of compose_fade.focused_recipient.  The
compose_fade code uses focused_recipient for kind of complicated
reasons that don't concern us here.
2018-04-26 08:42:47 -07:00
Steve Howell ebe6144326 node tests: Avoid sneaky throttle/debounce delays.
For all of our current tests, we want to just execute
throttled functions immediately.
2018-04-26 08:42:47 -07:00
Steve Howell 58c67d8cba zjquery: Improve errors when handlers aren't set correctly. 2018-04-26 08:42:47 -07:00
Tim Abbott d862bf7b48 casper: Attempt to fix nondeterministic failures in profile fields. 2018-04-26 08:33:56 -07:00
Umair Khan 93bb3e8d6e profile: Add UI for Choice field. 2018-04-26 00:35:54 -07:00
Shubham Dhama b411bc050e org settings: Change join org permissions to dropdown. 2018-04-25 16:00:55 -07:00
Tim Abbott ccb1a00e0a casper: Fix test sequencing for profile tests.
We check data only updated after the get_events call returned, without
actually waiting for that to happen.
2018-04-25 10:21:27 -07:00
Sampriti Panda e86d5139bb copy_and_paste.js: Remove excess newlines while pasting markdown html.
Fixes #8963
2018-04-24 08:27:43 -07:00
Shubham Dhama f19b0b3254 org settings: Change message_edit settings to dropdown.
This coverts the "checkbox" for `realm_allow_message_editing`  and
"input" for `realm_message_content_edit_limit_seconds` into a
dropdown with the option for custom time limit option.
2018-04-23 18:22:35 -07:00
Tim Abbott 3e49850d6b popovers: Fix broken node test.
This seems to have been introduced when rebasing
7533796ea9.
2018-04-23 17:29:15 -07:00
Vishnu Ks 7533796ea9 popover: Add an option to show user profile.
Fixes #8880
2018-04-23 16:56:24 -07:00
Rohitt Vashishtha c43f4e509c zblueslip: Improve usage documentation in test file. 2018-04-23 16:18:35 -07:00
Rohitt Vashishtha bddb6a1a14 zblueslip: Log output for all function calls.
Also adds asserts on blueslip.log() call in node_tests/people_errors.js.
2018-04-23 16:18:35 -07:00
Priyank Patel 7046409e12 Revert "quick fix: Revert ES6 idiom that istanbul warns about."
This reverts commit 55ff9a6806, the issue
about istanbul coverage not working for spread operator is fixed by using
nyc instead.
2018-04-23 15:27:16 -04:00
Tim Abbott 322fc52cd5 people: Suppress reporting late user additions when reloading.
If the browser is in the progress of reloading when it finishes
fetching some messages, it's not really a bug, and we shouldn't report
it as such.

This should help make Zulip's browser error reporting less spammy.
2018-04-23 12:20:27 -07:00
Vishnu Ks c9e932a7ce settings: Add support for Hangouts as the video chat provider.
The only thing that's annoying about this feature is that you need to
be a paying G Suite customer to use it.
2018-04-23 09:39:47 -07:00
Tim Abbott de691e8564 casper: Fix race condition in stars test.
I have no idea why this started failing just now, but the test was
written without a proper wait in between actions, and fixing that
fixes the failure I'd been seeing.
2018-04-23 09:15:12 -07:00
Tim Abbott e4c50ff4fd narrow: Remove unnecessary select_first_unread option.
We consistently either pass a `then_select_id` into narrow.activate,
or were using the select_first_unread option.  Now, we just compute
select_first_unread based on the value of then_select_id.
2018-04-22 21:33:33 -07:00
Tim Abbott 1d5204c82b narrow: Fix incorrect values for use_first_unread_anchor.
Apparently, we were incorrectly passing through something related to
opts.use_initial_narrow_pointer as the value for `use_first_anchor`.

If you read the logic in narrow.js carefully,
use_initial_narrow_pointer was unconditionally false.

The correct value for this attribute is when we're trying to narrow to
the first unread message in a given context.  There are two things to
check:

* then_select_id is -1; i.e. we don't have a specific message ID we're
  trying to narrow around.
* select_first_unread is True, i.e. we're trying to narrow to the
  first unread message.

A bit more work should allow us to get rid of the second condition,
but I'm not quite confident enough to do that yet.
2018-04-22 21:33:14 -07:00
Steve Howell 4b3d07c805 node tests: Localize focus logic for activity.js.
This does a few things:
        * removes some unnecessary setup
        * puts some jQuery setup closer to where it's needed
        * renames some variables
        * adds an assertion about highlighting
2018-04-22 20:08:08 -07:00
Steve Howell 54389f7b41 buddy list: Shrink overly large lists.
If we would have more than 600 people in a buddy list, it's kind of
cumbersome to scroll through it, and it's also expensive to render
it (short of doing progressive rendering, which adds a lot of
complexity).

So, as a short term measure, we filter out offline users whenever the
list would exceed 600 users.  Note that if you are doing a search that
narrows to fewer 600 users, the offline users will appear again.
2018-04-22 20:08:08 -07:00
Steve Howell 3f1930f9c5 buddy list: Extract buddy_data.js. 2018-04-22 20:08:08 -07:00
Steve Howell 536236d9b1 buddy list: Extract buddy_list.js. 2018-04-22 20:08:08 -07:00
Utkarsh Patil 955d03b8a0 emoji: Prefix sort for emojis.
Emoji prefix sort for "popular emojis first". Fixes #7625.
2018-04-21 22:28:45 -07:00
Priyank Patel 55ff9a6806 quick fix: Revert ES6 idiom that istanbul warns about. 2018-04-20 16:33:33 -07:00
Steve Howell 5f53fb1561 refactor: Remove factory code for toggle component.
We now have components.toggle simply return an object, without
putting the object into a lookup table.  The consumers of the
objects have all been changed to just store the object in their
own module scope.

The diff is a bit hard to read here, but it's mostly de-denting
code and removing these things:

        - we don't have opts.name
        - we don't have __toggle.lookup
        - we don't have keys
        - we don't create a sibling object to the prototype object
2018-04-20 13:45:58 -07:00
Priyank 02dddd6b35 node_test: Use let/const instead of var in activity.js.
This was left in previous cleanup.
2018-04-20 15:46:28 -04:00
Priyank 2dd2ab4f7e node_tests: Update alert_words.js to use es6. 2018-04-20 15:46:28 -04:00
Priyank 3174827f93 node_tests: Update channel.js to use es6. 2018-04-20 15:46:28 -04:00
Priyank b1c5f6c07d node_tests: Update bot_data.js to use es6.
bot_data.js uses let/const for variables, and uses rest operator
instead of _.extends.
2018-04-20 15:46:28 -04:00
Priyank 6c8753ef25 eslint: Update eslint config to have es6 env.
This will allow us to use spread operator.
2018-04-20 15:46:28 -04:00
Preston Hansen 76d6c71595 tests: Move zerver/fixtures to zerver/tests/fixtures for clarity.
Fixes #9153.
2018-04-19 21:50:17 -07:00
Rohitt Vashishtha ba21afe9a6 zblueslip: Convert node_tests/people_errors.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha a836473746 zblueslip: Convert node_tests/compose.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha 25c75b66d3 zblueslip: Convert node_tests/emoji.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha 4738644339 zblueslip: Create zblueslip.js for improved error handling.
Adds a basic API for controlling the allowed error messages and
documents the usage in the form of unit tests, similar to zjquery.

Fixes #8675.
2018-04-19 15:02:00 -04:00
Tarun Kumar 55f830c345 server_events_dispatch: Add node coverage for user groups. 2018-04-19 14:59:08 -04:00
Tarun Kumar deab3ac541 hash_util: Add 100% node-coverage for hash_util.js. 2018-04-19 14:59:08 -04:00
Shubham Dhama 9c096840be node tests: Increase coverage for settings_org. 2018-04-19 14:58:12 -04:00
Shubham Dhama 48fe77c61e node tests: Remove repeated zjquery code in settings_org tests. 2018-04-19 14:58:12 -04:00
Joshua Pan 99f07fe2e2 tests: Fully cover top_left_corner.js. 2018-04-19 14:56:55 -04:00
Joshua Pan 09469026c6 zjquery: Allow removeClass() to remove multiple classes simultaneously.
removeClass() now splits class_names by spaces to get multiple
class names. Then removes each individual class name.
2018-04-19 14:56:55 -04:00
Umair Khan 79ff89ed8b profile: Add hint field in the settings UI.
We still don't actually display it in the "Edit your profile" UI.
2018-04-19 11:32:45 -07:00
Steve Howell 6c4f02218e node tests: Add some coverage to list_render.js. 2018-04-17 17:52:19 -07:00
Steve Howell 6b44cdb286 zjquery: Extract make_event_store().
This pushes some of the most complex code of zjquery into its own
object.
2018-04-17 17:52:19 -07:00
Steve Howell 10d1c2fafa zjquery: Extract make_new_elem().
There was really no reason for this to be a nested function, since
we weren't closing on any variables.  Flatter is better.  Also, it
is plausible that folks will want more control over creating
individual jQuery elements (but still want this helper).
2018-04-17 17:52:19 -07:00
Steve Howell fca5cec2af node tests: Remove features to output HTML to files.
I don't think anybody ever really used this feature, which I
developed but don't even use myself.  It kind of runs counter
to the minimalist approach of the rest of node tests.

I would eventually like to re-think the template tests altogether.
They're slow, and we could solve that somewhat by replacing
jsdon/jquery with an HTML parser library to verify structural
things.

It's also possible that we can just rely on our template linters
to catch the biggest class of errors (malformed tags) and let
code review do the rest.

And it's also possible that we should make a second attempt to
ramp up tooling on making it easy to verify templates, but it
doesn't have to be part of the node tests.  If we did that, we
would also potentially use tooling for Python-side templates.
2018-04-17 17:52:19 -07:00
Steve Howell 74c939264b node tests: Add general.js.
This node test module is intended as a way for somebody to
quickly immerse themselves in our node testing methodologies,
plus it has the nice side effect of introducing several modules
(albeit very briefly).
2018-04-17 17:52:19 -07:00
Steve Howell da60d9c757 node tests: Remove unneeded zrequire in typeahead_helper.js. 2018-04-17 17:52:19 -07:00
Steve Howell 617bfa9275 node tests: Add coverage for popovers.js. 2018-04-17 17:52:19 -07:00
Steve Howell 94e9b85042 node tests: Add narrow_activate.js. 2018-04-17 17:52:19 -07:00
Steve Howell b1fd86c5c7 node tests: Add coverage to hashchange.js. 2018-04-17 17:52:19 -07:00
Steve Howell 1568df352d zjsunit: Extract read_fixture_data(). 2018-04-17 17:52:19 -07:00
Steve Howell e70203ad55 node tests: Use zjquery in hotkey.js. 2018-04-17 17:52:19 -07:00
Steve Howell c1a3c85a33 node tests: Clean up emoji tests.
A few things here:

    * Use _.each to follow our convention.
    * Just use new locals to avoid overwriting template and
      avoid strange Object.assign hack.
    * Just use simple string concatenation.
    * Use better var names: full_name, shortcut
    * Use chaining syntax.
2018-04-17 17:52:19 -07:00
Steve Howell 07591f03e2 node tests: Remove unneeded $ stub in compose_fade.js. 2018-04-17 17:52:19 -07:00
Steve Howell b3101ca41b node tests: Remove extra $ declaration. 2018-04-17 17:52:19 -07:00
Steve Howell 3a5b0841e4 node tests: Remove minor cruft from bots_data.js. 2018-04-17 17:52:19 -07:00
Priyank 26d8d98319 frontend_tests: Add prefer-const rule.
This rule checks for use of const wherever needed, currently does
nothing since we don't use `let`, instead we use `var`. This rule
can be used to use refactor a file to use const easily by replaceing
var with let using a editor and then by running
`./node_modules/.bin/eslint frontend_tests --fix --cache`. And then revert
those `let`'s back to `var`.
2018-04-17 12:56:25 -04:00
Priyank 6faa6f96e9 node_test: Convert function to arrow function where needed. 2018-04-17 12:56:25 -04:00
Priyank 7490932e1b node_tests: Use const for constants. 2018-04-17 12:56:25 -04:00
Cynthia Lin 7cbc9f40bf compose: Change styling of upload progress bar.
Related to #9095.
2018-04-16 09:46:35 -07:00
Tarun Kumar 0b62410f5e pm_pill: Achieve 100% node-test coverage for compose_pm_pill.js. 2018-04-13 11:59:57 -07:00
Tarun Kumar 51601fab44 muting: Achieve 100% node-test coverage for settings_muting.js. 2018-04-13 11:59:57 -07:00
Rohitt Vashishtha 7a4788b364 node-tests: Add basic tests for notifications API.
This commit exposes some inner variables of notifications.js to make
them easily testable. The first test added simply checks whether the
showing and closing of notifications works properly, and doesn't yet
verify the main code logic of the notification generation.
2018-04-13 09:13:50 -07:00
Rohitt Vashishtha 703351288a zjquery: Add replaceWith() and selector.location. 2018-04-13 09:13:50 -07:00
Rohitt Vashishtha 2e7f215f44 zjquery: Add option to silently ignore find() errors. 2018-04-13 09:13:50 -07:00
Steve Howell f56b4b7ec2 zjquery: Simplify validation for $(...).
We flatten the code a bit by removing a check that type is object,
and we replace it later with a check that type is string.

We also no longer allow document-like objects to be wrapped based
on the location-attribute-is-present hack.  Instead, we want the
tests to just set document to 'document-stub'.
2018-04-12 11:37:01 -07:00
Steve Howell 368b37e198 zjquery: Add a selector attribute to our wrapped elements.
We might as well have this for debugging purposes and to simplify
the code that happens when we double-wrap DOM elements.
2018-04-12 11:37:01 -07:00
Steve Howell f78947f2ba zjquery: Fix minor typo in comments.
This typo came from s/impl/self/ at some point :)
2018-04-12 11:37:01 -07:00
Steve Howell 174d065b2e zjquery: Add to_$ hook so elements can wrap themselves. 2018-04-12 11:37:01 -07:00
Steve Howell f505f3de04 zjquery: Support $.fn.foo mechanism.
We can now extend zjquery using the $.fn mechanism.  This isn't
necessarily recommended for test code (since you can just stub
individual objects directly), but some of our real code does this.
2018-04-12 11:37:00 -07:00
Steve Howell f5e0794d5c zjsquery: Give special treatment to "body" tag.
We don't do things like $('table') much in our code, but $('body')
is in the code.
2018-04-12 11:37:00 -07:00
Steve Howell 3971fae05d node tests: Fix some leaks with $(...). 2018-04-12 11:37:00 -07:00
Steve Howell 205bcb8ef9 Fix recently broken reactions tests with s/html/text/.
In the real code, as part of a quick security patch, we started
using text() to set values instead of html().  The tests now
reflect this.
2018-04-12 11:29:08 -07:00
Tim Abbott 65b9d9e0f3 CVE-2018-9990: Fix XSS issue with stream names in topic typeahead.
Zulip's search typeahead had a security bug, where when autocompleting
a specially crafted stream name, and then hitting space, code within
the stream name would be executed.

Zulip was doing HTML escaping correctly in the main code path using
Filter.describe to describe a narrow, but the escaping function was
not called in a few parallel code paths.  We fix this in a way that
should protect all of these code paths, by making Filter.describe
return properly escaped HTML, rather than depending on its callers to
do so.

Thanks to w2w for reporting this issue.
2018-04-12 09:46:54 -07:00
Rohitt Vashishtha 3bdc8bbaa5 CVE-2018-9986: Fix XSS issues with frontend markdown processor.
This fixes a set of XSS issues with Zulip's frontend markdown
processor, which is used in a limited set of contexts, such as local
echo of messages and the drafts feature.

The implementation of several syntax elements, including the <em>
syntax, user and stream mentions, and some others failed to properly
escape the content inside the syntax.

Fix this, and add tests for each corrected code path.

Thanks to w2w for reporting this issue.
2018-04-12 09:46:37 -07:00
YJDave 92a04b31a0 custom fields: Clean custom fields to use existing defined function. 2018-04-12 09:40:09 -07:00
Marco Burstein c36a658fee uploads: Fix the upload progress bar.
There was already a progress bar set up, but it became non-functional
after refactoring.  This fixes it.

The default animation was getting cut off when `uploadFinished` is
called, so we add a delay before removing the upload bar to make it
get to the end.

Tweaked by tabbott to have a more natural feeling animation setup
(where we don't animate the width adjustments; just the disappearance
of the bar).

Fixes #8863.
2018-04-09 22:53:06 -07:00
Tim Abbott a4def8d409 copy_and_paste: Re-disable copy-paste handler in production.
This reverts commit 6e048c5d3f.

See #8963 for the main issue we need to fix before re-enabling this;
basically, some combination of toMarkdown and the way text/html gets
written was introducing a lot of bonus/bogus whitespace, both in the
form of newlines and spaces converted to `&nbsp;`.
2018-04-09 22:10:28 -07:00
Shubham Dhama b650b6b38c markdown: Add @stream as an alias for @all.
Fixes: #8930.
2018-04-09 16:35:14 -07:00
Marco Burstein 7c66d11781 compose: Show avatars for people in typeahead autocompletes.
`@everone` and `@all` will have a megaphone icon from FontAwesome in
place of the avatar.

Also, fix the `composebox_typeahead` tests to account for the images.

Fix #6635.
2018-04-09 15:47:11 -07:00
Priyank ee078c372f install-node: Upgrade node, yarn, and nvm.
node -> v8.9.4
yarn -> 1.5.1
nvm -> 0.33.8

Also updates a test in timerender.js which depends on time
provided by node which is now changed in newer release.

Some changes have been made in circeci script, we just create ~/.config
directory and chown it to circleci user so installing new version of yarn
does not cause any ci failure on circleci during provision.
2018-04-09 13:56:48 -07:00
Tim Abbott dfac0302fc people: Extract small_avatar_url_for_person.
This is intended to be used in places like compose typeahead to
display users' avatars.
2018-04-09 12:12:44 -07:00
YJDave 24f51739eb subscription: Add real time sync for user-just-deactivated case.
Currently, stream subscriptions aren't getting updated without
hard reload when user is deactivated in realm.

Fix this issue by updating stream subscription widgets on user
deactivation event.

Fixes #5623
2018-04-08 16:54:12 -07:00
YJDave 386c56b466 stream_data.js: Replace user_email with user_id in func is_user_subscribed. 2018-04-08 16:54:12 -07:00
Balaji2198 c63d1c9205 node tests: Cover compose_not_subscribed in compose.js.
This commit covers the node tests to close(X) button and
subscribe button click handlers in compose.js.
2018-04-07 20:23:21 -07:00
YJDave f15ddc93e0 create stream: Fix stream email not rendering on stream creation.
Fixes #8817
2018-04-07 20:10:45 -07:00
Armaan Ahluwalia 58d07fabef settings: Change save and discard button look and feel.
This commit changes the way the save and discard buttons on the
organization profile, settings and permissions tabs look and fades
them out after a delay. It also cleans up the code a bit in the
settings_org.js file. It introduces changes to the css in
settings.css as well as the template for save-discard buttons.

It also fixes a bug on the user settings whereby if an option
that requires reload is clicked before clicking an option that does
not require reload, the reload message is erased. This could create
an issue where the user is not aware that a reload is required.
The loader is also changed to using fa-icon as loading spinner on
user settings and the colors are tweaked a little bit.
2018-04-05 21:49:12 -07:00
Tarun Kumar c53458c9c0 user-groups: Add template for non-editable groups. 2018-04-05 17:40:12 -07:00
Balaji2198 605916f6d7 compose: Add subscribe button to the not subscribed stream error message.
Before that, we needed to go the stream settings to subscribe to a
particular stream.

Fixes #3877.
2018-04-05 17:15:18 -07:00
Shubham Padia 6262460773 refactor: Rename mark_message(s)_as_read to notify_server_message(s)_read.
Fixes #8965.
Mark_message(s)_as_read is used in marking a message as having been
read by the browser, rename it to notify_server_message(s)_read to
avoid any confusion.
2018-04-05 09:54:48 -07:00
Steve Howell c164d07baa zjquery: Enforce only one arg for $(...) function. 2018-04-05 10:46:45 -04:00
Steve Howell 27770d7f6b Fix recent pitfall in toggle component.
This is a recent regression where we I refactored the toggle
component.  For some reason the old code was waiting until
after the callback to set some of its state, and I did the
same thing when I simplified how the state was stored.

Under the old code, this didn't manifest as a bug, although
the old code was problematic for other reasons.

This "fix" doesn't actually change anything user facing, as the
follow up commit fixes the proximal problem more directly. And
the toggle component is still prone to people writing code that
tries to inspect the state of the widget as it's being built.
2018-04-04 16:37:39 -07:00
Steve Howell bd591424e2 Add keydown_util.js module.
This is a pretty thin abstraction to prevent having to put
magic numbers in code, doing the which/keyCode hack, and remembering
to all preventDefault.

Hopefully we'll expand it to handle things like shift/alt keys
for components that want their own keyboard handlers (vs. going
through hotkey.js).
2018-04-04 16:37:39 -07:00
Shubham Dhama 2aaad502b4 org settings: Hide "disable" option when setting already disabled.
Fixes: #8942.
2018-04-04 11:40:35 -07:00
Tim Abbott 721b4e8373 i18n: Fix strings for wildcard mentions.
First, "Notify stream" is a lot clearer than "Notify everyone";
second, these strings should be tagged for translation.
2018-04-04 11:26:36 -07:00
Tim Abbott 682d4f2ea1 casper: Fix expected result for i18n test.
Now that this string is translated into German, the test should expect
it in German.
2018-04-03 11:05:48 -07:00
Tim Abbott e59c85c382 casper: Fix tests for custom profile fields. 2018-04-03 09:04:03 -07:00
Tim Abbott 938c4cee08 settings: Add option to control Jitsi video chat integration.
Fixes #8922.
2018-04-02 16:55:16 -07:00
Shubham Padia 10115491a3 real-time sync: Server sends recipent data with delete_message event.
Fixes #8853.
In certain cases, the browser is not able to look up the message.
Include the recipient data for the message in the delete_message event,
so look up of those attributes by the browser isn't required.
2018-04-01 22:19:08 -07:00
Shubham Padia e1d9e3ae03 real-time sync: Use process_read_messages_event in delete_message event.
Replace mark_message_as_read with process_read_messages_event as the
latter function is only correct for marking a message as having been
read by this browser.
2018-04-01 22:17:18 -07:00
Anurag Sharma 1227857de6 hotkeys: Replace C with x for composing PM.
Pressing the 'x' key can now be used to compose a PM.
Pressing the 'C' key displays a modal that shows a deprecation notice.

Fixes #6548.
2018-04-01 16:13:05 -07:00
Shubham Dhama b7aae89029 org settings: Add realm level default time format setting. 2018-03-31 16:23:26 -07:00
Shubham Dhama f4d6b2a853 org settings: Split "Language and notifications" section.
This splits "Language and notifications" section into "Default user
settings" and "Notifications".
With this, we can easily add other default user settings in the
same place.
2018-03-31 16:22:52 -07:00
Shubham Dhama e04b8271ca org settings: Remove obsolete UI updating code for realtime sync.
In our new system for updating realm settings, we don't need to create
separate functions to update the input elements for each feature.
Most of the work is done automatically by
`settings_org.sync_realm_settings`.
2018-03-31 16:19:09 -07:00
Balaji2198 724117cd45 org settings: Refactor the `render_notifications_stream_ui` function.
We are having a same code in `render_notifications_stream_ui`
and `render_signup_notifications_stream_ui` functions aside from
the HTML element. So this commit will remove the duplicate code in
`render_signup_notifications_stream_ui` and make use of
`render_notifications_stream_ui`.

Fixes #8886.
2018-03-31 16:08:47 -07:00
Balaji2198 21fe9fe20a org settings: Add elem param to the render_notifications_stream_ui. 2018-03-31 16:08:47 -07:00
Steve Howell cd8c15f1cf pills: Use a template to render the pills. 2018-03-31 09:32:52 -07:00
Tim Abbott 3fd8d718f4 websockets: Fix race condition in CSRF token initialization.
It appears that we were not always initializing the Socket object
after `setup.js` had the opportunity to set csrf_token.

This should fix #6961.
2018-03-31 09:29:56 -07:00
Tim Abbott e840e5b3a8 Revert "Ignore new messages when lists are behind."
This reverts commit bcdd12773e.

We need to do some improvements in handling FetchStatus for initial
narrows before this will be safe to deploy in production.
2018-03-30 11:52:14 -07:00
Tim Abbott 5c1dd162be settings: Eliminate remaining NEW_USER_BOT code.
I somehow missed this when removing the rest of the custom
NEW_USER_BOT logic.

This may fix a Casper test that has been failing.
2018-03-30 09:16:22 -07:00
Steve Howell 9ce9c2f9db Extract info_overlay.js.
There are several ways we open help for keyboard shortcuts,
markdown help, and search operators.

    - from the gear menu
    - from the compose box
    - from the search box
    - hitting ? for keyboard help
    - arrowing/clicking through the tabs

This just moves the relevant code into a module and changes a
bunch of one-line calls in various places.
2018-03-30 09:07:23 -07:00
Shubham Dhama aca2364455 settings: Focus "Add a new bot" tab when there is no active bot.
Fixes: #8872.
2018-03-30 16:07:01 +05:30
Steve Howell 90e10a11de components: Simplify toggle component.
This adds some helpers to avoid some duplication, and we also
now track the selected idx directly, since it's all under our
control.

The main addition is `select_tab`, which we now use for some
things that used to simulate clicks.
2018-03-29 16:13:46 -07:00
Umair Khan c14cefc24c settings: Add support for adding/removing custom profile fields.
Now that we have support for displaying custom profile fields, this
adds administrator-level support for creating them.

Tweaked by tabbott to fix a few small bugs and clean up the commit message.

Fixes #1760.
2018-03-29 13:59:16 -07:00
Steve Howell e145258fee node tests: Add 100% coverage for components.js. 2018-03-29 08:09:38 -07:00
Rohitt Vashishtha 115b633551 markdown-tests: Allow ignoring certain fixtures while developing.
Usually, to debug a small change, you have to remove some tests from JSON
because of lack of support for comments in JSON. This commit allows to
ignore some tests by setting `"ignore" : true` in the bugdown fixtures.

Also, since this is only for while developing, the complete test suite will
throw an error if we leave an 'ignored' test in a commit.
2018-03-28 17:35:47 -07:00
Rohitt Vashishtha c0ea4f2d5a markdown-tests: Show bugdown testcase name on failure. 2018-03-28 17:35:47 -07:00
Steve Howell df857fb214 Test maybe_load_newer_messages. 2018-03-28 09:13:46 -07:00
Steve Howell bcdd12773e Ignore new messages when lists are behind.
If individual messages arrive before we get the latest
messages from the server, they can create gaps in rendering,
and would often be offscreen anyway, so we just ignore them.
2018-03-28 09:12:25 -07:00
Rohitt Vashishtha 3c96b04763 emoji: Add translate_emoticons flag in bugdown testcases.
Also switches the default behaviour of the code to not translate the
emoticons. Earlier, the code was testing-aware, and used to translate
when there was no user profile data available(assuming that as a testing
environment).
2018-03-27 17:16:55 -07:00
Rohitt Vashishtha b976447102 markdown: Test the translate_emoticons flag.
The main testing of the translate emoticons code is in the
node_tests/emoji.js file. This code just checks if the setting
to enable/disable the emoticon translation is being honored.
2018-03-27 17:16:55 -07:00
Rohitt Vashishtha 6dda3fe83e emoji: Do selective local echo of emoticon conversions.
Earlier, we used to convert all occurrences of an emoticon on the
frontend. That behavior has been altered to do conversions only
when the emoticon has some terminal symbols around them, and not
any alphabet or number. Also adds tests for emoji conversions for
the above logic.

Fixes #8585.
2018-03-27 17:16:55 -07:00
Shubham Dhama 2f496ffe1f org profile: Use new org setting changes saving framework.
With this we have the same way to save changes done in org profile
subsection, i.e. show "Save" button beside header of subsection,
add "Discard changes" button for org profile subsection and
show "Save" and "Discard" button only when needed.

Also, there is so much code which become obsolete which is removed
in this commit.
2018-03-27 16:48:28 -07:00
Marco Burstein 6279a9ef09 message view: Hide "view source" and "quote" for deleted messages.
Fix #8839.
2018-03-27 16:43:24 -07:00
Joshua Pan ed9eb3bdb5 tests: Make test-js-with-node handling smarter.
Added support for passing a filename without `.js` suffix.
This then fixed the issue of no complaints for invalid test
files. Now, throws an error for invalid test files.

Fixes #8579.
2018-03-26 06:35:58 -04:00
Steve Howell f8e0137678 node test: Add message_fetch.js tests.
This tests the initialize() function for now.

It goes deep on this:
    * uses "mostly real" message lists
    * asserts on fetch parameters

It stubs out many modules that aren't really central to
the logic of fetching.  In particular, when messages are
processed, we notify things like the buddy list that messages
have been added.
2018-03-25 10:18:00 -07:00
Steve Howell 3dd1d784cb node tests: Add test_render_windows(). 2018-03-25 10:18:00 -07:00
Shubham Dhama 3e47a9fe22 org settings: Add real-time syncing for property changes. 2018-03-25 08:30:47 -07:00
Steve Howell aac76c14bd settings: Avoid duplicate form handlers.
For forms that are built early in setting up the settings panel,
we don't want to attach multiple submit handlers every time we
go into the gear menu, so we use "off" to clear any old handlers.

We also attach handlers directly to the form, instead of
using delegation up to the container div.
2018-03-25 08:28:04 -07:00
Steve Howell f97fe7842e zjquery: Add support for off(). 2018-03-25 08:28:04 -07:00
Aayush Agrawal 78a4924ecc markdown: Apply both bold and italic for words like ***text***.
Adds rule 'strong_em' to markdown parser to recognize ***{TEXT}***
Fixes #8155.
2018-03-23 15:01:24 -07:00
Tarun Kumar d403b7a2d5 user-groups: Prevent user not in user group from editing/deleting it.
Admin and user group members are allowed to edit/delete group.
Add node-tests to maintain 100% coverage for settings_user_groups.js
Fixes #8315.
2018-03-23 14:44:47 -07:00
Shubham Dhama 8304c37dfb org settings: Make each subsection of org-permissions independent.
This makes each subsection of org-permissions independent from the
perspective of saving changes.
All the behavior we have for org-settings are also ultimately
reflected here as well like individual "Save" button for each
subsection, "Discard" button for discarding changes done in a
subsection and appearance of this button only when required.
2018-03-23 07:28:46 -07:00
Priyank f0190fe0b8 electron_bridge: Notify electron app when org avatar is updated. 2018-03-22 22:05:12 -07:00
Shubham Dhama 42ee40d1bc org settings: Refactor failed status element to use class.
This changes failed status element to use class
`.admin-realm-failed-change-status` rather than id so that we can use
the same code in `save_organization_settings()` in future to refer to
failed-status element of that section.
2018-03-22 23:17:13 +05:30
YJDave 11c995b70f custom profile data: Send event to active user on update.
On update of custom profile fields, send an event to all
active users of realm.
2018-03-21 16:08:12 -07:00
YJDave b404d0e156 custom profile data: Set custom field's values in user setting page on load.
Set realm custom field's values for current user in user setting page
when page gets load.
2018-03-21 16:08:12 -07:00
YJDave 66f80441ce custom profile data: Add template for custom user profile fields. 2018-03-21 16:08:12 -07:00
Harshit Bansal a49655e0d4 emoji: Migrate realm emoji to be addressed by `id` rather than `name`.
This commit migrates realm emoji to be addressed by their `id` rather
than their name. This fixes a long standing issue which was causing
an error on uploading an emoji with same name as a deactivated realm
emoji.

Fixes: #6977.
2018-03-20 22:24:44 -07:00
knovokresch a021485b2e copy_and_paste.js: Support copying recipient headers from several topics.
Algorithm for copying messages from serveral topics was changed:
 - if there are selected messages from more than 1 recipient block
   then the recipient bar headers are copied;
 - If there are multiple messages from only one recipient block
   then recipient bar header is not copied.
Fixes #7217.

Also adds a full suite of Casper tests for the copy-paste functionality.
2018-03-20 21:56:05 -07:00
Steve Howell c282b94bab Track fetch status for initial narrow. 2018-03-20 15:23:29 -07:00
Shubham Dhama 62f646816d org settings: Show "save" button only when setting is changed.
With this "Save" button is only shown when there are changes in a
subsection. This means if we changed a setting and reverted it back to
original ones, then, "Save" button will get disappear. Hence, we're shown
"Save" when there are some property changes to send to the server.
2018-03-20 14:48:12 -07:00
Shubham Dhama be0298314a org settings: Make each subsection independent for saving changes.
This makes each subsection(like "Message feed") independent of changes
done in any other subsection and the save button of each subsection
saves the changes done in that subsection only.
2018-03-20 14:48:10 -07:00
YJDave 2cbfcbb740 subscription: Fix unexpected blueslip warnings on add subscriber.
In stream settings, if user add subscriber to unsubscribed public
stream from `Add` input widget it gives lots of blueslip warnings,
cause user isn't subscribed to public stream.

Fix this by changing condition to `sub.can_access_subscriber` from
`sub.subscribed` in blueslip warning, cause user can access
subscribers in such cases even if not subscribed to stream.

Tweaked by tabbott to make the node tests pass.
2018-03-19 10:24:14 -07:00
Cynthia Lin 333b8b095c subscriptions: Use tooltips for stream info hover content.
Fixes #8718.
2018-03-18 19:44:53 -07:00
gooca 591624972e Refactor perfect-scrollbar: Call ui methods in stream_list.js. 2018-03-16 12:47:47 -07:00
Shubham Padia 4fb1704e6e settings: Add save instructions below pill container on changes.
Fixes #8088.
2018-03-15 17:29:12 -07:00
Shubham Padia dd5ce49ce0 settings: Add button to cancel user group auto save on blur.
Clicking the cancel button removes all the changes and the user
group returns back to the original state. Saved button is showed
once the changes are saved on blur.
2018-03-15 17:29:12 -07:00
Shubham Padia 40d6ee54ca settings: Move user group delete button to top right corner.
Also replaces trash icon with "Delete" for the button.
2018-03-15 17:29:12 -07:00
Shubham Padia 28f0ac2e14 settings: Save user group name/desc changes along with member changes.
Add do_not_blur func to not save changes when blur event's origin
is one of name/description/pill input from the current user group.
Changes in any of name/desc/members are saved together on blur from
any of the input field given do_not_blur is false.
2018-03-15 17:29:12 -07:00
Shubham Padia 9aec2b8b74 settings: Auto save user group members on blur.
Auto saves group members if focus moves from the input field in the
pill container.
2018-03-15 17:29:12 -07:00
Tarun Kumar c8d5cf7d6c user-groups: Achieve 100% node-test coverage of user_groups.js.
Fixes #8704.
2018-03-15 10:09:28 -07:00
Shubham Dhama 8f4523e8dd compose typeahead: Add all public streams including unsubscribed streams.
This makes it convenient to mention a stream you're not subscribed to,
which can be useful for communicating about where a topic is
discussed, for example.

Fixes: #5757.
2018-03-14 11:10:43 -07:00
Shubham Dhama 342ec0a544 drafts: Add tests for draft formatting and sorting. 2018-03-14 10:57:11 -07:00
Shubham Dhama 7aeae688e7 compose: Remove draft older than 30 days.
This removes drafts older than 30 days as they become irrelevant
for the user. Those drafts are removed before populating them.

Fixes: #7602.
2018-03-14 10:57:11 -07:00
Harshit Bansal 40958e0824 emoji: Switch to 64px 256 color indexed sprite sheets.
This commit switches our emoji infrastructure to use 256 color indexed
64px spritesheets. Earlier we were using non-indexed 32px spritesheets
which were blurry on high dpi displays. These indexed spritesheets not
only provide a crispier display but are also smaller in size.

This commit also removes the `emoji-datasource` package as a dependency
as all the data is now sourced from individual datasource packages.

Fixes: #7862.
2018-03-14 10:28:45 -07:00
Tim Abbott bea9b6a748 user_groups: Fix real-time sync of user groups.
This fixes the user groups UI to follow the Zulip standard mechanisms
(using the appropriate server_events system to update all browsers
properly).  It also, as a side effect, fixes #8692, since it
eliminates the weird behavior of trying to re-insert a user group
after reformatting it in the frontend.

Thanks to Tarun Kumar for preliminary work on this.
2018-03-14 10:12:14 -07:00
Rohitt Vashishtha b22e8dc2b7 lint: Replace 'return undefined;' with 'return;'.
Also adds a custom rule to eslint. Since the recommended way of extending
eslint is to create plugins as standalone npm packages, the separate rule
is published as 'eslint-plugins-empty-returns'.

Fixes #8669.
2018-03-13 08:22:42 -04:00
Vishnu Ks 3da2a1e18d admin: Add a realm setting to disallow signups using disposable emails.
Fixes #2955
2018-03-11 22:05:58 -07:00
Tim Abbott 6e048c5d3f copy_and_paste: Enable copy-paste handler in production.
Now that we've fixed the issues we encountered when first testing
this, we can try it out in production again.
2018-03-11 15:26:27 -07:00
Tim Abbott 2a7e365b6f tests: Fix mock setup for update_calculated_fields.
This fixes a test failure introduced in
c5904499db.  It's not clear to me that
this mocking approach is a good idea; it's pretty messy.
2018-03-09 18:23:18 -08:00
Tim Abbott 51dc46bfb1 node: Fix test failures due to missing import.
I missed this when reviewing the last batch of changes.
2018-03-09 14:24:08 -08:00
Steve Howell fef2840531 Add FetchStatus class.
We will use this in subsequent commits to replace the
`load_more_enabled` flag.
2018-03-09 14:20:58 -08:00
Harshit Bansal 5aa8629a10 reactions: Migrate `emoji_code` to store `id` for realm emoji.
Till now, we had been storing realm emoji's name in emoji code field
in reactions' model. This commit migrates it to store realm emoji's id.
It is a part of effort to migrate realm emojis to be referenced by their
id and not by name.
2018-03-09 13:46:27 -08:00
Shubham Dhama 3b92f6115a hotkey: Add 'delete' to delete focused draft. 2018-03-09 13:30:09 -08:00
Shubham Dhama 777b6de689 org settings: Add setting to prevent users from adding bots.
Fixes: #7908.
2018-03-09 13:21:55 -08:00
Shubham Padia 077475c563 compose: Don't warn if mentioned stream members form a superset.
Fixes #8634.
Suppress private stream warning if you're to a stream whose
membership is a subset of #mentioned-stream-name.
2018-03-09 10:46:41 -08:00
Shubham Padia a78024f53d bots: Delete bot from bot_data set on realm_bot delete event.
Fixes #8577.
2018-03-08 07:54:19 -08:00
Steve Howell fb3293a24a node tests: Add tests for input_pill.js.
This gets us coverage on most of the core "data" code, but it
doesn't get deep into the key handlers.
2018-03-07 15:53:11 -08:00
Steve Howell 3e76d523c7 node tests: Add tests for user_pill.js.
This gets coverage to 100%.  (We already had a lot of indirect
coverage, but these tests should have more obvious failure
symptoms.)
2018-03-07 15:53:11 -08:00
Steve Howell 3a1bf04a56 compose: Add pills for typing in PM recipients.
@brockwhittaker wrote the original prototype for having
pills in the recipient box when users compose PMs (either
1:1 or huddle).  The prototype was test deloyed on our
main realm for several weeks.

This commit includes all the original CSS and HTML from
the prototype.

After some things changed with the codebase after the initial
test deployment, I made the following changes:

    * In prior commits I refactored out a module called
      `user_pill.js` that implemented some common functions
      against a more streamlined version of `input_pill.js`,
      and this commit largely integrates with that.

    * I made changes in a prior commit to handle Zephyr
      semantics (emails don't get validated) and tested
      this commit with zephyr.

    * I fixed a reload bug by extracting code out to
      `compose_pm_pill.js` and re-ordering some
      calls to `initialize`.

There are still two flaws related to un-pill-ified text in the
input:

    * We could be more aggressive about trying to pill-ify
      emails when you blur or tab away.

    * We only look at the pills when you send the message,
      instead of complaining about the un-pill-ified text.
      (Some folks may consider that a feature, but it's
      probably surprising to others.)
2018-03-07 15:53:11 -08:00
Steve Howell f0d101edf5 pills: Streamline input pills (for user groups).
The main point of this change is to streamline the core
code for input pills, and we use also modify user groups.

The main change to input_pill.js is that you now
configure a function called `create_item_from_text`, and
that can return an arbitrary object, and it just needs
a field called `display_value`.

Other changes:
    * You now call `input.create(opts)` to create the
      widget.
    * There is no longer a cache, because we can
      write smarter code in typeahead `source` functions
      that exclude ids up front.
    * There is no value/optinalKey complexity, because
      the calling code can supply arbitrary objects and
      do their own external data management on the pill
      items.
    * We eliminate `prependPill`.
    * We eliminate `data`, `keys`, and `values`, and just
      have `items`.
2018-03-07 15:53:11 -08:00