mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
settings: Add display setting for demoting inactive streams.
This adds a setting to control Zulip's default behavior of sorting to bottom and graying out inactive streams. The previous logic is still the default "automatic", but this gives users more control. See the models.py comment for details. Fixes #11524.
This commit is contained in:
@@ -607,6 +607,12 @@ var event_fixtures = {
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__demote_inactive_streams: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'demote_inactive_streams',
|
||||
setting: 2,
|
||||
},
|
||||
|
||||
update_display_settings__translate_emoticons: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'translate_emoticons',
|
||||
@@ -1389,6 +1395,14 @@ with_overrides(function (override) {
|
||||
page_params.fluid_layout_width = false;
|
||||
dispatch(event);
|
||||
assert_same(page_params.fluid_layout_width, true);
|
||||
|
||||
global.with_stub(function (stub) {
|
||||
event = event_fixtures.update_display_settings__demote_inactive_streams;
|
||||
override('stream_list.update_streams_sidebar', stub.f);
|
||||
page_params.demote_inactive_streams = 1;
|
||||
dispatch(event);
|
||||
assert_same(page_params.demote_inactive_streams, 2);
|
||||
});
|
||||
});
|
||||
|
||||
with_overrides(function (override) {
|
||||
|
||||
@@ -55,6 +55,8 @@ const denmark_stream = {
|
||||
// to make our tests more self-containted.
|
||||
|
||||
zrequire('stream_data');
|
||||
set_global('i18n', global.stub_i18n);
|
||||
zrequire('settings_display');
|
||||
|
||||
run_test('stream_data', () => {
|
||||
assert.equal(stream_data.get_sub_by_name('Denmark'), undefined);
|
||||
|
||||
@@ -9,6 +9,7 @@ set_global('$', function () {
|
||||
|
||||
set_global('blueslip', global.make_zblueslip());
|
||||
set_global('document', null);
|
||||
set_global('i18n', global.stub_i18n);
|
||||
global.stub_out_jquery();
|
||||
|
||||
zrequire('color_data');
|
||||
@@ -24,6 +25,7 @@ zrequire('Filter', 'js/filter');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('MessageListView', 'js/message_list_view');
|
||||
zrequire('message_list');
|
||||
zrequire('settings_display', 'js/settings_display');
|
||||
|
||||
run_test('basics', () => {
|
||||
var denmark = {
|
||||
@@ -291,15 +293,45 @@ run_test('is_active', () => {
|
||||
|
||||
var sub;
|
||||
|
||||
page_params.demote_inactive_streams =
|
||||
settings_display.demote_inactive_streams_values.automatic.code;
|
||||
|
||||
sub = {name: 'pets', subscribed: false, stream_id: 111};
|
||||
stream_data.add_sub('pets', sub);
|
||||
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
stream_data.set_filter_out_inactives(true);
|
||||
stream_data.subscribe_myself(sub);
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
stream_data.unsubscribe_myself(sub);
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
sub.pin_to_top = true;
|
||||
assert(stream_data.is_active(sub));
|
||||
sub.pin_to_top = false;
|
||||
|
||||
var opts = {
|
||||
stream_id: 222,
|
||||
message_id: 108,
|
||||
topic_name: 'topic2',
|
||||
};
|
||||
topic_data.add_message(opts);
|
||||
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
page_params.demote_inactive_streams =
|
||||
settings_display.demote_inactive_streams_values.always.code;
|
||||
|
||||
sub = {name: 'pets', subscribed: false, stream_id: 111};
|
||||
stream_data.add_sub('pets', sub);
|
||||
|
||||
assert(!stream_data.is_active(sub));
|
||||
|
||||
sub.pin_to_top = true;
|
||||
assert(stream_data.is_active(sub));
|
||||
sub.pin_to_top = false;
|
||||
|
||||
stream_data.subscribe_myself(sub);
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
@@ -309,13 +341,29 @@ run_test('is_active', () => {
|
||||
sub = {name: 'lunch', subscribed: false, stream_id: 222};
|
||||
stream_data.add_sub('lunch', sub);
|
||||
|
||||
assert(!stream_data.is_active(sub));
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
topic_data.add_message(opts);
|
||||
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
page_params.demote_inactive_streams =
|
||||
settings_display.demote_inactive_streams_values.never.code;
|
||||
|
||||
sub = {name: 'pets', subscribed: false, stream_id: 111};
|
||||
stream_data.add_sub('pets', sub);
|
||||
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
stream_data.subscribe_myself(sub);
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
stream_data.unsubscribe_myself(sub);
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
sub.pin_to_top = true;
|
||||
assert(stream_data.is_active(sub));
|
||||
|
||||
var opts = {
|
||||
stream_id: 222,
|
||||
message_id: 108,
|
||||
topic_name: 'topic2',
|
||||
};
|
||||
topic_data.add_message(opts);
|
||||
|
||||
assert(stream_data.is_active(sub));
|
||||
@@ -695,6 +743,7 @@ run_test('initialize', () => {
|
||||
}
|
||||
|
||||
initialize();
|
||||
page_params.demote_inactive_streams = 1;
|
||||
page_params.realm_notifications_stream_id = -1;
|
||||
stream_data.initialize();
|
||||
assert(!stream_data.is_filtering_inactives());
|
||||
|
||||
@@ -18,6 +18,8 @@ zrequire('list_cursor');
|
||||
zrequire('stream_list');
|
||||
zrequire('topic_zoom');
|
||||
zrequire('ui');
|
||||
set_global('i18n', global.stub_i18n);
|
||||
zrequire('settings_display');
|
||||
|
||||
stream_color.initialize();
|
||||
|
||||
@@ -33,10 +35,15 @@ set_global('keydown_util', {
|
||||
handle: noop,
|
||||
});
|
||||
|
||||
set_global('page_params', {
|
||||
is_admin: false,
|
||||
realm_users: [],
|
||||
});
|
||||
|
||||
run_test('create_sidebar_row', () => {
|
||||
// Make a couple calls to create_sidebar_row() and make sure they
|
||||
// generate the right markup as well as play nice with get_stream_li().
|
||||
|
||||
page_params.demote_inactive_streams = 1;
|
||||
var devel = {
|
||||
name: 'devel',
|
||||
stream_id: 100,
|
||||
|
||||
@@ -121,6 +121,7 @@ zrequire('starred_messages');
|
||||
zrequire('user_status');
|
||||
zrequire('user_status_ui');
|
||||
zrequire('ui_init');
|
||||
zrequire('settings_display');
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user