Commit Graph

175 Commits

Author SHA1 Message Date
Tim Abbott d0927d38fc streams: Use user IDs in membership list to track subscribers.
User IDs are more robust than email addresses as they don't change
with time, and also don't have complications with
different email_address_visibility settings.
2020-03-08 12:37:48 -07:00
Tim Abbott 324b5052c6 stream_edit: Fix error handling for unchanged stream name.
We were incorrectly passing a string version of an integer ID,
e.g. "10", to a function expecting an integer, e.g. 10.  Fix this by
using the common get_stream_id function intended for the purpose
rather than hand-written parsing.

This was likely broken in the recent Dict -> IntDict/Map migrations.
2020-02-24 23:49:07 -08:00
Anders Kaseorg 719546641f js: Convert a.indexOf(…) !== -1 to a.includes(…).
Babel polyfills this for us for Internet Explorer.

import * as babelParser from "recast/parsers/babel";
import * as recast from "recast";
import * as tsParser from "recast/parsers/typescript";
import { builders as b, namedTypes as n } from "ast-types";
import K from "ast-types/gen/kinds";
import fs from "fs";
import path from "path";
import process from "process";

const checkExpression = (node: n.Node): node is K.ExpressionKind =>
  n.Expression.check(node);

for (const file of process.argv.slice(2)) {
  console.log("Parsing", file);
  const ast = recast.parse(fs.readFileSync(file, { encoding: "utf8" }), {
    parser: path.extname(file) === ".ts" ? tsParser : babelParser,
  });
  let changed = false;

  recast.visit(ast, {
    visitBinaryExpression(path) {
      const { operator, left, right } = path.node;
      if (
        n.CallExpression.check(left) &&
        n.MemberExpression.check(left.callee) &&
        !left.callee.computed &&
        n.Identifier.check(left.callee.property) &&
        left.callee.property.name === "indexOf" &&
        left.arguments.length === 1 &&
        checkExpression(left.arguments[0]) &&
        ((["===", "!==", "==", "!=", ">", "<="].includes(operator) &&
          n.UnaryExpression.check(right) &&
          right.operator == "-" &&
          n.Literal.check(right.argument) &&
          right.argument.value === 1) ||
          ([">=", "<"].includes(operator) &&
            n.Literal.check(right) &&
            right.value === 0))
      ) {
        const test = b.callExpression(
          b.memberExpression(left.callee.object, b.identifier("includes")),
          [left.arguments[0]]
        );
        path.replace(
          ["!==", "!=", ">", ">="].includes(operator)
            ? test
            : b.unaryExpression("!", test)
        );
        changed = true;
      }
      this.traverse(path);
    },
  });

  if (changed) {
    console.log("Writing", file);
    fs.writeFileSync(file, recast.print(ast).code, { encoding: "utf8" });
  }
}

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-10 14:08:12 -08:00
Steve Howell b8f01f9cda people: Rename method to get_by_user_id().
This name is consistent with:

    get_by_email()
    get_by_name()
2020-02-05 12:04:56 -08:00
Ryan Rehman 174b2abcfd settings: Migrate to stream_post_policy structure.
This commit includes a new `stream_post_policy` setting,
by replacing the `is_announcement_only` field from the Stream model,
which is done by mirroring the structure of the existing
`create_stream_policy`.

It includes the necessary schema and database migrations to migrate
the is_announcement_only boolean field to stream_post_policy,
a smallPositiveInteger field similar to many other settings.

This change is done to allow organization administrators to restrict
new members from creating and posting to a stream. However, this does
not affect admins who are new members.

With many tweaks by tabbott to documentation under /help, etc.

Fixes #13616.
2020-02-04 17:08:08 -08:00
Pragati Agrawal e79c28e13c stream_edit: Use e.currentTarget instead of e.target.
Here we have attached our handler to `.sub_setting_checkbox` so
`e.currentTarget` will return element with class `.sub_setting_checkbox`
but `e.target` will return exactly which element we have clicked, which
could be a child of `.sub_setting_checkbox`. So instead of,

```
$(e.target).closest(".sub_setting_checkbox")
```

we can use

```
$(e.currentTarget)
```

which is more clean and intuitive.

- `e.currentTarget` is less popular which could be the reason behind using
  two step hack to get the targetted element.
2020-02-04 13:53:27 -08:00
Pragati Agrawal 16abd7ec96 subs: Use single jquery-handlers for multiple events.
Rather than defining two different jquery event-handlers for two different
events, we can use a single jquery handler as the function is the same for
both handlers.
2020-02-04 13:53:27 -08:00
Pragati Agrawal 84fd0b0974 stream_edit: Remove separate click handlers from notifications checkboxes.
Rather than looping on each setting checkbox (except "Mute stream"), we can
attach single click handler to `.sub_setting_checkbox` class.
2020-02-04 13:53:27 -08:00
Pragati Agrawal b2c71b7cd8 stream edit: Move realm_setting_disabled in settings context.
Basic intention for this change is just to make code clean and intuitive.
2020-01-28 14:09:07 -08:00
Pragati Agrawal ada37a10f4 stream edit: Move logic for disabled checkboxes from template to js.
In templates we determine checkboxes are disabled by using the following
`if` clause,
```
{{#if (or (and is_muted notification_setting) realm_setting_disabled)}}
disabled="disabled"
{{/if}}
```
and it is more intuitive to do such calculation in javascript code, so we
added an `if_disabled` attribute in `settings` context which replaces
logical operations from `if` statement.

So for non-notification settings, it is
```
is_disabled: check_realm_setting[setting]
```
where check_realm_setting[setting] is same as realm_setting_disabled.

and for notifiaction settings it is,

```
ret.is_disabled = check_realm_setting[setting] || sub.is_muted;
```
2020-01-28 14:09:07 -08:00
Pragati Agrawal b862184d23 stream edit: Move is_checked calculation of stream settings in js.
It is more intuitive to do logical operations in js code instead of
templates and it is also cleaner.
2020-01-28 14:09:07 -08:00
Pragati Agrawal fd09111d8d stream_edit: Minor refactoring of stream_edit.stream_settings function.
The primary reason for this refactor is `.map` is more suitable in this
context instead of `_.each`.
2020-01-28 14:09:07 -08:00
Tim Abbott e2681372f3 js: Clean up poorly named const id variables.
We have conventions for naming message_id, stream_id, etc. values that
way for readability; these entries are violations of those conventions.
2020-01-16 13:27:27 -08:00
Anders Kaseorg 45bee2f512 js: Clean up stream_id type confusion.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-01-16 13:23:47 -08:00
Steve Howell 110c15737f Rename filter.callback to filter.predicate.
The filter "callback" was only a "callback" in the
most general sense of the word.

It's just a filter predicate that returns a bool.

This is to prepare for another filtering option,
where the caller can filter the whole list
themselves.  I haven't figured out what I will name
the new option yet, but I know I want to make the
two options have specific names.
2020-01-14 22:43:08 -08:00
Steve Howell 9f7be51ce8 streams: Replace Dict with IntDict in stream_data.
There's another Dict that we'll convert to a Set
in a subsequent commit.
2020-01-05 12:28:28 -08:00
Steve Howell a3512553a8 streams: Add LazySet for subscribers.
This defers O(N*S) operations, where

    N = number of streams
    S = number of subscribers per stream

In many cases we never do an O(N) operation on
a stream.  Exceptions include:

    - checking stream links from the compose box
    - editing a stream
    - adding members to a newly added stream

An operation that used to be O(N)--computing
the number of subscribers--is now O(1), and we
don't even pay O(N) on a one-time basis to
compute it (not counting the cost to build the
array from JSON, but we have to do that).
2019-12-30 09:47:55 -08:00
Nat1405 d5f005fd61 wildcard_mentions_notify: Add per-stream override of global setting.
Adds required API and front-end changes to modify and read the
wildcard_mentions_notify field in the Subscription model.

It includes front-end code to add the setting to the user's "manage
streams" page. This setting will be greyed out when a stream is muted.
The PR also includes back-end code to add the setting the initial state of
a subscription.

New automated tests were added for the API, events system and front-end.
In manual testing, we checked that modifying the setting in the front end
persisted the change in the Subscription model. We noticed the notifications
were not behaving exactly as expected in manual testing; see
https://github.com/zulip/zulip/issues/13073#issuecomment-560263081 .

Tweaked by tabbott to fix real-time synchronization issues.

Fixes: #13429.
2019-12-09 16:09:38 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
Anders Kaseorg d17b577d0c js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-25 13:51:21 -07:00
Anders Kaseorg db0b33842c templates: Replace templates.render with require calls.
This removes an unnecessary layer of indirection and allows webpack to
catch filename mistakes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:14 -07:00
Anders Kaseorg 3c3471b720 templates: Rename *.handlebars ↦ *.hbs and - ↦ _.
Tweaked by tabbott to avoid accidentally disabling the linter for
handlebars templates.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:03 -07:00
Thomas Ip f6aaf43029 refactor: Use explicit path when referencing handlebars templates. 2019-07-02 16:23:30 -07:00
Pragati Agrawal 747e797092 stream settings: Disable Mobile notifications if push bouncer not set up.
This commit disables "Mobile notifications" if `push_notifications` are not
enabled. It also adds a tooltip explaining why this is disabled.

Fixes #12208
2019-06-24 14:46:45 -07:00
Yashashvi Dave 84234cabcb stream settings: Disable click handler on label for mute settings.
If stream setting is disabled, setting-checkbox can not be
clicked. Although, it does allow to change value by clicking
on setting label.
This commit fixes above bug and disable click handler on
setting-label for disabled stream settings.
2019-06-24 14:46:45 -07:00
Yashashvi Dave 88f3325970 stream settings: Deduplicate stream settings click handlers. 2019-06-24 14:46:45 -07:00
Yashashvi Dave 1b9c1a7898 stream settings: Deduplicate template rendering. 2019-06-24 14:46:45 -07:00
Yashashvi Dave de1f4066ba stream settings: Change settings element-id to match with pattern.
Change element ids of `is_muted` and `pin_to_top` settings,
to macth with the pattern of other stream settings.

This is preparatory refactor to support removing code duplication in
the stream settings templates.
2019-06-24 14:46:22 -07:00
Yashashvi Dave 25dbda1e53 stream settings: Fix bug in deactivate stream modal appearance.
Stream deactivation modal should be append to main
unique id, stream overlay element.
This commit also add `new-style` class to modal.

Fixes #12394
2019-06-20 11:09:52 -07:00
Yashashvi Dave 8e269b4651 models: Rename notification to `enable_stream_audible_notifications`.
Rename notification property `enable_stream_sounds` to
`enable_stream_audible_notifications` to match with other
notification property patterns.

Fixes part of #12304
2019-06-12 16:24:51 -07:00
YashRE42 869aaba6a7 overlays: Fix stream edit click-through bug.
Fixes #12369.
2019-06-06 14:57:16 -07:00
Yashashvi Dave 7d75cdef7f subs: Rename `in_home_view` checkbox-setting template element. 2019-05-30 21:39:06 -07:00
Yashashvi Dave 40f550038d subs: Replace all `in_home_view` uses with `is_muted` property.
Replace all uses of `in_home_view` subscription property
with `is_muted` property in frontend.

Fixes #12322
2019-05-30 21:39:06 -07:00
Anders Kaseorg 01613e71fb ui: Replace set_up_scrollbar with data-simplebar attribute.
With perfectScrollbar, we needed to call a function from JavaScript to
enable a scrollbar on a new element, but simplebar has a much simpler
default API one can do by using data-simplebar attributes in the HTML.

So we can delete all the scrollbar creation/deletion code.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-05-19 18:06:38 -07:00
Anders Kaseorg 141088586b Completely replace perfect-scrollbar with SimpleBar.
perfect-scrollbar replaces both the appearance and the behavior of the
scrollbar, and its emulated behavior will never feel native on most
platforms.  SimpleBar customizes the appearance while preserving the
native behavior.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-05-17 12:06:51 -07:00
Harshit Bansal b553507412 subscriptions: Migrate notification setting defaults model.
This commit migrates the Subscription's notification fields from a
BooleanField to a NullBooleanField where a value of None means to
inherit the value from user's profile.

Also includes a migrations to set the corresponding settings to None
if they match the user profile's values. This migration helps us in
getting rid of the weird "Apply to all" widget that we offered on
subscription settings page.

The mobile apps can't handle None appearing as the stream-level
notification settings, so for backwards-compatibility we arrange to
only send True/False to the mobile apps by applying those defaults
server-side.  We introduce a notification_settings_null value within a
client_capabilities structure that newer versions of the mobile apps
can use to request the new model.

This mobile compatibility code is pretty effectively tested by the
existing test_events tests for the subscriptions subsystem.
2019-05-08 17:45:10 -07:00
Yashashvi Dave 02a1b2e26b server events: Add realm-time-sync event to update stream privacy.
Add event to update stream settings whenever stream privacy is changed
accordingly.

Fixes #9470
2019-05-07 17:33:59 -07:00
Yashashvi Dave fbf25942d0 streams: Extract change-stream-permissions functions. 2019-05-07 17:33:59 -07:00
Yashashvi Dave ccd3b49555 streams: Disable sub-btn with explanation if user not allowed to subscribe. 2019-05-07 16:38:36 -07:00
Yashashvi Dave bfabb86f39 stream hash: Update hash before updating settings UI elements. 2019-05-06 17:30:33 -07:00
Yashashvi Dave 6ae6da5d22 stream_ui_updates: Move function `update_add_subscriptions_elements`. 2019-05-06 17:30:33 -07:00
Yashashvi Dave 71e561de76 stream_ui_updates: Extract `update_subscribers_list` function. 2019-05-06 17:30:33 -07:00
Yashashvi Dave 4cd33f23bc stream_ui_updates: Refactor update-stream-privacy-type function. 2019-05-06 17:30:33 -07:00
Yashashvi Dave d86ee6b4f0 stream_ui_updates: Extract `update_stream_privacy` function. 2019-05-06 17:30:33 -07:00
Yashashvi Dave 7a168216ff stream_ui_updates: Extract `update_change_stream_privacy_settings`. 2019-04-30 14:37:30 -07:00
Yashashvi Dave ecc165b899 stream_ui_updates: Extract `update_regular_sub_settings`. 2019-04-30 14:37:24 -07:00
Yashashvi Dave a71eb6aa15 subs: Extract change-stream-privacy block from function.
This commit removes code to update-stream-privacy-btn
in stream settings from update-sub-settings function.
Because stream-privacy-btn is not part of regular
sub-settings, it is admins only settings.
2019-04-30 14:36:52 -07:00
Yashashvi Dave 9dd9ea5721 stream settings: Update URL when opening empty settings panel. 2019-04-30 14:36:52 -07:00
Yashashvi Dave 460515a2ee stream settings: Extract `setup_subscriptions_tab_hash` function. 2019-04-30 14:36:52 -07:00
Yashashvi Dave ec5ef08a19 subs: Fix URL not updating as per UI on stream unsubscription.
When user unsubscribe from stream by clicking on
subscription-checkmark, the URL changes to unsubscribed
stream but stream settings UI is not updated.
We should change URL and stream settings modal
simultaneously. This PR moves update-hash function
inside open-stream-modal function, which make sure that
URL is getting updated everytime open-stream-modal
function is called and not otherwise.
2019-04-30 14:37:19 -07:00
Tim Abbott 60f33a374d streams: Fix announcement-only option being hidden.
Fixes an unpleasant regression in
746870df65.
2019-02-27 13:29:45 -08:00
Hemanth V. Alluri 77f24e2b56 click_handlers: Use stream desc. on edit instead of rendered desc.
On clicking the edit button for a stream description, the stream's
unrendered description should be made editable as text instead of
the stream's rendered description (which would be displayed as HTML
instead of text).

This completes the effort to use backend-rendered stream descriptions
here.  Fixes #11272.
2019-02-11 12:27:11 -08:00
Yashashvi Dave e8fbd855e6 subscriptions: Add tooltip, only subscribers can add user in private stream.
Add explanation in popover on disabled add-subscriptions input elements,
admin can't add subscribers to non subscribed private streams, only
subscribed users can.

Fixes #10593
2019-01-05 16:21:41 -08:00
Steve Howell 623e3f3c9f hashchange: Extract hash_util.stream_edit_uri. 2018-12-02 19:07:19 -08:00
Steve Howell 84d0b541e3 hashchange: Add hashchange.update_browser_history().
This helps us encapsulate the situation where we don't
want to trigger hashchanged(), without having to do it
within sub.js with prevent_once().
2018-12-02 19:07:10 -08:00
Steve Howell bea328b8b6 refactor: Split out functions for opening edit panel.
While they can share some code, opening the edit panel
for a stream and clearing the panel are pretty different
actions, so we simplify the API for each thing.

You no longer have to pass in booleans, and for the clear
case, you don't have to pass in a bogus node that just
gets ignored.
2018-12-02 18:40:00 -08:00
Steve Howell c91b804683 bug fix: Handle "Subscribe" button in empty views.
I don't know how long this has been broken, but it seems
some re-design of our message feed moved the Subscribe
button out #zfilt, so we use a different parent selector
now to turn on the click handler.

Hopefully this was a pretty obscure bug.  To reproduce
it go to "Manage Streams" and then select a stream you're
not subscribed to (from "All Streams"), and don't actually
subscribe, but then hit "View stream".

The user experience here is still a bit confusing, but
this is just a quick fix.
2018-09-28 14:08:37 -07:00
Yashashvi Dave 069acc08cd stream settings: Fix hide change-sub-type when admin unsubscribe stream.
Fixes #10163
2018-08-13 12:14:01 -07:00
Yashashvi Dave 55325b71a4 stream settings: Display nothing-selected when active-stream is deleted.
Display nothing-selected in stream settings tab, if we get delete-stream
event of active-stream(which stream's settings tab is opened) in
frontend.
2018-08-07 13:30:53 -07:00
Shubham Padia 7d6ee2e10a stream_edit: Display server error message when subscribing other users. 2018-07-31 11:12:09 -07:00
Sarah de2ec8a05c notification settings: Add UI for stream email notifications.
Previous commits have fully implemented the logic for stream email
notifications; this final commit adds support for configuring it to
the UI.

Fixes #6511.
2018-07-14 12:19:33 +05:30
Aditya Bansal ae6c8692a9 subscriptions_settings_modal: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:17:11 +05:30
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
Shubham Dhama 2aba7c239f list_render: Make list creation logic as an export in list_render module.
This changes how we create lists i.e.
    from `list_render($container, list, opts)`
        to `list_render.create($container, list, opts)`
2018-06-22 09:21:47 -04:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Shubham Dhama c6738889a9 eslint: Add and enable `space-unary-ops` rule.
Info about rule at https://eslint.org/docs/rules/space-unary-ops.
2018-06-05 00:47:35 +05:30
Shubham Dhama c03acaa078 streams: Improve and make stream_privacy_modal consistent with others.
Previously weren't registering modal properly, which gets fixed by
using open_modal. It further fixes closing of modal by using escape
and positioning of modal.

Fixes: #9590.
2018-06-01 10:05:13 -07:00
Shubham Padia 214ce1ccca streams: Add create and edit ui for is_announcement_only.
The user can now specify the value while creating a stream.
An admin can later change it via `Change stream permissions`
modal. Add is_announcement_only to subscription type text.
2018-05-30 14:22:15 -07:00
Tim Abbott 106d06b235 streams: Rename change_change_subscription_type to reference permissions.
This is a preparatory refactor for when we start having other
permissions options available in this UI (e.g. announcement-only streams).
2018-05-21 16:14:18 -07:00
Eeshan Garg 9c8865ba76 frontend: Add UI to create/edit private streams with public history.
This completes the effort of making this a user-facing feature.
2018-05-21 16:03:06 -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
Vishwesh Jainkuniya 3a514c7e41 stream-edit: Fix typo in comment. 2018-05-05 06:25:06 -07:00
Yashashvi Dave 86eddd79bc stream settings: Fix scrollbar bug on unsubscribing themselves.
Fix scrollbar not updating when user unsubscribe themselves
from "Stream members" list, by clicking "Unsubscribe" button.

Fixes #9029
2018-04-30 11:15:07 -07:00
Yashashvi Dave a28adb0ba3 stream settings: Reset stream description on error.
Reset old value of stream description on error. This commit
also update the error message on updating stream name and
description.
2018-04-30 10:11:25 -07:00
Yashashvi Dave 8729c9001d static/js/settings_streams.js: Move delete_stream func to `stream_edit.js`. 2018-04-30 17:48:16 +05:30
Tim Abbott feef35bf25 linter: Add checks for sloppy use of .html().
Since jQuery's .html() can be a source of security bugs, we add a new
lint rule that tries to catch common problematic uses.
2018-04-12 09:50:14 -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 ed70a92ed3 subscription: Fix error in being re-subscribed to private stream.
Fixes #9023
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
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
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
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 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
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 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 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
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
YJDave 81599cf906 stream settings: Display warning if user can not access subscribers.
Display warning, saying "You can not access private stream subscribers,
in which you aren't subscribed", if user can not access subscribers;
instead of showing zero subscriber to stream.
2018-01-22 18:26:36 -05:00
YJDave c22285c154 stream settings: Allow org admin to update settings of unsub-stream.
As per backend validations.
2018-01-22 18:26:36 -05:00
YJDave 8905744bb1 stream settings: Add period at the end of error messages. 2018-01-19 13:05:43 -05:00
YJDave d80d5a2443 stream settings: Restore original stream name in UI on error.
Update stream-name-editable span in UI if it throws error
changing stream name.
2018-01-04 16:52:54 -05:00