status: Add user menu options to set/revoke away status.

This commit is contained in:
Steve Howell 2018-12-20 14:22:30 +00:00 committed by Tim Abbott
parent 6507804637
commit cb691694d1
3 changed files with 46 additions and 1 deletions

View File

@ -143,6 +143,8 @@ run_test('sender_hover', () => {
case 'user_info_popover_content':
assert.deepEqual(opts, {
can_set_away: false,
can_revoke_away: false,
user_full_name: 'Alice Smith',
user_email: 'alice@example.com',
user_id: 42,

View File

@ -114,10 +114,25 @@ function calculate_info_popover_placement(size, elt) {
function render_user_info_popover(user, popover_element, is_sender_popover, private_msg_class,
template_class, popover_placement) {
var is_me = people.is_my_user_id(user.user_id);
var can_set_away = false;
var can_revoke_away = false;
if (is_me) {
if (user_status.is_away(user.user_id)) {
can_revoke_away = true;
} else {
can_set_away = true;
}
}
var args = {
can_revoke_away: can_revoke_away,
can_set_away: can_set_away,
is_active: people.is_active_user_for_popover(user.user_id),
is_bot: user.is_bot,
is_me: people.is_current_user(user.email),
is_me: is_me,
is_sender_popover: is_sender_popover,
pm_with_uri: hash_util.pm_with_uri(user.email),
presence_status: presence.get_status(user.user_id),
@ -761,6 +776,20 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
$('body').on('click', '.set_away_status', function (e) {
popovers.hide_all();
user_status.server_set_away();
e.stopPropagation();
e.preventDefault();
});
$('body').on('click', '.revoke_away_status', function (e) {
popovers.hide_all();
user_status.server_revoke_away();
e.stopPropagation();
e.preventDefault();
});
$('#user_presences').on('click', 'span.arrow', function (e) {
e.stopPropagation();

View File

@ -78,4 +78,18 @@
<i class="fa fa-bullhorn" aria-hidden="true"></i> {{#tr this}}View messages sent{{/tr}}
</a>
</li>
{{#if can_set_away}}
<li>
<a href="#" class="set_away_status">
<i class="fa fa-circle-thin" aria-hidden="true"></i> {{#tr this}}Set status to away{{/tr}}
</a>
</li>
{{/if}}
{{#if can_revoke_away}}
<li>
<a href="#" class="revoke_away_status">
<i class="fa fa-circle-thin" aria-hidden="true"></i> {{#tr this}}Clear away status{{/tr}}
</a>
</li>
{{/if}}
</ul>