Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

popovers: Hide "Send private message" if user not have PM permissions.

yogesh sirsat918c0b039b05
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js
index 183d555fb10..a0e9c3c64a1 100644
--- a/frontend_tests/node_tests/popovers.js
+++ b/frontend_tests/node_tests/popovers.js
@@ -176,6 +176,7 @@ test_ui("sender_hover", ({override, mock_template}) => {
can_revoke_away: false,
can_mute: true,
can_manage_user: false,
+ can_send_private_message: true,
can_unmute: false,
user_full_name: "Alice Smith",
user_email: "[email protected]",
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 05e55eb7c02..4ab5444f511 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -42,6 +42,7 @@ import * as realm_playground from "./realm_playground";
import * as reminder from "./reminder";
import * as resize from "./resize";
import * as rows from "./rows";
+import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data";
import * as settings_users from "./settings_users";
import * as stream_popover from "./stream_popover";
@@ -205,6 +206,7 @@ function render_user_info_popover(
}
const muting_allowed = !is_me && !user.is_bot;
+ const is_active = people.is_active_user_for_popover(user.user_id);
const is_muted = muted_users.is_user_muted(user.user_id);
const status_text = user_status.get_status_text(user.user_id);
const status_emoji_info = user_status.get_status_emoji(user.user_id);
@@ -221,9 +223,14 @@ function render_user_info_popover(
can_set_away,
can_mute: muting_allowed && !is_muted,
can_manage_user: page_params.is_admin && !is_me,
+ can_send_private_message:
+ is_active &&
+ !is_me &&
+ page_params.realm_private_message_policy !==
+ settings_config.private_message_policy_values.disabled.code,
can_unmute: muting_allowed && is_muted,
has_message_context,
- is_active: people.is_active_user_for_popover(user.user_id),
+ is_active,
is_bot: user.is_bot,
is_me,
is_sender_popover,
diff --git a/static/templates/user_info_popover_content.hbs b/static/templates/user_info_popover_content.hbs
index 9f9ed3befb2..7d832222288 100644
--- a/static/templates/user_info_popover_content.hbs
+++ b/static/templates/user_info_popover_content.hbs
@@ -117,14 +117,12 @@
</a>
</li>
{{/if}}
- {{#if is_active}}
- {{#unless is_me}}
+ {{#if can_send_private_message}}
<li>
<a tabindex="0" class="{{ private_message_class }}">
<i class="fa fa-envelope" aria-hidden="true"></i> {{#tr}}Send private message{{/tr}} {{#if is_sender_popover}}<span class="hotkey-hint">(R)</span>{{/if}}
</a>
</li>
- {{/unless}}
{{/if}}
{{#unless is_me}}
<li>