compose: Update the New topic button to New stream message in PMs.

If a user is narrowed by `is:private`, `pm-with`, or `group-pm-with`,
change the `New topic` button to say `New stream message` instead for
added clarity.

Also, add to the Casper and Node tests for this behavior.

Fix #9072.
This commit is contained in:
Marco Burstein
2018-08-08 20:59:55 -07:00
committed by Tim Abbott
parent 0a99fa2fd6
commit 6f14f4f047
4 changed files with 25 additions and 0 deletions

View File

@@ -88,6 +88,8 @@ function expect_stream_subject() {
'<p>test message B</p>',
'<p>test message D</p>',
]);
casper.test.assertEquals(casper.fetchText('#left_bar_compose_stream_button_big'), 'New topic');
});
});
}
@@ -149,6 +151,8 @@ function expect_all_pm() {
'<p>personal D</p>',
'<p>personal E</p>',
]);
casper.test.assertEquals(casper.fetchText('#left_bar_compose_stream_button_big'), 'New stream message');
});
});
}

View File

@@ -10,6 +10,7 @@ zrequire('search_pill');
set_global('blueslip', {});
set_global('channel', {});
set_global('compose', {});
set_global('compose_actions', {});
set_global('current_msg_list', {});
set_global('hashchange', {});
@@ -82,6 +83,7 @@ function test_helper() {
stub('top_left_corner', 'handle_narrow_activated');
stub('ui_util', 'change_tab_to');
stub('unread_ops', 'process_visible');
stub('compose', 'update_stream_button_for_stream');
stub_trigger(() => { events.push('trigger event'); });
@@ -206,6 +208,7 @@ run_test('basics', () => {
'message_scroll.hide_indicators',
'unread_ops.process_visible',
'hashchange.save_narrow',
'compose.update_stream_button_for_stream',
'search.update_button_visibility',
'compose_actions.on_narrow',
'top_left_corner.handle_narrow_activated',

View File

@@ -100,6 +100,16 @@ exports.clear_preview_area = function () {
$("#markdown_preview").show();
};
exports.update_stream_button_for_private = function () {
$("#left_bar_compose_stream_button_big").html(i18n.t("New stream message"));
$("#left_bar_compose_stream_button_big").prop("title", i18n.t("New stream message"));
};
exports.update_stream_button_for_stream = function () {
$("#left_bar_compose_stream_button_big").html(i18n.t("New topic"));
$("#left_bar_compose_stream_button_big").prop("title", i18n.t("New topic"));
};
function update_fade() {
if (!compose_state.composing()) {
return;

View File

@@ -253,6 +253,13 @@ exports.activate = function (raw_operators, opts) {
});
}
if (filter.has_operator("is") && filter.operands("is")[0] === "private"
|| filter.has_operator("pm-with") || filter.has_operator("group-pm-with")) {
compose.update_stream_button_for_private();
} else {
compose.update_stream_button_for_stream();
}
// Put the narrow operators in the search bar.
$('#search_query').val(Filter.unparse(operators));
search.update_button_visibility();
@@ -670,6 +677,7 @@ exports.deactivate = function () {
top_left_corner.handle_narrow_deactivated();
stream_list.handle_narrow_deactivated();
compose.update_stream_button_for_stream();
$(document).trigger($.Event('narrow_deactivated.zulip', {msg_list: current_msg_list}));