mirror of https://github.com/zulip/zulip.git
notification settings: Deduplicate template rendering.
This commit is contained in:
parent
31bb0439f9
commit
981433d13c
|
@ -1,5 +1,6 @@
|
||||||
zrequire('Handlebars', 'handlebars');
|
zrequire('Handlebars', 'handlebars');
|
||||||
zrequire('templates');
|
zrequire('templates');
|
||||||
|
zrequire('settings_notifications');
|
||||||
|
|
||||||
set_global('i18n', global.stub_i18n);
|
set_global('i18n', global.stub_i18n);
|
||||||
|
|
||||||
|
@ -1123,7 +1124,10 @@ run_test('settings_tab', () => {
|
||||||
"realm_name_in_notifications"];
|
"realm_name_in_notifications"];
|
||||||
|
|
||||||
// Render with all booleans set to true.
|
// Render with all booleans set to true.
|
||||||
var html = render('settings_tab', {page_params: page_params});
|
var html = render('settings_tab', {
|
||||||
|
page_params: page_params,
|
||||||
|
notification_settings: settings_notifications.all_notifications.settings,
|
||||||
|
});
|
||||||
|
|
||||||
// All checkboxes should be checked.
|
// All checkboxes should be checked.
|
||||||
_.each(checkbox_ids, function (checkbox) {
|
_.each(checkbox_ids, function (checkbox) {
|
||||||
|
|
|
@ -132,6 +132,9 @@ exports.build_page = function () {
|
||||||
can_create_new_bots: settings_bots.can_create_new_bots(),
|
can_create_new_bots: settings_bots.can_create_new_bots(),
|
||||||
settings_label: settings.settings_label,
|
settings_label: settings.settings_label,
|
||||||
demote_inactive_streams_values: settings_display.demote_inactive_streams_values,
|
demote_inactive_streams_values: settings_display.demote_inactive_streams_values,
|
||||||
|
notification_settings: settings_notifications.all_notifications.settings,
|
||||||
|
push_notification_tooltip:
|
||||||
|
settings_notifications.all_notifications.push_notification_tooltip,
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".settings-box").html(rendered_settings_tab);
|
$(".settings-box").html(rendered_settings_tab);
|
||||||
|
|
|
@ -7,26 +7,14 @@
|
||||||
<div class="alert-notification" id="stream-notify-settings-status"></div>
|
<div class="alert-notification" id="stream-notify-settings-status"></div>
|
||||||
<p>{{t "Unless I say otherwise for a particular stream, I want:" }}</p>
|
<p>{{t "Unless I say otherwise for a particular stream, I want:" }}</p>
|
||||||
|
|
||||||
|
{{#each notification_settings.stream_notification_settings}}
|
||||||
{{partial "settings_checkbox"
|
{{partial "settings_checkbox"
|
||||||
"setting_name" "enable_stream_desktop_notifications"
|
"setting_name" this
|
||||||
"is_checked" page_params.enable_stream_desktop_notifications
|
"is_checked" (lookup ../page_params this)
|
||||||
"label" settings_label.enable_stream_desktop_notifications}}
|
"label" (lookup ../settings_label this)
|
||||||
|
"realm_push_notifications_enabled" (lookup ../page_params.realm_push_notifications_enabled)
|
||||||
{{partial "settings_checkbox"
|
"push_notifications_tooltip" (lookup ../push_notification_tooltip this)}}
|
||||||
"setting_name" "enable_stream_audible_notifications"
|
{{/each}}
|
||||||
"is_checked" page_params.enable_stream_audible_notifications
|
|
||||||
"label" settings_label.enable_stream_audible_notifications}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "enable_stream_push_notifications"
|
|
||||||
"is_checked" page_params.enable_stream_push_notifications
|
|
||||||
"label" settings_label.enable_stream_push_notifications
|
|
||||||
"push_notifications_tooltip" true}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "enable_stream_email_notifications"
|
|
||||||
"is_checked" page_params.enable_stream_email_notifications
|
|
||||||
"label" settings_label.enable_stream_email_notifications}}
|
|
||||||
|
|
||||||
<p class="notification-settings-note">
|
<p class="notification-settings-note">
|
||||||
{{#tr this}}Change notification settings for individual streams on your <a href="/#streams">Streams page</a>.{{/tr}}
|
{{#tr this}}Change notification settings for individual streams on your <a href="/#streams">Streams page</a>.{{/tr}}
|
||||||
|
@ -37,26 +25,14 @@
|
||||||
<h3 class="inline-block">{{t "Private messages, @-mentions, and alert words" }}</h3>
|
<h3 class="inline-block">{{t "Private messages, @-mentions, and alert words" }}</h3>
|
||||||
<div class="alert-notification" id="pm-mention-notify-settings-status"></div>
|
<div class="alert-notification" id="pm-mention-notify-settings-status"></div>
|
||||||
|
|
||||||
|
{{#each notification_settings.pm_mention_notification_settings}}
|
||||||
{{partial "settings_checkbox"
|
{{partial "settings_checkbox"
|
||||||
"setting_name" "enable_desktop_notifications"
|
"setting_name" this
|
||||||
"is_checked" page_params.enable_desktop_notifications
|
"is_checked" (lookup ../page_params this)
|
||||||
"label" settings_label.enable_desktop_notifications}}
|
"label" (lookup ../settings_label this)
|
||||||
|
"realm_push_notifications_enabled" (lookup ../page_params.realm_push_notifications_enabled)
|
||||||
{{partial "settings_checkbox"
|
"push_notifications_tooltip" (lookup ../push_notification_tooltip this)}}
|
||||||
"setting_name" "enable_sounds"
|
{{/each}}
|
||||||
"is_checked" page_params.enable_sounds
|
|
||||||
"label" settings_label.enable_sounds}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "enable_offline_push_notifications"
|
|
||||||
"is_checked" page_params.enable_offline_push_notifications
|
|
||||||
"label" settings_label.enable_offline_push_notifications
|
|
||||||
"push_notifications_tooltip" true}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "enable_offline_email_notifications"
|
|
||||||
"is_checked" page_params.enable_offline_email_notifications
|
|
||||||
"label" settings_label.enable_offline_email_notifications}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="other_notifications">
|
<div id="other_notifications">
|
||||||
|
@ -66,10 +42,12 @@
|
||||||
|
|
||||||
<h5>{{t "Desktop" }}</h5>
|
<h5>{{t "Desktop" }}</h5>
|
||||||
|
|
||||||
|
{{#each notification_settings.desktop_notification_settings}}
|
||||||
{{partial "settings_checkbox"
|
{{partial "settings_checkbox"
|
||||||
"setting_name" "pm_content_in_desktop_notifications"
|
"setting_name" this
|
||||||
"is_checked" page_params.pm_content_in_desktop_notifications
|
"is_checked" (lookup ../page_params this)
|
||||||
"label" settings_label.pm_content_in_desktop_notifications}}
|
"label" (lookup ../settings_label this)}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
<label for="notification_sound">
|
<label for="notification_sound">
|
||||||
{{t "Notification sound" }}
|
{{t "Notification sound" }}
|
||||||
|
@ -91,33 +69,24 @@
|
||||||
|
|
||||||
<h5>{{t "Mobile" }}</h5>
|
<h5>{{t "Mobile" }}</h5>
|
||||||
|
|
||||||
|
{{#each notification_settings.mobile_notification_settings}}
|
||||||
{{partial "settings_checkbox"
|
{{partial "settings_checkbox"
|
||||||
"setting_name" "enable_online_push_notifications"
|
"setting_name" this
|
||||||
"is_checked" page_params.enable_online_push_notifications
|
"is_checked" (lookup ../page_params this)
|
||||||
"label" settings_label.enable_online_push_notifications
|
"label" (lookup ../settings_label this)
|
||||||
"push_notifications_tooltip" true}}
|
"realm_push_notifications_enabled" (lookup ../page_params.realm_push_notifications_enabled)
|
||||||
|
"push_notifications_tooltip" (lookup ../push_notification_tooltip this)}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
<h5>{{t "Email" }}</h5>
|
<h5>{{t "Email" }}</h5>
|
||||||
|
|
||||||
|
{{#each notification_settings.email_notification_settings}}
|
||||||
{{partial "settings_checkbox"
|
{{partial "settings_checkbox"
|
||||||
"setting_name" "enable_digest_emails"
|
"setting_name" this
|
||||||
"is_checked" page_params.enable_digest_emails
|
"is_checked" (lookup ../page_params this)
|
||||||
"label" settings_label.enable_digest_emails}}
|
"label" (lookup ../settings_label this)}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "enable_login_emails"
|
|
||||||
"is_checked" page_params.enable_login_emails
|
|
||||||
"label" settings_label.enable_login_emails}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "message_content_in_email_notifications"
|
|
||||||
"is_checked" page_params.message_content_in_email_notifications
|
|
||||||
"label" settings_label.message_content_in_email_notifications}}
|
|
||||||
|
|
||||||
{{partial "settings_checkbox"
|
|
||||||
"setting_name" "realm_name_in_notifications"
|
|
||||||
"is_checked" page_params.realm_name_in_notifications
|
|
||||||
"label" settings_label.realm_name_in_notifications}}
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div class="input-group {{#if is_nested}}disableable{{/if}} {{#if_not_a_or_b_and_not_c is_parent_setting_enabled push_notifications_tooltip page_params.realm_push_notifications_enabled}}control-label-disabled{{/if_not_a_or_b_and_not_c}}">
|
<div class="input-group {{#if is_nested}}disableable{{/if}} {{#if_not_a_or_b_and_not_c is_parent_setting_enabled push_notifications_tooltip realm_push_notifications_enabled}}control-label-disabled{{/if_not_a_or_b_and_not_c}}">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" class="inline-block setting-widget prop-element" name="{{setting_name}}" data-setting-widget-type="bool"
|
<input type="checkbox" class="inline-block setting-widget prop-element" name="{{setting_name}}" data-setting-widget-type="bool"
|
||||||
id="{{prefix}}{{setting_name}}"
|
id="{{prefix}}{{setting_name}}"
|
||||||
{{#if_not_a_or_b_and_not_c is_parent_setting_enabled push_notifications_tooltip page_params.realm_push_notifications_enabled}}disabled="disabled"{{/if_not_a_or_b_and_not_c}}
|
{{#if_not_a_or_b_and_not_c is_parent_setting_enabled push_notifications_tooltip realm_push_notifications_enabled}}disabled="disabled"{{/if_not_a_or_b_and_not_c}}
|
||||||
{{#if is_checked}}
|
{{#if is_checked}}
|
||||||
{{#unless_a_not_b push_notifications_tooltip page_params.realm_push_notifications_enabled}}
|
{{#unless_a_not_b push_notifications_tooltip realm_push_notifications_enabled}}
|
||||||
checked="checked"
|
checked="checked"
|
||||||
{{/unless_a_not_b}}
|
{{/unless_a_not_b}}
|
||||||
{{/if}} />
|
{{/if}} />
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
{{{label}}}
|
{{{label}}}
|
||||||
</label>
|
</label>
|
||||||
{{#if push_notifications_tooltip}}
|
{{#if push_notifications_tooltip}}
|
||||||
<i class="fa fa-question-circle settings-info-icon" {{#if page_params.realm_push_notifications_enabled}}style="display:none"{{/if}} data-toggle="tooltip"
|
<i class="fa fa-question-circle settings-info-icon" {{#if realm_push_notifications_enabled}}style="display:none"{{/if}} data-toggle="tooltip"
|
||||||
title="{{t 'Mobile push notifications are not configured on this server.' }}"></i>
|
title="{{t 'Mobile push notifications are not configured on this server.' }}"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue