mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
settings: Create an explicit invite_to_stream_policy setting.
This commit creates a new organization setting that determines whether a user can invite other users to streams. Previously this was linked to the waiting period threshold, but this was both not documented and overly limiting. With significant tweaks by tabbott to change the database model to not involve two threshhold fields, edit the tests, etc. This requires follow-up work to make the create stream policy setting work how this code implies it should. Fixes #12042.
This commit is contained in:
@@ -123,14 +123,13 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('#id_realm_create_stream_permission', function () {
|
||||
// Test Setting was saved
|
||||
// Test setting was saved
|
||||
casper.test.assertEval(function () {
|
||||
return $('input[type="text"][id="id_realm_waiting_period_threshold"]').val() === '6';
|
||||
}, 'Waiting period threshold set to 6 days');
|
||||
|
||||
|
||||
// Deactivate setting
|
||||
|
||||
casper.evaluate(function () {
|
||||
$("#id_realm_create_stream_permission").val("by_admins_only").change();
|
||||
});
|
||||
|
||||
@@ -200,11 +200,11 @@ var event_fixtures = {
|
||||
value: false,
|
||||
},
|
||||
|
||||
realm__update__invite_by_admins_only: {
|
||||
realm__update__invite_to_stream_policy: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'invite_by_admins_only',
|
||||
value: false,
|
||||
property: 'invite_to_stream_policy',
|
||||
value: 2,
|
||||
},
|
||||
|
||||
realm__update__invite_required: {
|
||||
@@ -875,8 +875,8 @@ with_overrides(function (override) {
|
||||
var event = event_fixtures.realm__update__create_stream_by_admins_only;
|
||||
test_realm_boolean(event, 'realm_create_stream_by_admins_only');
|
||||
|
||||
event = event_fixtures.realm__update__invite_by_admins_only;
|
||||
test_realm_boolean(event, 'realm_invite_by_admins_only');
|
||||
event = event_fixtures.realm__update__invite_to_stream_policy;
|
||||
test_realm_boolean(event, 'realm_invite_to_stream_policy');
|
||||
|
||||
event = event_fixtures.realm__update__invite_required;
|
||||
test_realm_boolean(event, 'realm_invite_required');
|
||||
|
||||
@@ -234,6 +234,12 @@ function test_submit_settings_form(submit_form) {
|
||||
};
|
||||
$("#id_realm_create_stream_permission").val("by_anyone");
|
||||
$("#id_realm_add_emoji_by_admins_only").val("by_anyone");
|
||||
const invite_to_stream_policy_elem = $("#id_realm_invite_to_stream_policy");
|
||||
invite_to_stream_policy_elem.val("1");
|
||||
invite_to_stream_policy_elem.attr('id', 'id_realm_invite_to_stream_policy');
|
||||
invite_to_stream_policy_elem.data = () => {
|
||||
return "integer";
|
||||
};
|
||||
const bot_creation_policy_elem = $("#id_realm_bot_creation_policy");
|
||||
bot_creation_policy_elem.val("1");
|
||||
bot_creation_policy_elem.attr('id', 'id_realm_bot_creation_policy');
|
||||
@@ -250,6 +256,7 @@ function test_submit_settings_form(submit_form) {
|
||||
let subsection_elem = $(`#org-${subsection}`);
|
||||
subsection_elem.set_find_results('.setting-widget', [
|
||||
bot_creation_policy_elem,
|
||||
invite_to_stream_policy_elem,
|
||||
email_address_visibility_elem,
|
||||
]);
|
||||
|
||||
@@ -259,6 +266,7 @@ function test_submit_settings_form(submit_form) {
|
||||
|
||||
let expected_value = {
|
||||
bot_creation_policy: '1',
|
||||
invite_to_stream_policy: '1',
|
||||
email_address_visibility: '1',
|
||||
add_emoji_by_admins_only: false,
|
||||
create_stream_by_admins_only: false,
|
||||
@@ -532,6 +540,18 @@ function test_sync_realm_settings() {
|
||||
assert.equal(waiting_period_input_parent.visible(), false);
|
||||
}
|
||||
|
||||
{
|
||||
/* Test invite to stream policy settings sync */
|
||||
const property_elem = $('#id_realm_invite_to_stream_policy');
|
||||
property_elem.length = 1;
|
||||
property_elem.attr('id', 'id_realm_invite_to_stream_policy');
|
||||
|
||||
page_params.realm_invite_to_stream_policy = 3;
|
||||
|
||||
settings_org.sync_realm_settings('invite_to_stream_policy');
|
||||
assert.equal($("#id_realm_invite_to_stream_policy").val(), "by_members_with_waiting_period");
|
||||
}
|
||||
|
||||
{
|
||||
/* Test message content edit limit minutes sync */
|
||||
const property_elem = $('#id_realm_message_content_edit_limit_minutes');
|
||||
@@ -743,8 +763,8 @@ run_test('set_up', () => {
|
||||
$("#enable_digest_emails_label").set_parent($.create('<stub digest setting checkbox>'));
|
||||
$("#id_realm_msg_edit_limit_setting").change = noop;
|
||||
$('#id_realm_msg_delete_limit_setting').change = noop;
|
||||
const parent_elem = $.create('waiting-period-parent-stub');
|
||||
$('#id_realm_waiting_period_threshold').set_parent(parent_elem);
|
||||
const waiting_period_parent_elem = $.create('waiting-period-parent-stub');
|
||||
$('#id_realm_waiting_period_threshold').set_parent(waiting_period_parent_elem);
|
||||
$("#allowed_domains_label").set_parent($.create('<stub-allowed-domain-label-parent>'));
|
||||
|
||||
const allow_topic_edit_label_parent = $.create('allow-topic-edit-label-parent');
|
||||
|
||||
Reference in New Issue
Block a user