mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
Add stream_data.get_streams_for_admin().
This commit is contained in:
@@ -328,6 +328,7 @@ zrequire('stream_data');
|
||||
name: 'c',
|
||||
color: 'cinnamon',
|
||||
subscribed: true,
|
||||
invite_only: false,
|
||||
};
|
||||
|
||||
var blue = {
|
||||
@@ -335,6 +336,7 @@ zrequire('stream_data');
|
||||
name: 'b',
|
||||
color: 'blue',
|
||||
subscribed: false,
|
||||
invite_only: false,
|
||||
};
|
||||
|
||||
var amber = {
|
||||
@@ -342,6 +344,7 @@ zrequire('stream_data');
|
||||
name: 'a',
|
||||
color: 'amber',
|
||||
subscribed: true,
|
||||
invite_only: true,
|
||||
};
|
||||
stream_data.clear_subscriptions();
|
||||
stream_data.add_sub(cinnamon.name, cinnamon);
|
||||
@@ -353,6 +356,14 @@ zrequire('stream_data');
|
||||
assert.equal(sub_rows[1].color, 'amber');
|
||||
assert.equal(sub_rows[2].color, 'cinnamon');
|
||||
|
||||
sub_rows = stream_data.get_streams_for_admin();
|
||||
assert.equal(sub_rows[0].name, 'a');
|
||||
assert.equal(sub_rows[1].name, 'b');
|
||||
assert.equal(sub_rows[2].name, 'c');
|
||||
assert.equal(sub_rows[0].invite_only, true);
|
||||
assert.equal(sub_rows[1].invite_only, false);
|
||||
assert.equal(sub_rows[2].invite_only, false);
|
||||
|
||||
}());
|
||||
|
||||
(function test_get_non_default_stream_names() {
|
||||
|
||||
@@ -444,6 +444,19 @@ exports.get_streams_for_settings_page = function () {
|
||||
return all_subs;
|
||||
};
|
||||
|
||||
exports.get_streams_for_admin = function () {
|
||||
// Sort and combine all our streams.
|
||||
function by_name(a,b) {
|
||||
return util.strcmp(a.name, b.name);
|
||||
}
|
||||
|
||||
var subs = stream_info.values();
|
||||
|
||||
subs.sort(by_name);
|
||||
|
||||
return subs;
|
||||
};
|
||||
|
||||
exports.initialize_from_page_params = function () {
|
||||
function populate_subscriptions(subs, subscribed) {
|
||||
subs.forEach(function (sub) {
|
||||
|
||||
Reference in New Issue
Block a user