mirror of https://github.com/zulip/zulip.git
typeahead helper: Hide email under hidden email-address-visibility cases.
In email hidden case (that is when `email_address_visibilty` is set to everyone), for "non admins", this commit hides emails from: - compose box user typeahead. - PM user typeahead In email hidden case, for admins, email is shown in user typeaheads.
This commit is contained in:
parent
cdc50090b6
commit
8eac7394f8
|
@ -14,6 +14,7 @@ zrequire('user_pill');
|
|||
zrequire('compose_pm_pill');
|
||||
zrequire('composebox_typeahead');
|
||||
zrequire('recent_senders');
|
||||
zrequire('settings_org');
|
||||
set_global('md5', function (s) {
|
||||
return 'md5-' + s;
|
||||
});
|
||||
|
@ -613,17 +614,17 @@ run_test('initialize', () => {
|
|||
// corresponding parts in bold.
|
||||
options.query = 'oth';
|
||||
actual_value = options.highlighter(othello);
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-othello@zulip.com?d=identicon&s=50" />\n<strong>Othello, the Moor of Venice</strong> \n<small class="autocomplete_secondary">othello@zulip.com</small>\n';
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-othello@zulip.com?d=identicon&s=50" />\n<strong>Othello, the Moor of Venice</strong>';
|
||||
assert.equal(actual_value, expected_value);
|
||||
|
||||
options.query = 'Lear';
|
||||
actual_value = options.highlighter(cordelia);
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-cordelia@zulip.com?d=identicon&s=50" />\n<strong>Cordelia Lear</strong> \n<small class="autocomplete_secondary">cordelia@zulip.com</small>\n';
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-cordelia@zulip.com?d=identicon&s=50" />\n<strong>Cordelia Lear</strong>';
|
||||
assert.equal(actual_value, expected_value);
|
||||
|
||||
options.query = 'othello@zulip.com, co';
|
||||
actual_value = options.highlighter(cordelia);
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-cordelia@zulip.com?d=identicon&s=50" />\n<strong>Cordelia Lear</strong> \n<small class="autocomplete_secondary">cordelia@zulip.com</small>\n';
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-cordelia@zulip.com?d=identicon&s=50" />\n<strong>Cordelia Lear</strong>';
|
||||
assert.equal(actual_value, expected_value);
|
||||
|
||||
// options.matcher()
|
||||
|
@ -776,7 +777,7 @@ run_test('initialize', () => {
|
|||
// content_highlighter.
|
||||
fake_this = { completing: 'mention', token: 'othello' };
|
||||
actual_value = options.highlighter.call(fake_this, othello);
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-othello@zulip.com?d=identicon&s=50" />\n<strong>Othello, the Moor of Venice</strong> \n<small class="autocomplete_secondary">othello@zulip.com</small>\n';
|
||||
expected_value = ' <img class="typeahead-image" src="https://secure.gravatar.com/avatar/md5-othello@zulip.com?d=identicon&s=50" />\n<strong>Othello, the Moor of Venice</strong>';
|
||||
assert.equal(actual_value, expected_value);
|
||||
|
||||
fake_this = { completing: 'mention', token: 'hamletcharacters' };
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
set_global('i18n', global.stub_i18n);
|
||||
set_global('page_params', {realm_is_zephyr_mirror_realm: false});
|
||||
set_global('templates', {});
|
||||
set_global('md5', function (s) {
|
||||
|
@ -14,6 +15,7 @@ zrequire('stream_data');
|
|||
zrequire('narrow');
|
||||
zrequire('hash_util');
|
||||
zrequire('marked', 'third/marked/lib/marked');
|
||||
zrequire('settings_org');
|
||||
var th = zrequire('typeahead_helper');
|
||||
|
||||
stream_data.create_streams([
|
||||
|
@ -399,7 +401,23 @@ run_test('highlight_with_escaping', () => {
|
|||
assert.equal(result, expected);
|
||||
});
|
||||
|
||||
run_test('render_person when emails hidden', () => {
|
||||
// Test render_person with regular person, under hidden email visiblity case
|
||||
settings_org.show_email = () => false;
|
||||
var rendered = false;
|
||||
global.templates.render = function (template_name, args) {
|
||||
assert.equal(template_name, 'typeahead_list_item');
|
||||
assert.equal(args.primary, matches[2].full_name);
|
||||
assert.equal(args.secondary, undefined);
|
||||
rendered = true;
|
||||
return 'typeahead-item-stub';
|
||||
};
|
||||
assert.equal(th.render_person(matches[2]), 'typeahead-item-stub');
|
||||
assert(rendered);
|
||||
});
|
||||
|
||||
run_test('render_person', () => {
|
||||
settings_org.show_email = () => true;
|
||||
// Test render_person with regular person
|
||||
var rendered = false;
|
||||
global.templates.render = function (template_name, args) {
|
||||
|
|
|
@ -91,15 +91,17 @@ exports.render_person = function (person) {
|
|||
if (html === undefined) {
|
||||
var avatar_url = people.small_avatar_url_for_person(person);
|
||||
|
||||
html = exports.render_typeahead_item({
|
||||
var typeahead_arguments = {
|
||||
primary: person.full_name,
|
||||
secondary: person.email,
|
||||
img_src: avatar_url,
|
||||
is_person: true,
|
||||
});
|
||||
};
|
||||
if (settings_org.show_email()) {
|
||||
typeahead_arguments.secondary = person.email;
|
||||
}
|
||||
html = exports.render_typeahead_item(typeahead_arguments);
|
||||
rendered.persons.set(person.user_id, html);
|
||||
}
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue