settings: Extract gear_menu.update_org_settings_menu_item().

The prior name of this was a bit inaccurate, as we no
longer ever hide the menu item for non-admins.  Also,
it belongs more naturally in `gear_menu.js` at this point.

Also, we remove one call to this, which was in a place
where it was no longer necessary.
This commit is contained in:
Steve Howell 2018-12-06 17:41:56 +00:00 committed by Tim Abbott
parent 1d07d0a532
commit fcf31cedbc
4 changed files with 13 additions and 18 deletions

View File

@ -12,8 +12,8 @@ set_global('settings_users', {
set_global('admin_sections', { set_global('admin_sections', {
maybe_disable_widgets: function () {}, maybe_disable_widgets: function () {},
}); });
set_global('admin', { set_global('gear_menu', {
show_or_hide_menu_item: function () {}, update_org_settings_menu_item: function () {},
}); });
set_global('page_params', { set_global('page_params', {
is_admin: true, is_admin: true,

View File

@ -2,15 +2,6 @@ var admin = (function () {
var exports = {}; var exports = {};
exports.show_or_hide_menu_item = function () {
var item = $('.admin-menu-item').expectOne();
if (page_params.is_admin) {
item.find("span").text(i18n.t("Manage organization"));
} else {
item.find("span").text(i18n.t("Organization settings"));
}
};
var admin_settings_label = { var admin_settings_label = {
// Organization settings // Organization settings
realm_allow_community_topic_editing: i18n.t("Users can edit the topic of any message"), realm_allow_community_topic_editing: i18n.t("Users can edit the topic of any message"),
@ -97,11 +88,6 @@ exports.setup_page = function () {
exports.launch_page(tab); exports.launch_page(tab);
settings_toggle.highlight_toggle('organization'); settings_toggle.highlight_toggle('organization');
} }
// Do this after calling the setup_up methods, so that we can
// disable any dynamically rendered elements.
exports.show_or_hide_menu_item();
}; };
exports.launch_page = function (section) { exports.launch_page = function (section) {

View File

@ -78,8 +78,17 @@ the selector and then calls info_overlay.show.
// when we switch back.) // when we switch back.)
var scroll_positions = {}; var scroll_positions = {};
exports.update_org_settings_menu_item = function () {
var item = $('.admin-menu-item').expectOne();
if (page_params.is_admin) {
item.find("span").text(i18n.t("Manage organization"));
} else {
item.find("span").text(i18n.t("Organization settings"));
}
};
exports.initialize = function () { exports.initialize = function () {
admin.show_or_hide_menu_item(); exports.update_org_settings_menu_item();
$('#gear-menu a[data-toggle="tab"]').on('show', function (e) { $('#gear-menu a[data-toggle="tab"]').on('show', function (e) {
// Save the position of our old tab away, before we switch // Save the position of our old tab away, before we switch

View File

@ -57,7 +57,7 @@ exports.update_person = function update(person) {
if (people.is_my_user_id(person.user_id)) { if (people.is_my_user_id(person.user_id)) {
page_params.is_admin = person.is_admin; page_params.is_admin = person.is_admin;
admin.show_or_hide_menu_item(); gear_menu.update_org_settings_menu_item();
admin_sections.maybe_disable_widgets(); admin_sections.maybe_disable_widgets();
} }
} }