mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
hotkeys: Add hotkey n for opening New streams modal in Streams menu.
This commit is contained in:
@@ -139,7 +139,7 @@ function stubbing(func_name_to_stub, test_function) {
|
|||||||
|
|
||||||
// Unmapped keys should immediately return false, without
|
// Unmapped keys should immediately return false, without
|
||||||
// calling any functions outside of hotkey.js.
|
// calling any functions outside of hotkey.js.
|
||||||
assert_unmapped('abdefhlmnoptuxyz');
|
assert_unmapped('abdefhlmoptuxyz');
|
||||||
assert_unmapped('BEFHILNOQTWXYZ');
|
assert_unmapped('BEFHILNOQTWXYZ');
|
||||||
|
|
||||||
// We have to skip some checks due to the way the code is
|
// We have to skip some checks due to the way the code is
|
||||||
@@ -178,6 +178,7 @@ function stubbing(func_name_to_stub, test_function) {
|
|||||||
hotkey.is_subs = return_true;
|
hotkey.is_subs = return_true;
|
||||||
assert_mapping('U', 'subs.keyboard_sub');
|
assert_mapping('U', 'subs.keyboard_sub');
|
||||||
assert_mapping('V', 'subs.view_stream');
|
assert_mapping('V', 'subs.view_stream');
|
||||||
|
assert_mapping('n', 'subs.new_stream_clicked');
|
||||||
hotkey.is_subs = return_false;
|
hotkey.is_subs = return_false;
|
||||||
|
|
||||||
assert_mapping('?', 'ui.show_info_overlay');
|
assert_mapping('?', 'ui.show_info_overlay');
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ var keypress_mappings = {
|
|||||||
105: {name: 'message_actions', message_view_only: true}, // 'i'
|
105: {name: 'message_actions', message_view_only: true}, // 'i'
|
||||||
106: {name: 'vim_down', message_view_only: true}, // 'j'
|
106: {name: 'vim_down', message_view_only: true}, // 'j'
|
||||||
107: {name: 'vim_up', message_view_only: true}, // 'k'
|
107: {name: 'vim_up', message_view_only: true}, // 'k'
|
||||||
|
110: {name: 'new_stream', message_view_only: false}, // 'n'
|
||||||
113: {name: 'query_users', message_view_only: false}, // 'q'
|
113: {name: 'query_users', message_view_only: false}, // 'q'
|
||||||
114: {name: 'reply_message', message_view_only: true}, // 'r'
|
114: {name: 'reply_message', message_view_only: true}, // 'r'
|
||||||
115: {name: 'narrow_by_recipient', message_view_only: true}, // 's'
|
115: {name: 'narrow_by_recipient', message_view_only: true}, // 's'
|
||||||
@@ -593,6 +594,11 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
subs.view_stream();
|
subs.view_stream();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case 'new_stream':
|
||||||
|
if (exports.is_subs()) {
|
||||||
|
subs.new_stream_clicked();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_msg_list.empty()) {
|
if (current_msg_list.empty()) {
|
||||||
|
|||||||
@@ -685,7 +685,7 @@ exports.change_state = (function () {
|
|||||||
if (hash.arguments.length > 0) {
|
if (hash.arguments.length > 0) {
|
||||||
// if in #streams/new form.
|
// if in #streams/new form.
|
||||||
if (hash.arguments[0] === "new") {
|
if (hash.arguments[0] === "new") {
|
||||||
$("#create_stream_button").click();
|
exports.new_stream_clicked();
|
||||||
components.toggle.lookup("stream-filter-toggle").goto("All streams");
|
components.toggle.lookup("stream-filter-toggle").goto("All streams");
|
||||||
} else if (hash.arguments[0] === "all") {
|
} else if (hash.arguments[0] === "all") {
|
||||||
components.toggle.lookup("stream-filter-toggle").goto("All streams");
|
components.toggle.lookup("stream-filter-toggle").goto("All streams");
|
||||||
@@ -1000,34 +1000,7 @@ exports.sub_or_unsub = function (sub) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.new_stream_clicked = function () {
|
||||||
$(function () {
|
|
||||||
|
|
||||||
stream_data.initialize_from_page_params();
|
|
||||||
stream_list.create_initial_sidebar_rows();
|
|
||||||
|
|
||||||
// We build the stream_list now. It may get re-built again very shortly
|
|
||||||
// when new messages come in, but it's fairly quick.
|
|
||||||
stream_list.build_stream_list();
|
|
||||||
|
|
||||||
var show_subs_pane = {
|
|
||||||
nothing_selected: function () {
|
|
||||||
$(".nothing-selected, #stream_settings_title").show();
|
|
||||||
$("#add_new_stream_title, .settings, #stream-creation").hide();
|
|
||||||
},
|
|
||||||
stream_creation: function () {
|
|
||||||
$("#stream_settings_title, .subscriptions-container .settings, .nothing-selected").hide();
|
|
||||||
$("#stream-creation, #add_new_stream_title").show();
|
|
||||||
},
|
|
||||||
settings: function () {
|
|
||||||
$(".settings, #stream_settings_title").show();
|
|
||||||
$("#add_new_stream_title, #stream-creation, .nothing-selected").hide();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
$("#subscriptions_table").on("click", "#create_stream_button", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var stream = $.trim($("#search_stream_name").val());
|
var stream = $.trim($("#search_stream_name").val());
|
||||||
|
|
||||||
if (!should_list_all_streams()) {
|
if (!should_list_all_streams()) {
|
||||||
@@ -1044,7 +1017,8 @@ $(function () {
|
|||||||
|
|
||||||
$(".stream-row.active").removeClass("active");
|
$(".stream-row.active").removeClass("active");
|
||||||
|
|
||||||
show_subs_pane.stream_creation();
|
$("#stream_settings_title, .subscriptions-container .settings, .nothing-selected").hide();
|
||||||
|
$("#stream-creation, #add_new_stream_title").show();
|
||||||
|
|
||||||
$('#create_stream_name').val(stream);
|
$('#create_stream_name').val(stream);
|
||||||
show_new_stream_modal();
|
show_new_stream_modal();
|
||||||
@@ -1064,6 +1038,32 @@ $(function () {
|
|||||||
// easy discovery.
|
// easy discovery.
|
||||||
|
|
||||||
window.location.hash = "#streams/new";
|
window.location.hash = "#streams/new";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
stream_data.initialize_from_page_params();
|
||||||
|
stream_list.create_initial_sidebar_rows();
|
||||||
|
|
||||||
|
// We build the stream_list now. It may get re-built again very shortly
|
||||||
|
// when new messages come in, but it's fairly quick.
|
||||||
|
stream_list.build_stream_list();
|
||||||
|
|
||||||
|
var show_subs_pane = {
|
||||||
|
nothing_selected: function () {
|
||||||
|
$(".nothing-selected, #stream_settings_title").show();
|
||||||
|
$("#add_new_stream_title, .settings, #stream-creation").hide();
|
||||||
|
},
|
||||||
|
settings: function () {
|
||||||
|
$(".settings, #stream_settings_title").show();
|
||||||
|
$("#add_new_stream_title, #stream-creation, .nothing-selected").hide();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$("#subscriptions_table").on("click", "#create_stream_button", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
exports.new_stream_clicked();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('change', '#user-checkboxes input, #make-invite-only input', update_announce_stream_state);
|
$('body').on('change', '#user-checkboxes input, #make-invite-only input', update_announce_stream_state);
|
||||||
|
|||||||
Reference in New Issue
Block a user