settings: Rename IDs of waiting-period-threshold setting elements.

This commit is contained in:
Sahil Batra
2022-12-13 17:02:01 +05:30
committed by Tim Abbott
parent 4dd1676e96
commit bc5f0e881e
5 changed files with 23 additions and 23 deletions

View File

@@ -597,8 +597,8 @@ manually handle such situations in a couple key functions:
- `settings_org.update_dependent_subsettings`: This handles settings - `settings_org.update_dependent_subsettings`: This handles settings
whose value and state depend on other elements. For example, whose value and state depend on other elements. For example,
`realm_waiting_period_threshold` is only shown for with the right `realm_waiting_period_threshold_custom_input` is only shown for with
state of `realm_waiting_period_setting`. the right state of `realm_waiting_period_threshold`.
Finally, update `server_events_dispatch.js` to handle related events coming from Finally, update `server_events_dispatch.js` to handle related events coming from
the server. There is an object, `realm_settings`, in the function the server. There is an object, `realm_settings`, in the function
@@ -646,9 +646,9 @@ Here are few important cases you should consider when testing your changes:
- If your setting is dependent on another setting, carefully check - If your setting is dependent on another setting, carefully check
that both are properly synchronized. For example, the input element that both are properly synchronized. For example, the input element
for `realm_waiting_period_threshold` is shown only when we have for `realm_waiting_period_threshold_custom_input` is shown only when
selected the custom time limit option in the we have selected the custom time limit option in the
`realm_waiting_period_setting` dropdown. `realm_waiting_period_threshold` dropdown.
- Do some manual testing for the real-time synchronization of input - Do some manual testing for the real-time synchronization of input
elements across the browsers and just like "Discard changes" button, elements across the browsers and just like "Discard changes" button,

View File

@@ -154,18 +154,18 @@ async function submit_joining_organization_change(page: Page): Promise<void> {
async function test_set_new_user_threshold_to_three_days(page: Page): Promise<void> { async function test_set_new_user_threshold_to_three_days(page: Page): Promise<void> {
console.log("Test setting new user threshold to three days."); console.log("Test setting new user threshold to three days.");
await page.waitForSelector("#id_realm_waiting_period_setting", {visible: true}); await page.waitForSelector("#id_realm_waiting_period_threshold", {visible: true});
await page.select("#id_realm_waiting_period_setting", "three_days"); await page.select("#id_realm_waiting_period_threshold", "three_days");
await submit_joining_organization_change(page); await submit_joining_organization_change(page);
} }
async function test_set_new_user_threshold_to_N_days(page: Page): Promise<void> { async function test_set_new_user_threshold_to_N_days(page: Page): Promise<void> {
console.log("Test setting new user threshold to three days."); console.log("Test setting new user threshold to three days.");
await page.waitForSelector("#id_realm_waiting_period_setting", {visible: true}); await page.waitForSelector("#id_realm_waiting_period_threshold", {visible: true});
await page.select("#id_realm_waiting_period_setting", "custom_period"); await page.select("#id_realm_waiting_period_threshold", "custom_period");
const N = "10"; const N = "10";
await common.clear_and_type(page, "#id_realm_waiting_period_threshold", N); await common.clear_and_type(page, "#id_realm_waiting_period_threshold_custom_input", N);
await submit_joining_organization_change(page); await submit_joining_organization_change(page);
} }

View File

@@ -168,7 +168,7 @@ function get_property_value(property_name, for_realm_default_settings, sub) {
return sub[property_name]; return sub[property_name];
} }
if (property_name === "realm_waiting_period_setting") { if (property_name === "realm_waiting_period_threshold") {
if (page_params.realm_waiting_period_threshold === 0) { if (page_params.realm_waiting_period_threshold === 0) {
return "none"; return "none";
} }
@@ -246,10 +246,10 @@ export function change_element_block_display_property(elem_id, show_element) {
} }
function set_realm_waiting_period_dropdown() { function set_realm_waiting_period_dropdown() {
const value = get_property_value("realm_waiting_period_setting"); const value = get_property_value("realm_waiting_period_threshold");
$("#id_realm_waiting_period_setting").val(value); $("#id_realm_waiting_period_threshold").val(value);
change_element_block_display_property( change_element_block_display_property(
"id_realm_waiting_period_threshold", "id_realm_waiting_period_threshold_custom_input",
value === "custom_period", value === "custom_period",
); );
} }
@@ -1084,7 +1084,7 @@ export function register_save_discard_widget_handlers(
break; break;
} }
const waiting_period_threshold = $("#id_realm_waiting_period_setting").val(); const waiting_period_threshold = $("#id_realm_waiting_period_threshold").val();
switch (waiting_period_threshold) { switch (waiting_period_threshold) {
case "none": case "none":
data.waiting_period_threshold = 0; data.waiting_period_threshold = 0;
@@ -1094,7 +1094,7 @@ export function register_save_discard_widget_handlers(
break; break;
case "custom_period": case "custom_period":
data.waiting_period_threshold = $( data.waiting_period_threshold = $(
"#id_realm_waiting_period_threshold", "#id_realm_waiting_period_threshold_custom_input",
).val(); ).val();
break; break;
} }
@@ -1190,7 +1190,7 @@ export function build_page() {
); );
}); });
$("#id_realm_waiting_period_setting").on("change", function () { $("#id_realm_waiting_period_threshold").on("change", function () {
const waiting_period_threshold = this.value; const waiting_period_threshold = this.value;
change_element_block_display_property( change_element_block_display_property(
"id_realm_waiting_period_threshold", "id_realm_waiting_period_threshold",

View File

@@ -1440,7 +1440,7 @@ $option_title_width: 180px;
/* These have enough space for all the options in German. */ /* These have enough space for all the options in German. */
.setting_desktop_icon_count_display, .setting_desktop_icon_count_display,
#id_realm_waiting_period_setting, #id_realm_waiting_period_threshold,
#id_realm_create_public_stream_policy, #id_realm_create_public_stream_policy,
#id_realm_create_private_stream_policy, #id_realm_create_private_stream_policy,
#id_realm_invite_to_stream_policy, #id_realm_invite_to_stream_policy,

View File

@@ -36,20 +36,20 @@
</div> </div>
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="realm_waiting_period_setting" class="dropdown-title"> <label for="realm_waiting_period_threshold" class="dropdown-title">
{{t "Waiting period before new members turn into full members" }} {{t "Waiting period before new members turn into full members" }}
{{> ../help_link_widget link="/help/restrict-permissions-of-new-members" }} {{> ../help_link_widget link="/help/restrict-permissions-of-new-members" }}
</label> </label>
<select name="realm_waiting_period_setting" id="id_realm_waiting_period_setting" class="prop-element"> <select name="realm_waiting_period_threshold" id="id_realm_waiting_period_threshold" class="prop-element">
<option value="none">{{t "None" }}</option> <option value="none">{{t "None" }}</option>
<option value="three_days">{{t "3 days" }}</option> <option value="three_days">{{t "3 days" }}</option>
<option value="custom_period">{{t "Custom" }}</option> <option value="custom_period">{{t "Custom" }}</option>
</select> </select>
{{!-- This setting is hidden unless `custom_period` --}} {{!-- This setting is hidden unless `custom_period` --}}
<div class="dependent-settings-block"> <div class="dependent-settings-block">
<label for="id_realm_waiting_period_threshold" class="inline-block">{{t "Waiting period (days)" }}:</label> <label for="id_realm_waiting_period_threshold_custom_input" class="inline-block">{{t "Waiting period (days)" }}:</label>
<input type="text" id="id_realm_waiting_period_threshold" <input type="text" id="id_realm_waiting_period_threshold_custom_input"
name="realm_waiting_period_threshold" name="realm_waiting_period_threshold_custom_input"
class="admin-realm-time-limit-input prop-element" class="admin-realm-time-limit-input prop-element"
value="{{ realm_waiting_period_threshold }}"/> value="{{ realm_waiting_period_threshold }}"/>
</div> </div>