mirror of https://github.com/zulip/zulip.git
js: Convert static/js/settings_account.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
db6e3a41d3
commit
8e8a2840c4
|
@ -156,7 +156,6 @@
|
||||||
"recent_topics": false,
|
"recent_topics": false,
|
||||||
"search_pill_widget": false,
|
"search_pill_widget": false,
|
||||||
"settings": false,
|
"settings": false,
|
||||||
"settings_account": false,
|
|
||||||
"settings_bots": false,
|
"settings_bots": false,
|
||||||
"settings_display": false,
|
"settings_display": false,
|
||||||
"settings_emoji": false,
|
"settings_emoji": false,
|
||||||
|
|
|
@ -55,7 +55,8 @@ const reload = {__esModule: true};
|
||||||
rewiremock("../../static/js/reload").with(reload);
|
rewiremock("../../static/js/reload").with(reload);
|
||||||
const scroll_bar = {__esModule: true};
|
const scroll_bar = {__esModule: true};
|
||||||
rewiremock("../../static/js/scroll_bar").with(scroll_bar);
|
rewiremock("../../static/js/scroll_bar").with(scroll_bar);
|
||||||
const settings_account = set_global("settings_account", {});
|
const settings_account = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/settings_account").with(settings_account);
|
||||||
const settings_bots = set_global("settings_bots", {});
|
const settings_bots = set_global("settings_bots", {});
|
||||||
const settings_display = set_global("settings_display", {});
|
const settings_display = set_global("settings_display", {});
|
||||||
const settings_emoji = set_global("settings_emoji", {});
|
const settings_emoji = set_global("settings_emoji", {});
|
||||||
|
|
|
@ -46,10 +46,13 @@ rewiremock("../../static/js/compose").with({
|
||||||
update_email() {},
|
update_email() {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const settings_account = set_global("settings_account", {
|
const settings_account = {
|
||||||
|
__esModule: true,
|
||||||
update_email() {},
|
update_email() {},
|
||||||
update_full_name() {},
|
update_full_name() {},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
rewiremock("../../static/js/settings_account").with(settings_account);
|
||||||
|
|
||||||
const message_live_update = {__esModule: true};
|
const message_live_update = {__esModule: true};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
|
import * as settings_account from "./settings_account";
|
||||||
import * as upload_widget from "./upload_widget";
|
import * as upload_widget from "./upload_widget";
|
||||||
|
|
||||||
export function build_bot_create_widget() {
|
export function build_bot_create_widget() {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import "../server_events";
|
||||||
import "../zulip";
|
import "../zulip";
|
||||||
import "../templates";
|
import "../templates";
|
||||||
import "../dropdown_list_widget";
|
import "../dropdown_list_widget";
|
||||||
import "../settings_account";
|
|
||||||
import "../settings_display";
|
import "../settings_display";
|
||||||
import "../settings_notifications";
|
import "../settings_notifications";
|
||||||
import "../settings_bots";
|
import "../settings_bots";
|
||||||
|
|
|
@ -28,7 +28,6 @@ declare let reactions: any;
|
||||||
declare let recent_topics: any;
|
declare let recent_topics: any;
|
||||||
declare let search_pill_widget: any;
|
declare let search_pill_widget: any;
|
||||||
declare let settings: any;
|
declare let settings: any;
|
||||||
declare let settings_account: any;
|
|
||||||
declare let settings_bots: any;
|
declare let settings_bots: any;
|
||||||
declare let settings_display: any;
|
declare let settings_display: any;
|
||||||
declare let settings_emoji: any;
|
declare let settings_emoji: any;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import * as people from "./people";
|
||||||
import * as reminder from "./reminder";
|
import * as reminder from "./reminder";
|
||||||
import * as resize from "./resize";
|
import * as resize from "./resize";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
|
import * as settings_account from "./settings_account";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
import * as settings_data from "./settings_data";
|
import * as settings_data from "./settings_data";
|
||||||
import * as stream_popover from "./stream_popover";
|
import * as stream_popover from "./stream_popover";
|
||||||
|
|
|
@ -21,6 +21,7 @@ import * as realm_icon from "./realm_icon";
|
||||||
import * as realm_logo from "./realm_logo";
|
import * as realm_logo from "./realm_logo";
|
||||||
import * as reload from "./reload";
|
import * as reload from "./reload";
|
||||||
import * as scroll_bar from "./scroll_bar";
|
import * as scroll_bar from "./scroll_bar";
|
||||||
|
import * as settings_account from "./settings_account";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
import * as starred_messages from "./starred_messages";
|
import * as starred_messages from "./starred_messages";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
|
|
@ -5,6 +5,7 @@ const render_settings_tab = require("../templates/settings_tab.hbs");
|
||||||
|
|
||||||
const overlays = require("./overlays");
|
const overlays = require("./overlays");
|
||||||
const people = require("./people");
|
const people = require("./people");
|
||||||
|
const settings_account = require("./settings_account");
|
||||||
const settings_config = require("./settings_config");
|
const settings_config = require("./settings_config");
|
||||||
const settings_panel_menu = require("./settings_panel_menu");
|
const settings_panel_menu = require("./settings_panel_menu");
|
||||||
const settings_toggle = require("./settings_toggle");
|
const settings_toggle = require("./settings_toggle");
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
"use strict";
|
import _ from "lodash";
|
||||||
|
|
||||||
const _ = require("lodash");
|
import render_settings_api_key_modal from "../templates/settings/api_key_modal.hbs";
|
||||||
|
import render_settings_custom_user_profile_field from "../templates/settings/custom_user_profile_field.hbs";
|
||||||
|
import render_settings_dev_env_email_access from "../templates/settings/dev_env_email_access.hbs";
|
||||||
|
|
||||||
const render_settings_api_key_modal = require("../templates/settings/api_key_modal.hbs");
|
import * as avatar from "./avatar";
|
||||||
const render_settings_custom_user_profile_field = require("../templates/settings/custom_user_profile_field.hbs");
|
import * as channel from "./channel";
|
||||||
const render_settings_dev_env_email_access = require("../templates/settings/dev_env_email_access.hbs");
|
import * as common from "./common";
|
||||||
|
import * as overlays from "./overlays";
|
||||||
|
import * as people from "./people";
|
||||||
|
import * as pill_typeahead from "./pill_typeahead";
|
||||||
|
import * as popovers from "./popovers";
|
||||||
|
import * as settings_ui from "./settings_ui";
|
||||||
|
import * as setup from "./setup";
|
||||||
|
import * as ui_report from "./ui_report";
|
||||||
|
import * as user_pill from "./user_pill";
|
||||||
|
|
||||||
const avatar = require("./avatar");
|
export function update_email(new_email) {
|
||||||
const channel = require("./channel");
|
|
||||||
const common = require("./common");
|
|
||||||
const overlays = require("./overlays");
|
|
||||||
const people = require("./people");
|
|
||||||
const pill_typeahead = require("./pill_typeahead");
|
|
||||||
const popovers = require("./popovers");
|
|
||||||
const settings_ui = require("./settings_ui");
|
|
||||||
const setup = require("./setup");
|
|
||||||
const ui_report = require("./ui_report");
|
|
||||||
const user_pill = require("./user_pill");
|
|
||||||
|
|
||||||
exports.update_email = function (new_email) {
|
|
||||||
const email_input = $("#email_value");
|
const email_input = $("#email_value");
|
||||||
|
|
||||||
if (email_input) {
|
if (email_input) {
|
||||||
email_input.text(new_email);
|
email_input.text(new_email);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.update_full_name = function (new_full_name) {
|
export function update_full_name(new_full_name) {
|
||||||
const full_name_field = $("#full_name_value");
|
const full_name_field = $("#full_name_value");
|
||||||
if (full_name_field) {
|
if (full_name_field) {
|
||||||
full_name_field.text(new_full_name);
|
full_name_field.text(new_full_name);
|
||||||
|
@ -39,9 +37,9 @@ exports.update_full_name = function (new_full_name) {
|
||||||
if (full_name_input) {
|
if (full_name_input) {
|
||||||
full_name_input.val(new_full_name);
|
full_name_input.val(new_full_name);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.user_can_change_name = function () {
|
export function user_can_change_name() {
|
||||||
if (page_params.is_admin) {
|
if (page_params.is_admin) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +47,9 @@ exports.user_can_change_name = function () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.user_can_change_avatar = function () {
|
export function user_can_change_avatar() {
|
||||||
if (page_params.is_admin) {
|
if (page_params.is_admin) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -59,19 +57,19 @@ exports.user_can_change_avatar = function () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.update_name_change_display = function () {
|
export function update_name_change_display() {
|
||||||
if (!exports.user_can_change_name()) {
|
if (!user_can_change_name()) {
|
||||||
$("#full_name").prop("disabled", true);
|
$("#full_name").prop("disabled", true);
|
||||||
$(".change_name_tooltip").show();
|
$(".change_name_tooltip").show();
|
||||||
} else {
|
} else {
|
||||||
$("#full_name").prop("disabled", false);
|
$("#full_name").prop("disabled", false);
|
||||||
$(".change_name_tooltip").hide();
|
$(".change_name_tooltip").hide();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.update_email_change_display = function () {
|
export function update_email_change_display() {
|
||||||
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
|
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
|
||||||
$("#change_email .button").prop("disabled", true);
|
$("#change_email .button").prop("disabled", true);
|
||||||
$(".change_email_tooltip").show();
|
$(".change_email_tooltip").show();
|
||||||
|
@ -79,17 +77,17 @@ exports.update_email_change_display = function () {
|
||||||
$("#change_email .button").prop("disabled", false);
|
$("#change_email .button").prop("disabled", false);
|
||||||
$(".change_email_tooltip").hide();
|
$(".change_email_tooltip").hide();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.update_avatar_change_display = function () {
|
export function update_avatar_change_display() {
|
||||||
if (!exports.user_can_change_avatar()) {
|
if (!user_can_change_avatar()) {
|
||||||
$("#user-avatar-upload-widget .image_upload_button").prop("disabled", true);
|
$("#user-avatar-upload-widget .image_upload_button").prop("disabled", true);
|
||||||
$("#user-avatar-upload-widget .image-delete-button .button").prop("disabled", true);
|
$("#user-avatar-upload-widget .image-delete-button .button").prop("disabled", true);
|
||||||
} else {
|
} else {
|
||||||
$("#user-avatar-upload-widget .image_upload_button").prop("disabled", false);
|
$("#user-avatar-upload-widget .image_upload_button").prop("disabled", false);
|
||||||
$("#user-avatar-upload-widget .image-delete-button .button").prop("disabled", false);
|
$("#user-avatar-upload-widget .image-delete-button .button").prop("disabled", false);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function display_avatar_upload_complete() {
|
function display_avatar_upload_complete() {
|
||||||
$("#user-avatar-upload-widget .upload-spinner-background").css({visibility: "hidden"});
|
$("#user-avatar-upload-widget .upload-spinner-background").css({visibility: "hidden"});
|
||||||
|
@ -137,7 +135,7 @@ function update_user_custom_profile_fields(fields, method) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.append_custom_profile_fields = function (element_id, user_id) {
|
export function append_custom_profile_fields(element_id, user_id) {
|
||||||
const person = people.get_by_user_id(user_id);
|
const person = people.get_by_user_id(user_id);
|
||||||
if (person.is_bot) {
|
if (person.is_bot) {
|
||||||
return;
|
return;
|
||||||
|
@ -188,9 +186,9 @@ exports.append_custom_profile_fields = function (element_id, user_id) {
|
||||||
});
|
});
|
||||||
$(element_id).append(html);
|
$(element_id).append(html);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.initialize_custom_date_type_fields = function (element_id) {
|
export function initialize_custom_date_type_fields(element_id) {
|
||||||
$(element_id).find(".custom_user_field .datepicker").flatpickr({
|
$(element_id).find(".custom_user_field .datepicker").flatpickr({
|
||||||
altInput: true,
|
altInput: true,
|
||||||
altFormat: "F j, Y",
|
altFormat: "F j, Y",
|
||||||
|
@ -212,9 +210,9 @@ exports.initialize_custom_date_type_fields = function (element_id) {
|
||||||
.on("click", function () {
|
.on("click", function () {
|
||||||
$(this).parent().find(".custom_user_field_value").val("");
|
$(this).parent().find(".custom_user_field_value").val("");
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.initialize_custom_user_type_fields = function (
|
export function initialize_custom_user_type_fields(
|
||||||
element_id,
|
element_id,
|
||||||
user_id,
|
user_id,
|
||||||
is_editable,
|
is_editable,
|
||||||
|
@ -282,9 +280,9 @@ exports.initialize_custom_user_type_fields = function (
|
||||||
}
|
}
|
||||||
|
|
||||||
return user_pills;
|
return user_pills;
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.add_custom_profile_fields_to_settings = function () {
|
export function add_custom_profile_fields_to_settings() {
|
||||||
if (!overlays.settings_open()) {
|
if (!overlays.settings_open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,14 +295,14 @@ exports.add_custom_profile_fields_to_settings = function () {
|
||||||
$("#account-settings #custom-field-header").hide();
|
$("#account-settings #custom-field-header").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.append_custom_profile_fields(element_id, people.my_current_user_id());
|
append_custom_profile_fields(element_id, people.my_current_user_id());
|
||||||
exports.initialize_custom_user_type_fields(element_id, people.my_current_user_id(), true, true);
|
initialize_custom_user_type_fields(element_id, people.my_current_user_id(), true, true);
|
||||||
exports.initialize_custom_date_type_fields(element_id);
|
initialize_custom_date_type_fields(element_id);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.set_up = function () {
|
export function set_up() {
|
||||||
// Add custom profile fields elements to user account settings.
|
// Add custom profile fields elements to user account settings.
|
||||||
exports.add_custom_profile_fields_to_settings();
|
add_custom_profile_fields_to_settings();
|
||||||
$("#account-settings-status").hide();
|
$("#account-settings-status").hide();
|
||||||
|
|
||||||
const setup_api_key_modal = _.once(() => {
|
const setup_api_key_modal = _.once(() => {
|
||||||
|
@ -392,7 +390,7 @@ exports.set_up = function () {
|
||||||
$("#change_full_name").on("click", (e) => {
|
$("#change_full_name").on("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (exports.user_can_change_name()) {
|
if (user_can_change_name()) {
|
||||||
$("#change_full_name_modal").find("input[name='full_name']").val(page_params.full_name);
|
$("#change_full_name_modal").find("input[name='full_name']").val(page_params.full_name);
|
||||||
overlays.open_modal("#change_full_name_modal");
|
overlays.open_modal("#change_full_name_modal");
|
||||||
}
|
}
|
||||||
|
@ -684,6 +682,4 @@ exports.set_up = function () {
|
||||||
if (page_params.realm_name_changes_disabled) {
|
if (page_params.realm_name_changes_disabled) {
|
||||||
$(".name_change_container").hide();
|
$(".name_change_container").hide();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
window.settings_account = exports;
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const alert_words_ui = require("./alert_words_ui");
|
const alert_words_ui = require("./alert_words_ui");
|
||||||
const attachments_ui = require("./attachments_ui");
|
const attachments_ui = require("./attachments_ui");
|
||||||
|
const settings_account = require("./settings_account");
|
||||||
const settings_muting = require("./settings_muting");
|
const settings_muting = require("./settings_muting");
|
||||||
|
|
||||||
const load_func_dict = new Map(); // group -> function
|
const load_func_dict = new Map(); // group -> function
|
||||||
|
|
|
@ -10,6 +10,7 @@ const loading = require("./loading");
|
||||||
const overlays = require("./overlays");
|
const overlays = require("./overlays");
|
||||||
const people = require("./people");
|
const people = require("./people");
|
||||||
const presence = require("./presence");
|
const presence = require("./presence");
|
||||||
|
const settings_account = require("./settings_account");
|
||||||
const settings_config = require("./settings_config");
|
const settings_config = require("./settings_config");
|
||||||
const settings_data = require("./settings_data");
|
const settings_data = require("./settings_data");
|
||||||
const settings_panel_menu = require("./settings_panel_menu");
|
const settings_panel_menu = require("./settings_panel_menu");
|
||||||
|
|
|
@ -9,6 +9,7 @@ import * as message_live_update from "./message_live_update";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as pm_list from "./pm_list";
|
import * as pm_list from "./pm_list";
|
||||||
|
import * as settings_account from "./settings_account";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
|
|
||||||
export const update_person = function update(person) {
|
export const update_person = function update(person) {
|
||||||
|
|
Loading…
Reference in New Issue