realm: Add setting to control adding "(guest)" indicator to name.

This commit adds new realm setting to control adding "(guest)"
indicator to names of guest users in the UI.

Fixes part of #26700.
This commit is contained in:
Sahil Batra 2023-09-13 16:47:00 +05:30 committed by Tim Abbott
parent 8702ca46ad
commit c51c1d5135
10 changed files with 57 additions and 1 deletions

View File

@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 8.0 ## Changes in Zulip 8.0
**Feature level 216**:
* `PATCH /realm`, [`POST register`](/api/register-queue),
[`GET /events`](/api/get-events): Added `enable_guest_user_indicator`
setting to control whether "(guest)" is added to user names in UI.
**Feature level 215** **Feature level 215**
* [`GET /events`](/api/get-events): Replaced the value `private` * [`GET /events`](/api/get-events): Replaced the value `private`

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# Changes should be accompanied by documentation explaining what the # Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**" # new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`. # entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 215 API_FEATURE_LEVEL = 216
# Bump the minor PROVISION_VERSION to indicate that folks should provision # Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump # only when going from an old version of the code to a newer version. Bump

View File

@ -61,6 +61,9 @@ const admin_settings_label = {
realm_enable_read_receipts_parens_text: $t({ realm_enable_read_receipts_parens_text: $t({
defaultMessage: "Users can always disable their personal read receipts.", defaultMessage: "Users can always disable their personal read receipts.",
}), }),
realm_enable_guest_user_indicator: $t({
defaultMessage: "Display “(guest)” after names of guest users",
}),
}; };
function insert_tip_box() { function insert_tip_box() {
@ -216,6 +219,7 @@ export function build_page() {
settings_config.automatically_follow_or_unmute_topics_policy_values, settings_config.automatically_follow_or_unmute_topics_policy_values,
automatically_unmute_topics_in_muted_streams_policy_values: automatically_unmute_topics_in_muted_streams_policy_values:
settings_config.automatically_follow_or_unmute_topics_policy_values, settings_config.automatically_follow_or_unmute_topics_policy_values,
realm_enable_guest_user_indicator: page_params.realm_enable_guest_user_indicator,
}; };
if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") { if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {

View File

@ -242,6 +242,7 @@ export function dispatch_normal_event(event) {
want_advertise_in_communities_directory: noop, want_advertise_in_communities_directory: noop,
wildcard_mention_policy: noop, wildcard_mention_policy: noop,
enable_read_receipts: settings_account.update_send_read_receipts_tooltip, enable_read_receipts: settings_account.update_send_read_receipts_tooltip,
enable_guest_user_indicator: noop,
}; };
switch (event.op) { switch (event.op) {
case "update": case "update":

View File

@ -85,6 +85,12 @@
prefix="id_" prefix="id_"
is_checked=realm_avatar_changes_disabled is_checked=realm_avatar_changes_disabled
label=admin_settings_label.realm_avatar_changes_disabled}} label=admin_settings_label.realm_avatar_changes_disabled}}
{{> settings_checkbox
setting_name="realm_enable_guest_user_indicator"
prefix="id_"
is_checked=realm_enable_guest_user_indicator
label=admin_settings_label.realm_enable_guest_user_indicator}}
</div> </div>
</div> </div>

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-09-13 11:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0477_alter_realmuserdefault_automatically_follow_topics_policy_and_more"),
]
operations = [
migrations.AddField(
model_name="realm",
name="enable_guest_user_indicator",
field=models.BooleanField(default=True),
),
]

View File

@ -712,6 +712,9 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
# they will not be available regardless of users' personal settings. # they will not be available regardless of users' personal settings.
enable_read_receipts = models.BooleanField(default=False) enable_read_receipts = models.BooleanField(default=False)
# Whether clients should display "(guest)" after names of guest users.
enable_guest_user_indicator = models.BooleanField(default=True)
# Duplicates of names for system group; TODO: Clean this up. # Duplicates of names for system group; TODO: Clean this up.
ADMINISTRATORS_GROUP_NAME = "role:administrators" ADMINISTRATORS_GROUP_NAME = "role:administrators"
@ -735,6 +738,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
edit_topic_policy=int, edit_topic_policy=int,
email_changes_disabled=bool, email_changes_disabled=bool,
emails_restricted_to_domains=bool, emails_restricted_to_domains=bool,
enable_guest_user_indicator=bool,
enable_read_receipts=bool, enable_read_receipts=bool,
enable_spectator_access=bool, enable_spectator_access=bool,
giphy_rating=int, giphy_rating=int,

View File

@ -4425,6 +4425,13 @@ paths:
`send_read_receipts` setting within `realm_user_settings_defaults`. `send_read_receipts` setting within `realm_user_settings_defaults`.
**Changes**: New in Zulip 6.0 (feature level 137). **Changes**: New in Zulip 6.0 (feature level 137).
enable_guest_user_indicator:
type: boolean
description: |
Whether clients should display "(guest)" after the names of
guest users to prominently highlight their status.
**Changes**: New in Zulip 8.0 (feature level 216).
additionalProperties: false additionalProperties: false
example: example:
{ {
@ -14080,6 +14087,15 @@ paths:
- 2 = Zulip Cloud free plan (LIMITED) - 2 = Zulip Cloud free plan (LIMITED)
- 3 = Zulip Cloud Standard plan (STANDARD) - 3 = Zulip Cloud Standard plan (STANDARD)
- 4 = Zulip Cloud Standard plan, sponsored for free (STANDARD_FREE) - 4 = Zulip Cloud Standard plan, sponsored for free (STANDARD_FREE)
realm_enable_guest_user_indicator:
type: boolean
description: |
Present if `realm` is present in `fetch_event_types`.
Whether clients should display "(guest)" after the names of
guest users to prominently highlight their status.
**Changes**: New in Zulip 8.0 (feature level 216).
zulip_plan_is_not_limited: zulip_plan_is_not_limited:
type: boolean type: boolean
description: | description: |

View File

@ -137,6 +137,7 @@ class HomeTest(ZulipTestCase):
"realm_emails_restricted_to_domains", "realm_emails_restricted_to_domains",
"realm_embedded_bots", "realm_embedded_bots",
"realm_emoji", "realm_emoji",
"realm_enable_guest_user_indicator",
"realm_enable_read_receipts", "realm_enable_read_receipts",
"realm_enable_spectator_access", "realm_enable_spectator_access",
"realm_filters", "realm_filters",

View File

@ -174,6 +174,7 @@ def update_realm(
json_validator=check_string_or_int, json_validator=check_string_or_int,
default=None, default=None,
), ),
enable_guest_user_indicator: Optional[bool] = REQ(json_validator=check_bool, default=None),
) -> HttpResponse: ) -> HttpResponse:
realm = user_profile.realm realm = user_profile.realm