Created stream_list.redraw_stream_privacy().

This function can redraws the lock icon (or lack of lock icon)
for a stream in the stream sidebar.  It can be called when
admins change the stream privacy.

(imported from commit 880133d02525137094c48ecad8cf2dfff59f3307)
This commit is contained in:
Steve Howell
2014-01-17 12:23:39 -05:00
parent a9e621fff4
commit bca0311b53
3 changed files with 28 additions and 0 deletions

View File

@@ -147,6 +147,22 @@ exports.add_stream_to_sidebar = function (stream_name) {
return build_stream_sidebar_row(stream_name);
};
exports.redraw_stream_privacy = function (stream_name) {
var li = exports.get_stream_li(stream_name);
var div = li.find('.stream-privacy');
var sub = stream_data.get_sub(stream_name);
var color = stream_data.get_color(stream_name);
var dark_background = stream_color.get_color_class(color);
var args = {
invite_only: sub.invite_only,
dark_background: dark_background
};
var html = templates.render('stream_privacy', args);
div.html(html);
};
exports.get_stream_li = function (stream_name) {
return get_filter_li('stream', stream_name);
};

View File

@@ -78,6 +78,10 @@ global.write_test_output = function (label, output) {
fs.appendFileSync(output_fn, data);
};
global.append_test_output = function (output) {
fs.appendFileSync(output_fn, output);
};
tests.forEach(function (filename) {
if (filename === 'index') {
return;

View File

@@ -85,4 +85,12 @@ global.use_template('stream_privacy');
assert.equal(li.find('a.subscription_name').text().trim(), 'social');
assert(li.find('.arrow').find("i").hasClass("icon-vector-chevron-down"));
global.append_test_output("Then make 'social' private.");
global.stream_data.get_sub('social').invite_only = true;
stream_list.redraw_stream_privacy('social');
html = $("body").html();
global.append_test_output(html);
assert(li.find('.stream-privacy').find("i").hasClass("icon-vector-lock"));
}());