From 32407b4dc062f2013fdefe1e7b04cc01377673f8 Mon Sep 17 00:00:00 2001 From: YJDave Date: Sat, 10 Feb 2018 00:35:56 +0530 Subject: [PATCH] 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. --- static/js/stream_edit.js | 26 +++++++++------ .../templates/subscription_members.handlebars | 32 +++++++++++++++++++ .../subscription_settings.handlebars | 30 ++--------------- 3 files changed, 52 insertions(+), 36 deletions(-) create mode 100644 static/templates/subscription_members.handlebars diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 40be3869d3..9c34e75b4f 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -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")); + } } }; diff --git a/static/templates/subscription_members.handlebars b/static/templates/subscription_members.handlebars new file mode 100644 index 0000000000..23aaec78ab --- /dev/null +++ b/static/templates/subscription_members.handlebars @@ -0,0 +1,32 @@ +{{#render_subscribers}} +
+
+ {{t "Stream membership" }} +
+
+
+
+ {{#if can_add_subscribers}} + + + + {{/if}} +
+
+
+
+
+
+
+ {{#if can_add_subscribers}} +
+ {{else}} +
+ {{t "This stream is private, so you can't see who is subscribed." }} +
+ {{/if}} +
+
+{{/render_subscribers}} diff --git a/static/templates/subscription_settings.handlebars b/static/templates/subscription_settings.handlebars index 9c386fe081..2e62a83ba9 100644 --- a/static/templates/subscription_settings.handlebars +++ b/static/templates/subscription_settings.handlebars @@ -107,33 +107,9 @@ {{/if}} - - {{#render_subscribers}} - {{#if can_add_subscribers}} -
-
- {{t "Stream membership" }} -
-
-
-
- - - -
-
-
-
-
-
-
-
-
-
- {{/if}} - {{/render_subscribers}} +
+ {{partial "subscription_members"}} +
{{/with}}