mirror of https://github.com/zulip/zulip.git
org settings: Remove old method of success status for notification streams.
For "New stream notifications" and "New user notifications" it is more intuitive to just use the new system for showing success/saving status feedback.
This commit is contained in:
parent
752d6dc6df
commit
e7c40f69de
|
@ -33,19 +33,15 @@ casper.then(function () {
|
|||
casper.click("#id_realm_notifications_stream .dropdown-list-body li.stream_name");
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('#admin-realm-notifications-stream-status', function () {
|
||||
casper.test.assertSelectorHasText('#admin-realm-notifications-stream-status',
|
||||
'Notifications stream changed!');
|
||||
casper.test.assertSelectorHasText('#realm_notifications_stream_name', '#Verona');
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.click(".notifications-stream-disable");
|
||||
casper.waitUntilVisible('#admin-realm-notifications-stream-status', function () {
|
||||
casper.test.assertSelectorHasText('#admin-realm-notifications-stream-status',
|
||||
'Notifications stream disabled!');
|
||||
casper.test.assertSelectorHasText('#realm_notifications_stream_name', 'Disabled');
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -59,19 +55,15 @@ casper.then(function () {
|
|||
casper.click("#id_realm_signup_notifications_stream .dropdown-list-body li.stream_name");
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('#admin-realm-signup-notifications-stream-status', function () {
|
||||
casper.test.assertSelectorHasText('#admin-realm-signup-notifications-stream-status',
|
||||
'Signup notifications stream changed!');
|
||||
casper.test.assertSelectorHasText('#realm_signup_notifications_stream_name', '#Verona');
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.click(".signup-notifications-stream-disable");
|
||||
casper.waitUntilVisible('#admin-realm-signup-notifications-stream-status', function () {
|
||||
casper.test.assertSelectorHasText('#admin-realm-signup-notifications-stream-status',
|
||||
'Signup notifications stream disabled!');
|
||||
casper.test.assertSelectorHasText('#realm_signup_notifications_stream_name', 'Disabled');
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -382,56 +382,6 @@ function test_upload_realm_icon(upload_realm_icon) {
|
|||
assert(posted);
|
||||
}
|
||||
|
||||
function test_disable_notifications_stream(disable_notifications_stream) {
|
||||
let success_callback;
|
||||
let error_callback;
|
||||
channel.patch = function (req) {
|
||||
assert.equal(req.url, '/json/realm');
|
||||
assert.equal(req.data.notifications_stream_id, '-1');
|
||||
success_callback = req.success;
|
||||
error_callback = req.error;
|
||||
};
|
||||
|
||||
disable_notifications_stream();
|
||||
|
||||
const response_data = {
|
||||
notifications_stream_id: -1,
|
||||
};
|
||||
|
||||
success_callback(response_data);
|
||||
assert.equal($('#admin-realm-notifications-stream-status').val(),
|
||||
'translated: Notifications stream disabled!');
|
||||
|
||||
error_callback({});
|
||||
assert.equal($('#admin-realm-notifications-stream-status').val(),
|
||||
'translated: Failed to change notifications stream!');
|
||||
}
|
||||
|
||||
function test_disable_signup_notifications_stream(disable_signup_notifications_stream) {
|
||||
let success_callback;
|
||||
let error_callback;
|
||||
channel.patch = function (req) {
|
||||
assert.equal(req.url, '/json/realm');
|
||||
assert.equal(req.data.signup_notifications_stream_id, '-1');
|
||||
success_callback = req.success;
|
||||
error_callback = req.error;
|
||||
};
|
||||
|
||||
disable_signup_notifications_stream();
|
||||
|
||||
const response_data = {
|
||||
signup_notifications_stream_id: -1,
|
||||
};
|
||||
|
||||
success_callback(response_data);
|
||||
assert.equal($('#admin-realm-signup-notifications-stream-status').val(),
|
||||
'translated: Signup notifications stream disabled!');
|
||||
|
||||
error_callback({});
|
||||
assert.equal($('#admin-realm-signup-notifications-stream-status').val(),
|
||||
'translated: Failed to change signup notifications stream!');
|
||||
}
|
||||
|
||||
function test_change_allow_subdomains(change_allow_subdomains) {
|
||||
const ev = {
|
||||
stopPropagation: noop,
|
||||
|
@ -793,8 +743,6 @@ run_test('set_up', () => {
|
|||
$('#id_realm_video_chat_provider').change = set_callback('realm_video_chat_provider');
|
||||
$("#id_realm_org_join_restrictions").change = set_callback('change_org_join_restrictions');
|
||||
$('#submit-add-realm-domain').click = set_callback('add_realm_domain');
|
||||
$('.notifications-stream-disable').click = set_callback('disable_notifications_stream');
|
||||
$('.signup-notifications-stream-disable').click = set_callback('disable_signup_notifications_stream');
|
||||
|
||||
let submit_settings_form;
|
||||
let discard_changes;
|
||||
|
@ -852,8 +800,6 @@ run_test('set_up', () => {
|
|||
test_realms_domain_modal(callbacks.add_realm_domain);
|
||||
test_submit_settings_form(submit_settings_form);
|
||||
test_upload_realm_icon(upload_realm_icon);
|
||||
test_disable_notifications_stream(callbacks.disable_notifications_stream);
|
||||
test_disable_signup_notifications_stream(callbacks.disable_signup_notifications_stream);
|
||||
test_change_allow_subdomains(change_allow_subdomains);
|
||||
test_extract_property_name();
|
||||
test_change_save_button_state();
|
||||
|
|
|
@ -699,6 +699,14 @@ exports.build_page = function () {
|
|||
// they do, we transition to the "unsaved" state showing the
|
||||
// save/discard widget; otherwise, we hide that widget (the
|
||||
// "discarded" state).
|
||||
|
||||
if ($(e.target).hasClass("no-input-change-detection")) {
|
||||
// This is to prevent input changes detection in elements
|
||||
// within a subsection whose changes should not affect the
|
||||
// visibility of the discard button
|
||||
return false;
|
||||
}
|
||||
|
||||
const subsection = $(e.target).closest('.org-subsection-parent');
|
||||
subsection.find('.subsection-failed-status p').hide();
|
||||
subsection.find('.save-button').show();
|
||||
|
@ -1060,33 +1068,18 @@ exports.build_page = function () {
|
|||
});
|
||||
});
|
||||
|
||||
const notifications_stream_status = $("#admin-realm-notifications-stream-status").expectOne();
|
||||
function notification_stream_update(data) {
|
||||
_.each(get_subsection_property_elements($("#org-discard-notifications")),
|
||||
discard_property_element_changes);
|
||||
const nearest_save_button = $("#org-submit-notifications");
|
||||
exports.save_organization_settings(data, nearest_save_button);
|
||||
}
|
||||
|
||||
function update_notifications_stream(new_notifications_stream_id) {
|
||||
exports.render_notifications_stream_ui(new_notifications_stream_id,
|
||||
$('#realm_notifications_stream_name'));
|
||||
notifications_stream_status.hide();
|
||||
|
||||
const url = "/json/realm";
|
||||
const data = {
|
||||
notification_stream_update({
|
||||
notifications_stream_id: JSON.stringify(parseInt(new_notifications_stream_id, 10)),
|
||||
};
|
||||
|
||||
channel.patch({
|
||||
url: url,
|
||||
data: data,
|
||||
|
||||
success: function (response_data) {
|
||||
if (response_data.notifications_stream_id !== undefined) {
|
||||
if (response_data.notifications_stream_id < 0) {
|
||||
ui_report.success(i18n.t("Notifications stream disabled!"), notifications_stream_status);
|
||||
} else {
|
||||
ui_report.success(i18n.t("Notifications stream changed!"), notifications_stream_status);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
ui_report.error(i18n.t("Failed to change notifications stream!"), xhr, notifications_stream_status);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1108,33 +1101,12 @@ exports.build_page = function () {
|
|||
update_notifications_stream(-1);
|
||||
});
|
||||
|
||||
const signup_notifications_stream_status = $("#admin-realm-signup-notifications-stream-status").expectOne();
|
||||
function update_signup_notifications_stream(new_signup_notifications_stream_id) {
|
||||
exports.render_notifications_stream_ui(new_signup_notifications_stream_id,
|
||||
$('#realm_signup_notifications_stream_name'));
|
||||
signup_notifications_stream_status.hide();
|
||||
const stringified_id = JSON.stringify(parseInt(new_signup_notifications_stream_id, 10));
|
||||
const url = "/json/realm";
|
||||
const data = {
|
||||
signup_notifications_stream_id: stringified_id,
|
||||
};
|
||||
|
||||
channel.patch({
|
||||
url: url,
|
||||
data: data,
|
||||
|
||||
success: function (response_data) {
|
||||
if (response_data.signup_notifications_stream_id !== undefined) {
|
||||
if (response_data.signup_notifications_stream_id < 0) {
|
||||
ui_report.success(i18n.t("Signup notifications stream disabled!"), signup_notifications_stream_status);
|
||||
} else {
|
||||
ui_report.success(i18n.t("Signup notifications stream changed!"), signup_notifications_stream_status);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
ui_report.error(i18n.t("Failed to change signup notifications stream!"), xhr, signup_notifications_stream_status);
|
||||
},
|
||||
notification_stream_update({
|
||||
signup_notifications_stream_id: JSON.stringify(
|
||||
parseInt(new_signup_notifications_stream_id, 10)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<div id="organization-settings" data-name="organization-settings" class="settings-section">
|
||||
<form class="form-horizontal admin-realm-form org-settings-form">
|
||||
<div class="alert" id="admin-realm-notifications-stream-status"></div>
|
||||
<div class="alert" id="admin-realm-signup-notifications-stream-status"></div>
|
||||
|
||||
<div id="org-msg-editing" class="org-subsection-parent">
|
||||
<div class="subsection-header">
|
||||
|
@ -115,7 +113,7 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu modal-bg" role="menu">
|
||||
<li class="dropdown-search" role="presentation">
|
||||
<input type="text" role="menuitem" placeholder="{{t 'Filter streams' }}" autofocus/>
|
||||
<input class="no-input-change-detection" type="text" role="menuitem" placeholder="{{t 'Filter streams' }}" autofocus/>
|
||||
</li>
|
||||
<span class="dropdown-list-body" data-simplebar></span>
|
||||
</ul>
|
||||
|
@ -137,7 +135,7 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu modal-bg" role="menu">
|
||||
<li class="dropdown-search" role="presentation">
|
||||
<input type="text" role="menuitem" placeholder="{{t 'Filter streams' }}" autofocus/>
|
||||
<input class="no-input-change-detection" type="text" role="menuitem" placeholder="{{t 'Filter streams' }}" autofocus/>
|
||||
</li>
|
||||
<span class="dropdown-list-body" data-simplebar></span>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue