Commit Graph

4249 Commits

Author SHA1 Message Date
Tim Abbott 5bcfecd0dc people: Extract gravatar_url_for_email. 2018-04-09 12:07:41 -07:00
YJDave 025956482a subscription: Fix error in appending current user on top of subscriber list. 2018-04-08 16:54:12 -07:00
YJDave f5a7d125c9 subscription: Clean functions `peer_subscribe` and `peer_unsubscribe`. 2018-04-08 16:54:12 -07:00
YJDave dcf9355502 subs.js: Rename function to `check_button_for_sub` to be more specific. 2018-04-08 16:54:12 -07:00
YJDave ed70a92ed3 subscription: Fix error in being re-subscribed to private stream.
Fixes #9023
2018-04-08 16:54:12 -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 cf40536ed2 stream_edit.js: Add helper func to rerender all subscriptions settings.
This add the function to rerender subscriptions settings which includes
subscriber count and subscriber list only if subscriptions tab is active.
2018-04-08 16:54:12 -07:00
YJDave 211eba2c56 stream_edit.js: Add helper func to check if sub settings tab is active.
This commit adds a new helper func to check if sub settings tab
is active or not and remove function `add_me_to_member_list`
function from `static/js/stream_edit.js`, cause we don't need to
render subscribers for particular case, as we are already doing that.
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 47f9e8319c compose: Close the compose error message box on clicking X. 2018-04-07 20:23:21 -07:00
Shubham Dhama f6d73a7444 settings: Fix label for message_content_in_email_notifications.
This was a regression introduced in deduplication of settings
template.
Fixes: #9021.
2018-04-07 20:22:33 -07:00
YJDave 21d1133c4f subscriptions: Clear email address on unsubscriptions from stream.
Currently, even after unsubscribing from private/public stream
email address of stream is still present in html widgets hidden.
Cause we don't clear email address on unsubscription event.

This clears email address from widget when user unsubscribe
from any stream.
2018-04-07 20:10:45 -07:00
YJDave f15ddc93e0 create stream: Fix stream email not rendering on stream creation.
Fixes #8817
2018-04-07 20:10:45 -07:00
Tim Abbott 65c4a43a82 lint: Fix errors with stats.js with new eslint.
This (for ... in) syntax we shouldn't be using anyway, but this at
least fixes the worst aspect of it.
2018-04-06 12:42:19 -07:00
Aastha Gupta c852185e9d stream settings: Make deactivate stream handler global.
Configure the click event handler for #do_deactivate_stream_button
once to avoid adding click handlers for it more than once.

Fixes #8979
2018-04-06 12:25:42 -07:00
Armaan Ahluwalia 7b8da9b6c0 settings: Changed checkbox and close icons on settings.
Introduced a new checkmark icon in the settings page
from entypo ( www.entypo.com )  to make icons more
consistent between user and organization settings.
2018-04-05 21:49:13 -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 5c11ab857e pills: Add exportable function for creating non-editable pills. 2018-04-05 17:40:12 -07:00
Armaan Ahluwalia 9a6a82516d settings: Make sticky feedback not disappear after delay.
This commit adds the ability to pass the sticky option to
in the change_display_setting function in order to have the
feedback element remain visible instead of fading out which
is the default behavior. Also passes true for that option in
two instances on the page.
2018-04-05 17:18:39 -07:00
Armaan Ahluwalia 381e498343 settings: Fixes spinners and fades out feedback in settings.
This commit changes the do_settings_change function so that it
defaults to showing the loading spinner for 500ms before fading
out the the feedback element. It also adds a sticky option so you
can override the fading out of the feedback element and have it
remain visible.
2018-04-05 17:18:35 -07:00
Armaan Ahluwalia 95634b9d17 ui: Add ability to hide ui feedback messages.
This adds the option to hide the container element after a given
duration in the message and success functions in the ui_report module.
2018-04-05 17:17:08 -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
Tim Abbott b12368aec5 compose: Fix fading when topic changes on re-narrow.
Now that we're changing the topic on re-narrow more frequently, we
need to ensure that we update the compose_fade state when we do so.
2018-04-05 15:21:02 -07:00
Tim Abbott 5a5b4730f1 compose_actions: Keep the compose box open on topic change.
This tweak to our compose on-topic-narrow logic may help make it a bit
easier to do quick replies without needing to re-open compose.  I'm
not 100% confident this actually makes Zulip better, but it's worth
testing and getting some feedback.

Fixes #6473.
2018-04-05 15:17:40 -07:00
Tim Abbott b9acdd947a compose_state: Re-fade message list when switching topics.
For a non-empty compose box, we previously considered closing the
compose box when switching topic narrows with content in the compose
box; now we leave it open unconditionally.

Part of #6473.
2018-04-05 15:17:40 -07:00
Priyank f5acbcb4c8 clipboard: Update clipboard to v2.0.0 to avoid variable name conflict.
It turns out, now we have a new standard way to access clipboard by
`Clipboard` method and currently this conflict with the constructor
exported by clipboard package. The new update v2.0.0 was released to address
this issue. The new version just exports the constructor as `ClipboardJS`.

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
Ref: https://github.com/zenorocha/clipboard.js/issues/468
2018-04-05 15:09:00 -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 4216b81e93 Fix Subscribed/All Streams bug.
We've had a longstanding bug where the streams settings code
was getting an i18n'ed value in the middle of a callback from
the toggle component, so it would have been broken for
non-English sites.  And then a recent cleanup of the toggle
code introduced a bug where the callback-in-the-callback was
getting stale state, so English sites broke too.

This fix just simplifies everything by using the key that
comes into our callback to determine whether we filter or not.

Fixes #8945
2018-04-04 16:37:39 -07: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 0e7073ec29 Fix keyboard handling for info overlays.
For info overlays (keyboard/markdown/search help) we now let
the modal portions of the widget have focus, so that you can
page around.  And then tab switching still works with the arrow
keys.
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
YJDave aeef925b93 custom fields: Fix error in rendering long textual custom fields.
Currently, long textual fields are rendered as short textual fields
in UI, this bug was introduced because of our recent changes in
custom fields type.
2018-04-04 10:46:18 -07:00
YJDave 8bc181882a custom fields: Remove unused code for custom fields.
It removes code related to custom profile field's placeholder styling
and related to numeric custom fields, as recently we removed support
for numeric custom fields.
2018-04-04 10:46:18 -07:00
Abhigyan Khaund 6f15e635d2 hotkeys: Add shortcuts for pan and zoom in lightbox view
This commit adds support for '+' and 'Z' for "zoom in" and '-' and 'z'
for "zoom out" shortcut keys in the lightbox image viewer for Pan and
Zoom.

Fixes: #8689.
2018-04-03 09:20:55 -07:00
Tim Abbott 4bf6904dca message_live_update: Fix double re-rendering of home_msg_list.
The previous logic incorrectly did current_msg_list plus
home_msg_list, so if one wasn't narrowed, we did all the work twice.
2018-04-02 18:58:51 -07:00
Tim Abbott ee939f4c1a message_list: Fix unnecessary work re-rendering all_msg_list.
Since all_msg_list is never displayed, there's no reason to do work
re-rendering it in these code paths.
2018-04-02 18:58:51 -07:00
Tim Abbott 2804a8c4f4 message_list: Fix scrolling upwards when users change names.
This fixes a messy bug where users would be randomly scrolled upwards
a large amount whenever a user's name was changed in Zulip.

Fixes #8921.
2018-04-02 18:58:51 -07:00
Tim Abbott 3d900a733f settings_users: Fix sending queries to /json/bots endpoint.
Apparently, since 1948cb6a89, we've been
sending requests by an administrator to change a user's name to the
/json/bots endpoint, which would end up changing the "bot owner" of
these objects to some random user.

We fix this by re-splitting the views code.
2018-04-02 18:48:55 -07:00
Tim Abbott 938c4cee08 settings: Add option to control Jitsi video chat integration.
Fixes #8922.
2018-04-02 16:55:16 -07:00
Greg Price e792fc6c07 spelling: Correctly write "cannot".
None of these errors were user-facing; mainly in comments, plus
one bit of internal docs and a developer tool.
2018-04-02 15:36:31 -07:00
guaca 83f4c0a723 ui.js: Add minimum scrollbar length. 2018-04-02 10:48:28 -07:00
Tim Abbott b58cd46e48 profile: Fix field types on the frontend. 2018-04-02 10:25:37 -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
Balaji2198 15d42f86f1 left sidebar: Fix "Compose" in stream actions popover prefills topic.
Fixes #8824.
2018-04-01 16:24:15 -07:00
Tim Abbott 3cfc760506 deprecation: Add fallback for if local storage is not available.
This falls back to a persistent variable for situations where local
storage is not enabled on the system.
2018-04-01 16:19:47 -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 ad066ca444 org settings: Use `get_property_value` to get property elem value. 2018-04-01 16:11:12 -07:00
Shubham Dhama 8d70e59ad0 org settings: Rename functions for more clarity. 2018-04-01 16:11:12 -07:00
Shubham Dhama 7fbf613f89 org settings: Unexport functions not used in other modules. 2018-04-01 16:11:12 -07:00
Shubham Dhama e317cd2c17 org settings: Add labels as a context to admin templates.
(It is a preliminary change for deduplication of org settings template.)
This adds org settings labels as a context to admin templates so that
they can be used as a context variables in admin templates.
The reason we did this in JS code because of translation issue when
passed (as a context in `partial` handlebars helper) directly within
template.
2018-04-01 14:52:12 +05:30
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
Aastha Gupta 9d052bcf5e copy_and_paste.js: Fix exception on IE11 with clipboardData.
On IE11, ClipboardData isn't defined; one can instead access it with
`window.clipboardData`, but that doesn't support text/html, so this
code path couldn't do anything special anyway.

So we instead just let the default paste handler run on IE11.

Fixes #8850.
2018-03-31 15:47:33 -07:00
Steve Howell cd8c15f1cf pills: Use a template to render the pills. 2018-03-31 09:32:52 -07:00
Steve Howell d48fb1d776 pills: Use insertText for copy/paste. 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
Akash Nimare 51113baebc desktop-app: Update app to latest v1.9.0. 2018-03-30 13:14:10 -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 8b91ea3a74 Revert "Suppress local echo when we are not caught up."
This reverts commit 80ed8294a1.

We need to do some improvements to FetchStatus for narrows before this
is safe to have running in production.
2018-03-30 11:51:52 -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 efeee28b12 settings: Remove obsolete lines of code.
There don't exist any element with this classes and it seems they
are accidentally added during addition of `bot_creation_policy`.
2018-03-30 16:07:53 +05:30
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
Shubham Dhama 0ef195ecc2 settings: Refactor code for focussing bot tabs. 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
Yago González 1237f819bb settings: Fix typo. 2018-03-29 08:04:51 -07:00
Shubham Dhama b580c62bd4 settings: Fix exception on updating bot_creation_policy.
This initializes the bot_creation_policy_values after the page
is loaded.

Previously we initialize these values in `settings.js` when settings page
is loaded at least once, so if we open two tabs, one(1) in which we
haven't opened the settings page yet and if in another tab (2) we
update the `bot_creation_policy` value, then because of the event
which calls `settings_bots.update_bot_permissions_ui` causes exception
in (1) because `bot_creation_policy_values` isn't initialized yet.

Fixes: #8852.
2018-03-29 08:03:42 -07:00
Tim Abbott 9f2a3c2921 settings_org: Fix spelling in set_create_stream_permission_dropdwon. 2018-03-29 08:02:19 -07:00
Shubham Dhama 35cfb86723 org settings: Fix real-time sync for realm_waiting_period_threshold.
This fixes a minor bug in which the value of `input` element of
`realm_waiting_period_threshold` don't get updated because in
`set_create_stream_permission_dropdwon` we don't change the
value of the input.
So, this minor refactor handles this more carefully.
2018-03-29 08:00:58 -07:00
Shubham Dhama 7eea186306 org settings: Make sync_realm_settings to be available at load time.
This moves `sync_realm_settings` function out of `_setup` so that
we can call `settings_org.sync_realm_settings` without opening
settings page at least once.

This also fixes a minor bug in which if we have two tabs opened and
in one we haven't opened settings page at least once and in
another we change an org setting, then we get an exception in
the former tab because of the event as `sync_realm_settings`
isn't defined yet.
2018-03-29 08:00:50 -07:00
Shubham Dhama 29f57d54a0 org settings: Move discard_property_element_changes out of `_setup`. 2018-03-29 17:44:39 +05:30
Shubham Dhama e53c6f5639 org settings: Move independent functions out of `_setup` function.
This commit moves some functions out of `_setup` function which are
independent of each other and any function inside `_setup` function.
2018-03-29 17:44:39 +05:30
Shubham Dhama 4472f5b230 org settings: Prefer `val` over `attr` to change value of dropdown.
Changing the selected value of dropdown by `val` has more advantage
over `attr` especially in the case when dropdown value is chnaged
multiple times like due to events and discarding changes.

Though it is applicable to other elements but in this commit it is just
used for `id_realm_create_stream_permission` dropdown.

There are many question about this at stackoverflow:
https://stackoverflow.com/a/22093618/7418550
https://stackoverflow.com/a/4837162/7418550
2018-03-29 17:44:38 +05:30
Shubham Dhama 6ec5c28e97 org settings: Move property types out of `_setup` function.
Since we don't have any string needed to be translated in
property_types we can move it outside `_setup` function to
get to the safe side if they needed to get accessed before
`_setup` is called.
2018-03-29 17:44:27 +05:30
Shubham Dhama 86967c2be1 settings: Include settings label as context to template.
This is a preliminary commit which includes settings' (checkboxes)
label as a context for rendering template.
The reason we did this in JS code because of translation issue when
passed (as a context in `partial` handlebars helper) directly within
template.
Currently this is done for notifications' settings.
(There will be no UI change)
2018-03-28 16:17:45 -07:00
Tim Abbott 3d5b6539d1 unread: Fix confusing aliasing of variable names. 2018-03-28 12:21:36 -07:00
Tim Abbott d92af69cce styles: Rename dark-mode to night-mode.
This matches the externally-facing name for the feature as well as the
setting variable in the code.
2018-03-28 10:41:26 -07:00
Steve Howell 084ef0bea9 Fetch new messages when you scroll forward in narrows.
Note from tabbott: This is a somewhat surprising feature to be adding
this late in Zulip's development, but the model we've had of what
narrows are easy to access via clicking around has meant that it was
fairly difficult to get into a narrow that didn't include the very
latest messages in that narrow.

Fixes #3465.
2018-03-28 09:12:59 -07:00
Steve Howell 80ed8294a1 Suppress local echo when we are not caught up. 2018-03-28 09:12:25 -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
Steve Howell 4e431516bf Update message_list.all.fetch_status during frontfill. 2018-03-27 18:14:09 -07:00
Steve Howell 60c77ddf6c Update message_list.all in do_backfill(). 2018-03-27 18:14:09 -07:00
Shubham Dhama 419208cabe settings: Refactor to use pluck to extract `setting` attribute.
This is just a small refactor to use `pluck` over manually using `map`.
2018-03-27 18:01:03 -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 33b6e19e31 org settings: Remove obsolete property_types's status messages.
Since now we use buttons as a method to show saving status,
we don't need anymore `msg`, `checked_msg` etc.
2018-03-27 16:48:29 -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
Tim Abbott ac7031de3a message_list_view: Add a workaround for Chrome scrolling down bug.
Based on extensive manual testing with print-debugg (the exact
situation here was highly reproducible), in the absence of this line
here or slightly above here, Chrome 64 will consistently trigger an
extra scroll-forward-by-12000-pixels size downward scrolling event
immediately after it finishes rendering the 5th batch of ~100 messages
one gets from hitting the End key in `near:1` narrows.

I don't understand clearly why this change would protect against such
a Chrome bug, but my best guess is that Chrome was doing some sort of
incorrect optimization, and querying the scrollTop was forcing it to
come to a clear conclusion about the scrolling position before
appending more content.

But runs with the scrollTop() line not present in that function show a
scrollTop of around 25K in `append()` just before the call to
`render()`, and 37K at the end; while runs with this scrollTop line
always show 25K both before and after, so it does seem to work.
2018-03-27 13:51:28 -07:00
Tim Abbott 43ec04dcff narrow: Fix a buggy condense_and_collapse call.
Previously, when unnarrowing, we were calling this on the wrong
selector (this was missed years ago when we refactored Zulip to use
divs rather than table rows in the main message feed).

Noticed while debugging #5312.
2018-03-27 09:53:45 -07:00
Puneeth Chaganti 97b90c1e87 condense: Re-condense all messages on window resize.
Previously, if you started out with a very small window, loaded the
Zulip webapp, and then resized the window to be larger, you'd get the
condensed "[More]" links on essentially every message.  This failure
mode was most visible with multi-protocol Electron apps like Rambox
that would sloppily start with a tiny window and then resize it when
loading Zulip.

The Rambox experience was essential to our being able to track this
down; once we knew what was happening, the fix was simply to
re-compute the condense state on resize.

Commit message rewritten by tabbott to explain the debugging and
context involved here, since this was one of our longest-lived mystery
bugs.

Fixes #5312.
2018-03-27 09:53:45 -07:00
Shubham Dhama 4cf42ce478 settings: Move remove-default-stream-button handler to settings_streams. 2018-03-26 10:27:09 -07:00
Steve Howell 825f5feba4 stream_create: Finish handler cleanup.
This commit is similar to the prior commit, in that we are
more disciplined about setting up handlers.  We set them up right
as the widgets get rendered, and the handlers only delegate
up to the container div (id="stream_creation").
2018-03-26 06:44:19 -04:00
Steve Howell 954fceeed6 stream_create: Make handlers more modular for users.
We now wire up the handlers that correspond to elements in
the 'new_stream_users' template when we render that template,
rather than at startup time.

We also delegate the events only up to #people_to_add, rather
than all the way up to body/document.
2018-03-26 06:44:19 -04:00
Steve Howell 04e25fe2a2 Extract stream_create.create_handlers_for_users(). 2018-03-26 06:44:19 -04:00
Shubham Dhama eb0da20b78 settings: Clean up repeating code in error callbacks.
This cleans repeating code in error callback in settings.
We made a generic function in `ui_report.js` which require two
arguments `xhr` and `btn`; we preferred `btn` over `row` as argument
because a row may have more than one buttons.

Fixes: #8788.
2018-03-25 10:40:40 -07:00
Shubham Dhama 3e47a9fe22 org settings: Add real-time syncing for property changes. 2018-03-25 08:30:47 -07:00
Shubham Dhama 315058498b org settings: Handle dependent sub settings manually.
This replaces the previous logic of triggering change() event.
(Also, when we trigger the change() event whole path for detecting
changes in a subsection are triggered which isn't good.)
2018-03-25 08:30:04 -07:00
Shubham Dhama 84a5786b2e org settings: Refactor the discard changes function.
This extract the logic of resetting the value of a single property element
at a time so that we can reuse this for real-time-syncing.
2018-03-25 08:30:04 -07:00
Shubham Dhama a779fc6095 org settings: Use disable_sub_setting_onchange for dependent checkbox.
This makes use of `settings_ui.disable_sub_setting_onchange` for
handling dependent `id_realm_disallow_disposable_email_addresses`
checkbox when `id_realm_restricted_to_domain` is changed.
2018-03-25 08:30:04 -07:00
Shubham Dhama f17fa3305b org settings: Fix discard changes for realm_create_stream_permission.
On discarding changes made for `realm_create_stream_permission` always
"by_admin_user_with_custom_time" get selected because
`create_stream_by_admins_only` isn't a valid page_param.
2018-03-25 08:30:04 -07:00
Shubham Dhama ce156dd21d settings_ui: Revert extension for success callback in do_settings_change.
This reverts success callback extension for `do_settings_change` function
because it seems it is better to make the request directly rather
than calling `do_settings_change`.
And hence `error` callback extension is also removed  for the same
reason, but a error_continuation is added to do additional tasks when
errors happened.
2018-03-25 08:30:04 -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 e30b619ad5 Fix leaky O(N) email hint handler.
We only have one possible email hint, so there's no reason
to create one for each stream row, especially since we don't
clean them out when we close stream settings.
2018-03-25 08:28:04 -07:00
Steve Howell 45f0df6d31 message view: Removed message_rendered.zulip event.
We don't have any consumers for this event after removing
some obsolete code related to subscribe buttons.

Handling this event reliably consumed about 75% of the time
spent in _post_process_dom_messages, and maybe a percentage
point or two of overall rendering, so this will be a minor
speedup.
2018-03-24 12:31:36 -04:00
Steve Howell 4f05cefb32 Remove obsolete code for stream subscribe buttons.
In 18e43895ff we replaced
stream subscribe buttons with stream links.  The new feature
has been well tested and well received for over a year now,
so it's safe to remove the older feature at this point.

Older sites will have super old messages that still have the
rendered markup; this commit does not attempt to address those
situations.  Most likely, clicking on an old button in the old
message will either do nothing or look like a message reply.
2018-03-24 12:31:36 -04:00
Tim Abbott 51073afc36 subs: Remove incorrect expectOne() in settings_button_for_sub.
This removes an assertion added in
b6408a0383 that was only true if that
stream's edit UI was visible.
2018-03-23 15:24:42 -07:00
Tim Abbott 195b96c989 lightbox: Add debugging code for unknown message IDs.
This should help debug a traceback we've been seeing in production
where the fetched message was undefined.
2018-03-23 15:17:21 -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
Tarun Kumar 5ac767149c user-groups: Update UI to mention only members can edit a user group.
Also, we remove unnecessary tips regarding modification settings.

Remove 'Only organization administrators can edit these settings'.
Remove 'Anyone in this organization can add user groups'.
2018-03-23 14:44:47 -07:00
YJDave 886e77e858 subscription: Fix bug in display email hint popover on hover.
Fixes #8743
2018-03-23 09:55:44 -07:00
Shubham Dhama c50117418e org settings: Fix unexpected saving of input-text fields on "Enter".
Before this commit when we press enter in the text-input field the
first subsection get saved because a click event is triggered for
the first save button (of first subsection) irrespective of the
location of text input field in the whole form which is expected
as a default behavior of the forms.

The simple fix is to make the button of type "button" and override
action of "enter" in an input field.

More info at https://stackoverflow.com/a/12914700/7418550 and
https://stackoverflow.com/a/7060762/7418550
2018-03-23 07:28:46 -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
Shubham Dhama 3b7f045da5 org settings: Extract function to discard changes done in a subsection.
In the new function, property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the value of input elements like we have in org
permissions section for properties like realm_add_emoji_by_admins_only
where we have used dropdown and hence we get a string value but we
expect a true/false (check/uncheck) value.

Also, it is better to trigger a `change` event after changing a value
because we have properties which are dependent on the values of another
settings. Previously we trigger `click` event for checkboxes but
there exist some settings other than checkboxes like dropdown
for realm_create_stream_permission where realm_waiting_period_threshold
only appears after selecting custom values for threshold value from
dropdown.
2018-03-23 07:28:46 -07:00
Aastha Gupta f900f955c0 message edit: show spinner on topic change.
On clicking the checkbox in topic edit form, display a spinner and
hide the cancel icon.  Also, do not display any success message.

Fixes #8793.
2018-03-23 07:21:22 -07:00
Priyank 603dc4a2ef electron_bridge: Notify electron app when realm name is updated. 2018-03-22 22:05:44 -07:00
Priyank f0190fe0b8 electron_bridge: Notify electron app when org avatar is updated. 2018-03-22 22:05:12 -07:00
sinwar 675e844e6b team page: Add contributors of zulip-terminal.
It adds zulip terminal contributions to
team page using github apis.
2018-03-22 21:06:18 -07:00
Tarun Kumar 59b1f59605 user-groups: Add function wrappers to reduce variable scope.
Extract set_up_typeahead function.
Extract pill_remove function.
2018-03-22 16:48:46 -07:00
Sarah 91197fa4f1 org settings: Add logic for applying allow_community_topic_editing.
Applies the logic to allow community members to edit topics
of others' messages if this setting is True. Otherwise,
only administrators can update the topic of others' messages.

This logic includes a 24-hour time limit for community topic editing.
2018-03-22 16:13:36 -07:00
Anupam-dagar 865480ec42 portico: Fix positioning of "disposable email address" errors.
Modified by tabbott to prevent losing the frontend errors, and make it
more clear which errors are from the frontend vs. backend.

Fixes: #8784.
2018-03-22 14:38:57 -07:00
Shubham Dhama f97cff54aa org settings: Fix casper failing due to check_property_changed. 2018-03-22 12:51:09 -07:00
Shubham Dhama 6cdbcfd80c org settings: Refactor check_property_changed.
In this refactor property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the input elements like we do have in org
permissions section for properties like realm_add_emoji_by_admins_only.

Small refactor in property_value_element_refers is to prevent many
return statements on further addition of property names.
2018-03-22 11:44:58 -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
Shubham Dhama 22ab571b8f org permissions: Extract logic to complete request data for subsection.
To keep click handler for "save" button clean, we extracted the
the `if` statements where we complete request data for certain fields
which aren't mentioned in `property_types`.
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 82c8d43209 custom profile data: Enable user to edit custom field's value in settings.
This will enable user to edit the value of custom fields from
user settings.
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
Steve Howell a110736584 Use do_backfill() in start_backfilling_messages().
This change mostly de-duplicates code, but it also prevents
some unnecessary backfills if you're in the home view and
happen to scroll back while the idle loop is right in the middle
of a backfill fetch, or if the idle loop has taken you back
to the oldest message already.  This is a consequence of
do_backfill() calling msg_list.fetch_status functions.

Everything else should work pretty much the same, since
do_backfill() computes anchor essentially the same way we
originally doing it in the onIdle() function.
2018-03-21 14:07:00 -07:00
Steve Howell 7242fa8eb8 message_fetch: Extract do_backfill().
This slightly changes the order of operations of what we do in
the `cont` callback, so that we update fetch status earlier.
The order is somewhat arbitrary here, but we generally want to
update data structures first.
2018-03-21 14:07:00 -07:00
Steve Howell e8bc781fd5 Use message_list.all for backfill anchor for home view.
The "all" list and "home" list are basically kept in sync, and
the former is a superset of the latter.

Whenever we are backfilling, we want to backfill "all", so we use
it as the anchor, even though home_msg_list is the message list
we are actually rendering.
2018-03-21 14:07:00 -07:00
Steve Howell f524a095a2 refactor: Extract message_fetch.get_backfill_anchor().
This is just moving code.
2018-03-21 14:07:00 -07:00
Tim Abbott 1e7dc70c7f reactions: Fix the hotkey for adding an emoji reaction.
This was incorrectly migrated in
a49655e0d4a868d3973e53cf8482b91aa2df1bb1; the toggle_emoji_reaction
function didn't expect this type.
2018-03-21 13:26:24 -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
Gooca 2363c9955a ui scrollbar: Update perfect-scrollbar to 1.3.0.
Update perfect-scrollbar to fix stutter space-scrolling in #8544. Also
reworked deprecated `element.perfectScrollbar` to `new
PerfectScrollbar(element)`.  Lastly, updated provision version and
changed node module path to new path.

This also refactors perfect-scrollbar in help.js to work with updated
version of perfect-scrollbar. Because the update also changed
perfect-scrollbar's css selectors for all scrollbars in zulip, we
update those too.

Fixes #8544.
2018-03-20 21:59:11 -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
knovokresch cdd3b816bf copy_and_paste.js: Extract method for constructing recipient header. 2018-03-20 21:55:01 -07:00
knovokresch 2320a38a9c copy_and_paste.js: Extract method for constructing div with copied text. 2018-03-20 21:55:01 -07:00
Steve Howell 4edf66f927 Track fetch status of initial home message load.
This has a small stylistic change.  The load_more function
is recursive, and we now early-exit when the recursion is
finished (i.e. when we've found the newest row).
2018-03-20 15:23:29 -07:00
Steve Howell df4d325d6c Extract start_backfilling_messages(). 2018-03-20 15:23:29 -07:00
Steve Howell c282b94bab Track fetch status for initial narrow. 2018-03-20 15:23:29 -07:00
Steve Howell 0169a06f99 stream_data: Fix traceback with opening the compose box.
We need to call update_calculated_fields earlier since we
use can_access_subscribers in user_is_subscribed.
2018-03-20 15:23:29 -07:00
Shubham Dhama 679941b319 compose: Fix "compose fade" not working when private message focused.
The problem was that we now have pills instead of emails in the compose
recipient box for private messages.
Fixes: #8755.
2018-03-20 15:09:47 -07:00
Shubham Dhama 9ca335bcb2 org settings: Add discard button to discard changes for a subsection.
This will reset the changes done in a subsection to the current ones
in page_params.

It will only appear when there are some user-provided changes to be reset.
2018-03-20 14:48:59 -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
Tim Abbott 1e453981a3 stream settings: Fix exceptions when rerendering subscribers.
If another user subscribed to or unsubscribed from a stream while the
current user was not subscribed, we previously would attempt to
rerender the subscriber counts for that stream, even though they
weren't rendered at all in the first place; this would trigger
blueslip errors from the expectOne() check in this function.

Fixes #8720.
2018-03-19 10:28:24 -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
Aastha Gupta 7485461cc6 notifications: Check if localstorage is enabled.
This checks for whether local storage is enabled and if it
is not enabled, then it will skip checking the value of
"dontAskForNotifications" key in the local storage.

This should eliminate an occasional JavaScript traceback we were
seeing in production.

Fixes #8721.
2018-03-18 12:54:11 -07:00
Shubham Dhama b34b8cdb97 hotspots: Fix real-time sync for dismissing hotspots.
This closes all the hotspots which aren't included in the event.hotspots.
This means we treat all the hotspots in event.hotspots as the hotspot
which need to be shown.

Fixes: #8690.
2018-03-18 10:22:09 -07:00
Shubham Dhama 120ebc8f13 hotspots: Move the code for closing hotspot icon to hotspots.js. 2018-03-18 10:22:09 -07:00
Tim Abbott c3f94fa388 stream_create: Fix use of "realm" in an error string. 2018-03-16 16:59:02 -07:00
Tim Abbott 8a53e83cf6 help: Use more consistent module name for perfectScrollbar.
The `Ps` alias that we were using previously was potentially confusing
and made this usage harder to grep for.
2018-03-16 12:50:33 -07:00
gooca 591624972e Refactor perfect-scrollbar: Call ui methods in stream_list.js. 2018-03-16 12:47:47 -07:00
gooca 26eb60b382 Refactor perfect-scrollbar: Call ui methods in topic_list.js. 2018-03-16 12:47:46 -07:00
gooca 336d81ca4a Refactor perfect-scrollbar: Call ui methods in resize.js. 2018-03-16 12:47:46 -07:00
gooca a50054bdc1 Refactor perfect-scrollbar: Call ui methods in scroll_bar.js. 2018-03-16 12:47:46 -07:00
gooca ba05ac5c77 Refactor perfect-scrollbar: Call ui methods in emoji_picker.js. 2018-03-16 12:47:44 -07:00
YJDave e8f6b9e575 js/stream_edit.js: Remove function to update stream on subs add/remove.
Remove the functions call for updating stream settings UI in
frontend, cause we are already handling this in the subscription
add and remove event we get after successful operation.
2018-03-16 12:22:06 -07:00
Balaji2198 6ffe2cc815 compose: Fix "New Topic" button behaviour auto-populates the current topic.
Previously, Clicking a "New Topic" in a topic narrow auto-populates
the current topic.

Fixes #8608.
2018-03-16 12:01:24 -07:00
Steve Howell 12509515ae message_viewport: Call set_message_offset() for prepending.
This is consistent with other places in the code.
2018-03-16 11:44:20 -07:00
Steve Howell 58c1427859 message_fetch: Use found_oldest flag from server.
We now use the found_oldest flag from the server to determine
whether we should load older messages.

This requires us to change a few places in the code where we
pass the whole payload around now instead of just the messages.

Actually, many of the "cont" callbacks don't even look at the
data, so this change wasn't as invasive as I might have
predicted.
2018-03-16 11:42:52 -07:00
Steve Howell 9105692b07 Add typing.initialize() to prevent tracebacks.
We now wait to start typing notifications until everything else
is initialized.  This prevents traceback where things like compose
pills have not been initialized.
2018-03-16 09:23:23 -07:00
sreenivas alapati a2fa087235 attachments_ui: Remove unnecessary export of bytes_to_size. 2018-03-15 18:06:04 -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 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
Shubham Dhama c4fda0e19e org settings: Extend populate_data_for_request for selected property types.
To populate data for requests limited to only selected input elements,
we have to extend `populate_data_for_request` for objects other
than `property_types`, e.g. now we can collect data only for user identity
by passing org_permissions.user_identity as changing_property_types.
2018-03-15 17:06:45 -07:00
Shubham Dhama c4d0fb602c org settings: Split `property_types` according to sections.
This splits property types according to sections in
"Organization settings" viz. Organization settings, Organization
permissions, and Organization profile. Where org. settings and
org. permissions are further categorized according to the
subsections.
These changes are made to save changes for each subsection independently.
2018-03-15 17:06:45 -07:00
Shubham Dhama 0bd5a7cf29 settings_ui: Extend `do_settings_change` for other request methods also.
With this, we need to send channel request method callback as an
argument while calling.
2018-03-15 17:06:45 -07:00
Shubham Dhama 01a160de5e settings_ui: Extend do_settings_change for other optional parameters.
This extends `do_settings_change` function for parameters like
`success` and `error` functions which will replace the default ones,
for functions that need to be excuted in success callbacks and for
desired success message.
All these parameters are optional.
2018-03-15 17:06:45 -07:00
Shubham Dhama 95067ddb08 org settings: Disable "Add filter" button when a request is in transit.
This prevents accidental multiple click requests due to which we get
some errors like "This field cannot be blank" (though we have successfully
added the desired filter).
Fixes: #8699.
2018-03-15 13:56:15 -07:00
Shubham Dhama 233e1b4b1b org settings: Clear input fields of filter settings on success. 2018-03-15 13:56:15 -07:00
Tarun Kumar dafaf28099 user-groups: Update user_group_name_dict, when name/description is edited.
We do not update user_group_name_dict when name or description is edited,
which may lead to errors if get_user_group_from_name is called, so to fix
that we update user_group_name_dict also.
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 5a9b1f863f drafts: Fix same day's timestamp when language is other than english. 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
Tarun Kumar 81a1612cbd user-groups: Fix reordering when name/description is edited.
The edited group iswas going to the bottom, it is not staying at its
position, so to fix this we sort by ids of the groups to maintain
proper relative order.

(Original commit also fixed another issue, but Tim replaced that with
the previous commit for a better solution).

Fixes #8692.
2018-03-14 10:12:46 -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
YJDave efffc07351 stream settings: Don't show add-subs-btn if user can't add subscribers.
Even if realm admin can access unsubscribed private stream subscribers,
admin can't add subscriber to stream. Hide the option to add subs to
stream in UI.
2018-03-14 09:21:14 -07:00
YJDave 2031118545 stream settings: Allow realm admins to access all private stream subs.
This will allow realm admins to access subscribers of unsubscribed
private stream.  This is a preparatory commit for letting realm admins
remove those users.
2018-03-13 14:59:09 -07:00
YJDave 37f9d5c193 stream settings: Allow realm admins to update any stream name & description.
This will allow realm admins to update the names and descriptions of
private streams even if they are not subscribed, which fixes the buggy
behavior that previously nobody could(!).
2018-03-13 14:59:09 -07:00
YJDave 3b8c2e45be user settings: Fix user avatar not updated in settings page.
On uploading new avatar, user avatar in settings page doesn't
get updated. Cause we have set `src` attribute of wrong html
element instead of image element in user settings page.

Fixes #8680.
2018-03-13 10:57:36 -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
Tim Abbott 4ae1418831 popovers: Rename confusing my_email to user_popover_email. 2018-03-12 12:24:50 -07:00
Priyank Patel 29c6d23043 user profiles: Add copy-to-clipboard btn for long emails.
Implements copy to clipboard btn that shows up if email is too long.
Making it easier for user to copy long emails.
2018-03-12 12:06:40 -07:00
Rohitt Vashishtha 3710252eba portico: Prevent Firefox from bfcaching the page.
Firefox stores the last state of the page in its back/forward cache
in memory and uses that for quickly rendering the page. Since our page's
last state was 'faded-out', the content wasn't visible when the browser
rendered the page from it's bfcache.

Fixes #7907.
2018-03-11 22:17:18 -07: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
Aastha Gupta dc60b3a44b compose: Don't clear compose box on narrow if it matches compose.
If we're entering a topic narrow, and the compose topic is the same as
narrowed topic, then leave the compose box open.

This is important if you open compose in a topic narrow, click on a
narrow, and then use the back button to return to that original
narrow.  Before this change, we'd close the compose box for no reason.

Fixes #6510.
2018-03-11 21:25:23 -07:00
Harshit Bansal e3c09e0308 settings: Prevent multiple requests while adding custom emoji.
This commit fixes a hard to reproduce issue which was causing
multiple requests while creating a realm emoji.

Fixes: #8475.
2018-03-11 16:17:47 -07:00
YJDave b6408a0383 stream settings: Fix sub-unsub btn not showing on private stream creation. 2018-03-11 15:58:18 -07:00
YJDave ff6d83b2f2 stream settings: Fix subscribers not showing on private stream creation.
Previously, stream subscribers were not rendering correctly. Due to
following reasons:
- Subscribers list didn't get initialized
- Subscriber members template add subscriber-list-table DOM element
  conditionally, which doesn't handle case if user have access to
  subscribers later.

Fix this by cleaning subscriber member template to hide the
elements, instead of conditionally adding DOM elements and
initialize subscribers list even if user can't access subscribers.
2018-03-11 15:58:18 -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 87f1516f5d subs: Harden subscriber count code path against bugs.
This expectOne() should catch some classes of bugs here.
2018-03-10 10:00:14 -08:00
Tim Abbott 12db219305 stream settings: Fix subscriber counts when creating invite-only streams.
Previously, when creating an invite-only stream, the subscriber counts
were not being rendered properly, in that the "create" event for the
stream had the user not yet subscribed (so can_add_subscribers was
false), and then the rerendering we did when the user susbcribed just
tried to update the number, not actually rerender the thing.
2018-03-10 10:00:14 -08:00
Tim Abbott ddef39832f subs: Reverse conditional for rerender_subscribers_count.
This is for more consistency with rerender_subscribers_list.
2018-03-10 10:00:14 -08:00
Tim Abbott a0d33fa1cf subs: Use sub_for_stream_row helper more consistently.
This cleans up a bunch of hard-to-read duplicated jQuery code.
2018-03-10 09:41:24 -08:00
YJDave e50cedfcb8 stream settings: Remove stream from subscribed list immediately on unsub.
When user click on unsubscribe button, to unsubscribe from private stream
immediately remove unsubscribed stream from all subscribed stream list.
We don't remove public stream immediately on unsubscription, cause
user may want to undo/subscribe back to stream.
2018-03-10 09:35:47 -08:00
YJDave 32407b4dc0 stream settings: Hide stream members immediately on unsub, if can't access.
If user unsubscribe from private stream, then user can't
access unsubscribed stream members.
After subscription removal, immediately render subscription members
template in case of user can't access stream subscriber.
2018-03-10 09:32:45 -08:00
YJDave c94b21e9ac settings: Add setting to disable message content in missed message emails.
Fixes #6938.
2018-03-09 21:16:02 -08:00
YJDave 7cc675cfc1 create stream: On stream create event, add sub to stream lists.
Currently, our stream creation do not add stream list to all
stream list. Only subscription-add event add stream list to
stream list. If public stream is created without acting user
subscribed to stream, then newly created stream is not listed
to all stream list.

On stream creation add sub to all stream list table.
2018-03-09 18:29:16 -08:00
YJDave 9183d59426 create stream: Restrict non-admin to create stream without subscribing.
Only allow realm admins to create stream without subscribing
themselves, restrict non realm admin users.

This new restriction is only for the UI; we don't actually block it at
the backend/API level (one could always create and then remove oneself
anyway).
2018-03-09 18:20:14 -08:00
Tim Abbott b8fd24b13d stream_create: Clear errors when re-submitting form.
Previously, if you fixed the errors and then tried to re-create a
stream, you'd see an error.
2018-03-09 18:15:46 -08:00
YJDave e9e6b126ec create stream: Don't allow creating stream with zero subscribers.
Restrict users(even realm admins) from creating stream with zero
subscribers only in UI.
In backend, if subscribers are zero, we automatically subscribe
current user to stream.
2018-03-09 18:09:38 -08:00
YJDave c3a289b473 create stream: Add div element indicating stream creation result.
Add div element to inform user whether stream is successfully
created or not. This will help to inform user in case if current
user is not subscribed to created stream.
2018-03-09 18:09:38 -08:00
YJDave 3280135a4c stream settings: Update subscription count on subscription event.
On subscription add or removal event, render subscription count
template in case of user can't access subscribers.
2018-03-09 18:00:49 -08:00
Tim Abbott c5904499db stream_data: Move calls to update_calculated_fields to events layer.
This migrates what were effectively data update functions to be called
from the main stream_events handlers, instead of being called from the
view-update code in subs.js.
2018-03-09 18:00:31 -08:00
YJDave cc2eb60ca5 stream settings: Fix error in rendering stream members in UI.
To re-render stream members on subscription add or remove event,
we are accessing undefined value "active_stream.stream_id" rather
than "active_stream.id", which resulted in falsey value and our
stream members were not updated unconditionally.
2018-03-09 18:00:20 -08:00
YJDave 777841781f stream settings: Hide stream membership part, if can't access subs.
Do not display stream membership section in stream settings,
if user not allowed to access stream subscribers.
2018-03-09 16:24:05 -08:00
YJDave c1f9b04435 stream settings: Don't show never subscribed private stream's preview-link.
For public stream, always show stream preview link.
For private stream, only show stream preview link if user is currently
subscribed or previously subscribed to private stream.
2018-03-09 16:24:05 -08:00
Steve Howell 616a06e5b2 Use msg_list.fetch_status instead of load_enabled.
We now attach a fetch_status to message lists, so that they
can track their fetch status individually.  When you go
back in a narrow and get all the older messages, we turn
off future fetches.

The narrow.js code no longer needs to orchestrate anything
here.  The "home" message list won't have as many redundant
fetches after this commit, because we don't need to reset
flags every time we do `narrow.deactivate`.

And then actual narrows get a new message list every time
you narrow, so their fetch status gets reset implicitly
as part of constructing the MessageList object.
2018-03-09 14:20:58 -08:00
Steve Howell 1e446fcb1a refactor: Call message_scroll.hide_indicators() directly.
We are going to remove message_fetch.reset_for_narrow() soon,
but its callers probably still want to hide any scrolling
indicators, and we just let them do that directly.
2018-03-09 14:20:58 -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
Steve Howell ec305149be Extract message_fetch.load_messages_for_narrow().
This helps us consolidate the fetching constants without
having to export them.  It will also remove some
responsibility for narrow.js to track fetching state.
2018-03-09 14:20:58 -08:00
Steve Howell 22162a02a8 Remove unused cont_will_add_messages flag.
(It was always false.)
2018-03-09 14:20:58 -08:00
Priyank cd48236756 electron_bridge: Send unread count to electron app on update. 2018-03-09 14:12:33 -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
Steve Howell 7bbdf79b78 Rename functions to show_loading_older/hide_loading_older. 2018-03-09 11:04:29 -08:00
Steve Howell 389421d9c2 Rename reset_load_more_status to reset_for_new_narrow.
We are about to make this logic a little more specific to
what happens when you make a new narrow.
2018-03-09 11:04:29 -08:00
Steve Howell ae84908eca Rename load_more_messages to maybe_load_older_messages.
We will soon have maybe_load_newer_messages as well.
2018-03-09 11:04:29 -08:00
Steve Howell 68d3441de1 Rename load_old_messages to load_messages.
This function will eventually sometimes load messages that
are "new" relative to the messages that have already been
loaded.
2018-03-09 11:04:29 -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
Robert Hönig 35c7428490 frontend: Add create-bot loading indicator.
The former "the-bot-is-being-created" indicator was useless,
since it only edited the value attribute of the "create-bot" button;
that attribute only sets the text of a button when it is initially created.

This commit replaces the old code with a spinning loading indicator,
like the one used for editing bots.
2018-03-08 15:05:00 -08:00
Steve Howell 47f3af9e50 refactor: Extract constants in message_fetch.js.
Having constants at the top is particularly convenient
for tweaking things while testing the fetch code.
2018-03-08 15:03:47 -08:00
Steve Howell 571773564f minor: Use message_viewport.at_top() in scroll_finished.
This effectively changes a condition from `=== 0` to `<= 0`,
but that probably doesn't matter (and would only help).  More
importantly, it just makes the code more consistent.
2018-03-08 15:03:47 -08:00
Steve Howell b8f39b2ff1 refactor: Early-exit in message_scroll.scroll_finished.
This is just cosmetic to flatten the function a bit.
2018-03-08 15:03:47 -08:00
Steve Howell 8063f73f6d Extract message_scroll.js.
This mostly moves code from ui.js.

We change the arguments to `message_fetch.load_more_messages()`
to be `opts` with callbacks for `show_loading` and `hide_loading`.

We also defer starting the scroll handler until `message_fetch.js`
has been initialized.
2018-03-08 15:03:47 -08:00
Steve Howell 7819319695 minor: Remove unused `ui.have_scrolled_away_from_top`. 2018-03-08 15:03:47 -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
Shubham Dhama a0ab87bef2 notifications: Clean and automate global notifications update handler.
To prevent specifying notifications individually for global
updates, automate handle_global_notification_updates using
settings_notifications.notification_settings where we have
the keys of all the types of notifications.
2018-03-08 07:19:48 -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 60f08b069c reload: Handle errors with compose_actions.start().
If we have bugs in our compose code, we don't want them to
cause other strange side effects during reload.  (We recently
had a test deployment that was a bit buggy, and the reload
problem was tough to chase down due to the misleading
symptoms.)
2018-03-07 15:53:11 -08:00
Steve Howell c7ad2a5a8e minor: Simplify declaration for reload.initialize().
We are moving away from this pattern in our code.

    export.foo = function bar__foo() { ...};
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 1aba722e63 user_pill: Add Zephyr logic.
For Zephyr realms we have to be more lax with email validation.

This will be relevant for compose pills.
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
Tim Abbott 0d29864c6a setting: De-duplicate logic for bulk-updating notifications settings.
In the new data model, this duplication was unnecessary.
2018-03-07 15:21:17 -08:00
Shubham Dhama 2782a5d8dc settings: Update notification settings to new feedback style.
This split notification settings to separate settings for streams,
PM/mention and other notifications settings.
Previously we have to treat them combined, but with this refactor,
we can treat them separately for future changes.

Fixes #8587.
2018-03-07 15:21:17 -08:00
Tim Abbott b55f881447 settings: Split notification_settings into a few sub-variables.
This refactor has no functional effect, but sets us up to be able to
do the next refactor.
2018-03-07 15:20:53 -08:00
Akash Nimare cd84fde8c5 apps: Update desktop app to latest release v1.8.2. 2018-03-07 14:09:35 -08:00
YJDave b358fb2c42 org settings: Hide table-list-data until page gets load.
Until page gets load, table lists are empty. Which results in
showing empty-data-text("No data match to search query") in
setting page parallel to loading spinner.

Hide table-list and show loading spniner until
setting page and table-list gets load.
2018-03-07 13:34:50 -08:00
YJDave f46d925208 org settings: Fix issue, loading spinners are not visible.
In org settings, loading spinners are not visible, currently
because their size is very small.

Fix this, by increasing width and height of spinners and
adding spinner text, to make spinners more visible.
Fixes #8502
2018-03-07 13:34:50 -08:00
Shubham Dhama a5812544ec settings: Fix real-time sync with notifications settings.
The if condition in "update_global_notifications" case was always false.
Similar to c672a1c.
2018-03-07 17:05:15 +05:30
YJDave a059247398 message editing: Fix bugs in `recipient-row` template rendering.
In `recipient-row` template, if conditions to add/hide/show edit
icon for message topic is incorrect.
In some cases, we only want to just hide the edit icon, but icon
should be in DOM, cause in future if organization settings are
changed we want to show edit icon in message row.

If user can edit topic of message, surely add edit icon element to
DOM regardless of user is allowed to edit or not. If user is
allowed to edit then show edit icon otherwise hide edit icon element.
2018-03-06 07:17:28 -08:00
YJDave eb67c46928 message editing: Move update msg-topic-edit-icon func to `message_edit.js`.
Move function `update_message_topic_editing_pencil` to file
`message_edit.js` from `settings_org.js`.
2018-03-06 07:17:28 -08:00
YJDave a4366d9a6d message editing: Clean update msg-topic-edit-icon function.
`update_message_topic_editing_pencil` function update edit
icon for message topic in message row header.

- Remove erroneous `meta.loaded` check.
- Add proper check of message editing permission in realm
  before updating message-topic-edit-icon in function.
- Update `always-visible-topic-edit` element in function
  simultaneously.
2018-03-06 07:17:28 -08:00
YJDave d360a70523 static/js/settings_org.js: Rename func which updates msg-topic-edit-pencil.
Rename `toggle_allow_message_editing_pencil` to
`update_message_topic_editing_pencil` in `settings_org.js`.
As this function update the pencil icon for updating message
topic in message row header.
2018-03-06 07:17:28 -08:00
Aditya Bansal 06cabc1e8a popovers: Fix issue with user-info-popover in legacy mention messages.
We fallback to using data-user-email attrib for mention messages
from the times when we use to expose user emails to frontend.
This is only required for cases where we are dealing with anything
that isn't rendered dynamically (like the messages that were already
sent and stored long time ago). Hopefully we won't be needing this
kind of fallback logic in more places so I am putting off efforts
to try to extract fallback logic for common use. Also this is like
this because it will probably be tricky to extract out a common
fallback logic in this case because of different situations involved.

Fixes: #8588.
2018-03-06 06:41:17 -08:00
Shubham Dhama 3fb862533f upload: Fix upload under message edit mode when edited using hotkeys.
This refactors the attachment of jQuery-filedrop handler into
`message_edit.start_edit_with_content`.
2018-03-05 10:42:38 -08:00
Tommy Ip 5ee6c608c0 message edit: Allow uploading files.
Fixes: #198.
2018-03-05 10:42:38 -08:00
Tim Abbott 787d5c50e0 upload: Inline clear_out_file_list.
This provides a slightly clearer interface, allowing us to remove the
unnecessary split of the code for the clone_file_input concept across
multiple modules (we now just clone it on-demand).
2018-03-05 10:42:38 -08:00
Rhea Parekh 416f11030f user settings: Display avatar source.
This makes it easier for users to tell how Zulip ended up with an
avatar for them without them uploading one: through the Gravatar
service used across many Wordpress blogs.

Fixes #8225.
2018-03-05 09:12:59 -08:00
YJDave d36ec962bb deactivation-stream-modal: Make stream name a template variable.
In stream deactivation modal, make "stream_name" a template variable,
rather than patching stream name to modal header in javascript.
Add tests for deactivation stream modal.
2018-03-04 19:26:50 -08:00
YJDave 8ba91e48c1 stream settings: Add delete stream button.
Add option to delete stream in stream setting page for
realm admins only.
2018-03-04 19:26:50 -08:00
YJDave 077e56e3b6 static/js/settings_streams.js: Refactor delete stream method. 2018-03-04 19:26:50 -08:00
Tim Abbott fb340811a4 display_settings: Fix pencil being lost updating default language.
The HTML was just done sloppily in the first version of this feature.
2018-03-04 19:23:58 -08:00
Tim Abbott 9acf30b3d3 display_settings: Fix real-time sync of default language.
We apparently weren't sending to the frontend the data needed to
update the display of the current language.
2018-03-04 19:23:58 -08:00
Tim Abbott c9724fe284 display_settings: Clean up and mark real-time sync issues.
This fixes the real-time sync of the settings state for night mode,
and also makes it clear where a few outstanding bugs are in this
page's sync.
2018-03-04 18:38:14 -08:00
Tim Abbott c672a1c112 settings: Fix real-time sync for display settings.
The conditional we previously had in server_events.js was always
false.
2018-03-04 18:32:05 -08:00
Tim Abbott cec34302be settings_ui: Move main function for new settings system to library code.
This should make it much easier to convert other checkboxes in the
product to use this mechanism.
2018-03-04 18:26:27 -08:00
Tim Abbott 4d8e18e58f settings: Move display_checkmark to settings_ui.js. 2018-03-04 18:26:27 -08:00
Tim Abbott 6a06e453c7 display_settings: Extend de-duplication of unnecessary logic.
We add a new option to the change_display_setting function to support
cases with a custom on-success or on-failure message.
2018-03-04 18:09:46 -08:00
Tim Abbott 7dbd515191 settings: De-duplicate code for managing display settings.
Now that we have a common framework here, there's no need for so many
copies of the channel.post logic.
2018-03-04 17:59:54 -08:00
Balaji2198 5aa7098c81 display_settings: Change success/failure feedback interface.
This replaces the cumbersome system we had for giving users feedback
on settings state changes in the display settings UI.

We expect this new system to be what we will attempt to migrate other
settings widgets to match over the coming weeks and months.  It also
provides the opportunity to significant refactor away a lot of the
code duplication in settings_display.js.

Thanks to Brock Whittaker for redoing the styling and improving the
code simplicity.

Fixes #7622.
2018-03-04 17:47:05 -08:00
Balaji2198 b846ab1000 settings: Change wordings of all alert-status in Display settings. 2018-03-04 16:36:56 -08:00
Marco Burstein bdb86f1b5e emoji: Add support for translating emoticons.
Add `translate_emoticons` to `prop_types` and `expected_keys`.
Furthermore, create a emoji-translating Markdown inline pattern.

Also use a JavaScript version of `translate_emoticons` and then use
this function during Markdown previews and as a preprocessor. This
is only needed for previews, because usually emoticon translation
happens on the backend after sending.

Add tests for emoticon translation, a settings UI, and a /help/ page
as well.

Tweaked by tabbott to fix various test failurse as well as how this
handles whitespace, requiring emoticons to not have adjacent
characters.

Fixes #1768.
2018-03-04 15:37:24 -08:00
YJDave 8cd3e55fae default stream: Fix default stream suggestion do not include private stream.
Private streams were not included in stream suggestions for default streams
in org settings.
Remove function, which exclude private streams from stream suggestions
for default streams.
2018-03-04 13:42:28 -08:00
Shubham Dhama bfcfe84bdd compose: Append space when text added at the end of textarea.
This appends a space when text is inserted at the end of a message
using `compose_ui.insert_syntax_and_focus`.  This is definitely what
users expect when using this feature.

Fixes: #8569.
2018-03-04 13:16:17 -08:00
Shubham Padia e15a22dae2 message-editing: Topic_data.remove_message on delete_message dispatch.
Fixes #8411.
If the last msg in a topic is removed, that topic is removed
from recent topics in the streams left sidebar.
2018-03-04 13:10:26 -08:00
Tim Abbott aed8cc9062 user_groups: Handle add/remove members events.
This fixes the real-time sync for the user groups membership data
structure to work like these work in the rest of Zulip; now, edits
made in one browser are immediately and correctly reflected in other
browsers.
2018-03-04 09:45:31 -08:00
Tim Abbott 0147826042 user_groups: Convert members to a dict in frontend. 2018-03-04 09:45:31 -08:00
Tim Abbott 3a14317376 user_groups: Move meta.loaded check to actual exported interface.
This should fix an exception that we were seeing where the expectOne()
check would fail if the user groups page hadn't been rendered yet.
2018-03-04 09:40:56 -08:00
YJDave 59cf67062f settings: Add generic func to disable settings elements in UI.
We have some settings which are inter-dependent. If one setting
is checked or unchecked, it's dependent-sub-setting get disabled
or enabled. i.e. If user unchecked setting allow-message-editing
then message-editing-time-limit setting should get disabled in UI.

Add generic function to change disable attribute of sub settings
on checked or unchecked event of main setting in `settings_ui.js`.
2018-03-03 08:38:54 -08:00
YJDave f5a24efdd8 static/js: Add `settings_ui.js` file for common settings UI functions. 2018-03-03 08:38:54 -08:00
Tim Abbott 92ba40b0c7 settings: Use .attr() properly for disabling name/email change.
It turns out the consistent `.prop()` approach I switched to a few
commits back didn't actually work.  Instead, we establish consistency
by always using `.attr`, which does.

Usually, I'd go back and fix the older commits, but in this case it
feels not worth it.
2018-03-02 12:49:46 -08:00
Tim Abbott 72a31150f7 settings: Move name/email change display commits to correct file.
These most properly belong in settings_account.js, since they are
updating the UI widgets on that page.
2018-03-02 12:49:36 -08:00
Tim Abbott 9fe0f81f4a settings: Simplify is_admin logic for name changes.
This now also should correctly handle when a user's state as to
whether they are an admin changes.
2018-03-02 12:49:36 -08:00
Tim Abbott 4e32b5df00 settings: Rename functions for updating email/name change UI.
These functions no longer do a toggle.
2018-03-02 12:49:36 -08:00
Tim Abbott 63db3e0b3d settings: Fix erroneous meta.loaded check for name/email change.
That check is for the settings_org.js page, which is of course not
actually the page that these fields are on.
2018-03-02 12:49:36 -08:00
Tim Abbott 9b8c541a74 settings: Set state of name/email change fields from data.
Rather than having a toggle function that just flips the state, it's
more correct to have the state just be set to what it should be.

Also, we clean up the use of .attr() for a thing better accessed via
.prop().

We should probably rename the function at this point, but we save that
for a future commit.
2018-03-02 12:49:32 -08:00
YJDave ce46cd914a settings: Allow admin to change email/name even if it is disabled in realm.
Allow realm admin users to change their email or name even,
changing name or email is disabled in realm.
2018-03-02 12:17:00 -08:00
Tim Abbott 483876ff9a typeahead: Remove check for impossible case.
The pre-matching that occurs before we even get here makes it
impossible for this case to occur, and it causes a test coverage
error.
2018-03-01 21:22:59 -08:00
Shubham Padia 8722c755e3 onboarding: Add bouncing ? next to hotspots.
Fixes #8124.
Adds bouncing question mark with twice the frequency of the
pulse.
2018-03-01 20:23:51 -08:00
Tim Abbott 542f4766d3 typeahead: Fix last word issues with latest typeahead feature.
Apparently, a bug in my refactor in
5edbcb87fd meant that "King L" would end
up matching "King Hamlet", because we weren't requiring a match at the
start of the word for the last word of a multi-word query.

Thanks to Greg Price for the report.
2018-03-01 16:00:33 -08:00
Tim Abbott 5edbcb87fd typeahead: Rewrite query_matches_source_attrs to be obviously correct.
This restructures this fairly complicated function to a much cleaner
implementation, with fewer unnecessary variables and a cleaner flow.
While we're at it, we document the function.
2018-03-01 14:45:09 -08:00
YJDave 245d65eb9e compose typeahead: Don't autocomplete for suffixes followed by a space.
For "#word text" (and similar situations, like "@word text" and
":word text"), we should only show the autocomplete for entries
where word matches the full first word of something being
completed (and similarly for multi-word phrases).

Fixes #8279
2018-03-01 14:45:09 -08:00
Alena Volkova e4a62aa778 compose: Add a function for handling validation errors. 2018-03-01 08:40:51 -08:00
Robert Hönig 695b3e48e8 frontend: Add embedded bot config data editing. 2018-03-01 08:25:43 -08:00
Robert Hönig 7b7f4cc62d bot settings: Generate embedded bot selector in handlebars.
It's better to do stuff like this in HTML templates like
handlebars instead of JS.
2018-03-01 08:25:43 -08:00
Robert Hönig 044b0beeab frontend: Store embedded bot data in bot_data.js.
In specific, this stores config_data and service_name
for embedded bots.
2018-03-01 08:25:43 -08:00
Shubham Dhama d6a38901ae compose: Fix clearing of existing text on replying from popovers.
compose_action.respond_to_message and compose_action.start starts new
compose box so we should check whether we are already composing
or not. So, behavior, when we are composing, is that the user we want
to mention is added to the same compose-text without the changing stream
and topic name.
2018-03-01 08:00:42 -08:00
Shubham Dhama dcac002213 compose: Use insert_syntax_and_focus to insert text in compose textarea.
Use compose_ui.insert_syntax_and_focus() when we need to insert text
inline-ly followed by the focus to compose textarea because it does
this job more smartly(it take cares of spaces).
2018-03-01 08:00:42 -08:00
Shubham Dhama c995c1a36a popovers: Fix two click handler attached to (rightbar) user_popovers.
No need to have separate click handler for user_popovers and
message_info_popovers as the same user-id can be extracted similarly
from the target of both the click events.

Another refactor, `sender_info_popover` was confusing as it doesn't
fix into the context of rightbar user popovers so changed it to
`info_popover_actions` since that section of popovers contains popover
actions.
2018-03-01 08:00:42 -08:00
Aastha Gupta d124597f4b org-settings: Add setting to turn off welcome emails.
This adds an organization-level setting to provide an option to turn
off the welcome emails.

Fixes #8000.
2018-02-28 12:39:01 -08:00
elenaoat 7b455f597b compose: Add spaces around markdown for attachments.
If your cursor is in the middle of a word when you upload
an image, the code will now properly put spaces in the markdown
around the attachment link.

Fixes: #7212.
2018-02-27 11:58:36 -05:00
Abhigyan Khaund a75f0aa594 hotkeys: Add "p" to narrow to next unread PM thread.
This works simimlar to the "n" key for next topics.

This commit does a few things:

    * It wires up the hotkey to an existing function
      that could change narrows.
    * It adds documentation.
    * It adds logic to make sure the compose box does
      not open.

@showell helped a bit with the wording of comments here.

Fixes #4874
2018-02-27 07:20:31 -05:00
Catherine Kleimeier d032e1ad96 Node Unit Tests: Create test for notifications.message_is_notifiable
We create a node unit test,
with 'muting' and 'stream_data' modules as dependencies,
to test the logic in notifications.message_is_notifiable.

Part of #2945
2018-02-26 16:50:14 -05:00
Aastha Gupta 2f99e6b7b2 settings: Add loading indicator for account deactivation.
Fixes #8175.
2018-02-23 08:20:45 -08:00
Sampriti Panda 90c89dcc5a copy_and_paste: Fix quirks with some parts of toMarkdown.
* Raw links don't use the proper markdown syntax and get pasted as is.
* Text in Ordered List format are not escaped like in normal markdown.
2018-02-22 08:26:45 -08:00
Umair Khan 7ad177abe6 i18n: Flag emojiset type name string for translation.
The other emojiset types are things like "Google", and "Twitter",
which don't need to be translated.  And the string is already tagged
for translation as a variable where it is used here:

  static/templates/settings/display-settings.handlebars#L87

Fixes #7970.
2018-02-22 05:36:03 -08:00
Shubham Dhama b17d4e193c popovers: Show hotkey reminder for sender info popovers only.
Hotkey reminders in user popovers( i.e. `@` and `R`) should be present
only for sender info popovers, hence for user-mention and user-presence
popovers it will show no such reminders.

Fixes: #8313.
2018-02-21 13:06:22 -08:00
Harshit Bansal cf203db78a emoji: Remove now unused `emojis_name_to_css_class` dict. 2018-02-21 12:48:27 -08:00
Harshit Bansal 31baf25783 emoji picker: Change the delimiter used in `emoji_id`.
We were using underscore as a delimiter in `emoji_id` in emoji picker
but since `emoji_type` also contains underscores, it seems wrong to
use underscore as a delimiter. This commit switches `emoji_id` to use
comma as a delimiter instead of underscore.
2018-02-21 12:48:27 -08:00
YJDave 105093e3f4 org settings: Fix bug in edit user-name-form in active user setting.
In active user settings, when user click on user-name-form to edit
user's full name, we don't set any default value for full-name
input field, which results in garbage or falsy value in input field.

Set true value of selected user's full name in input field by default
in user-name-form.
2018-02-21 09:16:45 -08:00
YJDave 4119eb342d org settings: Display error message on top of active user setting page.
Currently, an error message on active user setting is showing at
the row of edited user profile in user-profiles-list-table.
Instead, show error message on top of setting page.

Tweaked by tabbott to also remove the HTML element.
2018-02-21 09:11:53 -08:00
YJDave dc2b505acb org settings: Fix bug in error reporting on active users setting.
In active users setting, an errors occurred on editing user
profiles, are not reported correctly because there is missing
argument in call of ui_report.error() function.
Fix the issue by passing proper arguments in ui_report.error()
function call.
2018-02-21 09:11:46 -08:00
Brock Whittaker 4d54515455 input-pill: Add copy override functionality for input pills.
When a pill is selected and you press copy, it will by default return
the value, but it can be overridden with the `onCopyReturn` function.
2018-02-20 14:18:11 -08:00
Brock Whittaker bee0fa4001 input-pill: Disable input of commas with invalid pills.
A user should not be able to start forming a new pill if the previous
pill is invalid.
2018-02-20 14:11:51 -08:00
Brock Whittaker 4cd25fb861 input-pill: Add multiple pill support with pasting.
This allows for pasting in comma separated lists that will validate
pills on paste, along with creating an API for inserting many pills.

This now allows in the `input_pill.pill.append` a comma separated list
that will then call the `insertManyPills` method that will break up the
input and then call `append`.
2018-02-20 14:11:47 -08:00
Akash Nimare 9dba134c7a markdown: Do not use CMD+CTRL on macOS.
This fixes an issue where we allowed both the CMD+CTRL keys for our
compose markdown shortcuts.  The correct behavior is to allow either
Cmd or Ctrl, based on whether it's MacOS (Cmd) or Ctrl
(Linux/Windows), to match how those platforms work.

Fixes #8430.
2018-02-20 09:50:10 -08:00
Steve Howell 1f6ddf0110 refactor: Extract transmit.js from compose.js.
We now isolate the code to transmit messages into transmit.js.
It is stable code that most folks doing UI work in compose.js don't
care about the details of, so it's just clutter there.  Also, we may
soon have other widgets than the compose box that send messages.

This change mostly preserves test coverage, although in some cases
we stub at a higher level for the compose path (this is a good thing).
Extracting out transmit.js allows us to lock down 100% coverage on that
file.
2018-02-20 09:29:26 -08:00
Vishnu Ks d34dd4cd02 signup: Show subdomain availability during signup.
This uses an actual query to the backend to check if the subdomain is
available, using the same logic we would use to check when the
subdomain is in fact created.
2018-02-19 10:45:17 -08:00
Shubham Dhama da65e1dcb6 drafts: Sort drafts by last modified.
This moves the last modified draft to bottom.
2018-02-19 09:55:50 -08:00
Shubham Dhama 804a5f3306 drafts: Add timestamps showing when last modified.
Fixes: #3790.
2018-02-19 09:55:50 -08:00
Steve Howell c7724c6ec4 minor: Fix typos in hashchange comments.
We make the URL slightly more realistic and fix a spelling typo.
2018-02-19 09:03:11 -08:00
Steve Howell 46a49777c4 Add stream ids to urls for stream-related narrows.
This commit prefixes stream names in urls with stream ids,
so that the urls don't break when we rename streams.

strean name: foo bar.com%
before: #narrow/stream/foo.20bar.2Ecom.25
after: #narrow/stream/20-foo-bar.2Ecom.25

For new realms, everything is simple under the new scheme, since
we just parse out the stream id every time to figure out where
to narrow.

For old realms, any old URLs will still work under the new scheme,
assuming the stream hasn't been renamed (and of course old urls
wouldn't have survived stream renaming in the first place).  The one
exception is the hopefully rare case of a stream name starting with
something like "99-" and colliding with another stream whose id is 99.

The way that we enocde the stream name portion of the URL is kind
of unimportant now, since we really only look at the stream id, but
we still want a safe encoding of the name that is mostly human
readable, so we now convert spaces to dashes in the stream name.  Also,
we try to ensure more code on both sides (frontend and backend) calls
common functions to do the encoding.

Fixes #4713
2018-02-19 09:03:11 -08:00
Shubham Dhama 1192111ce2 group popovers: Refactor setting up scrollbar.
Using a wheelspeed of 0.68 is fine as used throughtout Zulip.
2018-02-18 20:20:51 -08:00
Shubham Dhama 9feae472f8 org settings: Add button to deactivate organization.
This adds button under "Organization profile" settings, which
deactivates the organization and sends an "event" to all the
active user and log out them.

Fixes: #8212.
2018-02-18 10:20:38 -08:00
ryan dea7d1d1b6 profile menu: Show profile-edit option when a user clicks on self-profile.
This removes some options when a user clicks on their own profile, and
replaces them with an option to edit their own profile settings.

Front end test adjusted because it was testing an option that does not
appear if a user clicks on their own profile.

Fixes #5075.
2018-02-16 16:59:45 -08:00
ihsavru 4103996a22 org-settings: Fix styling of Allowed Domains modal.
Fixes: #7628.

Cleaned up by Brock Whittaker and Node tests fixed by Steve Howell.
2018-02-16 16:00:21 -08:00
Eric Eslinger 786bda674c popovers: Add a popover for group mentions.
This adds a click handler to `.user-group-mention` which works in a
fashion that is quite similar to `.user-mention`. It generates and
displays a popover.

The popover has a list of members, their online status (if they are
not bots) or their bot status if they are bots (it's not clear whether
ultimately bots should be able to be members of usergroups, but I'm
able to add one, so I thought it would be worth supporting).

The popover's `UL` element has max-height and overflow-y atttributes
so large groups will grow a scrollbar.

Fixes #8300.
2018-02-16 13:37:02 -08:00
Eric Eslinger bc21344dc6 popovers: Fix memory leak with old popovers.
This change resets the list_of_popovers array to a new empty array after
hide_all has been called. Prior behavior kept it around, and it kept
pointers to orphaned DOM nodes.

Fixes #8416.
2018-02-16 13:33:06 -08:00
Shubham Padia 9802264302 message-editing: Mark message as read before deleting it.
Fixes most of #8411.

Unread counts in the left sidebar were previously not updated
immediately on message delete.
2018-02-16 12:53:20 -08:00
Brock Whittaker d30a6c64c3 Revert "Make recipient bar styling more compact and clean."
This reverts commit 8e2d9b8f68.

This adds the arrows back to the recipient bars because even though
it's not our end state, it looks better than the boxy design that we
had in between.
2018-02-16 11:55:00 -08:00
Shubham Dhama a32e1eb913 markdown: Require double-asterisk around all mentions.
This enforces `**` around all the mentions including "at-all" and
"at-everyone" mentions. Hence this makes `@all` and `@everyone`
invalid mentions, resulting into proper syntax for these mentions as
`@**all**` and `@**everyone**` respectively.

Note from tabbott: This removes an old feature/syntax, which made
sense back when @Tim was also a way to mention a user with Tim as
their first name.  Given how nice typeahead is now, the user part of
the feature was removed a while ago; this should have gone at the same
time.

Fixes: #8143.
2018-02-16 11:45:08 -08:00
Tim Abbott 55feafb513 unread_ops: Add a quick comment explaining an interface. 2018-02-16 11:44:41 -08:00
Shubham Padia b12a5a2da0 stream settings: Use a bulk query when changing all streams.
This avoids hitting Zulip's rate limits when there are more than 100
streams involved.

Manual testing:
- Changed notification settings for all streams from notifications tab of user settings
- Monitored the network tab to make sure 1 query is being sent
- Checked notification settings of individual streams

Fixes #5898.
2018-02-16 11:28:55 -08:00
Shubham Dhama 152da74e73 typeahead: Fix typeahead ordering for user group mentions.
Previously, a user with "ham" anywhere in their email address would be
sorted before a group whose name starts with "ham", which resulted in
a lot of frustrating when trying to mention groups.

Fixes: #8301.
2018-02-16 10:10:39 -08:00
Vishnu Ks a46e21ee3e bankruptcy: Add UI widget to mark all messages as read.
This is the natural analog of the similar streams UI feature.

Fixes #7585.
2018-02-15 18:01:03 -08:00
Shubham Dhama 995138d730 settings: Allow uploading same image as avatar after deleting.
Previous hack wasn't working but changing the value of
file input element to empty works.
For more info https://stackoverflow.com/questions/20549241.

Fixes: #8377.
2018-02-14 09:37:16 -08:00
Tim Abbott 118dfb9690 hotkey: Document message_view_only with a comment.
fixes #8323.
2018-02-14 09:34:32 -08:00
Tim Abbott dcda633b3a help: Fix scroll position when reloading browser window with hash.
This uses the same technique as the last commit, just with the final
case for how we navigate to/from these pages.
2018-02-14 09:26:42 -08:00
Aman Jain d48664fc5f help: Fix links with query selector from left sidebar.
This resolves the issue of scrolling to correct position when loaded
from left sidebar to a link with query selector.

Fixes #6714.
2018-02-14 09:25:26 -08:00
Tim Abbott 6638c12aef upload: Extract feature_check helper function. 2018-02-13 14:37:26 -08:00
Tim Abbott 8836161611 upload: Refactor file upload code path to use more variables.
Now, all the various DOM elements are named by a variable, keyed off
the configuration of the upload_options object.

This is most of the work required to support file upload in the
message edit area.
2018-02-13 14:37:26 -08:00
Tim Abbott 9de7a69b13 upload: Move compose initialization back to compose module.
This makes the lines of logic a bit simpler.
2018-02-13 14:37:26 -08:00
Tim Abbott 7af769a272 upload: Extract upload.options structure.
This is a nonfunctional refactor that is key preparation for allowing
uploading files in message editing.

Note that this makes no actual changes to the code; it just changes
the function structure.
2018-02-13 14:37:22 -08:00
Florian Jüngermann ec3e0caece right-sidebar: Enable up and down arrow keys.
This users the new generic functions in stream_list.js to implement a
similar behaviour for the right sidebar (user list).

Fixes #5920.
2018-02-12 15:38:23 -08:00
Florian Jüngermann b489ccc126 left-sidebar: Enable up and down arrow keys.
When in the stream-searchbar, a user can now use the arrow keys to iterate
through the suggestions. Therefore the currently selected list element is
assigned a CSS class 'highlighted_user'.
The main functional testing is done with casper but node test are still
included to keep the high coverage.
Line-wrapping issues are resolved. Night-mode CSS handling is included.
2018-02-12 15:35:56 -08:00