Repository: zulip/zulip

Issue:
Rename and reorder custom profile field types
<!-- Issue description -->

In the custom profile field type dropdown, we should:

1. Make the following naming changes:
   * Short text -> Text (short)
   * Long text -> Text (long)
   * Date picker -> Date
   * Person picker -> Users
2. Order the fields alphabetically.

Current menu:
![Screenshot 2024-01-09 at 3 12 38 PM](https://github.com/zulip/zulip/assets/2090066/e378f417-bd7c-49a3-abf0-833e1861fc5c)


<!-- Link to a message in the chat.zulip.org discussion. Message links will still work even if the topic is renamed or resolved. Link back to this issue from the chat.zulip.org thread. -->

[CZO thread](https://chat.zulip.org/#narrow/stream/137-feedback/topic/Improvements.20for.20Custom.20profile.20fields/near/1712583)



Discussion:
Hello @zulip/server-settings members, this issue was labeled with the "area: settings UI" label, so you may want to check it out!

<!-- areaLabelAddition -->

@zulipbot claim
Hello @Pratik2026, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again.

We look forward to your valuable contributions!

@zulipbot  claim

Welcome to Zulip, @Kushdapush! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

- Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.
- [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.

As you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!

Hi @Kushdapush , I think I have a solution if you end up not working on this, just let me know as I don't want to steal your issue

Resolving patch:
diff --git a/zerver/migrations/0417_alter_customprofilefield_field_type.py b/zerver/migrations/0417_alter_customprofilefield_field_type.py
--- a/zerver/migrations/0417_alter_customprofilefield_field_type.py
+++ b/zerver/migrations/0417_alter_customprofilefield_field_type.py
@@ -14,14 +14,14 @@ class Migration(migrations.Migration):
             name="field_type",
             field=models.PositiveSmallIntegerField(
                 choices=[
-                    (1, "Short text"),
-                    (2, "Long text"),
-                    (4, "Date picker"),
-                    (5, "Link"),
+                    (4, "Date"),
                     (7, "External account"),
-                    (8, "Pronouns"),
+                    (5, "Link"),
                     (3, "List of options"),
-                    (6, "Person picker"),
+                    (8, "Pronouns"),
+                    (2, "Text (long)"),
+                    (1, "Text (short)"),
+                    (6, "Users"),
                 ],
                 default=1,
             ),
diff --git a/zerver/models/custom_profile_fields.py b/zerver/models/custom_profile_fields.py
--- a/zerver/models/custom_profile_fields.py
+++ b/zerver/models/custom_profile_fields.py
@@ -94,7 +94,7 @@ class CustomProfileField(models.Model):
         (SELECT, gettext_lazy("List of options"), validate_select_field, str, "SELECT"),
     ]
     USER_FIELD_TYPE_DATA: List[UserFieldElement] = [
-        (USER, gettext_lazy("Person picker"), check_valid_user_ids, orjson.loads, "USER"),
+        (USER, gettext_lazy("Users"), check_valid_user_ids, orjson.loads, "USER"),
     ]
 
     SELECT_FIELD_VALIDATORS: Dict[int, ExtendedValidator] = {
@@ -106,9 +106,9 @@ class CustomProfileField(models.Model):
 
     FIELD_TYPE_DATA: List[FieldElement] = [
         # Type, display name, validator, converter, keyword
-        (SHORT_TEXT, gettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"),
-        (LONG_TEXT, gettext_lazy("Long text"), check_long_string, str, "LONG_TEXT"),
-        (DATE, gettext_lazy("Date picker"), check_date, str, "DATE"),
+        (SHORT_TEXT, gettext_lazy("Text (short)"), check_short_string, str, "SHORT_TEXT"),
+        (LONG_TEXT, gettext_lazy("Text (long)"), check_long_string, str, "LONG_TEXT"),
+        (DATE, gettext_lazy("Date"), check_date, str, "DATE"),
         (URL, gettext_lazy("Link"), check_url, str, "URL"),
         (
             EXTERNAL_ACCOUNT,
@@ -120,7 +120,9 @@ class CustomProfileField(models.Model):
         (PRONOUNS, gettext_lazy("Pronouns"), check_short_string, str, "PRONOUNS"),
     ]
 
-    ALL_FIELD_TYPES = [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA]
+    ALL_FIELD_TYPES = sorted(
+        [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA], key=lambda x: x[1]
+    )
 
     FIELD_VALIDATORS: Dict[int, Validator[ProfileDataElementValue]] = {
         item[0]: item[2] for item in FIELD_TYPE_DATA


Test patch:
diff --git a/web/e2e-tests/custom-profile.test.ts b/web/e2e-tests/custom-profile.test.ts
--- 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`),
-        "Short text",
+        "Text (short)",
     );
 }
 
@@ -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`),
-        "Short text",
+        "Text (short)",
     );
 }