settings: Rename create_stream_permission in templates.

This commit renames the `create_stream_permission` field in the
templates to `create_stream_policy`, matching the field used in the
database model. This matches what `invite_to_stream_policy` does and
will be clearer when the `waiting_period_threshold` is split into its
own field.
This commit is contained in:
David Wood
2019-05-06 17:41:36 +01:00
committed by Tim Abbott
parent 34d810aac3
commit f53a8f8bb6
6 changed files with 33 additions and 37 deletions

View File

@@ -556,8 +556,8 @@ var org_settings = {
```
Note that some settings, like `realm_create_stream_permission`,
reuqire special treatment, because they don't match the common
Note that some settings, like `realm_msg_edit_limit_setting`,
require special treatment, because they don't match the common
pattern. We can't extract the property name and compare the value of
such input elements with those in `page_params`, so we have to
manually handle such situations in a couple key functions:
@@ -570,7 +570,7 @@ manually handle such situations in a couple key functions:
- `settings_org.update_dependent_subsettings`: This handles settings
whose value and state depend on other elements. For example,
`realm_waiting_period_threshold` is only shown for with the right
state of `realm_create_stream_permission`.
state of `realm_create_stream_policy`.
Finally, update `server_events_dispatch.js` to handle related events coming from
the server. There is an object, `realm_settings`, in the function
@@ -621,7 +621,7 @@ Here are few important cases you should consider when testing your changes:
that both are properly synchronized. For example, the input element
for `realm_waiting_period_threshold` is shown only when we have
selected the custom time limit option in the
`realm_create_stream_permission` dropdown.
`realm_create_stream_policy` dropdown.
- Do some manual testing for the real-time synchronization of input
elements across the browsers and just like "Discard changes" button,

View File

@@ -88,9 +88,9 @@ function submit_permissions_change() {
// Test setting limiting stream creation to administrators
casper.then(function () {
casper.test.info("Test setting limiting stream creation to administrators");
casper.waitUntilVisible("#id_realm_create_stream_permission", function () {
casper.waitUntilVisible("#id_realm_create_stream_policy", function () {
casper.evaluate(function () {
$("#id_realm_create_stream_permission").val("by_admins_only").change();
$("#id_realm_create_stream_policy").val("by_admins_only").change();
});
submit_permissions_change();
});
@@ -105,9 +105,9 @@ casper.then(function () {
});
casper.then(function () {
casper.waitUntilVisible("#id_realm_create_stream_permission", function () {
casper.waitUntilVisible("#id_realm_create_stream_policy", function () {
casper.evaluate(function () {
$("#id_realm_create_stream_permission").val("by_admin_user_with_custom_time").change();
$("#id_realm_create_stream_policy").val("by_admin_user_with_custom_time").change();
$("#id_realm_waiting_period_threshold").val('6');
});
submit_permissions_change();
@@ -122,7 +122,7 @@ casper.then(function () {
});
});
casper.waitUntilVisible('#id_realm_create_stream_permission', function () {
casper.waitUntilVisible('#id_realm_create_stream_policy', function () {
// Test setting was saved
casper.test.assertEval(function () {
return $('input[type="text"][id="id_realm_waiting_period_threshold"]').val() === '6';
@@ -131,7 +131,7 @@ casper.waitUntilVisible('#id_realm_create_stream_permission', function () {
// Deactivate setting
casper.evaluate(function () {
$("#id_realm_create_stream_permission").val("by_admins_only").change();
$("#id_realm_create_stream_policy").val("by_admins_only").change();
});
submit_permissions_change();
});

View File

@@ -232,7 +232,7 @@ function test_submit_settings_form(submit_form) {
save_button.replace = () => {
return `${subsection}`;
};
$("#id_realm_create_stream_permission").val("by_anyone");
$("#id_realm_create_stream_policy").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");
@@ -525,9 +525,9 @@ function test_sync_realm_settings() {
{
/* Test create new stream permission settings sync */
const property_elem = $('#id_realm_create_stream_permission');
const property_elem = $('#id_realm_create_stream_policy');
property_elem.length = 1;
property_elem.attr('id', 'id_realm_create_stream_permission');
property_elem.attr('id', 'id_realm_create_stream_policy');
const waiting_period_input_parent = $.create('stub-waiting-period-input-parent');
$("#id_realm_waiting_period_threshold").set_parent(waiting_period_input_parent);
@@ -536,7 +536,7 @@ function test_sync_realm_settings() {
page_params.realm_waiting_period_threshold = 3;
settings_org.sync_realm_settings('create_stream_policy');
assert.equal($("#id_realm_create_stream_permission").val(), "by_admin_user_with_three_days_old");
assert.equal($("#id_realm_create_stream_policy").val(), "by_admin_user_with_three_days_old");
assert.equal(waiting_period_input_parent.visible(), false);
}
@@ -722,7 +722,7 @@ run_test('set_up', () => {
const verify_realm_domains = simulate_realm_domains_table();
simulate_auth_methods();
$('#id_realm_create_stream_permission').change = set_callback('realm_create_stream_permission');
$('#id_realm_create_stream_policy').change = set_callback('realm_create_stream_policy');
$('#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');

View File

@@ -70,7 +70,7 @@ function get_property_value(property_name) {
return exports.get_realm_time_limits_in_minutes('realm_message_content_delete_limit_seconds');
}
if (property_name === 'realm_create_stream_permission') {
if (property_name === 'realm_create_stream_policy') {
if (page_params.realm_create_stream_policy === 2) {
return "by_admins_only";
}
@@ -156,9 +156,9 @@ exports.extract_property_name = function (elem) {
return elem.attr('id').split('-').join('_').replace("id_", "");
};
function set_create_stream_permission_dropdown() {
var value = get_property_value("realm_create_stream_permission");
$("#id_realm_create_stream_permission").val(value);
function set_create_stream_policy_dropdown() {
var value = get_property_value("realm_create_stream_policy");
$("#id_realm_create_stream_policy").val(value);
if (value === "by_admin_user_with_custom_time") {
$("#id_realm_waiting_period_threshold").parent().show();
} else {
@@ -408,8 +408,8 @@ exports.populate_signup_notifications_stream_dropdown = function (stream_list) {
};
function update_dependent_subsettings(property_name) {
if (property_name === 'realm_create_stream_permission' || property_name === 'realm_waiting_period_threshold') {
set_create_stream_permission_dropdown();
if (property_name === 'realm_create_stream_policy' || property_name === 'realm_waiting_period_threshold') {
set_create_stream_policy_dropdown();
} else if (property_name === 'realm_invite_to_stream_policy') {
set_invite_to_stream_policy_dropdown();
} else if (property_name === 'realm_video_chat_provider' ||
@@ -456,10 +456,6 @@ exports.sync_realm_settings = function (property) {
if (property === 'message_content_edit_limit_seconds') {
property = 'message_content_edit_limit_minutes';
} else if (property === 'create_stream_policy') {
property = 'create_stream_permission';
} else if (property === 'invite_to_stream_policy') {
property = 'invite_to_stream_policy';
} else if (property === 'allow_message_editing') {
property = 'msg_edit_limit_setting';
} else if (property === 'emails_restricted_to_domains' || property === 'disallow_disposable_email_addresses') {
@@ -587,7 +583,7 @@ exports.build_page = function () {
return data;
}
set_create_stream_permission_dropdown();
set_create_stream_policy_dropdown();
set_invite_to_stream_policy_dropdown();
set_add_emoji_permission_dropdown();
set_video_chat_provider_dropdown();
@@ -714,7 +710,7 @@ exports.build_page = function () {
data.message_retention_days = new_message_retention_days !== "" ?
JSON.stringify(parseInt(new_message_retention_days, 10)) : null;
} else if (subsection === 'other_permissions') {
var create_stream_permission = $("#id_realm_create_stream_permission").val();
var create_stream_policy = $("#id_realm_create_stream_policy").val();
var invite_to_stream_policy = $("#id_realm_invite_to_stream_policy").val();
var add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
@@ -724,15 +720,15 @@ exports.build_page = function () {
data.add_emoji_by_admins_only = false;
}
if (create_stream_permission === "by_admins_only") {
if (create_stream_policy === "by_admins_only") {
data.create_stream_policy = 2;
} else if (create_stream_permission === "by_admin_user_with_three_days_old") {
} else if (create_stream_policy === "by_admin_user_with_three_days_old") {
data.create_stream_policy = 3;
data.waiting_period_threshold = 3;
} else if (create_stream_permission === "by_admin_user_with_custom_time") {
} else if (create_stream_policy === "by_admin_user_with_custom_time") {
data.create_stream_policy = 3;
data.waiting_period_threshold = $("#id_realm_waiting_period_threshold").val();
} else if (create_stream_permission === "by_anyone") {
} else if (create_stream_policy === "by_anyone") {
data.create_stream_policy = 1;
data.waiting_period_threshold = 0;
}
@@ -812,10 +808,10 @@ exports.build_page = function () {
}
});
$("#id_realm_create_stream_permission").change(function () {
var create_stream_permission = this.value;
$("#id_realm_create_stream_policy").change(function () {
var create_stream_policy = this.value;
var node = $("#id_realm_waiting_period_threshold").parent();
if (create_stream_permission === 'by_admin_user_with_custom_time') {
if (create_stream_policy === 'by_admin_user_with_custom_time') {
node.show();
} else {
node.hide();

View File

@@ -1545,7 +1545,7 @@ body:not(.night-mode) #account-settings .custom_user_field .datepicker {
pointer-events: all;
}
#id_realm_create_stream_permission,
#id_realm_create_stream_policy,
#id_realm_invite_to_stream_policy,
#id_realm_org_join_restrictions,
#id_realm_bot_creation_policy,

View File

@@ -66,8 +66,8 @@
</div>
<div class="m-10 inline-block organization-permissions-parent">
<div class="input-group">
<label for="realm_create_stream_permission" class="dropdown-title">{{t "Who can create streams" }}</label>
<select name="realm_create_stream_permission" id="id_realm_create_stream_permission" class="prop-element">
<label for="realm_create_stream_policy" class="dropdown-title">{{t "Who can create streams" }}</label>
<select name="realm_create_stream_policy" id="id_realm_create_stream_policy" class="prop-element">
<option value="by_anyone">{{t "Members and admins" }}</option>
<option value="by_admins_only">{{t "Admins only" }}</option>
<option value="by_admin_user_with_three_days_old">{{t "All admins, and members with accounts at least 3 days old" }}</option>