mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
Add stream_data.get_streams_for_admin().
This commit is contained in:
@@ -328,6 +328,7 @@ zrequire('stream_data');
|
|||||||
name: 'c',
|
name: 'c',
|
||||||
color: 'cinnamon',
|
color: 'cinnamon',
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
|
invite_only: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
var blue = {
|
var blue = {
|
||||||
@@ -335,6 +336,7 @@ zrequire('stream_data');
|
|||||||
name: 'b',
|
name: 'b',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
subscribed: false,
|
subscribed: false,
|
||||||
|
invite_only: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
var amber = {
|
var amber = {
|
||||||
@@ -342,6 +344,7 @@ zrequire('stream_data');
|
|||||||
name: 'a',
|
name: 'a',
|
||||||
color: 'amber',
|
color: 'amber',
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
|
invite_only: true,
|
||||||
};
|
};
|
||||||
stream_data.clear_subscriptions();
|
stream_data.clear_subscriptions();
|
||||||
stream_data.add_sub(cinnamon.name, cinnamon);
|
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[1].color, 'amber');
|
||||||
assert.equal(sub_rows[2].color, 'cinnamon');
|
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() {
|
(function test_get_non_default_stream_names() {
|
||||||
|
|||||||
@@ -444,6 +444,19 @@ exports.get_streams_for_settings_page = function () {
|
|||||||
return all_subs;
|
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 () {
|
exports.initialize_from_page_params = function () {
|
||||||
function populate_subscriptions(subs, subscribed) {
|
function populate_subscriptions(subs, subscribed) {
|
||||||
subs.forEach(function (sub) {
|
subs.forEach(function (sub) {
|
||||||
|
|||||||
Reference in New Issue
Block a user