Changes for new service category 40/96540/3
authoratif husain <atif.husain@team.telstra.com>
Wed, 2 Oct 2019 08:03:57 +0000 (18:03 +1000)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Wed, 16 Oct 2019 10:46:17 +0000 (10:46 +0000)
Introduced new service category, Partner Domain Service
Added logic to disable composition for Partner Domain Service category

Issue-ID: SDC-2382
Change-Id: I6ed135733c6f05914e102c037ebe9057ad731e75
Signed-off-by: Atif Husain <atif.husain@team.telstra.com>
catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
catalog-ui/configurations/menu.js
catalog-ui/src/app/utils/menu-handler.ts
catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
catalog-ui/src/app/view-models/workspace/workspace-view.html
catalog-ui/src/app/view-models/workspace/workspace.less

index e3851a3..f0aeb12 100644 (file)
@@ -17,6 +17,9 @@ services:
     Network_Service:
       name: "Network Service"
       icons: ['network_l_1-3']
+    Partner_Domain_Service:
+      name: "Partner Domain Service"
+      icons: ['partner_domain_service']
 resources:
   NetworkLayer23:
     name: "Network L2-3"
index d9138ae..c1c6d10 100644 (file)
@@ -500,7 +500,7 @@ const SDC_MENU_CONFIG = {
         "SERVICE": [
             {"text": "General", "action": "onMenuItemPressed", "state": "workspace.general"},
             {"text": "TOSCA Artifacts", "action": "onMenuItemPressed", "state": "workspace.tosca_artifacts"},
-            {"text": "Composition", "action": "onMenuItemPressed", "state": "workspace.composition.details"},
+            {"text": "Composition", "action": "onMenuItemPressed", "state": "workspace.composition.details", "disabledCategories":["Partner Domain Service"]},
             {"text": "Operation", "action":"onMenuItemPressed", "state": "workspace.interface_operation"},
             {"text": "Activity Log", "action": "onMenuItemPressed", "state": "workspace.activity_log"},
             {"text": "Management Workflow", "action": "onMenuItemPressed", "state": "workspace.management_workflow"},
index 4c25a02..eaef63f 100644 (file)
@@ -32,6 +32,7 @@ export class MenuItem {
     action:string;
     params:any;
     isDisabled:boolean;
+    disabledCategory:boolean;
     disabledRoles:Array<string>;
     blockedForTypes:Array<string>;  // This item will not be shown for specific components types.
 
@@ -43,13 +44,14 @@ export class MenuItem {
     url:string;                     // Data added to menu item, in case the function need to use it, example: for function "changeLifecycleState", I need to pass also the state "CHECKOUT" that I want the state to change to.
 
 
-    constructor(text:string, callback:(...args:Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?:any, blockedForTypes?:Array<string>) {
+    constructor(text:string, callback:(...args:Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?:any, blockedForTypes?:Array<string>, disabledCategory?:boolean) {
         this.text = text;
         this.callback = callback;
         this.state = state;
         this.action = action;
         this.params = params;
         this.blockedForTypes = blockedForTypes;
+        this.disabledCategory = disabledCategory;
     }
 }
 
index 9429022..f4bbed2 100644 (file)
@@ -177,6 +177,7 @@ export class WorkspaceViewModel {
     }
 
     private role:string;
+    private category:string;
     private components:Array<Component>;
 
     private initViewMode = ():WorkspaceMode => {
@@ -216,6 +217,7 @@ export class WorkspaceViewModel {
         this.$scope.version = this.cacheService.get('version');
         this.$scope.user = this.cacheService.get("user");
         this.role = this.$scope.user.role;
+        this.category = this.$scope.component.selectedCategory;
         this.$scope.mode = this.initViewMode();
         this.$scope.isValidForm = true;
         this.initChangeLifecycleStateButtons();
@@ -870,6 +872,21 @@ export class WorkspaceViewModel {
         return tempMenuItems;
     };
 
+       private updateMenuItemByCategory = (menuItems:Array<any>, category:string) => {
+        let tempMenuItems:Array<any> = new Array<any>();
+        menuItems.forEach((item:any) => {
+            //update flag disabledCategory to true if category is disabled
+            item.disabledCategory = false;
+            if ((item.disabledCategories && item.disabledCategories.indexOf(category) > -1))
+            {
+                item.disabledCategory = true;
+            }
+            tempMenuItems.push(item);
+        });
+        return tempMenuItems;
+    };
+
+
     private deleteArchiveCache = () => {
         this.cacheService.remove("archiveComponents"); //delete the cache to ensure the archive is reloaded from server
     };
@@ -894,7 +911,13 @@ export class WorkspaceViewModel {
 
         let inCreateMode = this.$scope.isCreateMode();
         this.$scope.leftBarTabs = new MenuItemGroup();
-        const menuItemsObjects:Array<any> = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
+        //const menuItemsObjects:Array<any> = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
+        let menuItemsObjects:Array<any> = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
+        if(this.$scope.component.getComponentSubType()==="SERVICE")
+        {
+            let menuItemsObjectsCategory:Array<any> = this.updateMenuItemByCategory(menuItemsObjects, this.category);
+               menuItemsObjects = menuItemsObjectsCategory;
+        }
 
         // Only adding plugins to the workspace if they can be displayed for the current user role
         _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
@@ -909,7 +932,7 @@ export class WorkspaceViewModel {
         });
 
         this.$scope.leftBarTabs.menuItems = menuItemsObjects.map((item:MenuItem) => {
-            const menuItem = new MenuItem(item.text, item.callback, item.state, item.action, item.params, item.blockedForTypes);
+            const menuItem = new MenuItem(item.text, item.callback, item.state, item.action, item.params, item.blockedForTypes, item.disabledCategory);
             if (menuItem.params) {
                 menuItem.params.state = menuItem.state;
             }
@@ -918,7 +941,9 @@ export class WorkspaceViewModel {
             }
             menuItem.callback = () => this.$scope[menuItem.action](menuItem.state, menuItem.params);
             menuItem.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != menuItem.state) ||
-                (States.WORKSPACE_DEPLOYMENT === menuItem.state && this.$scope.component.modules && this.$scope.component.modules.length === 0 && this.$scope.component.isResource());
+                (States.WORKSPACE_DEPLOYMENT === menuItem.state && this.$scope.component.modules
+                && this.$scope.component.modules.length === 0 && this.$scope.component.isResource()) ||
+                (menuItem.disabledCategory === true);
             return menuItem;
         });
 
index 5ae3e28..d22262c 100644 (file)
@@ -22,7 +22,7 @@
                 {{menuComponentTitle}}
             </div>
             <div class="i-sdc-designer-sidebar-section-content-item" ng-class="{'selected': isSelected(menuItem)}" ng-repeat="menuItem in leftBarTabs.menuItems track by $index">
-                <div class="expand-collapse-menu-box-item-text" ng-click="menuItem.callback()" ng-class="{'disabled': menuItem.isDisabled }" data-tests-id="{{menuItem.text}}LeftSideMenu">{{menuItem.text}}</div>
+                <div class="expand-collapse-menu-box-item-text" ng-class="{'disabled': menuItem.isDisabled }" data-tests-id="{{menuItem.text}}LeftSideMenu" ><button type="button" class="i-sdc-designer-sidebar-section-content-item-service-cat" ng-click="menuItem.callback()" ng-disabled={{menuItem.disabledCategory}}>{{menuItem.text}}</button></div>
             </div>
         </div>
 
index b9956c6..11c0976 100644 (file)
 
             }
         }
+        .i-sdc-designer-sidebar-section-content-item-service-cat {
+                border: none;
+                background: transparent;
+                text-align: left;
+                padding: 0;
+        }
     }
 
     .sdc-asset-creation-info {