Commit Graph

7185 Commits

Author SHA1 Message Date
Tim Abbott 7485cb2a50 widgets: Rename voting_widget to poll_widget.
This ensures greater consistency with our other widgets' naming
convention.
2018-12-16 19:46:48 -08:00
Tim Abbott 2cca6a1be8 csrf: Improve API for when no CSRF input is available.
Since we're adding this to a large number of portico pages, there's no
guarantee that these pages actually have a CSRF input.

Though given that the logout template contains a CSRF input,
realistically it should always be present.
2018-12-16 16:19:23 -08:00
Tim Abbott adebe1bd4e js: Extract csrf.js and include in common bundle.
This should make it possible to use this AJAX setup code in logged-out
code as well, which is necessary to use blueslip from portico pages.
2018-12-16 16:18:42 -08:00
Tim Abbott ed9430f3a6 Revert "js: Extract csrf.js and include in common bundle."
This reverts commit dbffa66b6d.

This broke the logged-in app, due to some webpack issue.
2018-12-16 16:16:06 -08:00
Tim Abbott 6416737e70 Revert "csrf: Improve API for when no CSRF input is available."
This reverts commit 9198fa4ec9.
2018-12-16 16:15:54 -08:00
Steve Howell 7d23076a0e drafts: Fix bug in finding current element.
We weren't using the actual sorted data to find
the last element.  This probably worked by accident
in some cases, but this commit makes it more
deterministic.
2018-12-16 15:46:41 -08:00
Steve Howell ebd6d84326 refactor: Call format_drafts() more directly.
We want the return value from this for the next
commit, so we no longer call `format_drafts` indirectly
from `populate_and_fill`, and we rename the latter
to `render_widgets`.
2018-12-16 15:46:41 -08:00
Steve Howell 1584789916 refactors: Move format_draft() to module level.
This is a pure code move.
2018-12-16 15:46:41 -08:00
Steve Howell e22a50a3e3 drafts: Use lists instead of dicts.
We were using a dict to return a sorted list of
formatted drafts, instead of building a list.
2018-12-16 15:46:41 -08:00
Steve Howell 29052b36a5 minor: Rename last_draft -> curr_draft. 2018-12-16 15:46:41 -08:00
Steve Howell c82233c435 drafts: Avoid callback mechanism.
We had an anonymous callback for drafts that was
hard to read.  It's much easier to flatten the code,
give functions actual names, and stub them as needed
in the unit tests.
2018-12-16 15:46:41 -08:00
Tim Abbott 9198fa4ec9 csrf: Improve API for when no CSRF input is available.
Since we're adding this to a large number of portico pages, there's no
guarantee that these pages actually have a CSRF input.

Though given that the logout template contains a CSRF input,
realistically it should always be present.
2018-12-16 15:35:54 -08:00
Tim Abbott dbffa66b6d js: Extract csrf.js and include in common bundle.
This should make it possible to use this AJAX setup code in logged-out
code as well, which is necessary to use blueslip from portico pages.
2018-12-16 15:35:54 -08:00
Steve Howell 840210a0ba minor: Move setup_event_handlers() in code.
We place this code under populate_and_fill().

And instead of calling this at the end of
populate_and_fill(), we call it AFTER
populate_and_fill().
2018-12-16 14:38:28 -08:00
Steve Howell e38496ddc0 drafts: Show active element clearly. 2018-12-16 14:38:28 -08:00
Tim Abbott 0779d343fa message_list: Fix handling of unknown email in mentions.
If a user has an old mention and has since been renamed, there's
really nothing for us to do to render it; we should just return as
though we have no data.
2018-12-16 14:36:26 -08:00
Marco Burstein 046ecc5d50 styles: Fix compose options hidden when editing.
Fix an issue that when a message is being edited, sometimes compose
options are hidden if there is no time limit. Also, move the options
further from the time limit to make them more noticeable.

Fix #11056.
2018-12-16 13:45:43 -08:00
Tim Abbott 728c601ff4 poll widget: Only show "Add option" if a question has been set.
This makes the UI less confusing.
2018-12-16 11:59:21 -08:00
Tim Abbott 5d31c57638 poll widget: Move the "Add option" feature below options.
This is the more normal ordering for a poll.  Fixes part of #11010.
2018-12-16 11:39:04 -08:00
Steve Howell 35b904b184 subject -> topic: Fix subject in opts.
It's kinda difficult to track down all the interactions
with the opts that go through compose_actions.start(),
but I think I got everything.
2018-12-16 11:26:18 -08:00
Steve Howell 057ee6633a reload: Use "topic" to encode compose topic. 2018-12-16 11:26:18 -08:00
Steve Howell 9861cdfeb6 drafts: Use "topic" internally.
We still have to support "subject" for old drafts,
but we write "topic" for new drafts.
2018-12-16 11:26:18 -08:00
Steve Howell 9ba7b4fcbb drafts: Extract drafts.restore_message().
We make our deep-copy more explicit, change
the var name from draft_copy to compose_args,
and clean up some code formatting.
2018-12-16 11:26:16 -08:00
Steve Howell d7aa5fcc38 compose: Remove obsolete references to replying_to_message.
The `replying_to_message` field was used in some
early versions of compose fade, but it has no more
use in the current code.

The drafts implementation didn't really make any sense,
anyway, as we were claiming to reply to the same
message we were drafting.
2018-12-16 11:26:02 -08:00
Tim Abbott bdc4876948 notifications: Fix missing translation tags for above-compose alerts.
Apparently, these had never made it to being translated.  Since
they're an important part of the user experience, we add translation
tags for them now.
2018-12-16 11:14:09 -08:00
Tim Abbott 6c7725d21f notifications: Compute link earlier in mix notifications code.
This should make it more obvious how to later add a feature to include
a link for out-of-view-scroll-down notifications, should we ever want
that.
2018-12-16 11:02:52 -08:00
Vaibhav 372cb20f9e notifications: Notify when sent message is scrolled down in view.
A common source of confusion for new users is sending a message when
you're scrolled up in the message feed; in this case, it's nice to
communicate to the user why the message is not in view.

Fixes #10792.

Restructured by tabbott to replace overly complex logic for getting
the position of the new message with a `message_list.get_row()` call.
2018-12-16 10:59:25 -08:00
Tim Abbott 008722b809 portico: Fix logic for whether a password field is present.
Now, we correctly avoid calling various password quality/strength
functions in the registration flow in the event that there isn't a
password form on the current page.

Before, some code wasn't inside a block at all, while other code was
using an incorrect check (an empty jQuery object is not falsey).

The overall result was that this would often crash on certain
pages/flows, stopping JS execution and causing various secondary
problems.
2018-12-15 13:58:38 -08:00
Steve Howell a4c80089f3 page load: Fix two bugs related to muting/unreads.
The first bug fixed here has been around for a long
time--we were redundantly updating unread counts
indirectly via muting_ui.initialize(). The
unread counts also get updated in
unread_ui.initialize(), when we have more valid
state.  (And it's worth noting here that the unread
counts get updated yet again once message fetches
complete.)

The second bug was a very recent regression from
my recent stream name -> stream id cleanup in the
muting system.  We now depend on stream_data to
initialize muting data, so we need to initialize
muting.js slightly later in the process.

These fixes are intertwined, because they were both
somewhat caused by the anti-pattern of having
muting_ui.js initialize unread_ui.js and muting.js,
instead of doing more direct, fine-grained initialization
from ui_init.js.

Essentially we replace this code:

    exports.update_muted_topics = function (muted_topics) {
        muting.set_muted_topics(muted_topics);
        unread_ui.update_unread_counts();
    };

with this:

    exports.initialize = function () {
        exports.set_muted_topics(page_params.muted_topics);
    };

And the modules load like this:

    stream_data
    ...
    muting
    ...
    unread_ui

And we don't need any page-load initialization for muting_ui,
which is mostly used for Settings/Muted topics.
2018-12-15 13:44:30 -08:00
Steve Howell 625388ccf0 refactor: Call stream_data.initialize() more directly.
This function used to be called initialize_from_page_params(),
and we called it indirectly through `subs.js`.

Now we call it directly from `ui_init.js`, which gives us a
bit more control over how things are initialized.  In fact,
this sets us up for the next commit, where I fix a recent
regression I introduced.
2018-12-15 13:44:30 -08:00
Rishi Gupta 111eda604b portico: Add /atlassian for Zulip users migrating from HipChat. 2018-12-14 23:42:47 -08:00
Steve Howell c8cee5d900 topic list: Remove unnecessary markup.
The data attribute here has some value if you're
inspecting the HTML in the browser, but it's not
worth the extra code.

All the list items have data-stream-id, so there's
no need for the parent to have it.
2018-12-14 16:05:40 -08:00
Steve Howell 012bb7b6c7 Use stream_id for by_stream__uri().
The stream_list test that was fixed here was sort of
broken.  It accomplished the main goal of verifying
what gets rendered, but now the data setup part is
more like the actual app code (and simpler, too).
2018-12-14 16:05:40 -08:00
Steve Howell aea074e744 Use stream_id for by_stream_topic_uri(). 2018-12-14 16:05:40 -08:00
Steve Howell 7a22d47338 Use stream_id for mark-topic-read handler. 2018-12-14 16:05:40 -08:00
Steve Howell 87851b0db0 muting: Use stream_id in muting.get_muted_topics(). 2018-12-14 16:05:37 -08:00
Steve Howell f18ce4f923 muting: Use stream_id in markup for action menus. 2018-12-14 16:05:37 -08:00
Steve Howell d75ff80eb2 muting: Add stream_id to markup for mute settings.
We also prefer `attr` over `data` (it's more greppable).
2018-12-14 16:05:35 -08:00
Steve Howell bf6f5e7bc5 muting: Pass stream_id to muting_ui.mute and unmute.
We temporarily allow settings_muting to have
incomplete line coverage--we will fix this soon.
2018-12-14 16:02:48 -08:00
Steve Howell 10b045f91b muting: Use stream_id as arg for notify_with_undo_option.
Also remove the unused meta.stream and meta.topic variables.
2018-12-14 16:02:40 -08:00
Steve Howell ba04ec7e85 muting: Use stream_id for persist_mute/persist_unmute. 2018-12-14 16:02:37 -08:00
Steve Howell a8718c9051 muting: Use stream_id for internal data structures.
This fixes the most core data structures inside of
muting.js.  We still use stream names for incoming
data to set_muted_topics and outgoing data from
get_muted_topics.

This will make us more resilient to stream name changes.
Before, if you were logged on when a stream rename
occured, topics that were muted under that stream would
appear to be unmuted.  (You could fix it with a reload,
but it can be jarring to have a bunch of unread messages
appear in your feed suddenly.)

Fixes #11033
2018-12-14 15:58:35 -08:00
Vishnu Ks 0fd6ff722b billing: Migrate /upgrade endpoint to JSON.
The fixture changes are because self.upgrade formerly used to cause a page load
of /billing, which in turn calls Customer.retrieve.

If we ran the full test suite with GENERATE_STRIPE_FIXTURES=True, we would
likely see several more Customer.retrieve.N.json's being deleted. But
keeping them there for now to keep the diff small.
2018-12-13 17:01:12 -08:00
Rishi Gupta 647103a4e0 message visibility: Make stylistic improvements to history-limited-box. 2018-12-13 16:50:52 -08:00
Cynthia Lin c9b75a8a65 night mode: Alter compose warning background to fit night mode.
Fixes #10916.
2018-12-13 13:29:14 -08:00
Vishnu Ks e5b3d39ce9 messages: Show banner when message history is limited.
This communicates to users clearly about the situation when the
history_limited flag is set by the backend (because message history
was cutoff).
2018-12-13 09:02:11 -08:00
Tim Abbott 1054d63820 message_fetch: Deduplicate logic for finish_newer_batch.
Like the other similar commits, we were doing the same work in all
code paths, just with a much more error-prone approach.

We can also now remove the now-unused finish_initial_narrow function.
2018-12-13 08:43:56 -08:00
Tim Abbott ce187b0899 message_fetch: Deduplicate logic for start_newer_batch.
Like the other commits in this series, we were already doing this in
all of the callers of load_messages; this centralizes that logic in a
less ad-hoc feeling way.

We no longer use or need the start_initial_narrow function.
2018-12-13 08:43:56 -08:00
Tim Abbott 7febf724f3 message_fetch: Deduplicate logic for start_older_batch.
We were doing this work individually in all the callers of
load_messages; better is to just do it in one place.
2018-12-13 08:43:56 -08:00
Tim Abbott 9ccb3a2ad1 message_fetch: Deduplicate logic for finish_older_batch.
Previously, each individual caller of load_messages that passed
num_before > 0 would do its own manual management of fetch_status;
now, we just do it inside load_messages.
2018-12-13 08:43:56 -08:00