mirror of https://github.com/zulip/zulip.git
eslint: Fix unicorn/prefer-switch.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
04569bc17e
commit
5ca763fc24
|
@ -102,7 +102,6 @@
|
||||||
"unicorn/prefer-module": "off",
|
"unicorn/prefer-module": "off",
|
||||||
"unicorn/prefer-node-protocol": "off",
|
"unicorn/prefer-node-protocol": "off",
|
||||||
"unicorn/prefer-spread": "off",
|
"unicorn/prefer-spread": "off",
|
||||||
"unicorn/prefer-switch": "off",
|
|
||||||
"unicorn/prefer-ternary": "off",
|
"unicorn/prefer-ternary": "off",
|
||||||
"unicorn/prevent-abbreviations": "off",
|
"unicorn/prevent-abbreviations": "off",
|
||||||
"valid-typeof": ["error", {"requireStringLiterals": true}],
|
"valid-typeof": ["error", {"requireStringLiterals": true}],
|
||||||
|
|
|
@ -38,20 +38,24 @@ run_test("initialize", (override) => {
|
||||||
let create_ajax_request_form_call_count = 0;
|
let create_ajax_request_form_call_count = 0;
|
||||||
helpers.__Rewire__("create_ajax_request", (url, form_name, stripe_token, redirect_to) => {
|
helpers.__Rewire__("create_ajax_request", (url, form_name, stripe_token, redirect_to) => {
|
||||||
create_ajax_request_form_call_count += 1;
|
create_ajax_request_form_call_count += 1;
|
||||||
if (form_name === "autopay") {
|
switch (form_name) {
|
||||||
assert.equal(url, "/json/billing/upgrade");
|
case "autopay":
|
||||||
assert.equal(stripe_token, "stripe_add_card_token");
|
assert.equal(url, "/json/billing/upgrade");
|
||||||
assert.equal(redirect_to, undefined);
|
assert.equal(stripe_token, "stripe_add_card_token");
|
||||||
} else if (form_name === "invoice") {
|
assert.equal(redirect_to, undefined);
|
||||||
assert.equal(url, "/json/billing/upgrade");
|
break;
|
||||||
assert.equal(stripe_token, undefined);
|
case "invoice":
|
||||||
assert.equal(redirect_to, undefined);
|
assert.equal(url, "/json/billing/upgrade");
|
||||||
} else if (form_name === "sponsorship") {
|
assert.equal(stripe_token, undefined);
|
||||||
assert.equal(url, "/json/billing/sponsorship");
|
assert.equal(redirect_to, undefined);
|
||||||
assert.equal(stripe_token, undefined);
|
break;
|
||||||
assert.equal(redirect_to, "/");
|
case "sponsorship":
|
||||||
} else {
|
assert.equal(url, "/json/billing/sponsorship");
|
||||||
throw new Error("Unhandled case");
|
assert.equal(stripe_token, undefined);
|
||||||
|
assert.equal(redirect_to, "/");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unhandled case");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -441,7 +441,6 @@ export function navigate(event_name, e) {
|
||||||
|
|
||||||
const selected_emoji = get_rendered_emoji(current_section, current_index);
|
const selected_emoji = get_rendered_emoji(current_section, current_index);
|
||||||
const is_filter_focused = $(".emoji-popover-filter").is(":focus");
|
const is_filter_focused = $(".emoji-popover-filter").is(":focus");
|
||||||
let next_section = 0;
|
|
||||||
// special cases
|
// special cases
|
||||||
if (is_filter_focused) {
|
if (is_filter_focused) {
|
||||||
// Move down into emoji map.
|
// Move down into emoji map.
|
||||||
|
@ -481,42 +480,32 @@ export function navigate(event_name, e) {
|
||||||
reset_emoji_showcase();
|
reset_emoji_showcase();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event_name === "tab") {
|
return false;
|
||||||
change_focus_to_filter();
|
}
|
||||||
return true;
|
|
||||||
} else if (event_name === "shift_tab") {
|
switch (event_name) {
|
||||||
if (!is_filter_focused) {
|
case "tab":
|
||||||
change_focus_to_filter();
|
case "shift_tab":
|
||||||
}
|
change_focus_to_filter();
|
||||||
return true;
|
return true;
|
||||||
} else if (event_name === "page_up") {
|
case "page_up":
|
||||||
next_section = current_section - 1;
|
maybe_change_active_section(current_section - 1);
|
||||||
maybe_change_active_section(next_section);
|
return true;
|
||||||
return true;
|
case "page_down":
|
||||||
} else if (event_name === "page_down") {
|
maybe_change_active_section(current_section + 1);
|
||||||
next_section = current_section + 1;
|
return true;
|
||||||
maybe_change_active_section(next_section);
|
case "down_arrow":
|
||||||
return true;
|
case "up_arrow":
|
||||||
} else if (!is_filter_focused) {
|
case "left_arrow":
|
||||||
let next_coord = {};
|
case "right_arrow": {
|
||||||
switch (event_name) {
|
const next_coord = get_next_emoji_coordinates(
|
||||||
case "down_arrow":
|
{down_arrow: 6, up_arrow: -6, left_arrow: -1, right_arrow: 1}[event_name],
|
||||||
next_coord = get_next_emoji_coordinates(6);
|
);
|
||||||
break;
|
return maybe_change_focused_emoji($emoji_map, next_coord.section, next_coord.index);
|
||||||
case "up_arrow":
|
}
|
||||||
next_coord = get_next_emoji_coordinates(-6);
|
default:
|
||||||
break;
|
return false;
|
||||||
case "left_arrow":
|
|
||||||
next_coord = get_next_emoji_coordinates(-1);
|
|
||||||
break;
|
|
||||||
case "right_arrow":
|
|
||||||
next_coord = get_next_emoji_coordinates(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return maybe_change_focused_emoji($emoji_map, next_coord.section, next_coord.index);
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_keypress(e) {
|
function process_keypress(e) {
|
||||||
|
|
|
@ -69,35 +69,42 @@ function message_in_home(message) {
|
||||||
function message_matches_search_term(message, operator, operand) {
|
function message_matches_search_term(message, operator, operand) {
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "has":
|
case "has":
|
||||||
if (operand === "image") {
|
switch (operand) {
|
||||||
return message_parser.message_has_image(message);
|
case "image":
|
||||||
} else if (operand === "link") {
|
return message_parser.message_has_image(message);
|
||||||
return message_parser.message_has_link(message);
|
case "link":
|
||||||
} else if (operand === "attachment") {
|
return message_parser.message_has_link(message);
|
||||||
return message_parser.message_has_attachment(message);
|
case "attachment":
|
||||||
|
return message_parser.message_has_attachment(message);
|
||||||
|
default:
|
||||||
|
return false; // has:something_else returns false
|
||||||
}
|
}
|
||||||
return false; // has:something_else returns false
|
|
||||||
case "is":
|
case "is":
|
||||||
if (operand === "private") {
|
switch (operand) {
|
||||||
return message.type === "private";
|
case "private":
|
||||||
} else if (operand === "starred") {
|
return message.type === "private";
|
||||||
return message.starred;
|
case "starred":
|
||||||
} else if (operand === "mentioned") {
|
return message.starred;
|
||||||
return message.mentioned;
|
case "mentioned":
|
||||||
} else if (operand === "alerted") {
|
return message.mentioned;
|
||||||
return message.alerted;
|
case "alerted":
|
||||||
} else if (operand === "unread") {
|
return message.alerted;
|
||||||
return unread.message_unread(message);
|
case "unread":
|
||||||
|
return unread.message_unread(message);
|
||||||
|
default:
|
||||||
|
return false; // is:whatever returns false
|
||||||
}
|
}
|
||||||
return false; // is:whatever returns false
|
|
||||||
|
|
||||||
case "in":
|
case "in":
|
||||||
if (operand === "home") {
|
switch (operand) {
|
||||||
return message_in_home(message);
|
case "home":
|
||||||
} else if (operand === "all") {
|
return message_in_home(message);
|
||||||
return true;
|
case "all":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false; // in:whatever returns false
|
||||||
}
|
}
|
||||||
return false; // in:whatever returns false
|
|
||||||
|
|
||||||
case "near":
|
case "near":
|
||||||
// this is all handled server side
|
// this is all handled server side
|
||||||
|
|
|
@ -680,21 +680,29 @@ export function process_hotkey(e, hotkey) {
|
||||||
) {
|
) {
|
||||||
compose_actions.cancel();
|
compose_actions.cancel();
|
||||||
// don't return, as we still want it to be picked up by the code below
|
// don't return, as we still want it to be picked up by the code below
|
||||||
} else if (event_name === "page_up") {
|
|
||||||
$(":focus").caret(0).animate({scrollTop: 0}, "fast");
|
|
||||||
return true;
|
|
||||||
} else if (event_name === "page_down") {
|
|
||||||
// so that it always goes to the end of the text box.
|
|
||||||
const height = $(":focus")[0].scrollHeight;
|
|
||||||
$(":focus").caret(Number.POSITIVE_INFINITY).animate({scrollTop: height}, "fast");
|
|
||||||
return true;
|
|
||||||
} else if (event_name === "search_with_k") {
|
|
||||||
// Do nothing; this allows one to use Ctrl+K inside compose.
|
|
||||||
} else if (event_name === "star_message") {
|
|
||||||
// Do nothing; this allows one to use Ctrl+S inside compose.
|
|
||||||
} else {
|
} else {
|
||||||
// Let the browser handle the key normally.
|
switch (event_name) {
|
||||||
return false;
|
case "page_up":
|
||||||
|
$(":focus").caret(0).animate({scrollTop: 0}, "fast");
|
||||||
|
return true;
|
||||||
|
case "page_down": {
|
||||||
|
// so that it always goes to the end of the text box.
|
||||||
|
const height = $(":focus")[0].scrollHeight;
|
||||||
|
$(":focus")
|
||||||
|
.caret(Number.POSITIVE_INFINITY)
|
||||||
|
.animate({scrollTop: height}, "fast");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "search_with_k":
|
||||||
|
// Do nothing; this allows one to use Ctrl+K inside compose.
|
||||||
|
break;
|
||||||
|
case "star_message":
|
||||||
|
// Do nothing; this allows one to use Ctrl+S inside compose.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Let the browser handle the key normally.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,18 +316,23 @@ export function create(opts) {
|
||||||
|
|
||||||
const $pill = store.$parent.find(".pill:focus");
|
const $pill = store.$parent.find(".pill:focus");
|
||||||
|
|
||||||
if (char === KEY.LEFT_ARROW) {
|
switch (char) {
|
||||||
$pill.prev().trigger("focus");
|
case KEY.LEFT_ARROW:
|
||||||
} else if (char === KEY.RIGHT_ARROW) {
|
$pill.prev().trigger("focus");
|
||||||
$pill.next().trigger("focus");
|
break;
|
||||||
} else if (char === KEY.BACKSPACE) {
|
case KEY.RIGHT_ARROW:
|
||||||
const $next = $pill.next();
|
$pill.next().trigger("focus");
|
||||||
const id = $pill.data("id");
|
break;
|
||||||
funcs.removePill(id);
|
case KEY.BACKSPACE: {
|
||||||
$next.trigger("focus");
|
const $next = $pill.next();
|
||||||
// the "Backspace" key in Firefox will go back a page if you do
|
const id = $pill.data("id");
|
||||||
// not prevent it.
|
funcs.removePill(id);
|
||||||
e.preventDefault();
|
$next.trigger("focus");
|
||||||
|
// the "Backspace" key in Firefox will go back a page if you do
|
||||||
|
// not prevent it.
|
||||||
|
e.preventDefault();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -79,18 +79,22 @@ function display_video(payload) {
|
||||||
).hide();
|
).hide();
|
||||||
|
|
||||||
let source;
|
let source;
|
||||||
if (payload.type === "youtube-video") {
|
switch (payload.type) {
|
||||||
source = "https://www.youtube.com/embed/" + payload.source;
|
case "youtube-video":
|
||||||
} else if (payload.type === "vimeo-video") {
|
source = "https://www.youtube.com/embed/" + payload.source;
|
||||||
source = "https://player.vimeo.com/video/" + payload.source;
|
break;
|
||||||
} else if (payload.type === "embed-video") {
|
case "vimeo-video":
|
||||||
// Use data: to load the player in a unique origin for security.
|
source = "https://player.vimeo.com/video/" + payload.source;
|
||||||
source =
|
break;
|
||||||
"data:text/html," +
|
case "embed-video":
|
||||||
window.encodeURIComponent(
|
// Use data: to load the player in a unique origin for security.
|
||||||
"<!DOCTYPE html><style>iframe{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box}</style>" +
|
source =
|
||||||
payload.source,
|
"data:text/html," +
|
||||||
);
|
window.encodeURIComponent(
|
||||||
|
"<!DOCTYPE html><style>iframe{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box}</style>" +
|
||||||
|
payload.source,
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const iframe = $("<iframe></iframe>");
|
const iframe = $("<iframe></iframe>");
|
||||||
|
|
|
@ -101,14 +101,20 @@ const funcs = {
|
||||||
if (!overlays.lightbox_open()) {
|
if (!overlays.lightbox_open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.key === "Z" || e.key === "+") {
|
switch (e.key) {
|
||||||
funcs.setZoom(meta, "+");
|
case "Z":
|
||||||
funcs.displayImage(canvas, context, meta);
|
case "+":
|
||||||
} else if (e.key === "z" || e.key === "-") {
|
funcs.setZoom(meta, "+");
|
||||||
funcs.setZoom(meta, "-");
|
funcs.displayImage(canvas, context, meta);
|
||||||
funcs.displayImage(canvas, context, meta);
|
break;
|
||||||
} else if (e.key === "v") {
|
case "z":
|
||||||
overlays.close_overlay("lightbox");
|
case "-":
|
||||||
|
funcs.setZoom(meta, "-");
|
||||||
|
funcs.displayImage(canvas, context, meta);
|
||||||
|
break;
|
||||||
|
case "v":
|
||||||
|
overlays.close_overlay("lightbox");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
|
@ -401,38 +401,44 @@ function edit_message(row, raw_content) {
|
||||||
stream_bar.decorate(stream_name, stream_header_colorblock, false);
|
stream_bar.decorate(stream_name, stream_header_colorblock, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (editability === editability_types.NO) {
|
switch (editability) {
|
||||||
message_edit_content.attr("readonly", "readonly");
|
case editability_types.NO:
|
||||||
message_edit_topic.attr("readonly", "readonly");
|
message_edit_content.attr("readonly", "readonly");
|
||||||
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
message_edit_topic.attr("readonly", "readonly");
|
||||||
} else if (editability === editability_types.NO_LONGER) {
|
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
||||||
// You can currently only reach this state in non-streams. If that
|
break;
|
||||||
// changes (e.g. if we stop allowing topics to be modified forever
|
case editability_types.NO_LONGER:
|
||||||
// in streams), then we'll need to disable
|
// You can currently only reach this state in non-streams. If that
|
||||||
// row.find('input.message_edit_topic') as well.
|
// changes (e.g. if we stop allowing topics to be modified forever
|
||||||
message_edit_content.attr("readonly", "readonly");
|
// in streams), then we'll need to disable
|
||||||
message_edit_countdown_timer.text($t({defaultMessage: "View source"}));
|
// row.find('input.message_edit_topic') as well.
|
||||||
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
message_edit_content.attr("readonly", "readonly");
|
||||||
} else if (editability === editability_types.TOPIC_ONLY) {
|
message_edit_countdown_timer.text($t({defaultMessage: "View source"}));
|
||||||
message_edit_content.attr("readonly", "readonly");
|
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
||||||
// Hint why you can edit the topic but not the message content
|
break;
|
||||||
message_edit_countdown_timer.text($t({defaultMessage: "Topic editing only"}));
|
case editability_types.TOPIC_ONLY:
|
||||||
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
message_edit_content.attr("readonly", "readonly");
|
||||||
} else if (editability === editability_types.FULL) {
|
// Hint why you can edit the topic but not the message content
|
||||||
copy_message.remove();
|
message_edit_countdown_timer.text($t({defaultMessage: "Topic editing only"}));
|
||||||
const edit_id = `#edit_form_${CSS.escape(rows.id(row))} .message_edit_content`;
|
create_copy_to_clipboard_handler(copy_message[0], message.id);
|
||||||
const listeners = resize.watch_manual_resize(edit_id);
|
break;
|
||||||
if (listeners) {
|
case editability_types.FULL: {
|
||||||
currently_editing_messages.get(rows.id(row)).listeners = listeners;
|
copy_message.remove();
|
||||||
|
const edit_id = `#edit_form_${CSS.escape(rows.id(row))} .message_edit_content`;
|
||||||
|
const listeners = resize.watch_manual_resize(edit_id);
|
||||||
|
if (listeners) {
|
||||||
|
currently_editing_messages.get(rows.id(row)).listeners = listeners;
|
||||||
|
}
|
||||||
|
composebox_typeahead.initialize_compose_typeahead(edit_id);
|
||||||
|
compose.handle_keyup(null, $(edit_id).expectOne());
|
||||||
|
$(edit_id).on("keydown", function (event) {
|
||||||
|
compose.handle_keydown(event, $(this).expectOne());
|
||||||
|
});
|
||||||
|
$(edit_id).on("keyup", function (event) {
|
||||||
|
compose.handle_keyup(event, $(this).expectOne());
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
composebox_typeahead.initialize_compose_typeahead(edit_id);
|
|
||||||
compose.handle_keyup(null, $(edit_id).expectOne());
|
|
||||||
$(edit_id).on("keydown", function (event) {
|
|
||||||
compose.handle_keydown(event, $(this).expectOne());
|
|
||||||
});
|
|
||||||
$(edit_id).on("keyup", function (event) {
|
|
||||||
compose.handle_keyup(event, $(this).expectOne());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add tooltip
|
// Add tooltip
|
||||||
|
|
|
@ -328,17 +328,21 @@ export function activate(raw_operators, opts) {
|
||||||
// particular message ID (which could be max_int), or we're
|
// particular message ID (which could be max_int), or we're
|
||||||
// asking the server to figure out for us what the first
|
// asking the server to figure out for us what the first
|
||||||
// unread message is, and center the narrow around that.
|
// unread message is, and center the narrow around that.
|
||||||
if (id_info.final_select_id === undefined) {
|
switch (id_info.final_select_id) {
|
||||||
anchor = "first_unread";
|
case undefined:
|
||||||
} else if (id_info.final_select_id === -1) {
|
anchor = "first_unread";
|
||||||
// This case should never happen in this code path; it's
|
break;
|
||||||
// here in case we choose to extract this as an
|
case -1:
|
||||||
// independent reusable function.
|
// This case should never happen in this code path; it's
|
||||||
anchor = "oldest";
|
// here in case we choose to extract this as an
|
||||||
} else if (id_info.final_select_id === LARGER_THAN_MAX_MESSAGE_ID) {
|
// independent reusable function.
|
||||||
anchor = "newest";
|
anchor = "oldest";
|
||||||
} else {
|
break;
|
||||||
anchor = id_info.final_select_id;
|
case LARGER_THAN_MAX_MESSAGE_ID:
|
||||||
|
anchor = "newest";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
anchor = id_info.final_select_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
message_fetch.load_messages_for_narrow({
|
message_fetch.load_messages_for_narrow({
|
||||||
|
|
|
@ -130,20 +130,27 @@ export function get_direction(str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bidi_class = get_bidi_class(ch);
|
const bidi_class = get_bidi_class(ch);
|
||||||
if (bidi_class === "I") {
|
switch (bidi_class) {
|
||||||
// LRI, RLI, FSI
|
case "I":
|
||||||
isolations += 1;
|
// LRI, RLI, FSI
|
||||||
} else if (bidi_class === "PDI") {
|
isolations += 1;
|
||||||
if (isolations > 0) {
|
break;
|
||||||
isolations -= 1;
|
case "PDI":
|
||||||
}
|
if (isolations > 0) {
|
||||||
} else if (bidi_class === "R") {
|
isolations -= 1;
|
||||||
// R, AL
|
}
|
||||||
if (isolations === 0) {
|
break;
|
||||||
return "rtl";
|
case "R":
|
||||||
}
|
// R, AL
|
||||||
} else if (bidi_class === "L" && isolations === 0) {
|
if (isolations === 0) {
|
||||||
return "ltr";
|
return "rtl";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "L":
|
||||||
|
if (isolations === 0) {
|
||||||
|
return "ltr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "ltr";
|
return "ltr";
|
||||||
|
|
|
@ -399,31 +399,37 @@ export function populate_auth_methods(auth_methods) {
|
||||||
function update_dependent_subsettings(property_name) {
|
function update_dependent_subsettings(property_name) {
|
||||||
if (simple_dropdown_properties.includes(property_name)) {
|
if (simple_dropdown_properties.includes(property_name)) {
|
||||||
set_property_dropdown_value(property_name);
|
set_property_dropdown_value(property_name);
|
||||||
} else if (property_name === "realm_waiting_period_threshold") {
|
return;
|
||||||
set_realm_waiting_period_dropdown();
|
}
|
||||||
} else if (
|
|
||||||
property_name === "realm_video_chat_provider"
|
switch (property_name) {
|
||||||
) {
|
case "realm_waiting_period_threshold":
|
||||||
set_video_chat_provider_dropdown();
|
set_realm_waiting_period_dropdown();
|
||||||
} else if (
|
break;
|
||||||
property_name === "realm_msg_edit_limit_setting" ||
|
case "realm_video_chat_provider":
|
||||||
property_name === "realm_message_content_edit_limit_minutes"
|
set_video_chat_provider_dropdown();
|
||||||
) {
|
break;
|
||||||
set_msg_edit_limit_dropdown();
|
case "realm_msg_edit_limit_setting":
|
||||||
} else if (property_name === "realm_message_retention_days") {
|
case "realm_message_content_edit_limit_minutes":
|
||||||
set_message_retention_setting_dropdown();
|
set_msg_edit_limit_dropdown();
|
||||||
} else if (
|
break;
|
||||||
property_name === "realm_msg_delete_limit_setting" ||
|
case "realm_message_retention_days":
|
||||||
property_name === "realm_message_content_delete_limit_minutes"
|
set_message_retention_setting_dropdown();
|
||||||
) {
|
break;
|
||||||
set_msg_delete_limit_dropdown();
|
case "realm_msg_delete_limit_setting":
|
||||||
} else if (property_name === "realm_org_join_restrictions") {
|
case "realm_message_content_delete_limit_minutes":
|
||||||
set_org_join_restrictions_dropdown();
|
set_msg_delete_limit_dropdown();
|
||||||
} else if (property_name === "realm_message_content_allowed_in_email_notifications") {
|
break;
|
||||||
set_message_content_in_email_notifications_visiblity();
|
case "realm_org_join_restrictions":
|
||||||
} else if (property_name === "realm_digest_emails_enabled") {
|
set_org_join_restrictions_dropdown();
|
||||||
settings_notifications.set_enable_digest_emails_visibility();
|
break;
|
||||||
set_digest_emails_weekday_visibility();
|
case "realm_message_content_allowed_in_email_notifications":
|
||||||
|
set_message_content_in_email_notifications_visiblity();
|
||||||
|
break;
|
||||||
|
case "realm_digest_emails_enabled":
|
||||||
|
settings_notifications.set_enable_digest_emails_visibility();
|
||||||
|
set_digest_emails_weekday_visibility();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,18 +442,25 @@ function discard_property_element_changes(elem) {
|
||||||
const property_name = extract_property_name(elem);
|
const property_name = extract_property_name(elem);
|
||||||
const property_value = get_property_value(property_name);
|
const property_value = get_property_value(property_name);
|
||||||
|
|
||||||
if (property_name === "realm_authentication_methods") {
|
switch (property_name) {
|
||||||
populate_auth_methods(property_value);
|
case "realm_authentication_methods":
|
||||||
} else if (property_name === "realm_notifications_stream_id") {
|
populate_auth_methods(property_value);
|
||||||
notifications_stream_widget.render(property_value);
|
break;
|
||||||
} else if (property_name === "realm_signup_notifications_stream_id") {
|
case "realm_notifications_stream_id":
|
||||||
signup_notifications_stream_widget.render(property_value);
|
notifications_stream_widget.render(property_value);
|
||||||
} else if (property_name === "realm_default_code_block_language") {
|
break;
|
||||||
default_code_language_widget.render(property_value);
|
case "realm_signup_notifications_stream_id":
|
||||||
} else if (property_value !== undefined) {
|
signup_notifications_stream_widget.render(property_value);
|
||||||
set_input_element_value(elem, property_value);
|
break;
|
||||||
} else {
|
case "realm_default_code_block_language":
|
||||||
blueslip.error("Element refers to unknown property " + property_name);
|
default_code_language_widget.render(property_value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (property_value !== undefined) {
|
||||||
|
set_input_element_value(elem, property_value);
|
||||||
|
} else {
|
||||||
|
blueslip.error("Element refers to unknown property " + property_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_dependent_subsettings(property_name);
|
update_dependent_subsettings(property_name);
|
||||||
|
@ -459,29 +472,39 @@ export function sync_realm_settings(property) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = page_params[`realm_${property}`];
|
const value = page_params[`realm_${property}`];
|
||||||
if (property === "notifications_stream_id") {
|
switch (property) {
|
||||||
notifications_stream_widget.render(value);
|
case "notifications_stream_id":
|
||||||
} else if (property === "signup_notifications_stream_id") {
|
notifications_stream_widget.render(value);
|
||||||
signup_notifications_stream_widget.render(value);
|
break;
|
||||||
} else if (property === "default_code_block_language") {
|
case "signup_notifications_stream_id":
|
||||||
default_code_language_widget.render(value);
|
signup_notifications_stream_widget.render(value);
|
||||||
|
break;
|
||||||
|
case "default_code_block_language":
|
||||||
|
default_code_language_widget.render(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === "message_content_edit_limit_seconds") {
|
switch (property) {
|
||||||
property = "message_content_edit_limit_minutes";
|
case "message_content_edit_limit_seconds":
|
||||||
} else if (property === "allow_message_editing") {
|
property = "message_content_edit_limit_minutes";
|
||||||
property = "msg_edit_limit_setting";
|
break;
|
||||||
} else if (
|
case "allow_message_editing":
|
||||||
property === "emails_restricted_to_domains" ||
|
property = "msg_edit_limit_setting";
|
||||||
property === "disallow_disposable_email_addresses"
|
break;
|
||||||
) {
|
case "emails_restricted_to_domains":
|
||||||
property = "org_join_restrictions";
|
case "disallow_disposable_email_addresses":
|
||||||
} else if (property === "message_content_delete_limit_seconds") {
|
property = "org_join_restrictions";
|
||||||
property = "message_content_delete_limit_minutes";
|
break;
|
||||||
} else if (property === "allow_message_deleting") {
|
case "message_content_delete_limit_seconds":
|
||||||
property = "msg_delete_limit_setting";
|
property = "message_content_delete_limit_minutes";
|
||||||
} else if (property === "invite_required" || property === "invite_to_realm_policy") {
|
break;
|
||||||
property = "user_invite_restriction";
|
case "allow_message_deleting":
|
||||||
|
property = "msg_delete_limit_setting";
|
||||||
|
break;
|
||||||
|
case "invite_required":
|
||||||
|
case "invite_to_realm_policy":
|
||||||
|
property = "user_invite_restriction";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
const element = $(`#id_realm_${CSS.escape(property)}`);
|
const element = $(`#id_realm_${CSS.escape(property)}`);
|
||||||
if (element.length) {
|
if (element.length) {
|
||||||
|
@ -515,31 +538,37 @@ export function change_save_button_state($element, state) {
|
||||||
let button_text;
|
let button_text;
|
||||||
let data_status;
|
let data_status;
|
||||||
let is_show;
|
let is_show;
|
||||||
if (state === "unsaved") {
|
switch (state) {
|
||||||
button_text = $t({defaultMessage: "Save changes"});
|
case "unsaved":
|
||||||
data_status = "unsaved";
|
button_text = $t({defaultMessage: "Save changes"});
|
||||||
is_show = true;
|
data_status = "unsaved";
|
||||||
|
is_show = true;
|
||||||
|
|
||||||
$element.find(".discard-button").show();
|
$element.find(".discard-button").show();
|
||||||
} else if (state === "saved") {
|
break;
|
||||||
button_text = $t({defaultMessage: "Save changes"});
|
case "saved":
|
||||||
data_status = "";
|
button_text = $t({defaultMessage: "Save changes"});
|
||||||
is_show = false;
|
data_status = "";
|
||||||
} else if (state === "saving") {
|
is_show = false;
|
||||||
button_text = $t({defaultMessage: "Saving"});
|
break;
|
||||||
data_status = "saving";
|
case "saving":
|
||||||
is_show = true;
|
button_text = $t({defaultMessage: "Saving"});
|
||||||
|
data_status = "saving";
|
||||||
|
is_show = true;
|
||||||
|
|
||||||
$element.find(".discard-button").hide();
|
$element.find(".discard-button").hide();
|
||||||
$saveBtn.addClass("saving");
|
$saveBtn.addClass("saving");
|
||||||
} else if (state === "failed") {
|
break;
|
||||||
button_text = $t({defaultMessage: "Save changes"});
|
case "failed":
|
||||||
data_status = "failed";
|
button_text = $t({defaultMessage: "Save changes"});
|
||||||
is_show = true;
|
data_status = "failed";
|
||||||
} else if (state === "succeeded") {
|
is_show = true;
|
||||||
button_text = $t({defaultMessage: "Saved"});
|
break;
|
||||||
data_status = "saved";
|
case "succeeded":
|
||||||
is_show = false;
|
button_text = $t({defaultMessage: "Saved"});
|
||||||
|
data_status = "saved";
|
||||||
|
is_show = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$textEl.text(button_text);
|
$textEl.text(button_text);
|
||||||
|
@ -557,18 +586,16 @@ function get_input_type(input_elem, input_type) {
|
||||||
export function get_input_element_value(input_elem, input_type) {
|
export function get_input_element_value(input_elem, input_type) {
|
||||||
input_elem = $(input_elem);
|
input_elem = $(input_elem);
|
||||||
input_type = get_input_type(input_elem, input_type);
|
input_type = get_input_type(input_elem, input_type);
|
||||||
if (input_type) {
|
switch (input_type) {
|
||||||
if (input_type === "boolean") {
|
case "boolean":
|
||||||
return input_elem.prop("checked");
|
return input_elem.prop("checked");
|
||||||
}
|
case "string":
|
||||||
if (input_type === "string") {
|
|
||||||
return input_elem.val().trim();
|
return input_elem.val().trim();
|
||||||
}
|
case "number":
|
||||||
if (input_type === "number") {
|
|
||||||
return Number.parseInt(input_elem.val().trim(), 10);
|
return Number.parseInt(input_elem.val().trim(), 10);
|
||||||
}
|
default:
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function set_input_element_value(input_elem, value) {
|
export function set_input_element_value(input_elem, value) {
|
||||||
|
@ -576,8 +603,7 @@ export function set_input_element_value(input_elem, value) {
|
||||||
if (input_type) {
|
if (input_type) {
|
||||||
if (input_type === "boolean") {
|
if (input_type === "boolean") {
|
||||||
return input_elem.prop("checked", value);
|
return input_elem.prop("checked", value);
|
||||||
}
|
} else if (input_type === "string" || input_type === "number") {
|
||||||
if (input_type === "string" || input_type === "number") {
|
|
||||||
return input_elem.val(value);
|
return input_elem.val(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,21 +635,28 @@ function check_property_changed(elem) {
|
||||||
let current_val = get_property_value(property_name);
|
let current_val = get_property_value(property_name);
|
||||||
let changed_val;
|
let changed_val;
|
||||||
|
|
||||||
if (property_name === "realm_authentication_methods") {
|
switch (property_name) {
|
||||||
current_val = sort_object_by_key(current_val);
|
case "realm_authentication_methods":
|
||||||
current_val = JSON.stringify(current_val);
|
current_val = sort_object_by_key(current_val);
|
||||||
changed_val = get_auth_method_table_data();
|
current_val = JSON.stringify(current_val);
|
||||||
changed_val = JSON.stringify(changed_val);
|
changed_val = get_auth_method_table_data();
|
||||||
} else if (property_name === "realm_notifications_stream_id") {
|
changed_val = JSON.stringify(changed_val);
|
||||||
changed_val = Number.parseInt(notifications_stream_widget.value(), 10);
|
break;
|
||||||
} else if (property_name === "realm_signup_notifications_stream_id") {
|
case "realm_notifications_stream_id":
|
||||||
changed_val = Number.parseInt(signup_notifications_stream_widget.value(), 10);
|
changed_val = Number.parseInt(notifications_stream_widget.value(), 10);
|
||||||
} else if (property_name === "realm_default_code_block_language") {
|
break;
|
||||||
changed_val = default_code_language_widget.value();
|
case "realm_signup_notifications_stream_id":
|
||||||
} else if (current_val !== undefined) {
|
changed_val = Number.parseInt(signup_notifications_stream_widget.value(), 10);
|
||||||
changed_val = get_input_element_value(elem, typeof current_val);
|
break;
|
||||||
} else {
|
case "realm_default_code_block_language":
|
||||||
blueslip.error("Element refers to unknown property " + property_name);
|
changed_val = default_code_language_widget.value();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (current_val !== undefined) {
|
||||||
|
changed_val = get_input_element_value(elem, typeof current_val);
|
||||||
|
} else {
|
||||||
|
blueslip.error("Element refers to unknown property " + property_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return current_val !== changed_val;
|
return current_val !== changed_val;
|
||||||
}
|
}
|
||||||
|
@ -770,128 +803,172 @@ export function build_page() {
|
||||||
function get_complete_data_for_subsection(subsection) {
|
function get_complete_data_for_subsection(subsection) {
|
||||||
let data = {};
|
let data = {};
|
||||||
|
|
||||||
if (subsection === "msg_editing") {
|
switch (subsection) {
|
||||||
const edit_limit_setting_value = $("#id_realm_msg_edit_limit_setting").val();
|
case "msg_editing": {
|
||||||
if (edit_limit_setting_value === "never") {
|
const edit_limit_setting_value = $("#id_realm_msg_edit_limit_setting").val();
|
||||||
data.allow_message_editing = false;
|
if (edit_limit_setting_value === "never") {
|
||||||
} else if (edit_limit_setting_value === "custom_limit") {
|
data.allow_message_editing = false;
|
||||||
data.message_content_edit_limit_seconds = parse_time_limit(
|
} else if (edit_limit_setting_value === "custom_limit") {
|
||||||
$("#id_realm_message_content_edit_limit_minutes"),
|
data.message_content_edit_limit_seconds = parse_time_limit(
|
||||||
|
$("#id_realm_message_content_edit_limit_minutes"),
|
||||||
|
);
|
||||||
|
// Disable editing if the parsed time limit is 0 seconds
|
||||||
|
data.allow_message_editing = Boolean(data.message_content_edit_limit_seconds);
|
||||||
|
} else {
|
||||||
|
data.allow_message_editing = true;
|
||||||
|
data.message_content_edit_limit_seconds =
|
||||||
|
settings_config.msg_edit_limit_dropdown_values.get(
|
||||||
|
edit_limit_setting_value,
|
||||||
|
).seconds;
|
||||||
|
}
|
||||||
|
const delete_limit_setting_value = $("#id_realm_msg_delete_limit_setting").val();
|
||||||
|
if (delete_limit_setting_value === "never") {
|
||||||
|
data.allow_message_deleting = false;
|
||||||
|
} else if (delete_limit_setting_value === "custom_limit") {
|
||||||
|
data.message_content_delete_limit_seconds = parse_time_limit(
|
||||||
|
$("#id_realm_message_content_delete_limit_minutes"),
|
||||||
|
);
|
||||||
|
// Disable deleting if the parsed time limit is 0 seconds
|
||||||
|
data.allow_message_deleting = Boolean(
|
||||||
|
data.message_content_delete_limit_seconds,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
data.allow_message_deleting = true;
|
||||||
|
data.message_content_delete_limit_seconds =
|
||||||
|
settings_config.msg_delete_limit_dropdown_values.get(
|
||||||
|
delete_limit_setting_value,
|
||||||
|
).seconds;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "notifications":
|
||||||
|
data.notifications_stream_id = Number.parseInt(
|
||||||
|
notifications_stream_widget.value(),
|
||||||
|
10,
|
||||||
);
|
);
|
||||||
// Disable editing if the parsed time limit is 0 seconds
|
data.signup_notifications_stream_id = Number.parseInt(
|
||||||
data.allow_message_editing = Boolean(data.message_content_edit_limit_seconds);
|
signup_notifications_stream_widget.value(),
|
||||||
} else {
|
10,
|
||||||
data.allow_message_editing = true;
|
|
||||||
data.message_content_edit_limit_seconds =
|
|
||||||
settings_config.msg_edit_limit_dropdown_values.get(
|
|
||||||
edit_limit_setting_value,
|
|
||||||
).seconds;
|
|
||||||
}
|
|
||||||
const delete_limit_setting_value = $("#id_realm_msg_delete_limit_setting").val();
|
|
||||||
if (delete_limit_setting_value === "never") {
|
|
||||||
data.allow_message_deleting = false;
|
|
||||||
} else if (delete_limit_setting_value === "custom_limit") {
|
|
||||||
data.message_content_delete_limit_seconds = parse_time_limit(
|
|
||||||
$("#id_realm_message_content_delete_limit_minutes"),
|
|
||||||
);
|
);
|
||||||
// Disable deleting if the parsed time limit is 0 seconds
|
break;
|
||||||
data.allow_message_deleting = Boolean(data.message_content_delete_limit_seconds);
|
case "message_retention": {
|
||||||
} else {
|
const message_retention_setting_value = $(
|
||||||
data.allow_message_deleting = true;
|
"#id_realm_message_retention_setting",
|
||||||
data.message_content_delete_limit_seconds =
|
).val();
|
||||||
settings_config.msg_delete_limit_dropdown_values.get(
|
if (message_retention_setting_value === "retain_forever") {
|
||||||
delete_limit_setting_value,
|
data.message_retention_days = JSON.stringify("forever");
|
||||||
).seconds;
|
} else {
|
||||||
|
data.message_retention_days = JSON.stringify(
|
||||||
|
get_input_element_value($("#id_realm_message_retention_days")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (subsection === "notifications") {
|
case "other_settings": {
|
||||||
data.notifications_stream_id = Number.parseInt(notifications_stream_widget.value(), 10);
|
const code_block_language_value = default_code_language_widget.value();
|
||||||
data.signup_notifications_stream_id = Number.parseInt(
|
// No need to JSON-encode, since this value is already a string.
|
||||||
signup_notifications_stream_widget.value(),
|
data.default_code_block_language = code_block_language_value;
|
||||||
10,
|
break;
|
||||||
);
|
|
||||||
} else if (subsection === "message_retention") {
|
|
||||||
const message_retention_setting_value = $("#id_realm_message_retention_setting").val();
|
|
||||||
if (message_retention_setting_value === "retain_forever") {
|
|
||||||
data.message_retention_days = JSON.stringify("forever");
|
|
||||||
} else {
|
|
||||||
data.message_retention_days = JSON.stringify(
|
|
||||||
get_input_element_value($("#id_realm_message_retention_days")),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if (subsection === "other_settings") {
|
case "other_permissions": {
|
||||||
const code_block_language_value = default_code_language_widget.value();
|
const add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
|
||||||
// No need to JSON-encode, since this value is already a string.
|
switch (add_emoji_permission) {
|
||||||
data.default_code_block_language = code_block_language_value;
|
case "by_admins_only":
|
||||||
} else if (subsection === "other_permissions") {
|
data.add_emoji_by_admins_only = true;
|
||||||
const add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
|
break;
|
||||||
|
case "by_anyone":
|
||||||
|
data.add_emoji_by_admins_only = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "org_join": {
|
||||||
|
const org_join_restrictions = $("#id_realm_org_join_restrictions").val();
|
||||||
|
switch (org_join_restrictions) {
|
||||||
|
case "only_selected_domain":
|
||||||
|
data.emails_restricted_to_domains = true;
|
||||||
|
data.disallow_disposable_email_addresses = false;
|
||||||
|
break;
|
||||||
|
case "no_disposable_email":
|
||||||
|
data.emails_restricted_to_domains = false;
|
||||||
|
data.disallow_disposable_email_addresses = true;
|
||||||
|
break;
|
||||||
|
case "no_restriction":
|
||||||
|
data.disallow_disposable_email_addresses = false;
|
||||||
|
data.emails_restricted_to_domains = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (add_emoji_permission === "by_admins_only") {
|
const user_invite_restriction = $("#id_realm_user_invite_restriction").val();
|
||||||
data.add_emoji_by_admins_only = true;
|
switch (user_invite_restriction) {
|
||||||
} else if (add_emoji_permission === "by_anyone") {
|
case "no_invite_required":
|
||||||
data.add_emoji_by_admins_only = false;
|
data.invite_required = false;
|
||||||
}
|
data.invite_to_realm_policy =
|
||||||
} else if (subsection === "org_join") {
|
settings_config.common_policy_values.by_members.code;
|
||||||
const org_join_restrictions = $("#id_realm_org_join_restrictions").val();
|
break;
|
||||||
if (org_join_restrictions === "only_selected_domain") {
|
case "no_invite_required_by_admins_only":
|
||||||
data.emails_restricted_to_domains = true;
|
data.invite_required = false;
|
||||||
data.disallow_disposable_email_addresses = false;
|
data.invite_to_realm_policy =
|
||||||
} else if (org_join_restrictions === "no_disposable_email") {
|
settings_config.common_policy_values.by_admins_only.code;
|
||||||
data.emails_restricted_to_domains = false;
|
break;
|
||||||
data.disallow_disposable_email_addresses = true;
|
case "no_invite_required_by_moderators_only":
|
||||||
} else if (org_join_restrictions === "no_restriction") {
|
data.invite_required = false;
|
||||||
data.disallow_disposable_email_addresses = false;
|
data.invite_to_realm_policy =
|
||||||
data.emails_restricted_to_domains = false;
|
settings_config.common_policy_values.by_moderators_only.code;
|
||||||
}
|
break;
|
||||||
|
case "no_invite_required_by_full_members":
|
||||||
|
data.invite_required = false;
|
||||||
|
data.invite_to_realm_policy =
|
||||||
|
settings_config.common_policy_values.by_full_members.code;
|
||||||
|
break;
|
||||||
|
case "by_admins_only":
|
||||||
|
data.invite_required = true;
|
||||||
|
data.invite_to_realm_policy =
|
||||||
|
settings_config.common_policy_values.by_admins_only.code;
|
||||||
|
break;
|
||||||
|
case "by_moderators_only":
|
||||||
|
data.invite_required = true;
|
||||||
|
data.invite_to_realm_policy =
|
||||||
|
settings_config.common_policy_values.by_moderators_only.code;
|
||||||
|
break;
|
||||||
|
case "by_full_members":
|
||||||
|
data.invite_required = true;
|
||||||
|
data.invite_to_realm_policy =
|
||||||
|
settings_config.common_policy_values.by_full_members.code;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
data.invite_required = true;
|
||||||
|
data.invite_to_realm_policy =
|
||||||
|
settings_config.common_policy_values.by_members.code;
|
||||||
|
}
|
||||||
|
|
||||||
const user_invite_restriction = $("#id_realm_user_invite_restriction").val();
|
const waiting_period_threshold = $("#id_realm_waiting_period_setting").val();
|
||||||
if (user_invite_restriction === "no_invite_required") {
|
switch (waiting_period_threshold) {
|
||||||
data.invite_required = false;
|
case "none":
|
||||||
data.invite_to_realm_policy = settings_config.common_policy_values.by_members.code;
|
data.waiting_period_threshold = 0;
|
||||||
} else if (user_invite_restriction === "no_invite_required_by_admins_only") {
|
break;
|
||||||
data.invite_required = false;
|
case "three_days":
|
||||||
data.invite_to_realm_policy =
|
data.waiting_period_threshold = 3;
|
||||||
settings_config.common_policy_values.by_admins_only.code;
|
break;
|
||||||
} else if (user_invite_restriction === "no_invite_required_by_moderators_only") {
|
case "custom_days":
|
||||||
data.invite_required = false;
|
data.waiting_period_threshold = $(
|
||||||
data.invite_to_realm_policy =
|
"#id_realm_waiting_period_threshold",
|
||||||
settings_config.common_policy_values.by_moderators_only.code;
|
).val();
|
||||||
} else if (user_invite_restriction === "no_invite_required_by_full_members") {
|
break;
|
||||||
data.invite_required = false;
|
}
|
||||||
data.invite_to_realm_policy =
|
break;
|
||||||
settings_config.common_policy_values.by_full_members.code;
|
|
||||||
} else if (user_invite_restriction === "by_admins_only") {
|
|
||||||
data.invite_required = true;
|
|
||||||
data.invite_to_realm_policy =
|
|
||||||
settings_config.common_policy_values.by_admins_only.code;
|
|
||||||
} else if (user_invite_restriction === "by_moderators_only") {
|
|
||||||
data.invite_required = true;
|
|
||||||
data.invite_to_realm_policy =
|
|
||||||
settings_config.common_policy_values.by_moderators_only.code;
|
|
||||||
} else if (user_invite_restriction === "by_full_members") {
|
|
||||||
data.invite_required = true;
|
|
||||||
data.invite_to_realm_policy =
|
|
||||||
settings_config.common_policy_values.by_full_members.code;
|
|
||||||
} else {
|
|
||||||
data.invite_required = true;
|
|
||||||
data.invite_to_realm_policy = settings_config.common_policy_values.by_members.code;
|
|
||||||
}
|
}
|
||||||
|
case "auth_settings":
|
||||||
const waiting_period_threshold = $("#id_realm_waiting_period_setting").val();
|
data = {};
|
||||||
if (waiting_period_threshold === "none") {
|
data.authentication_methods = JSON.stringify(get_auth_method_table_data());
|
||||||
data.waiting_period_threshold = 0;
|
break;
|
||||||
} else if (waiting_period_threshold === "three_days") {
|
case "user_defaults": {
|
||||||
data.waiting_period_threshold = 3;
|
const realm_default_twenty_four_hour_time = $(
|
||||||
} else if (waiting_period_threshold === "custom_days") {
|
"#id_realm_default_twenty_four_hour_time",
|
||||||
data.waiting_period_threshold = $("#id_realm_waiting_period_threshold").val();
|
).val();
|
||||||
|
data.default_twenty_four_hour_time = realm_default_twenty_four_hour_time;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (subsection === "auth_settings") {
|
|
||||||
data = {};
|
|
||||||
data.authentication_methods = JSON.stringify(get_auth_method_table_data());
|
|
||||||
} else if (subsection === "user_defaults") {
|
|
||||||
const realm_default_twenty_four_hour_time = $(
|
|
||||||
"#id_realm_default_twenty_four_hour_time",
|
|
||||||
).val();
|
|
||||||
data.default_twenty_four_hour_time = realm_default_twenty_four_hour_time;
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue