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.

user_card: Allow showing long text custom profile fields on user cards.

Amit Patil7a9acd7707ac
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 979db9a5fc3..2ba637741f6 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 12.0
+**Feature level 476**
+
+* [`POST /realm/profile_fields`](/api/create-custom-profile-field),
+ [`GET /realm/profile_fields`](/api/get-custom-profile-fields) The
+ `display_in_profile_summary` parameter can now be set to true for the
+ `Paragraph` field type.
+
**Feature level 475**
* [`GET /events`](/api/get-events): `realm_user` events with `op: "update"`
diff --git a/docs/THIRDPARTY b/docs/THIRDPARTY
index be3abde720d..72eff7a3b11 100644
--- a/docs/THIRDPARTY
+++ b/docs/THIRDPARTY
@@ -678,6 +678,11 @@ Source: https://lucide.dev/icons/loader-circle
Copyright: 2013-2026 Cole Bemis
License: ISC License
+Files: web/icons/id-card.svg
+Source: https://lucide.dev/icons/id-card
+Copyright: 2013-2026 Cole Bemis
+License: ISC License
+
Files: web/icons/video-call.svg
Copyright: 2013-2023 Cole Bemis (https://feathericons.com)
License: Expat
diff --git a/version.py b/version.py
index 5702d38beb1..b7f62c9483d 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide
# Also available at docs/documentation/api.md.
-API_FEATURE_LEVEL = 475
+API_FEATURE_LEVEL = 476
# 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
diff --git a/web/icons/id-card.svg b/web/icons/id-card.svg
new file mode 100644
index 00000000000..502a69a604a
--- /dev/null
+++ b/web/icons/id-card.svg
@@ -0,0 +1,7 @@
+<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path d="m 16,9 a 1,1 0 0 0 -1,1 1,1 0 0 0 1,1 h 2 a 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 z"/>
+ <path d="m 16,13 a 1,1 0 0 0 -1,1 1,1 0 0 0 1,1 h 2 a 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 z" />
+ <path d="m 9,11.996094 c -1.5574581,0 -3.164143,0.939846 -3.7734375,2.671875 a 1,1 0 0 0 0.6113281,1.27539 1,1 0 0 0 1.2753906,-0.611328 C 7.4441611,14.391446 8.1975453,13.996094 9,13.996094 c 0.8024547,0 1.555839,0.395352 1.886719,1.335937 a 1,1 0 0 0 1.27539,0.611328 1,1 0 0 0 0.611329,-1.27539 C 12.164143,12.93594 10.557458,11.996094 9,11.996094 Z" />
+ <path d="m 9,8 c -1.6450096,0 -3,1.3549904 -3,3 0,1.64501 1.3549904,3 3,3 1.64501,0 3,-1.35499 3,-3 C 12,9.3549904 10.64501,8 9,8 Z m 0,2 c 0.5641294,0 1,0.435871 1,1 0,0.564129 -0.4358706,1 -1,1 -0.5641294,0 -1,-0.435871 -1,-1 0,-0.564129 0.4358706,-1 1,-1 z" />
+ <path d="M 4,4 C 2.3552972,4 1,5.3552972 1,7 v 10 c 0,1.644703 1.3552972,3 3,3 h 16 c 1.644703,0 3,-1.355297 3,-3 V 7 C 23,5.3552972 21.644703,4 20,4 Z m 0,2 h 16 c 0.571297,0 1,0.4287028 1,1 v 10 c 0,0.571297 -0.428703,1 -1,1 H 4 C 3.4287028,18 3,17.571297 3,17 V 7 C 3,6.4287028 3.4287028,6 4,6 Z"/>
+</svg>
diff --git a/web/src/settings_profile_fields.ts b/web/src/settings_profile_fields.ts
index 982b512f62c..3571a15289d 100644
--- a/web/src/settings_profile_fields.ts
+++ b/web/src/settings_profile_fields.ts
@@ -137,7 +137,7 @@ export function field_type_id_to_string(type_id: number): string | undefined {
// Checking custom profile field type is valid for showing display on user card checkbox field.
function is_valid_to_display_in_summary(field_type: number): boolean {
const field_types = realm.custom_profile_field_types;
- if (field_type === field_types.LONG_TEXT.id || field_type === field_types.USER.id) {
+ if (field_type === field_types.USER.id) {
return false;
}
return true;
diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.ts
index 8644225f81a..f40bcb3de88 100644
--- a/web/src/tippyjs.ts
+++ b/web/src/tippyjs.ts
@@ -679,6 +679,7 @@ export function initialize(): void {
target: [
".custom-profile-field-value",
".copy-custom-profile-field-link",
+ ".copy-custom-profile-field-long-text",
"#popover-menu-copy-email",
".personal-menu-clear-status",
".user-card-clear-status-button",
diff --git a/web/src/user_card_popover.ts b/web/src/user_card_popover.ts
index f5978619ee5..6e0c42a0130 100644
--- a/web/src/user_card_popover.ts
+++ b/web/src/user_card_popover.ts
@@ -984,6 +984,17 @@ function register_click_handlers(): void {
show_check_icon: true,
});
});
+
+ $("body").on("click", ".copy-custom-profile-field-long-text", (e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ });
+
+ new ClipboardJS(".copy-custom-profile-field-long-text").on("success", (e) => {
+ show_copied_confirmation(e.trigger, {
+ show_check_icon: true,
+ });
+ });
}
export function initialize(): void {
diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts
index 55e4eb8c0f5..7b645eca174 100644
--- a/web/src/user_profile.ts
+++ b/web/src/user_profile.ts
@@ -79,6 +79,7 @@ export type CustomProfileFieldData = {
required: boolean;
value: string;
rendered_value?: string | null | undefined;
+ is_long_text: boolean;
subtype?: string;
link?: string;
};
@@ -488,6 +489,7 @@ export function get_custom_profile_field_data(
is_user_field: false,
is_link: field_type === field_types.URL.id,
is_external_account: field_type === field_types.EXTERNAL_ACCOUNT.id,
+ is_long_text: field_type === field_types.LONG_TEXT.id,
type: field_type,
display_in_profile_summary: field.display_in_profile_summary,
required: field.required,
diff --git a/web/styles/popovers.css b/web/styles/popovers.css
index 4fa98f8e30b..bf0e38e8f14 100644
--- a/web/styles/popovers.css
+++ b/web/styles/popovers.css
@@ -1052,6 +1052,12 @@ ul.popover-group-menu-member-list {
.popover-menu-icon {
position: relative;
top: -1px;
+
+ &.zulip-icon-id-card {
+ /* Override the top value for the id card icon,
+ since it looks more visually centered */
+ top: 0;
+ }
}
.info-density-controls {
diff --git a/web/templates/popovers/user_card/user_card_popover_custom_fields.hbs b/web/templates/popovers/user_card/user_card_popover_custom_fields.hbs
index c0de9290ae6..8a12e08feb1 100644
--- a/web/templates/popovers/user_card/user_card_popover_custom_fields.hbs
+++ b/web/templates/popovers/user_card/user_card_popover_custom_fields.hbs
@@ -1,4 +1,5 @@
{{#each profile_fields}}
+ {{#unless this.is_long_text}}
<li role="none" class="popover-menu-list-item text-item custom_user_field" data-type="{{this.type}}" data-field-id="{{this.id}}">
{{#if this.is_link}}
<a href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="custom-profile-field-value custom-profile-field-link" data-tippy-content="{{this.name}}" tabindex="0">
@@ -27,4 +28,19 @@
</div>
{{/if}}
</li>
+ {{/unless}}
+{{/each}}
+{{!-- Long text custom profile fields are rendered after all other custom profile fields --}}
+{{#each profile_fields}}
+ {{#if this.is_long_text}}
+ <li role="none" class="popover-menu-list-item link-item custom_user_field" data-type="{{this.type}}" data-field-id="{{this.id}}">
+ <div class="popover-menu-link view_full_user_profile" tabindex="0">
+ <i class="popover-menu-icon zulip-icon zulip-icon-id-card" aria-hidden="true"></i>
+ <span class="popover-menu-label">{{t this.name }}</span>
+ <span role="menuitem" tabindex="0" class="copy-button copy-custom-profile-field-long-text" aria-label="{{t 'Copy'}}" data-tippy-content="{{t 'Copy'}}" data-clipboard-text="{{this.value}}">
+ <i class="zulip-icon zulip-icon-copy" aria-hidden="true"></i>
+ </span>
+ </div>
+ </li>
+ {{/if}}
{{/each}}
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 4f44832b2a1..c0a6a6491be 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -14252,15 +14252,17 @@ paths:
user's profile (or in a more easily accessible "small profile").
At most 2 profile fields may have this property be true in a given
- organization. The "Paragraph" [profile field types][profile-field-types]
- profile field types cannot be selected to be displayed in profile summaries.
+ organization.
- The "Person picker" profile field is also not supported, but that is likely to
+ The "Person picker" profile field is not supported, but that is likely to
be temporary.
[profile-field-types]: /help/custom-profile-fields#profile-field-types
- **Changes**: New in Zulip 6.0 (feature level 146).
+ **Changes**: Before Zulip 12.0 (feature level 476), the
+ "Paragraph" field type was not supported.
+
+ New in Zulip 6.0 (feature level 146).
type: boolean
example: true
required:
@@ -26537,12 +26539,15 @@ components:
description: |
Whether the custom profile field, display or not on the user card.
- Must be false for `Paragraph` and `Person picker`
+ Must be false for `Person picker`
[profile field types](/help/custom-profile-fields#profile-field-types).
This field is only included when its value is `true`.
- **Changes**: New in Zulip 6.0 (feature level 146).
+ **Changes**: Before Zulip 12.0 (feature level 476), the
+ "Paragraph" field type was not supported.
+
+ New in Zulip 6.0 (feature level 146).
default: false
required:
type: boolean
diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py
index b4393b2fbac..a48483fec30 100644
--- a/zerver/tests/test_custom_profile_data.py
+++ b/zerver/tests/test_custom_profile_data.py
@@ -63,12 +63,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase):
data["name"] = "Phone"
data["hint"] = "Contact number"
- data["field_type"] = CustomProfileField.LONG_TEXT
- data["display_in_profile_summary"] = "true"
- result = self.client_post("/json/realm/profile_fields", info=data)
- self.assert_json_error(result, "Field type not supported for display in profile summary.")
-
data["field_type"] = CustomProfileField.USER
+ data["display_in_profile_summary"] = "true"
result = self.client_post("/json/realm/profile_fields", info=data)
self.assert_json_error(result, "Field type not supported for display in profile summary.")
diff --git a/zerver/views/custom_profile_fields.py b/zerver/views/custom_profile_fields.py
index 7102ee522a3..b21b2cc6678 100644
--- a/zerver/views/custom_profile_fields.py
+++ b/zerver/views/custom_profile_fields.py
@@ -69,10 +69,8 @@ def validate_display_in_profile_summary_field(
if not display_in_profile_summary:
return
- # The LONG_TEXT field type doesn't make sense visually for profile
- # field summaries. The USER field type will require some further
- # client support.
- if field_type in (CustomProfileField.LONG_TEXT, CustomProfileField.USER):
+ # The USER field type will require some further client support.
+ if field_type == CustomProfileField.USER:
raise JsonableError(_("Field type not supported for display in profile summary."))