From 6ba3f2f80531957521595a5eafdec4ea96aaef31 Mon Sep 17 00:00:00 2001 From: fspreck <f.spreckelsen@indiscale.com> Date: Tue, 11 Apr 2023 14:46:22 +0200 Subject: [PATCH] ENH: Add button to link to user management --- src/core/js/ext_entity_acl.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/js/ext_entity_acl.js b/src/core/js/ext_entity_acl.js index ce6d4160..4e78f580 100644 --- a/src/core/js/ext_entity_acl.js +++ b/src/core/js/ext_entity_acl.js @@ -32,10 +32,15 @@ * * BUILD_MODULE_EXT_ENTITY_ACL_URI_ROOT=[scheme://host:port]/what/evs * + * Enable/disable the creation of a user-management link that is shown to + * administrators with + * + * BUILD_MODULE_EXT_ENTITY_ACL_USER_MANAGEMENT_BUTTON=ENABLED + * * * @author Timm Fitschen */ -var ext_entity_acl = function ($, connection, getEntityVersion, getEntityID, logger) { +var ext_entity_acl = function ($, connection, getEntityVersion, getEntityID, logger, navbar, userIsAdministrator) { const BUILD_MODULE_EXT_ENTITY_ACL_URI_ROOT = connection.getBasePath() + "webinterface/acm/entityacl/"; const _buttons_list_class = "caosdb-v-entity-header-buttons-list"; @@ -69,6 +74,14 @@ var ext_entity_acl = function ($, connection, getEntityVersion, getEntityID, log $(entity).find(`.${_buttons_list_class} .${_entity_acl_link_class}`).remove(); } + var showUserManagementLink = function () { + if (userIsAdministrator()) { + navbar.add_button($('<a class="nav-link" href="/webinterface/acm/">User Administration</a>')[0], { + title: "Go to user administration" + }); + } + } + var _init = function () { for (let entity of $(".caosdb-entity-panel")) { remove_entity_acl_link(entity); @@ -82,6 +95,10 @@ var ext_entity_acl = function ($, connection, getEntityVersion, getEntityID, log * Removes all respective buttons if present before adding a new one. */ var init = function () { + if ("${BUILD_MODULE_EXT_ENTITY_ACL_USER_MANAGEMENT_BUTTON}" == "ENABLED") { + showUserManagementLink(); + } + _init(); // edit-mode-listener -- GitLab