From ee13abca4c080e90b58e274f16a8b809d6fbe1c9 Mon Sep 17 00:00:00 2001
From: Juan Fuentes <juanf@bs-mbpr465.d.ethz.ch>
Date: Fri, 20 Aug 2021 17:25:53 +0200
Subject: [PATCH] SSDM-11580 : Improving settings management for multi group
 instances

---
 .../1/as/webapps/eln-lims/html/js/config/Profile.js         | 5 ++++-
 .../1/as/webapps/eln-lims/html/js/config/SettingsManager.js | 6 ++++--
 .../eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js   | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
index 78257b13f6a..9cc0bccf539 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
@@ -237,7 +237,10 @@ $.extend(DefaultProfile.prototype, {
 //		Jupyter integration config
 //		this.jupyterIntegrationServerEndpoint = "https://bs-openbis-sis-dev.ethz.ch:8002";
 //		this.jupyterEndpoint = "https://bs-openbis-sis-dev.ethz.ch:8000/";
-		
+
+		this.settingsObjects = [];
+        this.isMultiGroup = false;
+
 		this.systemProperties = ["$ANNOTATIONS_STATE", "FREEFORM_TABLE_STATE"];
 		this.forcedDisableRTF = [];
 		this.forceMonospaceFont = [];
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
index f3fe3c59b23..f6e7c8a52b2 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
@@ -42,6 +42,9 @@ function SettingsManager(serverFacade) {
     this.loadSettingsAndApplyToProfile = function(doneCallback, profileToEditOrNull) {
 		this.loadSettings((function(settingsObjects) {
 			if(settingsObjects) {
+			    // Store settings objects globally to use latter
+			    profile.settingsObjects = settingsObjects;
+			    profile.isMultiGroup = settingsObjects.length > 2;
 				for(var sIdx = 0; sIdx < settingsObjects.length; sIdx++) {
 					var settingsObject = settingsObjects[sIdx];
 					if (settingsObject && settingsObject.properties && (settingsObject.properties["ELN_SETTINGS"] || settingsObject.properties["$ELN_SETTINGS"])) {
@@ -56,8 +59,7 @@ function SettingsManager(serverFacade) {
 								console.log("The settings contain the following errors:");
 								console.log(errors);
 							}
-							var isMergeGroup = settingsObjects.length > 2;
-							this.applySettingsToProfile(settings, (profileToEditOrNull)?profileToEditOrNull:profile, isMergeGroup);
+							this.applySettingsToProfile(settings, (profileToEditOrNull)?profileToEditOrNull:profile, (profile.isMultiGroup && sIdx > 0));
 						}
 					}
 				}
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
index 21920ab00c8..9d6b1a308d4 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
@@ -341,7 +341,7 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) {
             treeModelUtils.push({ displayName: "Storage Manager", title : storageManagerLink, entityType: "STORAGE_MANAGER", key : "STORAGE_MANAGER", folder : false, lazy : false, view : "showStorageManager" });
         }
         
-        if(profile.mainMenu.showUserManager && profile.isAdmin) {
+        if(profile.mainMenu.showUserManager && profile.isAdmin && !profile.isMultiGroup) {
             var userManagerLink = _this.getLinkForNode("User Manager", "USER_MANAGER", "showUserManagerPage", null, null);
             treeModelUtils.push({ displayName: "User Manager", title : userManagerLink, entityType: "USER_MANAGER", key : "USER_MANAGER", folder : false, lazy : false, view : "showUserManagerPage", icon : "fa fa-users" });
         }
-- 
GitLab