summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2018-03-13 19:59:46 +0200
committerIdan Amit <ia096e@intl.att.com>2018-03-13 20:02:12 +0200
commitfad1d735d7ac3896e28277c733920d15e105db6e (patch)
tree22dabd78b1383707776fc06ccd1c8b5814461131 /catalog-ui/src/app/view-models
parent0f3a80869bf57fc909ec5908601ba04271d92d97 (diff)
Fixed merge issues
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>
Diffstat (limited to 'catalog-ui/src/app/view-models')
-rw-r--r--catalog-ui/src/app/view-models/workspace/workspace-view-model.ts65
-rw-r--r--catalog-ui/src/app/view-models/workspace/workspace-view.html6
2 files changed, 39 insertions, 32 deletions
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
index 01b3aa3b22..5d83c34db8 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
@@ -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
+}
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view.html b/catalog-ui/src/app/view-models/workspace/workspace-view.html
index 0f686b1d64..1452754024 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view.html
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view.html
@@ -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>