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.

custom_profile_fields: Improve option names and sort alphabetically.

Ayush Bhagwat80cd7fc041dd
diff --git a/starlight_help/src/content/docs/custom-profile-fields.mdx b/starlight_help/src/content/docs/custom-profile-fields.mdx
index eb2d58afb1c..6bfa91d326c 100644
--- a/starlight_help/src/content/docs/custom-profile-fields.mdx
+++ b/starlight_help/src/content/docs/custom-profile-fields.mdx
@@ -73,7 +73,7 @@ Users will see custom profile fields in the specified order.
Organizations may find it useful to display additional fields on the
user card, such as pronouns, GitHub username, job title, team, etc.
-All field types other than "Long text" or "Person" have a checkbox option
+All field types other than "Paragraph" or "Person" have a checkbox option
that controls whether to display a custom field on the user card.
There's a limit to the number of custom profile fields that can be displayed
at a time. If the maximum number of fields is already selected, all unselected
@@ -138,13 +138,13 @@ Choose the profile field type that's most appropriate for the requested informat
* **Link**: For links to websites, including company-internal pages.
* **External account**: For linking to an external account (e.g., GitHub,
GitLab, LinkedIn, etc.).
-* **List of options**: A dropdown with a list of predefined options (e.g.,
+* **Dropdown**: A dropdown with a list of predefined options (e.g.,
office location).
* **Pronouns**: What pronouns should people use to refer to the user? Pronouns
are displayed in [user mention](/help/mention-a-user-or-group) autocomplete
suggestions.
-* **Text (long)**: For multiline responses (e.g., a user's intro message).
-* **Text (short)**: For one-line responses up to 50 characters (e.g., team
+* **Paragraph**: For multiline responses (e.g., a user's intro message).
+* **Short text**: For one-line responses up to 50 characters (e.g., team
name or role in your organization).
* **Users**: For selecting one or more users (e.g., manager or direct reports).
diff --git a/web/e2e-tests/custom-profile.test.ts b/web/e2e-tests/custom-profile.test.ts
index d1a60e06222..ab54b2f61cd 100644
--- a/web/e2e-tests/custom-profile.test.ts
+++ b/web/e2e-tests/custom-profile.test.ts
@@ -31,7 +31,7 @@ async function test_add_new_profile_field(page: Page): Promise<void> {
);
assert.strictEqual(
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
- "Text (short)",
+ "Short text",
);
}
@@ -57,7 +57,7 @@ async function test_edit_profile_field(page: Page): Promise<void> {
);
assert.strictEqual(
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
- "Text (short)",
+ "Short text",
);
}
diff --git a/web/src/settings_profile_fields.ts b/web/src/settings_profile_fields.ts
index 485d79a0052..e2914b62f70 100644
--- a/web/src/settings_profile_fields.ts
+++ b/web/src/settings_profile_fields.ts
@@ -305,9 +305,13 @@ function update_form_for_field_type_selection(): void {
}
function open_custom_profile_field_creation_form_modal(): void {
+ const sorted_custom_profile_field_types = Object.values(
+ realm.custom_profile_field_types,
+ ).toSorted((a, b) => util.strcmp(a.name, b.name));
+
const html_body = render_add_new_custom_profile_field_form({
realm_default_external_accounts: realm.realm_default_external_accounts,
- custom_profile_field_types: realm.custom_profile_field_types,
+ custom_profile_field_types: sorted_custom_profile_field_types,
});
function create_profile_field(): void {
diff --git a/web/tests/settings_profile_fields.test.cjs b/web/tests/settings_profile_fields.test.cjs
index 019a23915c8..03f119c5aef 100644
--- a/web/tests/settings_profile_fields.test.cjs
+++ b/web/tests/settings_profile_fields.test.cjs
@@ -17,9 +17,9 @@ const LONG_TEXT_ID = 2;
const USER_FIELD_ID = 6;
const SHORT_TEXT_NAME = "Short text";
-const SELECT_NAME = "Select";
+const SELECT_NAME = "Dropdown";
const EXTERNAL_ACCOUNT_NAME = "External account";
-const LONG_TEXT_NAME = "Long text";
+const LONG_TEXT_NAME = "Paragraph";
const USER_FIELD_NAME = "Person";
const custom_profile_field_types = {
diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py
index 04853eb881f..2ef7598e625 100644
--- a/zerver/data_import/slack.py
+++ b/zerver/data_import/slack.py
@@ -482,7 +482,8 @@ def process_customprofilefields(
for field in customprofilefield:
for field_value in customprofilefield_value:
if field_value["field"] == field["id"] and len(field_value["value"]) > 50:
- field["field_type"] = 2 # corresponding to Long text
+ # Paragraph field type
+ field["field_type"] = 2
break
diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py
index a87eae71ab9..7f95045f5fe 100644
--- a/zerver/migrations/0001_squashed_0569.py
+++ b/zerver/migrations/0001_squashed_0569.py
@@ -1545,12 +1545,12 @@ class Migration(migrations.Migration):
models.PositiveSmallIntegerField(
choices=[
(4, "Date"),
+ (3, "Dropdown"),
(7, "External account"),
(5, "Link"),
- (3, "List of options"),
+ (2, "Paragraph"),
(8, "Pronouns"),
- (2, "Text (long)"),
- (1, "Text (short)"),
+ (1, "Short text"),
(6, "Users"),
],
default=1,
diff --git a/zerver/migrations/0184_rename_custom_field_types.py b/zerver/migrations/0184_rename_custom_field_types.py
index ec948e5d432..19bf9d0bcb0 100644
--- a/zerver/migrations/0184_rename_custom_field_types.py
+++ b/zerver/migrations/0184_rename_custom_field_types.py
@@ -14,12 +14,12 @@ class Migration(migrations.Migration):
name="field_type",
field=models.PositiveSmallIntegerField(
choices=[
- (1, "Short text"),
- (2, "Long text"),
- (4, "Date picker"),
+ (4, "Date"),
+ (3, "Dropdown"),
(5, "Link"),
- (3, "List of options"),
- (6, "Person picker"),
+ (2, "Paragraph"),
+ (1, "Short text"),
+ (6, "Users"),
],
default=1,
),
diff --git a/zerver/migrations/0234_add_external_account_custom_profile_field.py b/zerver/migrations/0234_add_external_account_custom_profile_field.py
index ea8d1a65963..a80f202a8da 100644
--- a/zerver/migrations/0234_add_external_account_custom_profile_field.py
+++ b/zerver/migrations/0234_add_external_account_custom_profile_field.py
@@ -14,13 +14,13 @@ class Migration(migrations.Migration):
name="field_type",
field=models.PositiveSmallIntegerField(
choices=[
- (1, "Short text"),
- (2, "Long text"),
- (4, "Date picker"),
- (5, "Link"),
+ (4, "Date"),
+ (3, "Dropdown"),
(7, "External account"),
- (3, "List of options"),
- (6, "Person picker"),
+ (5, "Link"),
+ (2, "Paragraph"),
+ (1, "Short text"),
+ (6, "Users"),
],
default=1,
),
diff --git a/zerver/migrations/0417_alter_customprofilefield_field_type.py b/zerver/migrations/0417_alter_customprofilefield_field_type.py
index 048a443c802..bc89056c52d 100644
--- a/zerver/migrations/0417_alter_customprofilefield_field_type.py
+++ b/zerver/migrations/0417_alter_customprofilefield_field_type.py
@@ -15,12 +15,12 @@ class Migration(migrations.Migration):
field=models.PositiveSmallIntegerField(
choices=[
(4, "Date"),
+ (3, "Dropdown"),
(7, "External account"),
(5, "Link"),
- (3, "List of options"),
+ (2, "Paragraph"),
(8, "Pronouns"),
- (2, "Text (long)"),
- (1, "Text (short)"),
+ (1, "Short text"),
(6, "Users"),
],
default=1,
diff --git a/zerver/models/custom_profile_fields.py b/zerver/models/custom_profile_fields.py
index 4e8044de956..58c8be6dbb2 100644
--- a/zerver/models/custom_profile_fields.py
+++ b/zerver/models/custom_profile_fields.py
@@ -98,7 +98,7 @@ class CustomProfileField(models.Model):
# and value argument. i.e. SELECT require field_data, USER require
# realm as argument.
SELECT_FIELD_TYPE_DATA: list[ExtendedFieldElement] = [
- (SELECT, gettext_lazy("List of options"), validate_select_field, str, "SELECT"),
+ (SELECT, gettext_lazy("Dropdown"), validate_select_field, str, "SELECT"),
]
USER_FIELD_TYPE_DATA: list[UserFieldElement] = [
(USER, gettext_lazy("Users"), check_valid_user_ids, orjson.loads, "USER"),
@@ -113,8 +113,8 @@ class CustomProfileField(models.Model):
FIELD_TYPE_DATA: list[FieldElement] = [
# Type, display name, validator, converter, keyword
- (SHORT_TEXT, gettext_lazy("Text (short)"), check_short_string, str, "SHORT_TEXT"),
- (LONG_TEXT, gettext_lazy("Text (long)"), check_long_string, str, "LONG_TEXT"),
+ (SHORT_TEXT, gettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"),
+ (LONG_TEXT, gettext_lazy("Paragraph"), check_long_string, str, "LONG_TEXT"),
(DATE, gettext_lazy("Date"), check_date, str, "DATE"),
(URL, gettext_lazy("Link"), check_url, str, "URL"),
(
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 5afc6bbcc9a..a8cd14d6dc1 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -13853,8 +13853,8 @@ paths:
for more details on what each type means.
- **1**: Short text
- - **2**: Long text
- - **3**: List of options
+ - **2**: Paragraph
+ - **3**: Dropdown
- **4**: Date picker
- **5**: Link
- **6**: Person picker
@@ -13866,10 +13866,10 @@ paths:
example: 3
field_data:
description: |
- Field types 3 (List of options) and 7 (External account) support storing
+ Field types 3 (Dropdown) and 7 (External account) support storing
additional configuration for the field type in the `field_data` attribute.
- For field type 3 (List of options), this attribute is a JSON dictionary
+ For field type 3 (Dropdown), this attribute is a JSON dictionary
defining the choices and the order they will be displayed in the
dropdown UI for individual users to select an option.
@@ -13886,7 +13886,7 @@ 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 "Long text" [profile field types][profile-field-types]
+ organization. The "Paragraph" [profile field types][profile-field-types]
profile field types cannot be selected to be displayed in profile summaries.
The "Person picker" profile field is also not supported, but that is likely to
@@ -25765,8 +25765,8 @@ components:
article for details on what each type means.
- **1**: Short text
- - **2**: Long text
- - **3**: List of options
+ - **2**: Paragraph
+ - **3**: Dropdown
- **4**: Date picker
- **5**: Link
- **6**: Person picker
@@ -25791,10 +25791,10 @@ components:
field_data:
type: string
description: |
- Field types 3 (List of options) and 7 (External account) support storing
+ Field types 3 (Dropdown) and 7 (External account) support storing
additional configuration for the field type in the `field_data` attribute.
- For field type 3 (List of options), this attribute is a JSON dictionary
+ For field type 3 (Dropdown), this attribute is a JSON dictionary
defining the choices and the order they will be displayed in the
dropdown UI for individual users to select an option.
@@ -25804,7 +25804,7 @@ components:
description: |
Whether the custom profile field, display or not on the user card.
- Currently it's value not allowed to be `true` of `Long text` and `Person picker`
+ Must be false for `Paragraph` and `Person picker`
[profile field types](/help/custom-profile-fields#profile-field-types).
This field is only included when its value is `true`.