Commit Graph

474 Commits

Author SHA1 Message Date
Steve Howell 5641c77c94 refactor: Introduce other_stream_ids in filter_table().
We now build up three buckets of stream ids for slightly
more consistent code that will help in future refactorings.
2018-07-30 11:25:32 -07:00
Cynthia Lin ee82f14d04 subs: Use scroll_util to move selected stream rows into view.
This eliminates a bunch of complex logic we previously used when
trying to make keyboard stream row navigation smoother.
2018-07-27 09:08:49 -07:00
Steve Howell 8aa3eebe70 refactor: Render Stream Settings in two steps.
We now render the "skin" part of "Stream Settings" before
adding in the actual streams.  The new function
populate_stream_settings_left_panel() takes care of adding
the streams.  It uses a new template called
`subscriptions.handlebars`.

Splitting out this function will give us more flexibility
for various improvements.

First, we can decide to render the list after we open the
overlay, just to avoid the problem that users don't know why
the modal's opening.  (And we could add a loader spinner as
needed.)

Second, we can improve our filter features so that we do
filtering in the data instead of moving DOM rows around,
which is expensive.

Third, we can eventually introduce progressive rendering.

Finally, having the function broken out will make profiling
more precise about where bottlenecks exist.
2018-07-26 11:20:46 -07:00
Steve Howell 9608b82a36 refactor: Make vars local inside subs.filter_table().
There was no reason for these to be module variables.
2018-07-23 10:01:38 -07:00
Cynthia Lin 84a977967b subs: Fix regression in Filter streams input focus during modal opening.
This behavior was originally implemented in commit 6993f89, but due to not
specifying a toggle option, the Subscribed/All streams switcher tab was
focused after the input was focused, leading to the input's loss of focus.

Fixes #9981.
2018-07-22 10:20:44 -04:00
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Aditya Bansal db7448c4e3 subs: Remove dead css and js left over from a redesign.
This cleans up some leftover js and css from the effort of
redesign the rows of the #subscriptions table. Redesign happened
in commit 368b5859 and but we forgot to clean up these js and css
pieces.

squash to subs.js.
2018-07-04 23:51:45 +05:30
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama c6738889a9 eslint: Add and enable `space-unary-ops` rule.
Info about rule at https://eslint.org/docs/rules/space-unary-ops.
2018-06-05 00:47:35 +05:30
Yashashvi Dave 3422766c25 create stream: Fix widget for changing privacy doesn't render initially.
When admin user create new private stream, widget for changing privacy
of stream doesn't render. Because we render subscription-settings
template partially on subscription-add event, so this case wasn't
handled.

Fixes #9469
2018-06-01 12:09:50 -07:00
Tim Abbott 276b70ffb8 subs: Remove now-unnecssary call to ensure_i18n. 2018-05-30 09:10:43 -07:00
Steve Howell 9eb3bdaf6c page load: Make initializations more explicit.
We now initialize most modules in ui_init.js, which
isn't the perfect place to do it, but at least now
we have a mostly consolidated entry point.

All the new foo.initialize() methods introduced in
this module run the same order relative to each
other as before this commit. (I did some console
logging with a hacked version of the program to
get the order right.)  They happen a bit later than
before, though.

A couple modules still have the `$(function() {`
idiom for miscellaneous reasons:

       archive - is a different bundle
       common - used elsewhere
       list_render - non-standard code style
       scroll_bar - no exports
       setup - probably special?
       socket - $(function () is nested!
       transmit - coupled to socket
       translations - i18n is a bigger problem
       ui_init - this bootstraps everything
2018-05-15 15:46:04 -07:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Yashashvi Dave dbd24c5c93 create stream: Fix preview btn not showing on private stream creation.
Fixes #9028
2018-04-30 11:15:07 -07:00
Yashashvi Dave 66759358e2 create stream: Add maxlength restriction on name and description. 2018-04-30 10:11:25 -07:00
Steve Howell 5f53fb1561 refactor: Remove factory code for toggle component.
We now have components.toggle simply return an object, without
putting the object into a lookup table.  The consumers of the
objects have all been changed to just store the object in their
own module scope.

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

        - we don't have opts.name
        - we don't have __toggle.lookup
        - we don't have keys
        - we don't create a sibling object to the prototype object
2018-04-20 13:45:58 -07:00
Steve Howell 7666e9c7a9 stream settings: Simplify how we select streams tabs.
This commit introduces a helper function called
maybe_select_tab() that goes to the correct tab in the
toggler widget.

It avoids the "lookup" mechanism, which I am hoping to
deprecate, and it handles hypothetical startup issues
by warning instead of crashing.
2018-04-14 11:40:03 -07:00
Steve Howell 9319da8e1d stream settings: Fix bug with Subscribed/All.
Before this commit, this sequence would lead to errors:

        * Open streams page via the gear menu.
        * Go to "All" tab.
        * Leave streams settings.
        * Re-open stream settings via the gear menu.

After doing this, the tab would show "Subscribed" but the list
would be of all messages.

Now we explicitly goto the first tab.

I added a long comment explaining how subs.js contributed
to this bug--in short, we re-build the widget instead of just
re-opening this.

We may also want the toggle component to simply default the
initial tab to the first tab.
2018-04-14 11:40:03 -07:00
Tim Abbott a6d80969f5 subs: Clean up variable name for rendered subscription count. 2018-04-12 09:48:02 -07:00
YJDave 95461761e4 subscription: Show current user on top of subscribers list if present.
Fixes #9027.
2018-04-11 09:54:42 -07:00
YJDave c662867f14 subscription: Add comments for recent changes covering corner cases. 2018-04-11 09:51:52 -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 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 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
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
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
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 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
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
YJDave 886e77e858 subscription: Fix bug in display email hint popover on hover.
Fixes #8743
2018-03-23 09:55:44 -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
Cynthia Lin 333b8b095c subscriptions: Use tooltips for stream info hover content.
Fixes #8718.
2018-03-18 19:44:53 -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 b6408a0383 stream settings: Fix sub-unsub btn not showing on private stream creation. 2018-03-11 15:58:18 -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 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 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
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
Brock Whittaker 6028e79440 subs: Remove call to go to "all-streams" on stream creation.
This will essentially run the code paths to go from whatever you were
at before to /all and back in the case of /new, which will call the
render function three times (!!), so remove this call because it isn’t
really necessary anyways.
2018-02-09 17:29:59 -08:00
Brock Whittaker ad4e976406 streams: Have new streams list only populate once.
Currently the new streams user list will populate twice when you click
the new stream button (or “+”), because it is triggered once directly
by the button click and then once by the hash change to /new, so we
want to ignore the changes by the hash change.
2018-02-09 17:29:59 -08:00
YJDave 31cfd16f85 stream settings: Update subscription-btn display instant.
If user unsubscribe from private stream, then immediately remove
subscription option from settings.
2018-01-04 16:52:54 -05:00
YJDave 19eef98305 stream setting: Change email address popover placement to right. 2018-01-04 16:25:28 -05:00
YJDave 8c7d4bb5ad stream setting: Fix bug in email address popover.
Email address popover was not showing, because add popover
jquery function was executed before DOM elements get load.
2018-01-04 16:25:28 -05:00
YJDave ce43daa236 stream settings: Fix all dead code related to #subscriptions-status.
Remove all references of #subscriptions-status and add error handling
of stream settings endpoints.

Fixes #4647
2018-01-04 11:35:37 -05:00
Cynthia Lin e92a8ac8ee subs: Properly focus on Stream name box while creating a new stream.
Fixes #7473.
2017-11-28 10:07:11 -08:00
Tim Abbott 1978455287 subs: Fix exception with streams overlay open but no active stream.
Previously, if you had the streams overlay open (but no active stream
clicked) while another user edited your subscriptions state, we'd
throw an exception handle the get_events call, because the code for
rerendering the subscribers list didn't consider the possibility that
there was no active stream.
2017-10-23 22:56:14 -07:00
Tim Abbott bdc7772bab subs: Fix bug with invalid access to stream IDs.
`sub.id` isn't a valid field; it's `sub.stream_id`.
2017-10-23 22:44:05 -07:00
Brock Whittaker 9090d6b12f streams: Re-render subscriber list on sub/unsub.
This re-renders the subscriber list on sub/unsub as long as that is the
current active stream settings.

Fixes: #6955.
2017-10-18 11:45:07 -07:00
Brock Whittaker 586369296c /subs/: Refactor to create a "get_safe_hash" method.
This returns a string always, checks if the “location” variable exists
inside of window, and will trim the first character (“#”) on hashes.
2017-10-18 11:45:07 -07:00
Brock Whittaker a93bedc8e6 streams: Re-highlight row after re-subscribing.
When re-subscribing by way of the "Subscribe" button in the right
side settings panel, the row will now be marked as active to
highlight that the row is still selected and being looked at.

Fixes: #6955.
2017-10-18 11:45:07 -07:00
Brock Whittaker 6039687ecd streams: Add "Create Stream" button to right side.
This adds a button to allow a user to more easily discover the
stream creation functionality to the right side of the streams
overlay.
2017-10-11 16:17:36 -07:00
Brock Whittaker 1096bd11c9 streams: Rename settings hide/show functions.
The stream settings hide/show functions were "collapse" and
"show_sub", and this changes them to be "hide_sub_settings" and
"show_sub_settings".
2017-10-11 12:44:10 -07:00
Brock Whittaker 20af49b2bb streams: Call `actually_filter_streams` on stream events update.
Previously it was called before the event was processed by the server
and the subscription was updated to have the user subscribed to a
stream, so there was a race condition that would make it iso that
sometimes the stream line would disappear on the next render pass due
to the event not having completed yet.

This makes it so that the re-render happens after the event is
processed in `stream_events.js`.

Fixes: #6797.
2017-10-11 12:44:10 -07:00
Brock Whittaker 2ae2727c8b streams: Refactor `actually_filter_streams` to be public.
This refactors the function to be publicly accessible so we can call
the filter streams function from other modules.
2017-10-11 12:44:10 -07:00
Cynthia Lin 395a71a433 subs: Fix jerky stream subscriptions scrolling with up/down keys.
Fixes #4230.
2017-09-22 05:09:14 -07:00
Brock Whittaker e0a9310c41 subscriptions: Maintain scroll position when subscribing.
The current behavior is that when you subscribe to a new stream
the scroll position moves back up to the top because the list updates,
when in reality the user shouldn't notice this, so we record the
previous scroll position and then apply it once the DOM update is
finished before the next paint cycle.

Fixes: #6606.
2017-09-21 09:09:45 -07:00
Vaida Plankyte 11d935f52a frontend: Add perfectScrollbar to right pane of manage subs overlay.
Tweaked by tabbott to use a more precise selector.
2017-08-16 08:23:34 -07:00
Vaida Plankyte 8ae263bf15 frontend: Add perfectScrollbar to left sidebar of manage subs overlay.
Tweaked by tabbott to use a more precise selector.
2017-08-16 08:23:33 -07:00
Brock Whittaker f2b71ba12a subs: Make "All streams" link to appropriate hash.
This makes the “All streams” toggle bring the user to the hash
“streams/all” which saves their state.

Fixes: #5984.
2017-08-03 10:59:13 -07:00
Brock Whittaker c1599a1463 streams-modal: Fix back arrow on streams modal.
This fixes the back arrow to work again properly after a regression
in which a change in the class name disrupted the click events and
styling for it.
2017-06-12 18:31:04 -04:00
Cynthia Lin b81e7ad51f hotkeys: Fix arrow key navigation in Streams modal.
Previously, one could not move past unsubscribed streams in the
Subscribed tab.

Fixes #5066.
2017-05-30 22:51:35 -07:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
Rohitt Vashishtha 442537ebb8 overlays: Rename hashchange.exit_modal() to exit_overlay. 2017-05-28 18:40:54 -07:00
Cynthia Lin 6993f8900a subs: Focus in Filter streams input when menu is first opened. 2017-05-24 12:19:15 -07:00
Tim Abbott df5a0e7c92 hotkeys: Simplify logic for checking for subscriptions page. 2017-05-15 20:28:56 -07:00
Steve Howell 4bcb4d6c15 Use modal.open_overlay() in subs.js. 2017-05-08 22:04:56 -07:00
fionabunny 70fe2eab60 home.py: move is_zephyr_mirror_realm as realm_is_zephyr_mirror_realm.
Part of #3853.
2017-04-28 21:12:16 -07:00
Steve Howell 4762673929 Fix how we calculate fields in stream_data.js.
We used to have code scattered in multiple places to
calculate things like admin options, preview urls,
subscriber counts, and rendered descriptions for
streams before we rendered templates in the "Manage
Stream" code.

These are all consolidated into a new function
called stream_data.update_calculated_fields().

This is mostly code cleanup, but it also fixes a bug where
the "View Stream" button would not work for a newly created
stream.
2017-04-28 17:49:33 -07:00
Steve Howell 8eb86335b9 Extract narrow_state.js.
Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).

The only new functions are simple setter/getters that
encapsulate the current_filter variable:

    narrow_state.reset_current_filter()
    narrow_state.set_current_filter()
    narrow_state.get_current_filter()

We removed narrow.predicate() as part of this, since it was dead
code.

Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
2017-04-25 09:57:32 -07:00
Steve Howell 7326971380 Extract stream_edit.js.
This code makes the right pane work in "Manage Streams" when
you are editing a stream subscription.  It handles basic
functionality (submitting forms, etc.), live updates, and
showing the pane as needed.

Most of the code here was simply moved from subs.js, but some
functions were pulled out of larger functions:

    live update:
        add_me_to_member_list
        update_stream_name
        update_stream_description

    collapse/show:
        collapse
        show_sub

We also now export subs.show_subs_pane.

We eventually want stream_edit not to call into subs.js, and
this should be fairly easy--we just need to move some shared
methods to a new module.
2017-04-25 09:57:32 -07:00
Steve Howell ca2aea8d01 Extract stream_create.js.
This new modules handles the UI to create streams.  It mostly moves
code from subs.js.

It introduces an API around what used to be called meta.stream_created:

    reset_created_stream()
    set_name()
    get_name()

It only partially moves new_stream_clicked().
2017-04-25 09:57:32 -07:00
wangjames 744f4aa663 Fix modals dependency cycle.
This commit forces the files that create modals to create their own
modal closing function instead of creating all of them in the modals
file. These functions are then passed to the modals.close object. This
is intended to remove modals.js's dependencies on these other files.
2017-04-24 14:30:02 -07:00
Steve Howell 70b7d4c00b Extract compose_state.js.
This is mostly just moving methods out of compose.js.

The variable `is_composing_message`, which isn't a boolean, has
been renamed to `message_type`, and there are new functions
set_message_type() and get_message_type() that wrap it.

This commit removes some shims related to the global variable
`compose_state`; now, `compose_state` is a typical global
variable with a 1:1 relationship with the module by the same
name.

The new module has 100% line coverage, most of it coming
via the tests on compose_actions.js.  (The methods here are
super simple, so it's a good thing that the tests are somewhat
integrated with a higher layer.)
2017-04-18 12:26:58 -07:00
Tim Abbott 97af418be2 subs: Fix going down from 'Filter streams'.
The correct behavior here should be selecting the very first row.
2017-04-05 12:30:36 -07:00
Raghav Jajodia 40018f29fc create_stream: Disable up/down arrow keys when creating new streams.
Prevent switching of stream rows on pressing arrow key when focussed
on the 'Create stream' section (this would cancel the curren stream
creation flow).
2017-04-05 12:30:36 -07:00
Brock Whittaker bccda3c76a Change subscriber data source to come from in-memory.
The subscriber data is currently pulled from the web needlessly
when it exists in memory. This processes data returned from
the `stream_data.get_sub_by_id(n).subscribers` and the
`people.get_person_from_user_id(n).email` methods to build the
same list of subscribers that is sent from the server.

Fixes: #4314.
2017-04-04 18:26:17 -07:00
Raghav Jajodia 4b0ca4c852 streams: Restore stream name in 'Create streams'.
On filling out the name and description for new stream,
and changing the tab (e.g. by clicking on a stream on the left),
then come back to 'Create streams', it should restore stream name
similar to the stream description.

Fix #4311.
2017-04-04 17:17:20 -07:00
Yago González 2f5addc174 i18n: Add missed strings. 2017-03-27 14:30:28 -07:00
Cynthia Lin f41883ce8d subs.js: Refactor row data functions to return objects. 2017-03-25 18:35:21 -07:00
Cynthia Lin 6e2d180a34 hotkeys: Add hotkey `n` for opening New streams modal in Streams menu. 2017-03-25 18:35:21 -07:00
Cynthia Lin ca460fad1f hotkeys: Add hotkey `V` for viewing selected stream in Streams menu. 2017-03-25 18:35:21 -07:00
Cynthia Lin a027e9318d hotkeys: Move cursor to Filter streams input if at top of Streams menu.
Fixes #4227
2017-03-25 18:35:21 -07:00
Cynthia Lin b800cb05c0 hotkeys: Add left/right arrow keys to toggle views in Streams menu.
Fixes #4228
2017-03-25 18:35:21 -07:00
Cynthia Lin fb89d8a2bf subs.js: Refactor modal row functions. 2017-03-25 18:35:21 -07:00
Cynthia Lin 69c32daffa hotkeys: Add `U` hotkey for unsubscribing/subscribing in Streams menu.
Fixes #4229
2017-03-25 18:35:21 -07:00
Cynthia Lin d17131dcb4 hotkeys: Rename subs.arrow_keys() to subs.switch_rows(). 2017-03-25 18:35:21 -07:00
Tim Abbott 1ad0d35966 subs: Clean up ancient collapsing logic. 2017-03-21 23:09:32 -07:00
Tim Abbott bfc67f6602 subs: Toggle notification settings on subscribe. 2017-03-21 23:09:32 -07:00
Tim Abbott dfddea77b7 subscriptions: Show stream settings after toggling checkbox.
Based on Aakash Tiyagi's work in #4026.

Fixes #3971.
2017-03-21 23:09:32 -07:00
Tim Abbott 9347fc4742 subs: Move show_stream_row earlier in file. 2017-03-21 23:09:29 -07:00
Tim Abbott a7610c8b7e subs: Clarify show_stream_row arguments. 2017-03-21 23:07:28 -07:00
Tim Abbott e70bf13bef subs: Extract setup_subscriptions_stream_hash. 2017-03-21 22:17:50 -07:00
Cynthia Lin 1dfac12c4b hotkeys: Add arrow key navigation in streams/subscriptions menu.
Fixes #4198.
2017-03-21 20:32:28 -07:00
Tim Abbott cebaf140c6 subs: Fix stream descriptions rendering on creation.
This is kinda hacky and probably not how we want this to work
long-term, but I think it's a larger refactoring project to make this
part of the model make sense.
2017-03-20 23:25:43 -07:00
Tim Abbott a903d28d78 subs: fix missing ; introduced by rebase error. 2017-03-20 23:19:14 -07:00
Raghav Jajodia 2d4ba0fde5 stream_data: Linkify URL in stream description.
If a url is present in stream description, it will be
rendered as a clickable link under /streams page.

Tweaked by tabbott to use the separate rendered_description element to
avoid duplicate rendering and to live-update.

Fixes #1435.
2017-03-20 22:25:03 -07:00
Steve Howell d026344b37 Extract js/ui_util.js. 2017-03-19 11:05:45 -07:00
Steve Howell 099f401b9b Move mark_subscribed/mark_unsubscribed to stream_events.js. 2017-03-19 11:05:45 -07:00
Steve Howell b98cd55ddb Add ui_report shim. 2017-03-19 11:05:44 -07:00
Steve Howell 1d7d6869c9 Extract stream_events.js 2017-03-19 10:56:09 -07:00
Steve Howell cfd1e8cbc3 Extract stream_muting.js. 2017-03-19 10:56:09 -07:00
Steve Howell 5b2407bb22 Add ui_state.home_tab_obscured() shim. 2017-03-19 10:56:09 -07:00
Steve Howell 27f37e6378 Add hash_util.encodeHashComponent() shim. 2017-03-18 15:52:50 -07:00
Luke W Faraone 68e7a8a824 Show stream properties on subscription in Zephyr.
On realms with ``should_list_all_streams() == False``, previously, we
would subscribe a user to a stream, but also incorrectly show the stream
creation dialog.

Instead, we act as if the stream was newly created.
2017-03-18 15:51:27 -07:00
Steve Howell 7b1bfd6703 Break typeahead_helper's dependency on compose.js.
We now have typeahead_helper's callers pass in compose.stream()
when it's needed for sorting purposes.
2017-03-18 10:35:52 -07:00
Tim Abbott 8efe4d530d js: check_stream_existence to subs.js.
We want to remove this, but in the meantime, this is a more coherent
place for htis to live than compose.js.
2017-03-17 15:16:11 -07:00
Tim Abbott af5852a55b subs: Eliminate confusing use of settings local.
The name was never good, and was suggestive of the settings module.
2017-03-17 15:07:49 -07:00
Brock Whittaker b0e5aeb313 Consolidate JavaScript modal closing in modals.js.
This consolidates all actions to close modals into modals.js and
triggers the correct cleaning/collapsing function dependent on what the
data-overlay attribute is labeled as.

It also ensures these all have an e.stopPropagation().

Fixes #4029.
2017-03-15 12:27:44 -07:00
Brock Whittaker 2e30cef8e9 Change "hashchange.exit_settings" to "hashchange.exit_modal".
Change the name of the hashignore and replace mechanism from
exit_settings to exit_modals since it is now used for more than just
the settings.
2017-03-15 12:17:27 -07:00
Tim Abbott 5e39ccd642 js: Rename viewport.js to message_viewport.js.
This fixes the mobile web experience for Chrome on iOS.

Apparently, Chrome-on-iOS silently has a `viewport` module that
overrides and user-defined module by that name, causing all of our
code that accesses the viewport module to not work on that platform.
We fix this by renaming it.
2017-03-10 14:59:59 -08:00
Tim Abbott 3b59e6c3cc subs: Rename /#subscriptions to /#streams.
Fixes #3653.
2017-03-08 16:57:58 -08:00
Tim Abbott fc3927a124 subs: Improve meta.stream_created targeting.
This fixes a potential race where you get subscribed to a stream
around the same time that you create a stream.
2017-03-08 14:47:49 -08:00
Brock Whittaker 022aeca085 subs: Prepend new streams to top of stream list.
This prepends new streams that are created to the top of the list so
that they are more visible when being created.
2017-03-08 14:47:00 -08:00
Steve Howell ba49962f9a refactor: Extract stream_popover_sub().
Part of this change moved a click handler from subs.js to
popover.js.
2017-03-05 15:44:43 -08:00
Steve Howell 6630b84dc0 Remove data-stream-name from subscription_settings. 2017-03-05 15:44:43 -08:00
Steve Howell 58b018858e refactor: Pass in sub to ajaxUnsubscribe(). 2017-03-05 15:44:43 -08:00
Steve Howell 761a0beb7e refactor: Rename variable in show_settings_for(). 2017-03-05 15:44:43 -08:00
Steve Howell e703b0bfdb refactor: Remove stream_name param in update_stream_color(). 2017-03-05 15:44:43 -08:00
Steve Howell f8819256b0 Use stream_id in update_subscription_properties(). 2017-03-05 15:44:43 -08:00
Steve Howell 95cdc744d9 refactor: Simplify code for renaming streams. 2017-03-05 11:55:09 -08:00
Steve Howell c5757ac8fe refactor: Change params for subs.mark_subscribed().
We pass in sub instead of stream_name, to support callers that
already do lookups by stream id.

And then we make the second optional argument be subscribers, since
that is all we were using from the old `attrs` argument.
2017-03-05 11:55:09 -08:00
Steve Howell 2f8ecad295 Remove unused get_stream_name(). 2017-03-05 11:55:09 -08:00
Steve Howell 4f1108cc27 refactor: Pass in a sub to remove_user_from_stream(). 2017-03-05 11:55:09 -08:00
Steve Howell 190b2ab1d3 refactor: Pass in a sub to invite_users_to_stream(). 2017-03-05 11:55:09 -08:00
Steve Howell 24631a7405 refactor: Pass in a sub to subs.toggle_pin_to_top_stream(). 2017-03-05 11:55:09 -08:00
Steve Howell 32c2dc63f1 refactor: Pass in a sub to subs.toggle_home(). 2017-03-05 11:55:09 -08:00
Steve Howell 3a93a7310e refactor: Pass in a sub to set_stream_property().
This helps us localize the legacy need to pass stream names
(vs. ids) to the back end to set stream properties.
2017-03-05 11:55:09 -08:00
Steve Howell 1904871d77 refactor: Start to deprecate get_stream_name().
When possible, we should use get_sub_from_target() instead of
get_stream_name(), not only because it often saves a lookup later,
but it also makes it easier to audit the code for name vs. id
bugs.  (When you rename a stream, there can be races where you
use the old stream name instead of the more durable stream_id).

This commit handles the easy cases where the caller directly
wanted the sub, not the name.
2017-03-05 11:55:09 -08:00
Steve Howell df6d644788 refactor: Extract get_sub_for_target(). 2017-03-05 11:55:09 -08:00
Steve Howell a4376efd0f refactor: De-dup code using subs.sub_or_unsub(). 2017-03-05 11:55:09 -08:00
Steve Howell 67e558f905 refactor: Pass in a full sub to sub_or_unsub(). 2017-03-05 11:55:09 -08:00
Steve Howell c38bbea6b9 Add tests for subs.sub_or_unsub(). 2017-03-05 11:55:09 -08:00
Tim Abbott 7fb406b889 lint: Expand lint check for use of .text() without i18n.
Fixes #3705.
2017-02-28 20:37:52 -08:00
Brock Whittaker a66cd814af Huge performance update for subscriber list in streams.
Previously the mechanism worked such that the innerHTML was being
appended to directly potentially thousands of times which has horrific
performance implications. By concating all the strings together before
appending to the HTML it all gets rendered in one chunk without forcing
a re-render of previous elements. Performance is ~15x-20x faster now.
2017-02-26 21:11:23 -08:00
Tim Abbott bd03bb76fd subs: Remove unnecessary data-is-private variable. 2017-02-25 18:33:07 -08:00
Harshit Bansal f20993787c subscriptions: Add a modal for changing stream privacy.
Change the remaining "Admin settings" with a button, namely
changing a stream's privacy, to instead be a "[Change]" link
opening a confirmation modal.

Fixes: #3493.
2017-02-25 18:23:15 -08:00
Harshit Bansal 1d33c759e4 subs.js: Make `change_stream_privacy()` function global. 2017-02-25 18:23:15 -08:00
Brock Whittaker 434317b4cc Add "all" and "subscribed" deeplink for subscriptions.
This adds a deep link to “all” which is to show all streams,
along with "subscribed" for only streams you are subscribed to.
2017-02-23 15:34:30 -08:00
Brock Whittaker 461066cab9 Add deep linking to #subscriptions/new and #subscriptions/:stream_id.
This mechanism allows for a user to deep link to a particular
subscription or the form for creating a new subscription.
2017-02-23 15:34:30 -08:00