user_profile: Show tooltip when removing last user from private stream.

We now show tooltip on "Unsubscribe" button in user profile modal
if the stream is private and the user is last user in the stream
mentioning that user should use stream settings to unsubscribe.
This commit is contained in:
Sahil Batra
2023-10-16 15:30:03 +05:30
committed by Tim Abbott
parent 545c4caa05
commit effc9c366a
2 changed files with 4 additions and 1 deletions

View File

@@ -173,6 +173,8 @@ function format_user_stream_list_item_html(stream, user) {
people.can_admin_user(user) || stream_data.can_unsubscribe_others(stream);
const show_private_stream_unsub_tooltip =
people.is_my_user_id(user.user_id) && stream.invite_only;
const show_last_user_in_private_stream_unsub_tooltip =
stream.invite_only && peer_data.get_subscriber_count(stream.stream_id) === 1;
return render_user_stream_list_item({
name: stream.name,
stream_id: stream.stream_id,
@@ -181,6 +183,7 @@ function format_user_stream_list_item_html(stream, user) {
is_web_public: stream.is_web_public,
show_unsubscribe_button,
show_private_stream_unsub_tooltip,
show_last_user_in_private_stream_unsub_tooltip,
stream_edit_url: hash_util.stream_edit_url(stream),
});
}

View File

@@ -8,7 +8,7 @@
{{#if show_unsubscribe_button}}
<td class="remove_subscription">
<div class="subscription_list_remove">
<button type="button" name="unsubscribe" class="remove-subscription-button button small rounded btn-danger {{#if show_private_stream_unsub_tooltip}}tippy-zulip-tooltip{{/if}}" data-tippy-content='{{t "Use stream settings to unsubscribe from private streams."}}'>
<button type="button" name="unsubscribe" class="remove-subscription-button button small rounded btn-danger {{#if (or show_private_stream_unsub_tooltip show_last_user_in_private_stream_unsub_tooltip)}}tippy-zulip-tooltip{{/if}}" data-tippy-content='{{#if show_private_stream_unsub_tooltip}}{{t "Use stream settings to unsubscribe from private streams."}}{{else}}{{t "Use stream settings to unsubscribe the last user from a private stream."}}{{/if}}'>
{{t 'Unsubscribe' }}
</button>
</div>