Commit Graph

1925 Commits

Author SHA1 Message Date
Shubham Padia 56644d149a typeahead: Replace `no-break space (U+00A0)` in query with `space (U+0020)`.
Typing "tim " did not did not produce any match when suggesting person
in composebox typeahead or user group typeahead as the space at the
end of the "tim " string passed by the browser was a
`no break-space (U+00A0)`  instead of `space (U+0020)`.

Although there are unicode characters other than `no break-space` which
represent spaces, only U+00A0 is replaced as it was the only space
character encountered when testing this issue manually.

Fixes #10039.
2018-07-25 14:55:11 -07:00
Joshua Pan 8de454ad2d tests: Test private msg validation with zephyr mirror. 2018-07-24 07:51:11 -04:00
Joshua Pan f5ee360c57 tests: Test nonexistent_stream_reply_error(). 2018-07-24 07:51:11 -04:00
Joshua Pan ac133c357c tests: Test Google Hangouts video call link. 2018-07-24 07:51:11 -04:00
Marco Burstein bb09bea0b6 ui: Simplify hotkey deprecation notices.
To reduce code duplication when creating hotkey deprecation notices,
create the `get_hotkey_deprecation_notice` function. Also, create a
`ui` testing file with a test for the new function.

Fix #10004.
2018-07-23 22:41:59 -07:00
Steve Howell 520e85b866 Use topic_data.js for topic typeaheads.
This replaces some old code with calls to topic_data.js.

Now our topic typeahead uses the same data as our
sidebar, stream suggestions, and the "n" key, so any
future improvements to that data will benefit all
features the same.

This is an important piece of #9857.
2018-07-23 16:08:24 -07:00
Harshit Bansal a906d564a3 emoji: Rename `css_class` to `emoji_code` in emoji.js.
Now that `emoji_collection` and `emojis_by_name` are global
datasources in the webapp we need to rename things carefully
to reflect their actual meaning. The fact that emoji code is
used as a css class for unicode emoji is one thing but it is
not its sole use so renaming it seems a good idea.
2018-07-23 12:35:08 -07:00
Harshit Bansal 88bc78645d emoji: Move `emoji_collection` from emoji picker to emoji.js.
This commit moves the `emoji_collection` datasource in the emoji
picker to emoji.js and renames it to `emojis_by_name`. It is a
mapping from emoji name to object where each object describes an
emoji. This is an effort in the direction of de-duplicating and
unifying the datasets being used by various our widgets(like
emoji picker and composebox typeahead) in the webapp. Migrating
all the widgets to a single datasource will help us in removing
the whole class of annoying bugs which causes some emojis to be
missing from some widgets.
2018-07-23 12:35:08 -07:00
Harshit Bansal c0b0fb7cce emoji: Move `EMOTICON_CONVERSIONS` mapping to build_emoji infra.
This commit closes a long pending issue which involved moving the
`EMOTICON_CONVERSION` mapping to build_emoji infrastructure so
that there is only one source of truth. This was pending from the
time when this feature was implemented.
2018-07-23 12:35:08 -07:00
Joshua Pan 565fd75661 tests: Test closing alert word status msg. 2018-07-23 14:53:49 -04:00
Joshua Pan 056e7e9a31 tests: Test removing alert words. 2018-07-23 14:53:49 -04:00
Joshua Pan c02b8dbc34 tests: Test adding alert word with keypress. 2018-07-23 14:53:49 -04:00
Shubham Padia 9b1dc48ebd keyboard-shortcuts: Focus instead of select on `/` if search pills enabled.
If search pills are not enabled, the text present in the search bar
will be selected on pressing '/' and writing someting without deselecting
the text will clear the search text. Since selecting the pills would
not make sense in this context, the search box is focused instead.
2018-07-23 11:29:10 -07:00
Shubham Padia 22b2393cae pills: Use `widget` instead of `my_pill` throughout the app.
`compose_pm_pill.my_pill`, `search_pill_widget.my_pill` and any of
its occurrences throughout the app have been replaced to use `widget`
instead.
2018-07-23 11:29:10 -07:00
Shubham Padia 1f553a41d0 search: Higlight `#searchbox` on focus.
Adds box-shadow to `#searchbox` when either `#search_query` or any
of the pills have focus. Uses jquery instead of pure css as the
`:focus` event occurs on `#search_query`, while we want to add
box-shadow to `#searchbox`. This could have been done with
`:focus-within` CSS selector, but it is not supported in IE or Opera.

`#search_query` already had an onfocus/focusout listener, adding
listeners to `#searchbox.pills` for those events wouldn't have worked
as you don't want the focusout event to fire when the focus shifts
from input to pill.

Also adds `focusin`, `focusout` and `css()` to zjquery. `css` is
same as `val`, except it returns an empty object in case of no value
instead of an empty string. I don't think `css()` is valid syntax
in actual jquery.
2018-07-23 11:29:10 -07:00
Shubham Padia 73e4f3b3fa search: Do not display `All messages` suggestion if bar not empty.
Previously `All messages` was displayed irrespective of the existing
pills. Now the suggestion is displayed only if no pills are present
2018-07-23 11:29:10 -07:00
Shubham Padia 8b153f6452 search: Validate suggestion against existing operators.
After adding search pills, suggestions were based only on the
current input and no validation against the existing pills was done.
operator_subset_suggestions have been removed. Default suggestions
for base_operators have also been removed.
Handle multiple operators:
if `is:starred stream:Ver` was typed without selecting the typeahead
or pressing enter in between i.e search pill for is:starred has not yet
been added, then the description of `is:starred` will act as a prefix
in every suggestion.
Also makes changes re-enabling person suggestions for names with spaces.
2018-07-23 11:29:10 -07:00
Tim Abbott 5b0e9b7fe6 search: Duplicate search_suggestions.get_suggestions.
This large function will need to be modified significantly as part of
the pills effort, and copying it lets us preserve behavior in
production until we're ready to cut things over.
2018-07-23 11:29:10 -07:00
Shubham Padia 069a4f1626 search: Disable tab_bar due to addition of search pills.
tab_bar.js becomes redundant after implementation of search pills.
This commit adds a comment to tab_bar.initiliaze, so the event
listeners related to it do not get initiated. This does not remove
any code related to tab_bar.js.
Also adds left and right border around the search icon.
2018-07-23 11:29:10 -07:00
Shubham Padia 36707a33ca search: Add a basic implementation of search pills.
Following points have been implemented in this commit:
1.) Add search pill on selecting typeahead.
2.) Re-narrow after removing a search pill.
3.) Add quiet optional parameter to removeLastPill.
4.) Pre populate search pills in narrow.activate.
5.) Clear existing search pills on narrow.deactivate.

Description of above points:
1.) I tried out using the description from suggestions.lookup_table
to append a pill using appendValidatedData so that the description
had not to be calculated again. But the description in the suggestions
lookup contains html due to highlighting. This html is escaped when
inputed in a pill. An attempt was also made to remove the higlighting
by replacing the tags. But other espaced characters like < also
popped up, so it was better to use append_search_string.
3.) If one wants to refresh the pill using pill.clear and wants to
repopulate them, evaluating the event_handler associated with the
action of removing the pill may not be desired.
4.) Pill population code is added to narrow.activate. Pills are not
populated if the narrow was triggered by search as search handles the
addition and removal of pill by itself. The reason for not handling
search too in narrow.activate is to avoid clearing the pills and
repopulating them. Example of some of the triggers for narrow.activate
include `restore draft`, `topic change`,`sidebar`.

Also modifies tests for search.js
2018-07-23 11:29:10 -07:00
Tim Abbott 5c01ae87a0 search: Duplicate search node tests for pills.
This forks off search_legacy.js and search_suggestion_legacy.js so
that we can continue running automated tests against the legacy search
code while we develop the input pills feature.
2018-07-23 11:29:10 -07:00
Yashashvi Dave bbe326dd29 message edit: Add markdown shortcuts to message edit UI.
This makes the ctrl+B, ctrl+I, ctrl+shift+L shortcuts available when
doing message editing.

Fixes #9917.
2018-07-23 10:41:46 -07:00
Cynthia Lin c3b1381c2a left sidebar: Make sure the selected stream is visible in left sidebar.
This triggers a scroll in the left sidebar after an initial narrow if
the target stream isn't visible.

Fixes #9043.
2018-07-23 10:32:10 -07:00
Cynthia Lin 66df4e3e84 input-pill: Refactor pills to eliminate fixed positioning of elements. 2018-07-23 10:21:13 -07:00
Harshit Bansal bf70955c0c emoji: Update `emoji-datasource` packages.
This commit updates the `emoji-datasource` packages to version 4.0.4.
This update brings following changes to emoji infra:

1: Fix for the bleeding sprite sheets.

2: The category of some emojis has been changed. Categorywise breakup of
   net gain or loss is as follows:
    Travel & Places: 58 (gain)
    Symbols: 47 (loss)
    Smileys & People: 52 (gain)
    Objects: 11 (loss)
    Food & Drink: 3 (gain)
    Animals and Nature: 46 (gain)
    Activities: 9 (loss)

3: There were some changes in the image farm of the package which were
   breaking our old emoji farm. I fixed them by modifying the remapped
   emoji map.

Fixes: #8235.
2018-07-23 08:04:58 -07:00
Joshua Pan 015bc8b01e tests: Reach 100% coverage for keydown_util.
This commit pretty much just gets line coverage.
2018-07-23 08:42:11 -04:00
Anders Kaseorg f15cef27db frontend_tests/run-casper: Avoid shelling out for mkdir, rm.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-07-19 10:43:37 -07:00
Marco Burstein 11cbe2bf6a lightbox: Fix a "Pan & Zoom" causing an error with thumbnailed images.
Images on the new thumbnailing system generate an error when
"Pan & Zoom" is enabled:

    Browser Error: Lightbox for unknown message undefined
    39648: http://localhost:9991/webpack/app.js
        | Object.blueslip_error [as error]
    50743: http://localhost:9991/webpack/app.js
        | Object../static/js/lightbox.js.exports.open
    50897: http://localhost:9991/webpack/app.js
        | HTMLDivElement.
    39474: http://localhost:9991/webpack/app.js
        | HTMLDivElement.blueslip_wrapper
    16299: http://localhost:9991/webpack/app.js
        | HTMLDivElement.dispatch
    16107: http://localhost:9991/webpack/app.js
        | HTMLDivElement.elemData.handle

To fix this, instead of using the `src` attribute as the key for
`asset_map`, which can be either the original or thumbnailed version
depending on the situation, always use the original version.

Also, create `frontend_tests/node_tests/lightbox.js` to test this
functionality.

Fix #9955.
2018-07-18 10:19:56 -07:00
Joshua Pan 2ccc7711ae tests: Test adding alert words ui. 2018-07-18 08:35:42 -04:00
Joshua Pan c485bdf05d tests: Cover render_alert_words_ui(). 2018-07-18 08:35:42 -04:00
Steve Howell eeac8cfa41 zjquery: Show multiple handlers in demo code.
This also makes the error messaging for true
duplicates a bit more specific.
2018-07-18 08:25:15 -04:00
Sarah de2ec8a05c notification settings: Add UI for stream email notifications.
Previous commits have fully implemented the logic for stream email
notifications; this final commit adds support for configuring it to
the UI.

Fixes #6511.
2018-07-14 12:19:33 +05:30
Harshit Bansal f636882e04 build_emoji: Migrate to use `emoji_names.py` file.
This migrates Zulip to use a dramatically better set of names and
aliases for our emoji set, defined in emoji_names.py (which is in turn
manually generated from our hand-curated CSV file).

This should significantly improve the experience of using Zulip's
emoji picker and emoji typeahead for finding what one is looking for.
2018-07-13 21:18:02 +05:30
Aditya Bansal f605fdf2c8 topic_edit_form.handlebars: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:31:17 +05:30
Aditya Bansal 66096e9509 single_message.handlebars: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:31:17 +05:30
Aditya Bansal 76ed02dd35 admin_invites_list.handlebars: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:31:16 +05:30
Aditya Bansal 21b9e8dee1 typeahead_list_item.handlebars: Upgrade to font-awesome 4.7 icon prefixes.
We also remove a CSS hack that was required because the original icon
was poorly centered.
2018-07-11 20:31:03 +05:30
Steve Howell 353843aa7c node tests: Add rtl/ltr tests for compose box. 2018-07-11 19:20:22 +05:30
Rohitt Vashishtha 71648912ad zblueslip: Convert node_tests/widgetize.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha b3215dc601 zblueslip: Convert node_tests/user_groups.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 083681aeda zblueslip: Convert node_tests/user_events.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 1b9ba8c126 zblueslip: Convert node_tests/topic_generator.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 5b36a30163 zblueslip: Convert node_tests/stream_data.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 92259094b7 node_tests: Add missing stream_id field to tests in stream_data.
These were resulting in inadvertant calls to blueslip.fatal but
the code continued beyond that point, since in our testing environment
we do not stop executing when fatal is called.

This commit also adds checks to ensure that the subs were created.
2018-07-10 16:22:52 -04:00
Rohitt Vashishtha e8531ab477 zblueslip: Convert node_tests/server_events.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha e14dbecdd1 zblueslip: Store more_info and stack as well in the logs.
Now, the get_test_logs() returns an array of objects instead
of an array of strings as follows:

[{
  message: "something",
  more_info: {},
  stack: {},
}]
2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 61f8a6fd55 zblueslip: Convert node_tests/reactions.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 910a2ec448 zblueslip: Convert node_tests/hashchange.js to zblueslip. 2018-07-10 16:22:52 -04:00
Rohitt Vashishtha 17bdb8e984 zblueslip: Add exception_msg and wrap_function functions.
This commit brings zblueslip on par with blueslip.
2018-07-10 16:22:52 -04:00
Anupam Dagar 88ddf2bf5d settings UI: Add copy zuliprc button to bot information box.
Fixes: #9510
2018-07-10 15:19:05 +05:30
Shubham Padia 7a3f2bbfb5 pills: Enable user avatar images for user pills.
Fixes #9842.
Enables avatar images in pills wherever user_pill.js is used.
(e.g composebox, user group settings)
Changes to search_pill.js are not made as search pills haven't been
added yet completely and search_pill.js just contains the preparatory
code right now.
No change to compose_pm_pill.js is not required as it uses
`user_pill.create_item_from_text` in its `create` function.
2018-07-10 15:07:56 +05:30
Shubham Padia e5f28e8960 pills: Add basic support for images in input pills.
Allow passing image link in the item passed to appendValidatedData.
When passing image link via any of the append* functions, make sure
that create_item_from_text for that pill also adds the image link to
the item created.
This commit does not make any visual change to the current app.
Changes to user_pill.js are necessary to enable user avatars for
pills.
2018-07-10 15:07:56 +05:30
Steve Howell c407ba5175 Add narrow_state.is_reading_mode(). 2018-07-10 14:20:24 +05:30
Steve Howell bec40af614 Remove redundant narrow_state.get_current_filter().
We now use narrow_state.filter() everywhere.  The
two functions did the same thing, and I slightly
prefer the concise name, which was already in use
in lots of places.
2018-07-10 14:20:24 +05:30
Rhea Parekh fe4cad15a4 widgets: Add todo widget. 2018-07-10 11:18:05 +05:30
Shayan Toqraee 0757d022f5 messages: Add support for right-to-left messages.
This implements right-to-left message automatic detection support in
the compose box as well as the message feed.  Full unit tests and
support in the message-editing UI are for future work (as are
potentially more fancy things like supporting things like
right-to-left multi-word names for users/streams/etc.).

Fixes #3123.
2018-07-10 10:47:56 +05:30
Steve Howell 930f3937dc Remove feature_flags.mark_read_at_bottom.
We removed all code related to the possibility
of it being false.
2018-07-07 10:19:15 +02:00
Shubham Dhama ced6f967bc voting_widget: Increase node test coverage to 100%. 2018-07-06 11:30:12 -04:00
Shubham Dhama 53cd1be294 zjquery: Add `clear_all_elements` to remove all cached elements.
The reason to add this api is that many times some elements are
already used/cached and then their value interfere/exists in
other tests which gives false results.
2018-07-06 11:30:12 -04:00
Aditya Bansal 4f090861e7 admin_streams_list.handlebars: Remove since its dead.
This was killed when the "Deleted Streams" feature was dropped
in commit 7bbe44d7 but we forgot to deal with it at the time.

squash to admin_streams_list
2018-07-04 23:51:45 +05:30
Steve Howell 41b6999428 node tests: Test message_flags.toggle_starred. 2018-07-03 06:05:22 -07:00
Steve Howell 26b48b95dc refactor: Export settings_bots.render_bots().
We also now call this explicitly when we need to
re-render (instead of triggering a custom event).
2018-07-03 06:02:49 -07:00
Shubham Dhama b938523592 widgets: Increase node tests coverage to 100%. 2018-07-03 08:48:49 -04:00
Shubham Dhama 98e6b287b5 zjquery: Implement empty function for when there is no argument. 2018-07-03 08:48:49 -04:00
Steve Howell 1fdfe11e8b node tests: Add tests for voting_widget.js.
This first commit starts by testing handling of
inbound data.
2018-07-02 13:46:30 -04:00
Yashashvi Dave aa39b1e28e custom field: Allow admin to change custom fields order using drag & drop.
Using sortablejs library, allow admin to modify custom fields order
in admin settings using drag and drop of custom field list element.

Fixes #9351
2018-07-01 02:05:00 -07:00
Shubham Padia 2977a4cb6f right-sidebar: Narrow pm/group-pm on clicking unread count badge.
Fixes #9797.
Clicking on the unread count badge on the right sidebar did not
narrow the selected pm/group-pm. This commit moves the count div
inside selectable_sidebar_block. Also uses flexbox instead of
inline-blocks for user presences selectable_sidebar_block.
2018-06-27 11:26:24 -04:00
Shubham Padia 1364971a17 search: Extract phrase_match to common.js.
Extracts phrase_match to common.js so it can be used by other
components like integrations search.
2018-06-26 20:38:47 -04:00
Shubham Dhama eaeaf2d851 list_render: Remove rows sort click handler from the body.
This removes the click handler previously attached to the body, now
we just need to pass `parent_container` which at least contains the
table heads.
2018-06-22 09:21:47 -04:00
Shubham Dhama 5b18a381fb list_render: Extract sort handler function from data-sort click handler. 2018-06-22 09:21:47 -04:00
Shubham Dhama 2aba7c239f list_render: Make list creation logic as an export in list_render module.
This changes how we create lists i.e.
    from `list_render($container, list, opts)`
        to `list_render.create($container, list, opts)`
2018-06-22 09:21:47 -04:00
Marco Burstein 9643c8ed26 hotkeys: Deactivate `ctrl + shift` hotkeys.
This disables `ctrl + shift + [`, while `ctrl + [` will still trigger
an action.

Also, add a test for ensuring that the `ctrl + shift` combinations fall
through.
2018-06-22 09:10:23 -04:00
Marco Burstein 56f711d5ff hotkeys: Deactivate `cmd-or-ctrl + shift` hotkeys.
This disables `cmd-or-ctrl + shift + k` and `cmd-or-ctrl + shift + s`,
while `cmd-or-ctrl + k` and `cmd-or-ctrl + s` will still trigger
actions.

Also, add tests for ensuring that the `cmd-or-ctrl + shift`
combinations fall through.

Fix #9779.
2018-06-22 09:10:23 -04:00
Shubham Padia 6853530eba search: Add search_pill.js with basic operations.
Adds search_pill.js to the static asset pipeline. The items
for search pill contain 2 keys, display_value and search_string.
Adding all the operator information i.e the operator, operand and
negated fields along with the search_string and description was tried out.
It was dropped because it didn't provide any advantage as one had to
always calculate the search_string and the description from the operator.
2018-06-22 09:05:36 -04:00
Shubham Dhama c167227ddc search: Add 100% coverage for search.js. 2018-06-22 07:58:06 -04:00
Shubham Dhama 8e032376f9 guest: Restrict guest access to user group creation and updation. 2018-06-19 11:04:14 -07:00
Shubham Dhama 05323e776e user groups: Refactor settings_user_groups.can_edit. 2018-06-19 11:04:14 -07:00
Shubham Dhama acd2528038 transmit: Refactor logic for deferring the socket initialization.
This makes sure that CSRF token is available while initializing
Socket, irrespective of the order of execution of deferred callbacks
after document becomes ready.

This is part of #9416.
2018-06-18 06:51:42 -07:00
Shubham Dhama 38db0ce270 settings_org: Increase node test coverage. 2018-06-17 09:28:19 -04:00
Shubham Dhama 0875bbfecb settings_org: Refactor node tests. 2018-06-17 09:28:19 -04:00
Shubham Dhama 603139500a settings_bots: Extract logic for ability to create bots.
This is a minor refactor/deduplication and renaming of
'admin_only_bot_creation' to 'can_create_new_bots'
2018-06-16 06:33:14 -07:00
Shubham Dhama 18374d8f18 message_edit: Add coverage for get_deletability function. 2018-06-13 06:04:48 -04:00
Shubham Padia 5f9cdf9b08 popovers: Enable keyboard navigation on user profile menu.
Fixes #9318.
Calls popovers.user_info_popover_handle_keyboard in process_hotkey.js.
Makes popovers.message_info_popped public.
2018-06-13 05:57:14 -04:00
Steve Howell 91086e80c0 node tests: Add coverage for settings_bots.focus_tab. 2018-06-13 05:47:55 -04:00
Steve Howell 90ecea5177 node tests: Extract set_up in settings_bots.js. 2018-06-13 05:47:55 -04:00
Steve Howell 754a05a69e minor: Use => notation in settings_bots tests. 2018-06-13 05:47:55 -04:00
Eeshan Garg 0a43e5e257 Replace all user-facing references to "invite-only" with "private".
Fixes #9611.
2018-06-12 13:37:45 -04:00
Steve Howell 6f1f72f8ba node tests: Add tests for settings_profile_fields.js. 2018-06-12 10:15:18 -04:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Yashashvi Dave 40590bb6b9 custom fields: Fix exception in rendering custom profile field template.
The function `settings_account.add_custom_profile_fields_to_settings`
called twice, which resulted in two templates objects being
rendered.

The function also didn't check whether settings overlay was open or
not when processing new events, and thus would throw an "undefined"
error if a custom profile field was editing while the overlay was not
open.

Fixes #9668.
2018-06-10 13:50:38 -07:00
Shubham Dhama 51ae82fbcf left-sidebar: Fix opening of compose box on narrowing using hotkeys.
Explaining the problem a bit: When we narrow to a stream/private message
using `q+Enter`/`w+Enter` compose box opens which isn't desirable here.
The bug here was the propagation of event after getting handled in
`keydown_util.handle` to `hotkeys.process_enter_key`.

Fixes: #9679.
2018-06-09 12:53:24 -04:00
Cynthia Lin 88795898a2 message edit: Fix edit author text overflow on images.
Fixes #9175.
2018-06-08 07:49:28 -07:00
Steve Howell e7e38253ec settings: Add better keyboard navigation for panel menus.
You can now use all four arrow keys intuitively in the
Settings/Organization panel menus.
2018-06-06 09:42:33 -07:00
Shubham Dhama f148ed5bbf org settings: Improve error handling status elements.
With styling work by @maxnuss.

Fixes: #9188.
2018-06-06 09:00:35 -07:00
Shubham Dhama 8852ed588a style: Remove redundant brackets from typeof operator. 2018-06-05 09:22:26 -07:00
Tim Abbott 6111b4ebd0 node: Fix test errors from recent custom profile field changes. 2018-06-04 16:52:55 -07:00
Steve Howell a361e2b993 Fix recent regressions with All Messages (muted topics).
My recent refactoring that split out MessageListData
introduced a nasty bug where we were putting muted
messages into the "All Messages" view even though
the underlying list was correctly filtering
them, so the symptoms were two-fold:

    - muted messages cluttered up your feed
    - replying to the message caused a traceback (since
      it wasn't actually in the underlying data
      structure)

This has to do with what MessageListData.add_messages()
was passing back to MessageList to orchestrate drawing
in MessageListView.

I think what happened here is I got this working kind
of sloppily but correctly for the non-muting case and
then got in the weeds of some other stuff.  Not my
finest moment.

The actual correct code here is simple enough.  We
triage top, interior, and bottom, and then the respective
methods that put the data into the data structure
return the filtered lists (i.e. not muted) and put them
into the info structure.

Fixes #9656
2018-06-04 14:35:23 -07:00
Steve Howell f625d4d237 node tests: Add muting cases for message_list_data. 2018-06-04 14:35:23 -07:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Shubham Dhama c6738889a9 eslint: Add and enable `space-unary-ops` rule.
Info about rule at https://eslint.org/docs/rules/space-unary-ops.
2018-06-05 00:47:35 +05:30
Steve Howell 8deb2fc9ef toggler: Always call back to callback function.
In our toggler component (the thing that handles tabs in things
like our markdown/search help, settings/org, etc.), we have
a callback mechanism when you switch to the tab.  We were
being tricky and only calling it when the tab changed.

It turns out it's better to just always call the callback,
since these things are often in modals that open and close,
and if you open a modal for the second time, you want to do
the callback task for whichever setting you're going to.

There was actually kind of a nasty bug with this, where the
keyboard handling in the keyboard-help modal worked fine the
first time you opened it, but then it didn't work the second
time (if you focused some other element in the interim), and
it was due to not re-setting the focus to the inner modal
because we weren't calling the callback.

Of course, there are pitfalls in calling the same callbacks
twice, but our callbacks should generally be idempotent
for other reasons.
2018-06-04 09:02:58 -07:00
Robert Hönig 5d9a8cf64f bots: Add token to outgoing webhook zuliprc.
We want the Botserver to not only work with the
botserverrc, but also with a zuliprc of an outgoing
webhook. Because the Botserver uses the outgoing
webhook token for authentication, we need to include
it in the zuliprc for outgoing webhooks.
2018-06-04 08:39:24 -07:00
Robert Hönig d08c701bb4 frontend: Use bot_data instead of HTML data to generate zuliprc.
It is better to retrieve all information about a bot from
the central bot data store, rather than relying on the
bot card's HTML attributes.
2018-06-04 08:39:11 -07:00
Steve Howell 4b2e8b83c4 slash commands: Add /ping command (via zcommand).
This adds a /ping command that will be useful for users
to see what the round trip to the Zulip server is (including
only a tiny bit of actual server time to basically give a
200).

It also introduce the "/zcommand" endpoint and zcommand.js
module.
2018-06-02 09:40:12 -07:00
Anupam Dagar 0e8081093b hotkey: Add deprecation notice for '*' hotkey. 2018-06-02 08:59:42 -07:00
Joshua Pan 0f6211fbc3 node tests: Use run_test helper in templates.js. 2018-06-02 06:10:34 -04:00
Joshua Pan f4b341c2d4 node tests: Use run_test helper in user_pill.js. 2018-06-02 06:10:34 -04:00
Joshua Pan c9c06ae13c node tests: Use run_test helper in topic_data.js. 2018-06-02 06:10:34 -04:00
Joshua Pan 53d482194a node tests: Move templates.render to global definition. 2018-06-02 06:10:34 -04:00
Joshua Pan 9b1e0bbf3d node tests: Use run_test helper in input_pill.js. 2018-06-02 06:10:34 -04:00
Joshua Pan 43ba3196ee node tests: Use run_test helper in general.js. 2018-06-02 06:10:34 -04:00
Joshua Pan 7214315e00 node tests: Use run_test helper in buddy_data.js. 2018-06-02 06:10:34 -04:00
Joshua Pan f74d298478 node tests: Use run_test helper in bot_data.js. 2018-06-02 06:10:34 -04:00
Joshua Pan dd453e8dbe node tests: Remove unnecessary function in activity.js. 2018-06-02 06:10:34 -04:00
Steve Howell df9761391c node tests: Add narrow_local.js. 2018-06-01 12:45:02 -07:00
Steve Howell baa691db7d narrow: Fix how we select ids for narrows.
This commit fixes a couple regression related to narrowing.

For a long time we've had bugs where we too aggressively
preserve the currrent selection on topic -> stream
re-narrows ("s" key) even when the wider narrow may
have unread messages before the selection.

Also, we recently introduced a bug so that when you used
a link from the "copy link to conversation" (aka a "near"
query), it would advance you to your first unread message
despite the near:999 specifier.  (The code would work for
subsequent "near" queries once you had fetched some of
your original messages).

This commit introduces a new data structure called id_info (replacing
the select_strategy data structure) in various functions and uses that
to track all the ids of relevance.

Significantly rewritten by tabbott to handle a few extra corner cases,
and add a ton of comments explaining why it works the way it does.

Fixes #2091.
Fixes #9606.
2018-06-01 12:45:02 -07:00
Anupam Dagar 9674a139bf hotkeys: Change * to Ctr+s for starring a message.
Fixes: #9613.
2018-06-01 09:53:15 -07:00
Tim Abbott c8db7b7dd7 node: Provide a default window object for the node tests.
This is preparation for our migration of our JS pipeline to webpack,
which includes as part of the process a hack of exporting globals via
the window object.
2018-05-31 14:55:28 -07:00
Steve Howell 7642ed66cf Expand get_unread_ids() to all local narrows.
This commit makes it so that any query for
which we do a local filter leads to us
examining the full list of unread message
ids in our cache to find a potentially
unread message that passes the filter.  This
can often allow us to more immediately
jump to a new narrow with an appropriately
selected message.

Fixes #9319
2018-05-31 08:44:18 -07:00
Steve Howell 4c235bfe65 Handle non-local case in get_first_unread_info().
We want to be able to call get_first_unread_info() even
if we cannot apply a search locally.  It was returning
the correct value before, but this change removes a
blueslip warning that will allow our callers to remove
some guard code in a subsequent commit.
2018-05-31 08:44:18 -07:00
Steve Howell 7305d4f652 submessages: Add update_message() function.
We want to update message.submessages for new events, even
though our couple of widgets (poll/tictactoe) that can process
"update" events currently just apply events as "deltas"
to their current data.

This does fix a subtle issue where you may get incoming
events for a message that the client knows about but which
it hasn't yet activated as a widget.  Up until now,
we've rarely seen the bug that's fixed here, since it's
usually the case that as soon as we receive a message, we
widgetize it right away.
2018-05-30 14:47:36 -07:00
Shubham Padia 214ce1ccca streams: Add create and edit ui for is_announcement_only.
The user can now specify the value while creating a stream.
An admin can later change it via `Change stream permissions`
modal. Add is_announcement_only to subscription type text.
2018-05-30 14:22:15 -07:00
Shubham Padia 518764b843 streams: Change stream-privacy-model save button text to `Save changes`. 2018-05-30 14:18:41 -07:00
Tim Abbott bab09a6579 stream_types: Suggest private, shared history before protected history.
This feels like the more common use case for most users.
2018-05-30 14:17:32 -07:00
Steve Howell bfc13ecea4 submessages: Just send content for submessage events.
For some reason in my original version I was sending both
content and data to the client for submessage events,
where data === JSON.parse(content).  There's no reason
to not just let the client parse it, since the client
already does it for data that comes on the original
message, and since we might eventually have non-JSON
payloads.

The server still continues to validate that the payload
is JSON, and the client will blueslip if the server
regressses and sends bad JSON for some reason.
2018-05-30 13:53:11 -07:00
Steve Howell d76450a117 node tests: Test submessage.handle_event(). 2018-05-30 13:53:11 -07:00
Steve Howell a6e7520819 node tests: Use run_test helper in submessage.js. 2018-05-30 13:53:11 -07:00
Shubham Dhama 0caf55f2f0 settings_bots: Move bot_creation_policy_values to top-level.
Since ensure_i18n is dead we don't need to explictly load them.
2018-05-30 23:25:02 +05:30
Tim Abbott d9347dea3e i18n: Remove now-unused ensure_i18n function. 2018-05-30 09:13:48 -07:00
Robert Hönig 647c63050f botserver: Add outgoing webhook tokens to botserverrc.
The tokens will be used to authorize the server when sending
messages to the Botserver.
2018-05-30 10:00:19 -04:00
Shubham Padia 0ffcb7fccf search: Remove blueslip warnings for invalid emails in 'pm-with' filter.
Fixes #3380.
The blueslip warning mentioned in #3380 were from paths ending at
people.email_list_to_user_ids_string. Some additional blueslip warnings
were raised after using that function.
Although we can put a validation check somewhere in the call stack of
people.email_list_to_user_ids_string, this function itself is used to
validate the operand by the higher order functions, so it wouldn't make
sense to put a validation check before that. Instead, removing the
blueslip warning altogether was chosen.
people.email_list_to_user_ids_string was replaced by
people.reply_to_to_user_ids_string which is a blueslip-free version
of the same. Other blueslip warnings were removed.
2018-05-30 07:49:59 -04:00
Yashashvi Dave 3654d4f92d jquery-form: Remove jquery-form use from get-API-key form in user settings. 2018-05-30 03:14:39 +05:30
Robert Hönig 04d68d2570 code: Rename flaskbotrc to botserverrc. 2018-05-29 10:19:17 +02:00
Steve Howell 26e1fca7ed Add message_list.is_at_end() helper. 2018-05-28 16:49:57 -07:00
Shubham Padia 88b4a9f2d7 pm_list: Do not expand pm_list for invalid emails in `pm-with`. 2018-05-28 11:29:54 -07:00
Shubham Padia d9b0ab2ae7 narrow: Show non-existing user message for invalid emails.
Also adds people.is_valid_bulk_emails_for_compose and refactors
narrow_state.set_compose_defaults to use it.
2018-05-28 10:45:42 -07:00
Shubham Padia 2ce7ef73e8 compose: Add tests for compose_actions.on_narrow. 2018-05-28 10:45:42 -07:00
Shubham Padia 6ea6f5e0af search: Do not open compose box if invalid recipient present in `pm-with`.
If atleast one of the private_message_recipients is invalid, compose
box will not be opened.
Thanks to Aastha Gupta <aastha.gupta4104@gmail.com> for some preliminary
work on this.
2018-05-28 10:45:42 -07:00
Steve Howell a074056127 Add prev/next helpers for MessageList. 2018-05-27 22:41:19 -07:00
Joshua Pan 300654613e test: Cover majority of functions in MLD.
This gets coverage to about 97%.
2018-05-25 23:52:52 -07:00
Cynthia Lin 818611ac4e user groups: Sanitize pill_container selector to avoid escaped strings.
Fixes #9325.
2018-05-25 12:02:34 -07:00
Robert Hönig 53891a9bed bots: Don't name section headers in flaskbotrc.
The Botserver uses section headers in the flaskbotrc to
determine which bot to run. Silently setting the section
headers to a bot's username is confusing and makes it
harder for Botserver users to figure out how to get the
Botserver to run the bots they want. This commit empties
all flaskbotrc section headers and thus makes the assignment
of bots explicit and mandatory.
2018-05-25 10:33:40 -07:00
Shubham Padia 5d750a5d44 search: Respect spaces in person name in new suggestions only.
Fixes #6515.
New suggestions for `sender:King ha` will respect spaces and the new
suggestion will be `Sent by King Hamlet <email>` instead of `Sent by King,
search for ha`. But if first term of sender operand is a valid user email,
tokens will be seperated by spaces. e.g `sender:hamlet@zulip.com abc`
will show `Sent by King Hamlet <email>, search for abc`.
2018-05-25 09:03:27 -07:00
Steve Howell 435719c65b Add a schema checking concept to the web app.
This starts the concept of a schema checker, similar to
zerver/lib/validator.py on the server.  We can use this
to validate incoming data.  Our server should filter most
of our incoming data, but it's useful to have client-side
checking to defend against things like upgrade
regressions (i.e. what if we change the name of the field
on the server side without updating all client uses).
2018-05-24 09:30:22 -07:00
Steve Howell a5dee62b8f transmit.js: Add reply_message(). 2018-05-24 09:30:22 -07:00
Steve Howell 84c9be45af node tests: Remove requirement to test all templates.
We have less urgency to test all templates now.  The
most common error is probably unbalanced tags, and our
python-based template checker catches those problems
pretty well.

It's still possible to create bad templates, of course,
but the node tests have never been super deep at finding
semantic errors.
2018-05-24 09:30:22 -07:00
Tim Abbott 5a5ca12f6f hotkey: Move ctrl+[ back from cmd+[.
This was incorrectly changed; the goal here is to match what vim does
for this keyboard shortcut.

Fixes #9525.
2018-05-24 08:31:55 -07:00
Shubham Dhama d1da4116ef node tests: Add `removeClass` to `stub_out_jquery`. 2018-05-23 15:29:34 -07:00
Joshua Pan dcee398622 onboarding: Redesign intro_reply hotspot in bottom whitespace.
This is a trial to have the first reply hotspot in the bottom
whitespace (and stick there until "Got it!"  is pressed).

Tweaked by tabbott to clean it up a bit.  Still needs more work on the
visuals.
2018-05-23 14:22:19 -07:00