Header hiding the tab menu 09/104009/4
authorstatta <statta@research.att.com>
Thu, 19 Mar 2020 20:26:13 +0000 (16:26 -0400)
committerstatta <statta@research.att.com>
Fri, 20 Mar 2020 18:18:41 +0000 (14:18 -0400)
Issue-ID: PORTAL-857
Change-Id: I11eab7411aff67db1fa247d01bd7519ad1c34ed5
Signed-off-by: statta <statta@research.att.com>
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImplTest.java
portal-FE-os/src/assets/images/global.logo

index fc926eb..4de10d9 100644 (file)
@@ -78,6 +78,12 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService {
        private ExternalAccessRolesService externalAccessRolesService;
        @Autowired
        private DataAccessService dataAccessService;
+       
+       public final String appHome = "applicationsHome";
+       public final String appCatalog = "appCatalog";
+       public final String widCatalog = "widgetCatalog";
+       public final String users = "users";
+       
 
        /*
         * (non-Javadoc)
@@ -176,7 +182,7 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService {
                for (JSONObject navItemsDetail : jsonObjs)
                        navItems.put(navItemsDetail);
 
-               sidebarModel.put("label", "ECOMP portal");
+               sidebarModel.put("label", "Portal");
                sidebarModel.put("navItems", navItems);
                return sidebarModel.toString();
        }
@@ -188,38 +194,27 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService {
         */
        private void loadDefaultNavMap(Map<String, JSONObject> defaultNavMap) {
                String leftMenuRootValue = getLeftMenuPrefixValue();
+               
                JSONObject navItemsDetails1 = new JSONObject();
                navItemsDetails1.put("name", "Home");
-               navItemsDetails1.put("state",
-                               (isLeftMenuHasRoot(leftMenuRootValue))
-                                               ? leftMenuRootValue+".applicationsHome"
-                                               : "applicationsHome");
-               navItemsDetails1.put("imageSrc", isLeftMenuHasRoot(leftMenuRootValue) ? "icon-building-home" : "home");
-               defaultNavMap.put("applicationsHome", navItemsDetails1);
+               navItemsDetails1.put("state",leftMenuRootValue+appHome);
+               navItemsDetails1.put("imageSrc", "home");
+               defaultNavMap.put(appHome, navItemsDetails1);
 
                JSONObject navItemsDetails2 = new JSONObject();
                navItemsDetails2.put("name", "Application Catalog");
-               navItemsDetails2.put("state",
-                               (isLeftMenuHasRoot(leftMenuRootValue))
-                                               ? leftMenuRootValue+".appCatalog"
-                                               : "appCatalog");
-               navItemsDetails2.put("imageSrc", isLeftMenuHasRoot(leftMenuRootValue) ? "icon-apps-marketplace" : "apps");
-               defaultNavMap.put("appCatalog", navItemsDetails2);
+               navItemsDetails2.put("state",leftMenuRootValue+appCatalog);
+               navItemsDetails2.put("imageSrc", "apps");
+               defaultNavMap.put(appCatalog, navItemsDetails2);
 
                JSONObject navItemsDetails3 = new JSONObject();
                navItemsDetails3.put("name", "Widget Catalog");
-               navItemsDetails3.put("state",
-                               isLeftMenuHasRoot(leftMenuRootValue)
-                                               ? leftMenuRootValue+".widgetCatalog"
-                                               : "widgetCatalog");
-               navItemsDetails3.put("imageSrc", isLeftMenuHasRoot(leftMenuRootValue) ? "icon-apps-marketplace" : "apps");
-               defaultNavMap.put("widgetCatalog", navItemsDetails3);
+               navItemsDetails3.put("state",leftMenuRootValue+widCatalog);
+               navItemsDetails3.put("imageSrc", "apps");
+               defaultNavMap.put(widCatalog, navItemsDetails3);
 
        }
 
-       private boolean isLeftMenuHasRoot(String leftMenuRootValue) {
-               return (leftMenuRootValue != "" || leftMenuRootValue.isEmpty()) && leftMenuRootValue.equals("root");
-       }
 
        @SuppressWarnings("unchecked")
        private void loadNavMapByUserAdminRole(Map<String, JSONObject> defaultNavMap, EPUser user) {
@@ -231,16 +226,26 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService {
                if (applicationsList.size() > 0) {
                        JSONObject navItemsDetails = new JSONObject();
                        navItemsDetails.put("name", "Users");
-                       navItemsDetails.put("state",
-                                       ((leftMenuRootValue != "" || !leftMenuRootValue.isEmpty()) && leftMenuRootValue.equals("root")) ? leftMenuRootValue+".users"
-                                                       : "users");
-                       navItemsDetails.put("imageSrc", isLeftMenuHasRoot(leftMenuRootValue) ? "person" : "icon-user");
-                       defaultNavMap.put("users", navItemsDetails);
+                       navItemsDetails.put("state",leftMenuRootValue+users);
+                       navItemsDetails.put("imageSrc", "person");
+                       defaultNavMap.put(users, navItemsDetails);
+               }
+       }
+
+       protected String getLeftMenuPrefixValue() {
+               String leftMenuRootValue = getLeftMenuValue();
+               if (leftMenuRootValue != null) {
+                       leftMenuRootValue += ".";
+               } else {
+                       leftMenuRootValue = "";
                }
+               
+               return leftMenuRootValue;
+       
        }
 
-       private String getLeftMenuPrefixValue() {
-               return EPCommonSystemProperties.getProperty(EPCommonSystemProperties.PORTAL_LEFT_MENU);
+       String getLeftMenuValue() {
+               return EPCommonSystemProperties.containsProperty(EPCommonSystemProperties.PORTAL_LEFT_MENU) ? EPCommonSystemProperties.getProperty(EPCommonSystemProperties.PORTAL_LEFT_MENU):null;
        }
 
 }
index 9a2568d..258bf99 100644 (file)
@@ -20,7 +20,6 @@
 package org.onap.portalapp.portal.service;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -29,6 +28,7 @@ import java.util.Set;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InjectMocks;
@@ -37,16 +37,18 @@ import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.onap.portalapp.portal.domain.CentralizedApp;
 import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.framework.MockitoTestSuite;
 import org.onap.portalsdk.core.domain.MenuData;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.service.DataAccessServiceImpl;
 
-public class EPLeftMenuServiceImplTest {
+public class EPLeftMenuServiceImplTest extends MockitoTestSuite{
 
        @Mock
        DataAccessService dataAccessService = new DataAccessServiceImpl();
+       
        @Mock
-        ExternalAccessRolesService externalAccessRolesService;
+       ExternalAccessRolesService externalAccessRolesService;
        
        @Before
        public void setup() {
@@ -54,7 +56,12 @@ public class EPLeftMenuServiceImplTest {
        }
        
        @InjectMocks
-       EPLeftMenuServiceImpl epLeftMenuServiceImpl = new EPLeftMenuServiceImpl();
+       EPLeftMenuServiceImpl epLeftMenuServiceImpl = new EPLeftMenuServiceImpl() {
+               
+               String getLeftMenuValue() {
+                       return null;
+               }
+       };
        
        @Test
        public void getLeftMenuItemsTest() {
@@ -97,13 +104,15 @@ public class EPLeftMenuServiceImplTest {
                
                JSONObject sidebarModel = new JSONObject();
                JSONArray navItems = new JSONArray();
-               Collection<JSONObject> jsonObjs = defaultNavMap.values();
+
                navItems.put(navItemsDetails3);
                sidebarModel.put("label", "ECOMP portal");
                sidebarModel.put("navItems", navItems);
                
-               epLeftMenuServiceImpl.getLeftMenuItems(epUser, fullMenuSet, roleFunctionSet);
                
+               String menuStr = epLeftMenuServiceImpl.getLeftMenuItems(epUser, fullMenuSet, roleFunctionSet);
+               Assert.assertTrue(!menuStr.contains("root"));
+               Assert.assertEquals("{\"navItems\":[{\"name\":\"Home\",\"imageSrc\":\"home\",\"state\":\"applicationsHome\"},{\"name\":\"Application Catalog\",\"imageSrc\":\"apps\",\"state\":\"appCatalog\"},{\"name\":\"Widget Catalog\",\"imageSrc\":\"apps\",\"state\":\"widgetCatalog\"}],\"label\":\"Portal\"}", menuStr);
                
        }
 }
index 8d60100..bf85815 100644 (file)
Binary files a/portal-FE-os/src/assets/images/global.logo and b/portal-FE-os/src/assets/images/global.logo differ