mirror of https://github.com/zulip/zulip.git
hotkeys: Disable 'n' stream creation if user cannot create streams.
Tweaked by tabbott to handle a corner case and add test coverage.
This commit is contained in:
parent
901e0258df
commit
bd7d9da668
|
@ -17,6 +17,9 @@ set_global('activity', {
|
|||
set_global('drafts', {
|
||||
});
|
||||
|
||||
set_global('page_params', {
|
||||
});
|
||||
|
||||
set_global('overlays', {
|
||||
});
|
||||
|
||||
|
@ -194,12 +197,15 @@ function stubbing(func_name_to_stub, test_function) {
|
|||
hotkey.processing_text = return_false;
|
||||
overlays.settings_open = return_false;
|
||||
|
||||
page_params.can_create_streams = true;
|
||||
overlays.streams_open = return_true;
|
||||
overlays.is_active = return_true;
|
||||
assert_mapping('S', 'subs.keyboard_sub');
|
||||
overlays.is_active = return_false;
|
||||
assert_mapping('V', 'subs.view_stream');
|
||||
assert_mapping('n', 'subs.new_stream_clicked');
|
||||
page_params.can_create_streams = false;
|
||||
assert_unmapped('n');
|
||||
overlays.is_active = return_false;
|
||||
overlays.streams_open = return_false;
|
||||
|
||||
assert_mapping('?', 'ui.maybe_show_keyboard_shortcuts');
|
||||
|
|
|
@ -603,14 +603,18 @@ exports.process_hotkey = function (e, hotkey) {
|
|||
case 'view_selected_stream':
|
||||
if (overlays.streams_open()) {
|
||||
subs.view_stream();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case 'n_key':
|
||||
if (overlays.streams_open()) {
|
||||
subs.new_stream_clicked();
|
||||
} else {
|
||||
narrow.narrow_to_next_topic();
|
||||
if (page_params.can_create_streams) {
|
||||
subs.new_stream_clicked();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
narrow.narrow_to_next_topic();
|
||||
return true;
|
||||
case 'open_drafts':
|
||||
drafts.toggle();
|
||||
|
|
Loading…
Reference in New Issue