Fixed merge issues 47/35547/1
authorIdan Amit <ia096e@intl.att.com>
Tue, 13 Mar 2018 17:59:46 +0000 (19:59 +0200)
committerIdan Amit <ia096e@intl.att.com>
Tue, 13 Mar 2018 18:02:12 +0000 (20:02 +0200)
Fixed merge issues that broke the behavior of the plugins development

Change-Id: I6333944939628f745eb36c4619be33780881d27d
Issue-ID: SDC-1126
Signed-off-by: Idan Amit <ia096e@intl.att.com>
catalog-ui/configurations/dev.js
catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts
catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
catalog-ui/src/app/ng2/services/plugins.service.ts
catalog-ui/src/app/services/components/component-service.ts
catalog-ui/src/app/services/components/service-service.ts
catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
catalog-ui/src/app/view-models/workspace/workspace-view.html
catalog-ui/webpack.server.js

index e15dae6..7e67dbb 100644 (file)
@@ -47,6 +47,7 @@ const SDC_CONFIG = {
                "GET_lifecycle_state_CERTIFICATIONREQUEST":"lifecycleState/CERTIFICATIONREQUEST",
                "GET_lifecycle_state_UNDOCHECKOUT":"lifecycleState/UNDOCHECKOUT",
                "root": "/sdc1/feProxy/rest",
+        "no_proxy_root": "/sdc1/rest",
                "PUT_service": "/v1/catalog/services/:id/metadata",
                "GET_download_artifact": "/v1/catalog/",
         "GET_SDC_Version": "/version",
index 12f8df8..a0b6b2b 100644 (file)
@@ -143,9 +143,9 @@ export class TopNavComponent {
         }
     }
 
-    goToState(state:string, params:Array<any>):Promise<boolean> {
+    goToState(state:string, params:any):Promise<boolean> {
         return new Promise((resolve, reject) => {
-            this.$state.go(state, params && params.length > 0 ? [0] : undefined);
+            this.$state.go(state, params || undefined);
             resolve(true);
         });
     }
index eb7d138..fc0af53 100644 (file)
@@ -48,7 +48,7 @@ export class PluginFrameComponent implements OnInit {
         // Listening to the stateChangeStart event in order to notify the plugin about it being closed
         // before moving to a new state
         this.$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
-            if (fromState.name !== toState.name) {
+            if ((fromState.name !== toState.name) || (fromState.name === toState.name) && (toParams.path !== fromParams.path)) {
                 if (!this.isClosed) {
                     event.preventDefault();
 
index 1243225..4ec90d1 100644 (file)
@@ -13,5 +13,11 @@ export class PluginsService {
         });
 
         return PluginsConfiguration.plugins[pluginKey];
+    };
+
+    public isPluginDisplayedInContext = (plugin: Plugin ,userRole: string, contextType: string) => {
+        return plugin.pluginDisplayOptions["context"] &&
+               plugin.pluginDisplayOptions["context"].displayRoles.includes(userRole) &&
+               plugin.pluginDisplayOptions["context"].displayContext.indexOf(contextType) !== -1
     }
 }
index 74166a0..8331bdb 100644 (file)
@@ -232,10 +232,10 @@ export class ComponentService implements IComponentService {
 
         // Notifying about events before executing the actual actions
         switch (state) {
-            case "checkIn":
+            case "lifecycleState/CHECKIN":
                 this.eventBusService.notify("CHECK_IN");
                 break;
-            case "submitForTesting":
+            case "lifecycleState/certificationRequest":
                 this.eventBusService.notify("SUBMIT_FOR_TESTING");
                 break;
         }
index d55cae7..ee3a023 100644 (file)
@@ -42,7 +42,8 @@ export class ServiceService extends ComponentService implements IServiceService
         'sdcConfig',
         'Sdc.Services.SharingService',
         '$q',
-        '$base64'
+        '$base64',
+        'EventBusService'
     ];
 
     public distribution:string = "distribution";
index 01b3aa3..5d83c34 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,6 +37,7 @@ import {
 } from "app/services";
 import {FileUploadModel} from "../../directives/file-upload/file-upload";
 import {EventBusService} from "../../ng2/services/event-bus.service";
+import {PluginsService} from "../../ng2/services/plugins.service";
 
 
 export interface IWorkspaceViewModelScope extends ng.IScope {
@@ -119,7 +120,8 @@ export class WorkspaceViewModel {
         'Notification',
         '$stateParams',
         'Sdc.Services.ProgressService',
-        'EventBusService'
+        'EventBusService',
+        'PluginsService'
     ];
 
     constructor(private $scope:IWorkspaceViewModelScope,
@@ -139,7 +141,8 @@ export class WorkspaceViewModel {
                 private Notification:any,
                 private $stateParams:any,
                 private progressService:ProgressService,
-                private eventBusService:EventBusService) {
+                private eventBusService:EventBusService,
+                private pluginsService:PluginsService) {
 
         this.initScope();
         this.initAfterScope();
@@ -669,8 +672,15 @@ export class WorkspaceViewModel {
 
             let selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0;
 
-            if (stateArray[1] === 'plugins') {
-                selectedIndex += _.findIndex(PluginsConfiguration.plugins, (plugin: Plugin) => plugin.pluginStateUrl === this.$state.params.path);
+           if (stateArray[1] === 'plugins') {
+                _.forEach(PluginsConfiguration.plugins, (plugin) => {
+                    if (plugin.pluginStateUrl == this.$state.params.path) {
+                        return false;
+                    }
+                    else if (this.pluginsService.isPluginDisplayedInContext(plugin, this.role, this.$scope.component.getComponentSubType())) {
+                            selectedIndex++;
+                    }
+                });
             }
 
             this.$scope.leftBarTabs.selectedIndex = selectedIndex;
@@ -678,7 +688,7 @@ export class WorkspaceViewModel {
 
         this.$scope.isSelected = (menuItem:MenuItem): boolean => {
             return this.$scope.leftBarTabs.selectedIndex === _.indexOf(this.$scope.leftBarTabs.menuItems, menuItem);
-        }
+        };
 
         this.$scope.$watch('$state.current.name', (newVal:string):void => {
             if (newVal) {
@@ -730,9 +740,9 @@ export class WorkspaceViewModel {
         return new MenuItem(text, null, States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]);
     };
 
-    private updateMenuItemByRole = (menuItems:Array<MenuItem>, role:string) => {
-        let tempMenuItems:Array<MenuItem> = new Array<MenuItem>();
-        menuItems.forEach((item:MenuItem) => {
+    private updateMenuItemByRole = (menuItems:Array<any>, role:string) => {
+        let tempMenuItems:Array<any> = new Array<any>();
+        menuItems.forEach((item:any) => {
             //remove item if role is disabled
             if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) {
                 tempMenuItems.push(item);
@@ -765,31 +775,28 @@ export class WorkspaceViewModel {
 
         // Only adding plugins to the workspace if they can be displayed for the current user role
         _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
-            if (plugin.pluginDisplayOptions["context"] && plugin.pluginDisplayOptions["context"].displayRoles.includes(this.role)) {
-                let displayOptions : PluginDisplayOptions = plugin.pluginDisplayOptions["context"];
-
-                if (displayOptions.displayContext.indexOf(this.$scope.component.getComponentSubType()) !== -1) {
-                    menuItemsObjects.push({
-                        text: displayOptions.displayName,
-                        action: 'onMenuItemPressed',
-                        state: 'workspace.plugins',
-                        params: {path: plugin.pluginStateUrl}
-                    });
-                }
+            if (this.pluginsService.isPluginDisplayedInContext(plugin, this.role, this.$scope.component.getComponentSubType())) {
+                menuItemsObjects.push({
+                    text: plugin.pluginDisplayOptions["context"].displayName,
+                    action: 'onMenuItemPressed',
+                    state: 'workspace.plugins',
+                    params: {path: plugin.pluginStateUrl}
+                });
             }
         });
 
         this.$scope.leftBarTabs.menuItems = menuItemsObjects.map((item:MenuItem) => {
-            if (item.params) {
-                item.params.state = item.state;
+            const menuItem = new MenuItem(item.text, item.callback, item.state, item.action, item.params, item.blockedForTypes);
+            if (menuItem.params) {
+                menuItem.params.state = menuItem.state;
             }
             else {
-                item.params = {state: item.state};
+                menuItem.params = {state: menuItem.state};
             }
-            item.callback = () => this.$scope[item.action](item.state, item.params);
-            item.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != item.state) ||
-                (States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource());
-            return new MenuItem(item.text, item.callback, item.state, item.action, item.params, item.blockedForTypes);
+            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.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource());
+            return menuItem;
         });
 
         if (this.cacheService.get('breadcrumbsComponents')) {
@@ -822,4 +829,4 @@ export class WorkspaceViewModel {
         });
     };
 
-}
\ No newline at end of file
+}
index 0f686b1..1452754 100644 (file)
@@ -5,8 +5,8 @@
             <div class="menu-header" tooltips tooltip-content="{{menuComponentTitle}}">
                 {{menuComponentTitle}}
             </div>
-            <div class="i-sdc-designer-sidebar-section-content-item" ng-class="{'selected': menuItem.state == $state.current.name}" ng-repeat="menuItem in leftBarTabs.menuItems track by $index">
-                <div class="expand-collapse-menu-box-item-text" ng-click="onMenuItemPressed(menuItem.state)" ng-class="{'disabled': menuItem.isDisabled }" data-tests-id="{{menuItem.text}}LeftSideMenu">{{menuItem.text}}</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>
         </div>
 
@@ -62,7 +62,7 @@
 
                     <span data-ng-if="isDesigner()" data-ng-class="{'disabled' :isDisableMode() || isViewMode() || !isActiveTopBar}"  ng-click="revert()" class="sprite-new revert-btn" data-tests-id="revert"
                           data-ng-show="showFullIcons()" sdc-smart-tooltip="">Revert</span>
-                    
+
                     <span class="delimiter"></span>
                     <span class="sprite-new x-btn" data-ng-click="goToBreadcrumbHome()" sdc-smart-tooltip="">Close</span>
 
index 608063a..f55be99 100644 (file)
@@ -40,15 +40,23 @@ module.exports = function(env) {
        // Redirect all '/sdc1/feProxy/rest' to feHost
        middlewares.push(
                proxy(['/sdc1/feProxy/rest'],{
-                       target: 'http://' + loclahost + ':' + fePort,
+                    target: 'http://localhost:' + fePort,
                        changeOrigin: true,
                        secure: false
                }));
 
+       // Redirect all '/sdc1/rest' to feHost
+    middlewares.push(
+        proxy(['/sdc1/rest'],{
+            target: 'http://localhost:' + fePort,
+            changeOrigin: true,
+            secure: false
+        }));
+
        // Redirect dcae urls to feHost
        middlewares.push(
                proxy(['/dcae','/sdc1/feProxy/dcae-api'],{
-                       target: 'http://' + loclahost + ':' + fePort,
+                    target: 'http://localhost:' + fePort,
                        changeOrigin: true,
                        secure: false,
                        onProxyRes: (proxyRes, req, res) => {
@@ -62,7 +70,7 @@ module.exports = function(env) {
        // Redirect onboarding urls to feHost
        middlewares.push(
                proxy(['/onboarding','/sdc1/feProxy/onboarding-api'],{
-                       target: 'http://' + loclahost + ':' + fePort,
+                    target: 'http://localhost:' + fePort,
                        changeOrigin: true,
                        secure: false,
                        onProxyRes: (proxyRes, req, res) => {
@@ -78,4 +86,4 @@ module.exports = function(env) {
 };
 
        return ServerConfig;
-}
\ No newline at end of file
+}