Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Add UI for default_avatar_source realm setting.
Prakhar Pratyush3ce2710fe7f4
diff --git a/static/images/gravatar-1.png b/static/images/gravatar-1.pngnew file mode 100644index 00000000000..bdf38554165Binary files /dev/null and b/static/images/gravatar-1.png differdiff --git a/static/images/gravatar-2.png b/static/images/gravatar-2.pngnew file mode 100644index 00000000000..2fbba217529Binary files /dev/null and b/static/images/gravatar-2.png differdiff --git a/static/images/gravatar-3.png b/static/images/gravatar-3.pngnew file mode 100644index 00000000000..af51e5d5f58Binary files /dev/null and b/static/images/gravatar-3.png differdiff --git a/static/images/gravatar-4.png b/static/images/gravatar-4.pngnew file mode 100644index 00000000000..523b2c48385Binary files /dev/null and b/static/images/gravatar-4.png differdiff --git a/static/images/jdenticon-1.png b/static/images/jdenticon-1.pngnew file mode 100644index 00000000000..66b32482b92Binary files /dev/null and b/static/images/jdenticon-1.png differdiff --git a/static/images/jdenticon-2.png b/static/images/jdenticon-2.pngnew file mode 100644index 00000000000..c37e6240a71Binary files /dev/null and b/static/images/jdenticon-2.png differdiff --git a/static/images/jdenticon-3.png b/static/images/jdenticon-3.pngnew file mode 100644index 00000000000..22615f3a05bBinary files /dev/null and b/static/images/jdenticon-3.png differdiff --git a/static/images/jdenticon-4.png b/static/images/jdenticon-4.pngnew file mode 100644index 00000000000..b19b48a5f90Binary files /dev/null and b/static/images/jdenticon-4.png differdiff --git a/web/src/admin.ts b/web/src/admin.tsindex f986f39b5f8..8ac18e053b6 100644--- a/web/src/admin.ts+++ b/web/src/admin.ts@@ -62,6 +62,7 @@ const admin_settings_label = {realm_enable_welcome_message_custom_text: $t({defaultMessage: "Send a custom Welcome Bot message to new users",}),+ realm_default_avatar_source: $t({defaultMessage: "Default profile pictures for new users"}),// Organization permissionsrealm_require_unique_names: $t({defaultMessage: "Require unique names"}),@@ -300,6 +301,7 @@ export function build_page(): void {information_density.get_string_display_value_for_line_height(realm_user_settings_defaults.web_line_height_percent,),+ default_avatar_source_values: settings_config.default_avatar_source_values,};const rendered_admin_tab = render_admin_tab(options);diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.jsindex 7a5000b5324..c6300d7c9ed 100644--- a/web/src/server_events_dispatch.js+++ b/web/src/server_events_dispatch.js@@ -298,6 +298,7 @@ export function dispatch_normal_event(event) {can_set_topics_policy_group: noop,can_summarize_topics_group: noop,create_multiuse_invite_group: noop,+ default_avatar_source: noop,default_code_block_language: noop,default_language: noop,description: noop,diff --git a/web/src/settings_components.ts b/web/src/settings_components.tsindex 359c2f512a3..7c188a0c917 100644--- a/web/src/settings_components.ts+++ b/web/src/settings_components.ts@@ -912,6 +912,9 @@ export function check_realm_settings_property_changed(elem: HTMLElement): booleaassert(elem instanceof HTMLSelectElement);proposed_val = get_jitsi_server_url_setting_value($(elem), false);break;+ case "realm_default_avatar_source":+ proposed_val = get_input_element_value(elem, "radio-group");+ break;default:if (current_val !== undefined) {proposed_val = get_input_element_value(elem, typeof current_val);diff --git a/web/src/settings_config.ts b/web/src/settings_config.tsindex 32e36b9d8e3..5014174544d 100644--- a/web/src/settings_config.ts+++ b/web/src/settings_config.ts@@ -1385,3 +1385,14 @@ export const realm_plan_types = {};export const no_folder_selected = -1;++export const default_avatar_source_values = {+ jdenticon: {+ code: "J",+ description: $t({defaultMessage: "Default"}),+ },+ gravatar: {+ code: "G",+ description: $t({defaultMessage: "Gravatar"}),+ },+};diff --git a/web/src/settings_org.ts b/web/src/settings_org.tsindex d91960f8c1c..6a5ae5e7414 100644--- a/web/src/settings_org.ts+++ b/web/src/settings_org.ts@@ -245,6 +245,14 @@ function set_gif_rating_policy_dropdown(): void {$("#id_realm_gif_rating_policy").val(rating_id);}+function set_default_avatar_source_setting(): void {+ const setting_value = realm.realm_default_avatar_source;+ $(`#id_realm_default_avatar_source input[value='${CSS.escape(setting_value)}']`).prop(+ "checked",+ true,+ );+}+function update_message_edit_sub_settings(is_checked: boolean): void {settings_ui.disable_sub_setting_onchange(is_checked,@@ -669,6 +677,9 @@ export function discard_realm_property_element_changes(elem: HTMLElement): voidcase "realm_waiting_period_threshold":set_realm_waiting_period_setting();break;+ case "realm_default_avatar_source":+ set_default_avatar_source_setting();+ break;case "realm_welcome_message_custom_text":unsaved_welcome_message_custom_text = "";set_welcome_message_custom_text_visibility();@@ -1547,6 +1558,7 @@ export function build_page(): void {set_create_web_public_stream_dropdown_visibility();disable_create_user_groups_if_on_limited_plan();set_welcome_message_custom_text_visibility();+ set_default_avatar_source_setting();register_save_discard_widget_handlers($(".admin-realm-form"), "/json/realm", false);maybe_restore_unsaved_welcome_message_custom_text();diff --git a/web/src/state_data.ts b/web/src/state_data.tsindex 22768ff334b..510e5a6f05a 100644--- a/web/src/state_data.ts+++ b/web/src/state_data.ts@@ -481,6 +481,7 @@ export const realm_schema = z.object({realm_can_summarize_topics_group: group_setting_value_schema,realm_create_multiuse_invite_group: group_setting_value_schema,realm_date_created: z.number(),+ realm_default_avatar_source: z.enum(["G", "J"]),realm_default_code_block_language: z.string(),realm_default_external_accounts: z.record(z.string(),diff --git a/web/styles/settings.css b/web/styles/settings.cssindex 77ad0fa4495..26f1094f0ee 100644--- a/web/styles/settings.css+++ b/web/styles/settings.css@@ -1291,6 +1291,35 @@ label.preferences-radio-choice-label {}}+.default_avatar_source_values {+ width: 25em; /* 400px / 16px em */++ .preferences-radio-choice-label {+ align-items: center;++ .radio-choice-controls {+ display: flex;+ align-items: center;+ }++ input[type="radio"] {+ top: 0;+ margin-right: 0.5em; /* 8px / 16px em */+ }+ }++ .right {+ display: flex;+ gap: 0.5em; /* 8px / 16px em */+ }++ .avatar {+ height: 2.625em; /* 42px / 16px em */+ width: 2.625em; /* 42px / 16px em */+ border-radius: 0.25em; /* 4px / 16px em */+ }+}+.user_list_style_values {max-width: 25em; /* 350px / 14px em */diff --git a/web/templates/settings/organization_settings_admin.hbs b/web/templates/settings/organization_settings_admin.hbsindex 02de2f4c0c0..255fbcf6050 100644--- a/web/templates/settings/organization_settings_admin.hbs+++ b/web/templates/settings/organization_settings_admin.hbs@@ -77,6 +77,38 @@{{> settings_save_discard_widget section_name="onboarding" }}</div><div class="organization-settings-parent">+ {{#if development}}+ <div class="input-group">+ <label class="settings-field-label">+ {{admin_settings_label.realm_default_avatar_source}}+ {{> ../help_link_widget link="/help/configure-default-new-user-settings" }}+ </label>+ <div class="default_avatar_source_values settings-highlight-box prop-element" id="id_realm_default_avatar_source" data-setting-widget-type="radio-group" data-setting-choice-type="string">+ {{#each (object_values default_avatar_source_values)}}+ <label class="preferences-radio-choice-label">+ <span class="radio-choice-controls">+ <input type="radio" name="default_avatar_source" value="{{this.code}}"/>+ <span class="preferences-radio-choice-text">{{this.description}}</span>+ </span>+ <span class="right">+ {{#if (eq this.code "J") }}+ <img class="avatar" src="/static/images/jdenticon-1.png" />+ <img class="avatar" src="/static/images/jdenticon-2.png" />+ <img class="avatar" src="/static/images/jdenticon-3.png" />+ <img class="avatar" src="/static/images/jdenticon-4.png" />+ {{else}}+ <img class="avatar" src="/static/images/gravatar-1.png" />+ <img class="avatar" src="/static/images/gravatar-2.png" />+ <img class="avatar" src="/static/images/gravatar-3.png" />+ <img class="avatar" src="/static/images/gravatar-4.png" />+ {{/if}}+ </span>+ </label>+ {{/each}}+ </div>+ </div>+ {{/if}}+{{> settings_checkboxsetting_name="realm_enable_welcome_message_custom_text"prefix="id_"