compose_ui: Add "(guest)" to user names in compose box placeholder.

This commit adds "(guest)" indicator to guest user names in
compose box placeholder if enable_guest_user_indicator setting
is enabled in the organization.
This commit is contained in:
Sahil Batra 2023-09-18 14:37:14 +05:30 committed by Tim Abbott
parent 127378f0ec
commit 7d7698930a
2 changed files with 17 additions and 0 deletions

View File

@ -252,6 +252,9 @@ export function compute_placeholder_text(opts) {
const recipient_names = recipient_list
.map((recipient) => {
const user = people.get_by_email(recipient);
if (people.should_add_guest_user_indicator(user.user_id)) {
return $t({defaultMessage: "{name} (guest)"}, {name: user.full_name});
}
return user.full_name;
})
.join(", ");

View File

@ -6,6 +6,7 @@ const {$t} = require("./lib/i18n");
const {mock_esm, set_global, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery");
const {page_params} = require("./lib/zpage_params");
const noop = () => {};
@ -248,6 +249,19 @@ run_test("compute_placeholder_text", () => {
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message Alice, Bob"}),
);
alice.is_guest = true;
page_params.realm_enable_guest_user_indicator = true;
assert.equal(
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message translated: Alice (guest), Bob"}),
);
page_params.realm_enable_guest_user_indicator = false;
assert.equal(
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message Alice, Bob"}),
);
});
run_test("quote_and_reply", ({override, override_rewire}) => {