From d0ba0c740962611444b82770115be1dec6540f24 Mon Sep 17 00:00:00 2001 From: Pragati Agrawal Date: Sun, 7 Apr 2019 22:02:42 +0530 Subject: [PATCH] org settings: Add generalised function for tip-box for org settings. This commit adds a `insert_tip_box` function and thus adds a `organization-settings-tip` handlebars file to add a genaralised tip for all organization settings pages. This further removes the code for tipbox which was added in `populate_auth_methods` functions, as it wasn't making sense there, making it more clear and readable. --- static/js/settings_org.js | 21 +++++++++++-------- .../organization-settings-tip.handlebars | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 static/templates/settings/organization-settings-tip.handlebars diff --git a/static/js/settings_org.js b/static/js/settings_org.js index 98adc9a8d0..0c39142f00 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -294,17 +294,19 @@ exports.populate_auth_methods = function (auth_methods) { })); }); loading.destroy_indicator($('#admin_page_auth_methods_loading_indicator')); - if (!page_params.is_admin) { - var tip_box = $("
") - .text(i18n.t("Only organization administrators can edit these settings.")); - // Don't prepend a tip to custom emoji settings page. We handle it separately. - $(".organization-box").find(".settings-section:not(.can-edit)") - .not("#emoji-settings") - .not("#user-groups-admin") - .prepend(tip_box); - } }; +function insert_tip_box() { + if (page_params.is_admin) { + return; + } + var tip_box = templates.render("organization-settings-tip", {is_admin: page_params.is_admin}); + $(".organization-box").find(".settings-section:not(.can-edit)") + .not("#emoji-settings") + .not("#user-groups-admin") + .prepend(tip_box); +} + exports.render_notifications_stream_ui = function (stream_id, elem) { @@ -529,6 +531,7 @@ exports.build_page = function () { // Populate authentication methods table exports.populate_auth_methods(page_params.realm_authentication_methods); + insert_tip_box(); function populate_data_for_request(subsection) { var data = {}; diff --git a/static/templates/settings/organization-settings-tip.handlebars b/static/templates/settings/organization-settings-tip.handlebars new file mode 100644 index 0000000000..f5f62e2d43 --- /dev/null +++ b/static/templates/settings/organization-settings-tip.handlebars @@ -0,0 +1,3 @@ +{{#unless is_admin}} +
{{t "Only organization administrators can edit these settings."}}
+{{/unless}}