dropdown-list-widget: Allow customization for "Disable" option.

We currently always show fa-ban icon and "Disable" text for
"Disabled" or "None selected" option in dropdown-list widget.

This commit adds code to provide an option for not showing the
fa-ban icon and having the option text be something other than
"Disable". This will be used in channel folder dropdown widget
where we want to have "None" text in the option without icon.
This commit is contained in:
Sahil Batra
2025-06-05 16:59:30 +05:30
committed by Tim Abbott
parent 647eab4f58
commit e643d7e6fd
3 changed files with 28 additions and 3 deletions

View File

@@ -1121,6 +1121,8 @@ export let init_dropdown_widgets = (): void => {
const disabled_option = { const disabled_option = {
is_setting_disabled: true, is_setting_disabled: true,
show_disabled_icon: true,
show_disabled_option_name: false,
unique_id: DISABLED_STATE_ID, unique_id: DISABLED_STATE_ID,
name: $t({defaultMessage: "Disabled"}), name: $t({defaultMessage: "Disabled"}),
}; };
@@ -1169,6 +1171,8 @@ export const combined_code_language_options = (): dropdown_widget.Option[] => {
const disabled_option = { const disabled_option = {
is_setting_disabled: true, is_setting_disabled: true,
show_disabled_icon: true,
show_disabled_option_name: false,
unique_id: "", unique_id: "",
name: $t({defaultMessage: "No language set"}), name: $t({defaultMessage: "No language set"}),
}; };

View File

@@ -26,7 +26,16 @@
{{else if is_direct_message}} {{else if is_direct_message}}
<i class="zulip-icon zulip-icon-users channel-privacy-type-icon"></i> <span class="decorated-dm-name">{{name}}</span> <i class="zulip-icon zulip-icon-users channel-privacy-type-icon"></i> <span class="decorated-dm-name">{{name}}</span>
{{else if is_setting_disabled}} {{else if is_setting_disabled}}
<span class="setting-disabled-option"><i class="setting-disabled-option-icon fa fa-ban" aria-hidden="true"></i>{{t "Disable" }}</span> <span class="setting-disabled-option">
{{#if show_disabled_icon}}
<i class="setting-disabled-option-icon fa fa-ban" aria-hidden="true"></i>
{{/if}}
{{#if show_disabled_option_name}}
{{name}}
{{else}}
{{t "Disable" }}
{{/if}}
</span>
{{else}} {{else}}
{{#if bold_current_selection}} {{#if bold_current_selection}}
<span class="dropdown-list-bold-selected">{{name}}</span> <span class="dropdown-list-bold-selected">{{name}}</span>

View File

@@ -718,7 +718,13 @@ test("test combined_code_language_options", ({override}) => {
})); }));
const expected_options_without_realm_playgrounds = [ const expected_options_without_realm_playgrounds = [
{is_setting_disabled: true, unique_id: "", name: $t({defaultMessage: "No language set"})}, {
is_setting_disabled: true,
unique_id: "",
name: $t({defaultMessage: "No language set"}),
show_disabled_icon: true,
show_disabled_option_name: false,
},
...default_options, ...default_options,
]; ];
@@ -731,7 +737,13 @@ test("test combined_code_language_options", ({override}) => {
]); ]);
const expected_options_with_realm_playgrounds = [ const expected_options_with_realm_playgrounds = [
{is_setting_disabled: true, unique_id: "", name: $t({defaultMessage: "No language set"})}, {
is_setting_disabled: true,
unique_id: "",
name: $t({defaultMessage: "No language set"}),
show_disabled_icon: true,
show_disabled_option_name: false,
},
{unique_id: "custom_lang_1", name: "custom_lang_1"}, {unique_id: "custom_lang_1", name: "custom_lang_1"},
{unique_id: "custom_lang_2", name: "custom_lang_2"}, {unique_id: "custom_lang_2", name: "custom_lang_2"},
...default_options, ...default_options,