Commit Graph

2878 Commits

Author SHA1 Message Date
Brock Whittaker aa645eb72b eslint: Remove `no-new` rule.
This removes the `no-new` rule which is relatively detrimental to
code cleanliness in our codebase because third-party libraries may
utilize data structures that don't fly well with our linting rules.

This also fixes abstractions that were created due to the limitations
and impositions of this lint rule.
2017-07-27 11:31:33 -07:00
Brock Whittaker 59ffb97ea9 Fix: Change .on => .bind.
This changes a typo where a function was attempting to execute the
scope of the parent's "this" by using `function () {}.on()`, rather
than using the `Function.prototype.bind` built-in.
2017-07-26 17:30:25 -07:00
Vishnu Ks 2396619ec6 popover: User .on('load') instead of .load().
.load is deprecated since jQuery 1.8. We are currently on
jQuery 3.2.1.
2017-07-26 11:32:33 -07:00
Brock Whittaker e3ba44710e /apps/: Fix failing tests.
The ES6 backticks in /static/js/portico/landing-page.js were causing
the server to trip up. This was fixed by switching from JS string
interpolation to string concatenation (ES5).
2017-07-26 11:08:43 -07:00
Brock Whittaker dc671ac0bd /apps/: Redesign apps page.
Tweaked by tabbott to update the URLs to point to the Electron desktop app.
2017-07-26 09:56:04 -07:00
digi0ps 3f60074c33 emoji: Create tests to check the typeahead resuts.
Also, this commit exports the typeahead matcher and sorter functions.
Fixes #4126.
2017-07-26 09:27:17 -07:00
digi0ps 9a179b486b emoji: Allow searching of emojis using spaces in emoji picker. 2017-07-26 09:27:17 -07:00
digi0ps 2d92f9dc0b emoji: Change emoji image titles to use spaces instead of underscores.
Previously, the emoji images title display `🍼`.
This commit changes the title to display `baby bottle`.
2017-07-26 09:27:17 -07:00
digi0ps 0f3c1c04d5 emoji: Use spaces instead of underscores for emojis in composebox.
Adds support to use spaces for multi word emojis instead of
underscore in compose box.
2017-07-26 09:27:17 -07:00
David Coleman 159064ccaa uploads: Only display year uploaded if previous year.
Modified timerender.js absolute_time() to include the year
in the returned string when the supplied timestamp is in
an older year. This included adding an optional second
argument to specify the current date to facilitate unit
tests.

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

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

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

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

Addresses issue #5696.
2017-07-24 17:35:41 -07:00
Rishi Gupta ad47d3b651 settings: Update wording in organization-permissions-admin.handlebars. 2017-07-24 17:33:14 -07:00
Greg Price 709c3b50fc tornado: Use a machine-readable error code when an event queue is gone.
This fixes the original issue that #5598 was the root cause of; when
the user returns to a Zulip browser tab after they've been idle past
the timeout (10 min, per IDLE_EVENT_QUEUE_TIMEOUT_SECS), we now
correctly reload the page even if they're using Zulip in German or
another non-English language where we have a translation for the
relevant error message.
2017-07-24 16:41:22 -07:00
Cory Lynch d32e89aae4 jQuery: Remove broken use of "removeAttr".
This function no longer sets properties to false, so the supported
way of doing this is to instead use prop(foo, false). Some tests
had to be fixed to accommodate this.
2017-07-24 10:54:47 -07:00
Cory Lynch 9f91d4c265 Remove deprecated jQuery "delegate" function.
Replaced by "on".
2017-07-24 10:47:16 -07:00
Cory Lynch 274cabff98 Remove instances of deprecated jQuery "bind".
They have been replaced with "on".
2017-07-24 10:47:16 -07:00
Shubham Gupta caee548074 overlays: Fix compose box closing when clicking on overlays.
This was a bug introduced by a recent refactoring to rename .modal to
.overlay for consistency.

Fixes #5886.
2017-07-22 12:06:00 -07:00
Harshit Bansal c1dc48f41b emoji: Merge the two semantically same tips on the `Custom emoji` page.
In case the user was not allowed to upload an emoji, we were displaying
two different but sematically same tips. This commit merges them and
also updates `update_custom_emoji_ui()` function in settings_emoji.js
to live update tooltip.
2017-07-21 13:29:27 -07:00
Cynthia Lin e21c3e1cb7 settings: Nest PM content setting in Desktop notification setting.
Fixes #5879
2017-07-21 12:13:43 -07:00
Steve Howell 0e25055c1d Add explicit message field for locally_echoed.
We now set locally_echoed to true for messages that are
locally echoed, and we change some of our code to look
for this flag.
2017-07-21 11:38:25 -07:00
Steve Howell fca158e387 local echo: Remove pencil icon on failed messages.
Our code to edit messages that were echoed locally but failed
by the server was broken.  We just disable it for now.

We have opened #5841 to try to restore this functionality.
2017-07-21 11:38:25 -07:00
Steve Howell 7134bbfbe3 message edit: Prevent editing any failed messages.
Our logic for editing failed messages is broken in various ways,
so we are removing the codepath for editing for now.  We will
try to restore these features as part of #5841.
2017-07-21 11:38:25 -07:00
Steve Howell bd59b91faa reactions: Simplify markup related to message ids.
Because of local echo, message ids can change in message rows.
Having reactions use markup to indicate their message id just
creates more moving parts, since we would need to handle
message_id_changed events.

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

This has several benefits:
    - no more initialize() function
    - no more scary comments about garbage collection
    - the function has a real name now
    - the function is less indented
    - we can easily see when the message_store step happens
    - simpler node tests
    - simpler tracebacks (no jQuery cruft)
2017-07-21 11:38:25 -07:00
Steve Howell 8de28ec66d hotkeys: Fix glitch related to closing message edits.
If you use the escape key to close a message edit, we need
to blur out the text fields.  Otherwise, hotkeys.js thinks
we are still editing the text.  This bug would disable the
use of things like arrow keys until the user subsequently
focused another field.

We probably eventually want hotkeys.js to be smarter about
ignoring hidden fields that still have the focus, but there's
also no reason not to blur the fields here, and this is a more
local, less risky fix.
2017-07-19 10:10:35 -07:00
Steve Howell 0deb59052e Extract get_local_notify_mix_reason().
There are also minor cleanups to notify_local_mixes() here.
2017-07-18 12:11:43 -07:00
Steve Howell eb2659a26a local echo: Rename function to notify_local_mixes().
This commit renames possibly_notify_new_messages_outside_viewport()
to the more concise name notify_local_mixes().

We really only need to call this function in one place, so we
have the caller check the `local_id` condition.  We can eventually
upstream this code even further so that it's completely
obvious that it's only ever called from the local-echo codepath.
2017-07-18 12:11:43 -07:00
Steve Howell b5cb21ab2c Remove unneeded call in maybe_add_narrowed_messages().
We were calling maybe_add_narrowed_messages() in a place
where local_id is guaranteed to be undefined, since
we always set local_id to undefined when
can_apply_locally() fails.

In turn maybe_add_narrowed_messages() was calling
possibly_notify_new_messages_outside_viewport(), which
requires a local_id to do anything meaningful.

This removes all the associated dead code--passing in
a parameter that we know always was undefined and
calling a function that we know always would no-op.

Not only does this simplify the code a bit, but it avoids
us stepping on the toes of the alternative code path that
deals with non-locally-echoed messages.
2017-07-18 12:11:43 -07:00
Steve Howell 0f7addf5e3 Clean up possibly_notify_new_messages_outside_viewport.
This commit early-exits before our loop when local_id is none,
and it tries to more clearly indicate that the callers will
generally be just calling this with messages sent on the
local-echo path.
2017-07-18 12:11:43 -07:00
Steve Howell 7d49bb8dbd Extract maybe_advance_to_recently_sent_message.
All the rest of the code in its caller was high-level dispatch
stuff, so it just looked fine of funny.
2017-07-18 12:11:43 -07:00
Steve Howell 1fd38e7e26 local echo: Make get_next_local_id() less aggressive.
We now make it so that get_next_local_id() only returns up
to 5 local ids relative to any given max id.

For example, if your pointer is at message 999, we'd give out
999.01, 999.02, ..., 999.05.

We also avoid giving out the same local id twice.  This prevents
a bug where if you had aborted a previously failed locally echoed
message, a subsequent local echo would get into a funny state.

In order to to prevent false alarms on using the same local id
twice, we call get_next_local_id() later in the try_deliver_locally()
function.
2017-07-18 12:03:16 -07:00
Steve Howell 92ad988144 local echo: Remove buggy restart-related code.
We had code that would try to re-render locally echoed messages
that were rendered right before a browser restart.  This code
has gotten buggy over time, so we are removing it for now.

We will try to re-solve the problem as part of #5825, but
possibly with a different strategy.
2017-07-18 12:03:16 -07:00
Pweaver (Paul Weaver) d3ffc81726 Enable Hot Module Replacement in webpack.
This allow the webbpack dev server to properly reload JavaScript modules
while running in dev without restarting the server. We need to connect
to webpack-dev-server directly because SockJS doesn't support more than
one connection on the same host/port.
2017-07-18 11:02:05 -07:00
Steve Howell 1ed35be88c stream_list: Use more direct code in build_stream_list.
We eliminate `.get(0)` calls in buld_stream_list.

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

The more subtle case is that we also don't do `.get(0)` calls
to get DOM out of our individual list items.  By passing
in full jQuery objects to `append()`, we should prevent ourself
from orphaning the old objects, which may in the future have
things like tooltip logic attached to them.
2017-07-18 09:58:16 -07:00
Vaida Plankyte c9bc803118 frontend: Change inaccurate aria-hidden assignments on buttons.
This either removes aria-hidden=true assignments from buttons with
text, or adds a span to only hide the 'x' symbol rather than the
button for closing buttons.
2017-07-17 16:40:28 -07:00
Vishnu Ks 32fddf9a8b analytics: Add translation tags to stats.js. 2017-07-16 16:20:20 -07:00
Durga Akhil Mundroy 146dfa6f0b org-permissions: Add allow_edit_history organiztion setting.
This new setting controls whether or not users are allowed to see the
edit history in a Zulip organization.  It controls access through 2
key mechanisms:

* For long-ago edited messages, get_messages removes the edit history
  content from messages it sends to clients.

* For newly edited messages, clients are responsible for checking the
  setting and not saving the edit history data.  Since the webapp was
  the only client displaying it before this change, this just required
  some changes in message_events.js.

Significantly modified by tabbott to fix some logic bugs and add a
test.
2017-07-16 10:10:06 -07:00
Cory Lynch 1dba70ca0d search_suggestion: Fix highlighting for multi-word streams.
I deleted a test case that involved a highlighted stream, but
the query was empty. This produces kind of a weird result with
typeahead_helper.highlight_with_escaping, but this function already
has coverage in node_tests/typeahead_helper.js, so the check here
was essentially redundant anyway. Specifically, the highlighter
wraps every character individually with <strong>, and looks really
messy in html.
2017-07-14 17:33:09 -07:00
Cory Lynch 76e4350d4d filter.js: Allow quotes to handle spaces in operand.
Fixes #3496. This was just a simple regex addition to filter
to accept the format `operand:"foo bar"` as a token. Also,
it will now accept an additional space after the separating colon.
2017-07-14 17:33:09 -07:00
Vaida Plankyte 28ea174ed9 backend: Implement high contrast mode display setting. 2017-07-14 14:53:24 -07:00
Steve Howell 475eb21a5e Revert commits related to client_message_id.
I pushed a bunch of commits that attempted to introduce
the concept of `client_message_id` into our server, as
part of cleaning up our codepaths related to messages you
sent (both for the locally echoed case and for the host
case).

When we deployed this, we had some strange failures involving
double-echoed messages and issues advancing the pointer that appeared
related to #5779.  We didn't get to the bottom of exactly why the PR
caused havoc, but I decided there was a cleaner approach, anyway.
2017-07-14 12:13:35 -07:00
Tim Abbott cbd5223429 i18next: Disable i18n cache in development. 2017-07-13 21:37:56 -07:00
Tim Abbott 8c5cce7f2b i18next: Decrease cache expiration time to a couple days. 2017-07-13 21:34:35 -07:00
Brock Whittaker e3f1d025ae i18n: Garbage collect old translations from localStorage.
The old translation copies in localStorage were not being removed
when they were no longer needed, so we can free up the storage
by deleting them.

This was accidentally not merged months ago when originally
implemented, but it was written to fix #4443 and in fact does so.
2017-07-13 21:33:49 -07:00
Steve Howell fe66d4f3b0 Encapsulate message_state.maybe_restart_event_loop().
We now set the timer for missing events inside the
message_state class, where it's easier for us to know
which state we're in.
2017-07-13 23:42:27 -04:00
Steve Howell bc67f6a8ca Add sent_messages.track_messages().
This change has us tracking messages as soon as we start
sending the message to the server.  The next step is to
reconfigure the timeouts a bit to deal with the server not
responding.
2017-07-13 23:42:27 -04:00