mirror of https://github.com/zulip/zulip.git
settings: Move name/email change display commits to correct file.
These most properly belong in settings_account.js, since they are updating the UI widgets on that page.
This commit is contained in:
parent
9fe0f81f4a
commit
72a31150f7
|
@ -32,11 +32,14 @@ set_global('settings_emoji', {
|
||||||
update_custom_emoji_ui: noop,
|
update_custom_emoji_ui: noop,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
set_global('settings_account', {
|
||||||
|
update_email_change_display: noop,
|
||||||
|
update_name_change_display: noop,
|
||||||
|
});
|
||||||
|
|
||||||
set_global('settings_org', {
|
set_global('settings_org', {
|
||||||
reset_realm_default_language: noop,
|
reset_realm_default_language: noop,
|
||||||
toggle_allow_message_editing_pencil: noop,
|
toggle_allow_message_editing_pencil: noop,
|
||||||
update_email_change_display: noop,
|
|
||||||
update_name_change_display: noop,
|
|
||||||
update_message_retention_days: noop,
|
update_message_retention_days: noop,
|
||||||
update_realm_description: noop,
|
update_realm_description: noop,
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ set_global('$', global.make_zjquery());
|
||||||
set_global('i18n', global.stub_i18n);
|
set_global('i18n', global.stub_i18n);
|
||||||
|
|
||||||
zrequire('stream_data');
|
zrequire('stream_data');
|
||||||
|
zrequire('settings_account');
|
||||||
zrequire('settings_org');
|
zrequire('settings_org');
|
||||||
|
|
||||||
var noop = function () {};
|
var noop = function () {};
|
||||||
|
@ -36,8 +37,6 @@ set_global('templates', {
|
||||||
settings_org.populate_realm_domains();
|
settings_org.populate_realm_domains();
|
||||||
settings_org.reset_realm_default_language();
|
settings_org.reset_realm_default_language();
|
||||||
settings_org.toggle_allow_message_editing_pencil();
|
settings_org.toggle_allow_message_editing_pencil();
|
||||||
settings_org.update_name_change_display();
|
|
||||||
settings_org.update_email_change_display();
|
|
||||||
settings_org.update_realm_description();
|
settings_org.update_realm_description();
|
||||||
settings_org.update_message_retention_days();
|
settings_org.update_message_retention_days();
|
||||||
settings_org.populate_auth_methods();
|
settings_org.populate_auth_methods();
|
||||||
|
@ -528,29 +527,27 @@ function test_change_allow_subdomains(change_allow_subdomains) {
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
|
|
||||||
page_params.realm_name_changes_disabled = false;
|
page_params.realm_name_changes_disabled = false;
|
||||||
settings_org.update_name_change_display();
|
settings_account.update_name_change_display();
|
||||||
assert.equal($('#full_name').prop('disabled'), false);
|
assert.equal($('#full_name').prop('disabled'), false);
|
||||||
|
|
||||||
page_params.realm_name_changes_disabled = true;
|
page_params.realm_name_changes_disabled = true;
|
||||||
settings_org.update_name_change_display();
|
settings_account.update_name_change_display();
|
||||||
assert.equal($('#full_name').prop('disabled'), true);
|
assert.equal($('#full_name').prop('disabled'), true);
|
||||||
|
|
||||||
page_params.realm_email_changes_disabled = false;
|
page_params.realm_email_changes_disabled = false;
|
||||||
settings_org.update_email_change_display();
|
settings_account.update_email_change_display();
|
||||||
assert.equal($("#change_email .button").prop('disabled'), false);
|
assert.equal($("#change_email .button").prop('disabled'), false);
|
||||||
|
|
||||||
page_params.realm_email_changes_disabled = true;
|
page_params.realm_email_changes_disabled = true;
|
||||||
settings_org.update_email_change_display();
|
settings_account.update_email_change_display();
|
||||||
assert.equal($("#change_email .button").prop('disabled'), true);
|
assert.equal($("#change_email .button").prop('disabled'), true);
|
||||||
|
|
||||||
// Test should't toggle name display or email display for org admins.
|
// If organization admin, these UI elements are never disabled.
|
||||||
page_params.is_admin = true;
|
page_params.is_admin = true;
|
||||||
$('#full_name').prop('disabled', false);
|
settings_account.update_name_change_display();
|
||||||
settings_org.update_name_change_display();
|
|
||||||
assert.equal($('#full_name').prop('disabled'), false);
|
assert.equal($('#full_name').prop('disabled'), false);
|
||||||
|
|
||||||
$('#change_email .button').prop('disabled', false);
|
settings_account.update_email_change_display();
|
||||||
settings_org.update_email_change_display();
|
|
||||||
assert.equal($("#change_email .button").prop('disabled'), false);
|
assert.equal($("#change_email .button").prop('disabled'), false);
|
||||||
|
|
||||||
page_params.realm_description = 'realm description';
|
page_params.realm_description = 'realm description';
|
||||||
|
|
|
@ -60,7 +60,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||||
create_stream_by_admins_only: noop,
|
create_stream_by_admins_only: noop,
|
||||||
default_language: settings_org.reset_realm_default_language,
|
default_language: settings_org.reset_realm_default_language,
|
||||||
description: settings_org.update_realm_description,
|
description: settings_org.update_realm_description,
|
||||||
email_changes_disabled: settings_org.update_email_change_display,
|
email_changes_disabled: settings_account.update_email_change_display,
|
||||||
inline_image_preview: noop,
|
inline_image_preview: noop,
|
||||||
inline_url_embed_preview: noop,
|
inline_url_embed_preview: noop,
|
||||||
invite_by_admins_only: noop,
|
invite_by_admins_only: noop,
|
||||||
|
@ -68,7 +68,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||||
mandatory_topics: noop,
|
mandatory_topics: noop,
|
||||||
message_retention_days: settings_org.update_message_retention_days,
|
message_retention_days: settings_org.update_message_retention_days,
|
||||||
name: notifications.redraw_title,
|
name: notifications.redraw_title,
|
||||||
name_changes_disabled: settings_org.update_name_change_display,
|
name_changes_disabled: settings_account.update_name_change_display,
|
||||||
notifications_stream_id: noop,
|
notifications_stream_id: noop,
|
||||||
send_welcome_emails: noop,
|
send_welcome_emails: noop,
|
||||||
signup_notifications_stream_id: noop,
|
signup_notifications_stream_id: noop,
|
||||||
|
|
|
@ -25,6 +25,26 @@ exports.update_full_name = function (new_full_name) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.update_name_change_display = function () {
|
||||||
|
if (page_params.realm_name_changes_disabled && !page_params.is_admin) {
|
||||||
|
$('#full_name').prop('disabled', true);
|
||||||
|
$(".change_name_tooltip").show();
|
||||||
|
} else {
|
||||||
|
$('#full_name').prop('disabled', false);
|
||||||
|
$(".change_name_tooltip").hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.update_email_change_display = function () {
|
||||||
|
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
|
||||||
|
$('#change_email .button').prop('disabled', true);
|
||||||
|
$(".change_email_tooltip").show();
|
||||||
|
} else {
|
||||||
|
$('#change_email .button').prop('disabled', false);
|
||||||
|
$(".change_email_tooltip").hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function settings_change_error(message, xhr) {
|
function settings_change_error(message, xhr) {
|
||||||
ui_report.error(message, xhr, $('#account-settings-status').expectOne());
|
ui_report.error(message, xhr, $('#account-settings-status').expectOne());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,26 +70,6 @@ exports.reset_realm_default_language = function () {
|
||||||
$("#id_realm_default_language").val(page_params.realm_default_language);
|
$("#id_realm_default_language").val(page_params.realm_default_language);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.update_name_change_display = function () {
|
|
||||||
if (page_params.realm_name_changes_disabled && !page_params.is_admin) {
|
|
||||||
$('#full_name').prop('disabled', true);
|
|
||||||
$(".change_name_tooltip").show();
|
|
||||||
} else {
|
|
||||||
$('#full_name').prop('disabled', false);
|
|
||||||
$(".change_name_tooltip").hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.update_email_change_display = function () {
|
|
||||||
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
|
|
||||||
$('#change_email .button').prop('disabled', true);
|
|
||||||
$(".change_email_tooltip").show();
|
|
||||||
} else {
|
|
||||||
$('#change_email .button').prop('disabled', false);
|
|
||||||
$(".change_email_tooltip").hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.toggle_allow_message_editing_pencil = function () {
|
exports.toggle_allow_message_editing_pencil = function () {
|
||||||
if (!meta.loaded) {
|
if (!meta.loaded) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue