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.
This commit is contained in:
YJDave 2018-02-10 00:35:56 +05:30 committed by Tim Abbott
parent 920afb9447
commit 32407b4dc0
3 changed files with 52 additions and 36 deletions

View File

@ -24,16 +24,24 @@ function get_email_of_subscribers(subscribers) {
}
exports.rerender_subscribers_list = function (sub) {
var emails = get_email_of_subscribers(sub.subscribers);
var subscribers_list = list_render.get("stream_subscribers/" + sub.stream_id);
if (!sub.can_add_subscribers) {
// It is also possible that user don't have rights to access subscribers.
// If user can't add subscribers, user can't access subscribers.
var html = templates.render('subscription_members', sub);
var stream_settings = settings_for_sub(sub);
stream_settings.find('.subscription-members-setting').expectOne().html(html);
} else {
var emails = get_email_of_subscribers(sub.subscribers);
var subscribers_list = list_render.get("stream_subscribers/" + sub.stream_id);
// Changing the data clears the rendered list and the list needs to be re-rendered.
// Perform re-rendering only when the stream settings form of the corresponding
// stream is open.
if (subscribers_list) {
subscribers_list.data(emails);
subscribers_list.render();
ui.update_scrollbar($(".subscriber_list_container"));
// Changing the data clears the rendered list and the list needs to be re-rendered.
// Perform re-rendering only when the stream settings form of the corresponding
// stream is open.
if (subscribers_list) {
subscribers_list.data(emails);
subscribers_list.render();
ui.update_scrollbar($(".subscriber_list_container"));
}
}
};

View File

@ -0,0 +1,32 @@
{{#render_subscribers}}
<div class="subscriber_list_settings">
<div class="sub_settings_title float-left">
{{t "Stream membership" }}
<div class="stream_subscription_info small"></div>
</div>
<div class="subscriber_list_add float-right">
<form class="form-inline">
{{#if can_add_subscribers}}
<input type="text" class="search" placeholder="{{t 'Search subscribers' }}" />
<input type="text" name="principal" placeholder="{{t 'Email address' }}" value="" class="input-block" autocomplete="off" tabindex="-1" />
<button type="submit" name="add_subscriber" class="button add-subscriber-button small rounded" tabindex="-1 ">
{{t 'Add' }}
</button>
{{/if}}
</form>
</div>
<div class="clear-float"></div>
</div>
<div class="subscriber-list-box">
<div class="subscriber_list_container">
<div class="subscriber_list_loading_indicator"></div>
{{#if can_add_subscribers}}
<table class="subscriber-list"></table>
{{else}}
<div class="hide-subscriber-list">
{{t "This stream is private, so you can't see who is subscribed." }}
</div>
{{/if}}
</div>
</div>
{{/render_subscribers}}

View File

@ -107,33 +107,9 @@
</div>
{{/if}}
</div>
{{#render_subscribers}}
{{#if can_add_subscribers}}
<div class="subscriber_list_settings">
<div class="sub_settings_title float-left">
{{t "Stream membership" }}
<div class="stream_subscription_info small"></div>
</div>
<div class="subscriber_list_add float-right">
<form class="form-inline">
<input type="text" class="search" placeholder="{{t 'Search subscribers' }}" />
<input type="text" name="principal" placeholder="{{t 'Email address' }}" value="" class="input-block" autocomplete="off" tabindex="-1" />
<button type="submit" name="add_subscriber" class="button add-subscriber-button small rounded" tabindex="-1 ">
{{t 'Add' }}
</button>
</form>
</div>
<div class="clear-float"></div>
</div>
<div class="subscriber-list-box">
<div class="subscriber_list_container">
<div class="subscriber_list_loading_indicator"></div>
<table class="subscriber-list"></table>
</div>
</div>
{{/if}}
{{/render_subscribers}}
<div class="subscription-members-setting">
{{partial "subscription_members"}}
</div>
</div>
</div>
{{/with}}